Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dual-readout tubes barrel calorimeter in IDEA_o2 #413

Merged
merged 27 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
721d1f5
Add DRBarrelTubes calorimeter subdetector
lopezzot Nov 26, 2024
26e6b5b
Add DRBarrelTubes in IDEA_o2, adjust muon params
lopezzot Nov 26, 2024
ba2666d
Move DDDRCalTubes dimensions in IDEA_o2 xml
lopezzot Dec 2, 2024
a88eac3
Move DRBarrelTubes vis attr to DectDimensions xml
lopezzot Dec 2, 2024
168e540
Increase DRBarrelTubes granularity
lopezzot Dec 2, 2024
dc6871e
Cosmetic changes to DRTubesconstructor print
lopezzot Dec 2, 2024
520cca5
Rename to DDDRCaloTubes_o1_v01
lopezzot Dec 2, 2024
893b52a
Fixed overlap of towers with stave by correct shortening of towers
s6anloes Dec 7, 2024
1c69de7
Avoid overlap between drbarrel staves and solenoid
lopezzot Dec 9, 2024
9600909
Fix bug in materials definition
lopezzot Dec 9, 2024
863b2b0
Set DDDRCaloTubes detID and assign
lopezzot Dec 9, 2024
067d93e
Added and reworked comments to explain calorimeter barrel construction
s6anloes Dec 9, 2024
d92ca70
More comments and removal of unused function
s6anloes Dec 9, 2024
e35dfa6
Renamed DDDRCaloTubes to DRBarrelTubes for consistency with endcaps
s6anloes Dec 9, 2024
36fe2dc
Add barrel in dual-readout-tubes_o1_v01 readme
lopezzot Dec 10, 2024
8b0b903
Update IDEA_o2 README description
lopezzot Dec 10, 2024
55c7053
Added forgotten copynumber for air volume inside tower
s6anloes Dec 16, 2024
82da3b1
Extend DRTubsSDAction to handle barrel signals
lopezzot Dec 16, 2024
5bca18b
Fix bug in DRTubesSDAction theta coordinate
lopezzot Dec 17, 2024
47323e1
Change name of DRTubesSDAction hit collections
lopezzot Dec 17, 2024
23f9e1e
Restore optical properties for DRBarrelTubes
lopezzot Dec 18, 2024
074a124
Remove DRTubesSDAction printout
lopezzot Dec 18, 2024
032bf9e
Fix printout of DRTubesSDAction
lopezzot Dec 18, 2024
b25f2d4
Comment out volID check for barrel calo
lopezzot Dec 19, 2024
26809b2
Changed air copy number to 63 for quick differentiation between endca…
s6anloes Jan 21, 2025
5c38b43
Change DRTubesSDAction IsBarrel implementation
lopezzot Jan 22, 2025
c63359b
Comment out IDEA_o2 test
lopezzot Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add DRBarrelTubes calorimeter subdetector
Co-authored-by: Andreas Loeschcke Centeno <andreas.loeschcke.centeno@cern.ch>
lopezzot and s6anloes committed Jan 23, 2025
commit 721d1f542ff5f8ff02884e1cbb69c78883348322
144 changes: 144 additions & 0 deletions detector/calorimeter/dual-readout-tubes/include/DRTubesconstructor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#ifndef DRconstructor_H
#define DRconstructor_H 1

#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Objects.h"
#include "XML/Layering.h"
#include "XML/Utilities.h"
#include "DDRec/DetectorData.h"

#include "DRutils.h"

using namespace dd4hep;

namespace DDDRCaloTubes {

class DRTubesconstructor {
public:
// Constructor
DRTubesconstructor(Detector* description,
xml_h& entities,
SensitiveDetector* sens);

// Destructor
~DRTubesconstructor() {}

void calculate_tower_parameters();
void calculate_phi_parameters();
void calculate_theta_parameters();
void prepare_tube_volumes();
void assert_tube_existence(int key, bool cher);
double calculate_trap_width(double given_y, double given_z, bool backface = false);
double calculate_tower_width(int given_row, bool backface = true);
void assemble_tower(Volume& tower_air_volume);
void construct_tower_trapezoid(Volume& trap_volume);
void calculate_tower_position();
void construct_tower(Volume& trap_volume);
void increase_covered_theta(const double& delta_theta) {m_covered_theta += delta_theta;}
void place_tower(Volume& stave_volume,
Volume& tower_volume,
unsigned int layer);

void construct_calorimeter(Volume& calorimeter_volume);

private:
Detector* m_description;
xml_h m_entities;
SensitiveDetector* m_sens;

// Calorimeter parameters
double m_calo_inner_r;
double m_calo_outer_r;
double m_calo_inner_half_z;

double m_barrel_endcap_angle; // calculated from m_calo_inner_half_z and m_calo_inner_r

// Tube parameters
double m_capillary_outer_r;
double m_scin_clad_outer_r;
double m_scin_core_outer_r;
double m_cher_clad_outer_r;
double m_cher_core_outer_r;
Material m_capillary_material;
Material m_scin_clad_material;
Material m_scin_core_material;
Material m_cher_clad_material;
Material m_cher_core_material;
std::string m_capillary_visString;
std::string m_scin_clad_visString;
std::string m_scin_core_visString;
std::string m_cher_clad_visString;
std::string m_cher_core_visString;
bool m_capillary_isSensitive;
bool m_scin_clad_isSensitive;
bool m_scin_core_isSensitive;
bool m_cher_clad_isSensitive;
bool m_cher_core_isSensitive;


std::unordered_map<int, Volume> m_scin_tube_volume_map;
std::unordered_map<int, Volume> m_cher_tube_volume_map;

double m_tolerance;

double m_capillary_diameter; // calculated from m_capillary_outer_r

// Constants used through the function (calculated from other parameters)
// double m_D; // Long diagonal of hexagaon with capillary_outer_r as inradius
double m_V; // Vertical spacing for pointy top oriented tubes

// Tower parameters
double m_tower_theta;
double m_tower_phi;

double m_tower_half_phi;
double m_tower_tan_half_phi; // calculated from m_tower_phi
double m_tower_half_length; // calculated from m_calo_inner_r and m_calo_outer_r and m_trap_half_length

// Tower Phi parameters
unsigned int m_num_phi_towers; // number of towers in phi direction
double m_tower_frontface_rightangleedge_x;
double m_tower_frontface_thetaangleedge_x;
double m_tower_backface_rightangleedge_x;
double m_tower_backface_thetaangleedge_x;
double m_angle_edges_x;

// Tower Theta parameters
double m_tower_tan_theta;
double m_tower_frontface_y;
double m_tower_backface_y;
double m_tower_polar_angle;
double m_tower_azimuthal_angle;

// Trapezoid support parameters
double m_stave_half_length;
double m_trap_wall_thickness_sides;
double m_trap_wall_thickness_front;
double m_trap_wall_thickness_back;
double m_trap_frontface_rightangleedge_x; // width for frontface
double m_trap_frontface_thetaangleedge_x;
double m_trap_backface_rightangleedge_x; // width for backface
double m_trap_backface_thetaangleedge_x;
double m_trap_frontface_y; // height for frontface
double m_trap_backface_y; // height for backface
double m_trap_azimuthal_angle; // azimuthal angle for the trapezoid
double m_trap_polar_angle; // polar angle for the trapezoid
double m_trap_half_length; // half length for the trapezoid
Material m_trap_material;
std::string m_trap_visString;


// Construction parameters
double m_covered_theta;
double m_back_shift;
Position m_tower_position;
// Assembly* m_tower_volume;

Material m_air;
std::string m_air_visString;

};

} // namespace DDDRCaloTubes

#endif // DRCONSTRUCTOR_H
23 changes: 23 additions & 0 deletions detector/calorimeter/dual-readout-tubes/include/DRutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef DRutils_h
#define DRutils_h 1

#include <vector>

#include "DD4hep/Objects.h"
#include "DD4hep/DD4hepUnits.h"

using namespace dd4hep;

namespace DDDRCaloTubes
{
int fast_floor(double x);
int fast_ceil(double x);
bool check_for_integer(double x);

std::vector<double> get_plane_equation(const Position& point1, const Position& point2, const Position& point3);
Position get_intersection(const std::vector<double>& plane_coefficients, const Position& line_point, const Direction& line_direction);
Position get_intersection(const Direction& plane_normal, const Position& plane_point, const Position& line_point, const Direction& line_direction);
double distance_from_plane(const std::vector<double>& plane_coefficients, const Position& point);
} // namespace DDDRCaloTubes

#endif // DRutils_h
55 changes: 55 additions & 0 deletions detector/calorimeter/dual-readout-tubes/src/DDDRCaloTubes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Objects.h"
#include "XML/Layering.h"
#include "XML/Utilities.h"
#include "DDRec/DetectorData.h"

#include "DRutils.h"
#include "DRTubesconstructor.h"

using namespace dd4hep;


static Ref_t create_detector(Detector& description,
xml_h entities,
SensitiveDetector sens)
{
xml_det_t x_det = entities;
int det_id = x_det.id();
std::string det_name = x_det.nameStr();

Material air = description.air();

sens.setType("calorimeter");

// Cylinder encompassing entire calorimeter
xml_dim_t x_dim = x_det.dimensions();
double calo_inner_r = x_dim.inner_radius();
double calo_outer_r = x_dim.outer_radius();

double tower_length = calo_outer_r - calo_inner_r;
if (tower_length<=0*mm) throw std::runtime_error("Outer calorimeter radius needs to be larger than inner radius");

Assembly barrel_volume("calorimeter_barrel");
barrel_volume.setMaterial(air);
barrel_volume.setVisAttributes(description, "assembly_vis");

DetElement s_detElement(det_name, det_id);
Volume mother_volume = description.pickMotherVolume(s_detElement);


DDDRCaloTubes::DRTubesconstructor constructor(&description, entities, &sens);
constructor.construct_calorimeter(barrel_volume);


PlacedVolume barrel_placed = mother_volume.placeVolume(barrel_volume);
barrel_placed.addPhysVolID("system", det_id);
s_detElement.setPlacement(barrel_placed);



return s_detElement;
}


DECLARE_DETELEMENT(DDDRCaloTubes,create_detector)
710 changes: 710 additions & 0 deletions detector/calorimeter/dual-readout-tubes/src/DRTubesconstructor.cpp

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions detector/calorimeter/dual-readout-tubes/src/DRutils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <cmath>
#include "DRutils.h"

using namespace dd4hep;

namespace DDDRCaloTubes
{
int fast_floor(double x)
{
return (int) x - (x < (int) x);
}

int fast_ceil(double x)
{
return (int) x + (x > (int) x);
}

bool check_for_integer(double x)
{
return (std::abs(x - std::round(x)) < 1e-6);
}

std::vector<double> get_plane_equation(const Position& point1, const Position& point2, const Position& point3)
{
Direction normal = (point2 - point1).Cross(point3 - point1).Unit();
double A = normal.x();
double B = normal.y();
double C = normal.z();
double D = -1.0 * (A * point1.x() + B * point1.y() + C * point1.z());
std::vector<double> coefficients = {A, B, C, D};
return coefficients;
}

Position get_intersection(const std::vector<double>& plane_coefficients, const Position& line_point, const Direction& line_direction)
{
double A = plane_coefficients[0];
double B = plane_coefficients[1];
double C = plane_coefficients[2];
double D = plane_coefficients[3];
double t = (-1.0*(A * line_point.x() + B * line_point.y() + C * line_point.z() + D)) / (A * line_direction.x() + B * line_direction.y() + C * line_direction.z());
Position intersection = line_point + t * line_direction;
return intersection;
}

Position get_intersection(const Direction& plane_normal, const Position& plane_point, const Position& line_point, const Direction& line_direction)
{
double t = (plane_normal.Dot(plane_point - line_point)) / plane_normal.Dot(line_direction);
Position intersection = line_point + t * line_direction;
return intersection;
}

double distance_from_plane(const std::vector<double>& plane_coefficients, const Position& point)
{
double A = plane_coefficients[0];
double B = plane_coefficients[1];
double C = plane_coefficients[2];
double D = plane_coefficients[3];
return std::abs(A * point.x() + B * point.y() + C * point.z() + D);
}

} // namespace DDDRCaloTubes