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

DCH patch #416

Merged
merged 8 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
82 changes: 81 additions & 1 deletion detector/tracker/DriftChamber_o1_v02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ using DCH_length_t = dd4hep::rec::DCH_info_struct::DCH_length_t;
using DCH_angle_t = dd4hep::rec::DCH_info_struct::DCH_angle_t;
using DCH_layer = dd4hep::rec::DCH_info_struct::DCH_layer;

dd4hep::Solid CompositeTT(double twist_angle, double cell_rin_z0, double cell_rout_z0, double dz, double dphi, const dd4hep::rec::DCH_info & DCH_i);

/// Function to build DCH
static dd4hep::Ref_t create_DCH_o1_v02(dd4hep::Detector &desc, dd4hep::xml::Handle_t handle, dd4hep::SensitiveDetector sens)
{
Expand Down Expand Up @@ -75,6 +77,7 @@ static dd4hep::Ref_t create_DCH_o1_v02(dd4hep::Detector &desc, dd4hep::xml::Hand
}

bool debugGeometry = detElem.hasChild(_Unicode(debugGeometry));
bool useG4TT = detElem.hasChild(_Unicode(useG4TT));
atolosadelgado marked this conversation as resolved.
Show resolved Hide resolved
auto gasElem = detElem.child("gas");
auto gasvolMat = desc.material(gasElem.attr<std::string>(_Unicode(material)));
auto gasvolVis = desc.visAttributes(gasElem.attr<std::string>(_Unicode(vis)));
Expand Down Expand Up @@ -285,7 +288,9 @@ static dd4hep::Ref_t create_DCH_o1_v02(dd4hep::Detector &desc, dd4hep::xml::Hand
DCH_length_t cell_rout_zLhalf = DCH_i->Radius_zLhalf(cell_rout_z0);
DCH_length_t cell_dz = DCH_i->Lhalf;
DCH_angle_t cell_phi_width = phi_step - safety_phi_interspace;
dd4hep::TwistedTube cell_s( cell_twistangle, cell_rin_zLhalf, cell_rout_zLhalf, cell_dz, 1, cell_phi_width);
dd4hep::Solid cell_s;
if( useG4TT ) cell_s = dd4hep::TwistedTube ( cell_twistangle, cell_rin_zLhalf, cell_rout_zLhalf, cell_dz, 1, cell_phi_width);
else cell_s = CompositeTT(cell_twistangle, cell_rin_z0, cell_rout_z0, cell_dz, cell_phi_width, *DCH_i);
atolosadelgado marked this conversation as resolved.
Show resolved Hide resolved

// initialize cell volume
std::string cell_name = detName+"_layer"+std::to_string(ilayer)+"_cell";
Expand Down Expand Up @@ -510,6 +515,81 @@ static dd4hep::Ref_t create_DCH_o1_v02(dd4hep::Detector &desc, dd4hep::xml::Hand

}

inline double Circumradius(double Apothem, double dphi){return Apothem/cos(0.5*dphi/dd4hep::rad);}

dd4hep::Solid CompositeTT(double twist_angle, double cell_rin_z0, double cell_rout_z0, double dz, double dphi, const dd4hep::rec::DCH_info & DCH_i)
{

//----------------- G. trapezoid -------------
// make generic trapezoid bigger, later intersected with hyperboloid of proper radii
double rmin_zLhalf = DCH_i.Radius_zLhalf(cell_rin_z0 );
double rout_zLhalf = DCH_i.Radius_zLhalf(cell_rout_z0);
double trap_rin = 0.9*rmin_zLhalf;
double trap_rout = Circumradius(1.1*rout_zLhalf, dphi);

double poly_angle = dphi/2;
double twist_angle_half = twist_angle/2.;
// change sign, so the final shape has the same orientation as G4 twisted tube
twist_angle_half*= -1;

// define points of 8 genenric trapezoid
struct point2d
{
double x = {0.0};
double y = {0.0};
};

struct face
{
point2d A;
point2d B;
point2d C;
point2d D;
};

face fZneg;
face fZpos;

fZpos.A = { trap_rin*cos( poly_angle + twist_angle_half ), trap_rin*sin( poly_angle + twist_angle_half ) };
atolosadelgado marked this conversation as resolved.
Show resolved Hide resolved
fZpos.B = { trap_rin*cos( -poly_angle + twist_angle_half ), trap_rin*sin( -poly_angle + twist_angle_half ) };

fZneg.A = { trap_rin*cos( poly_angle - twist_angle_half ), trap_rin*sin( poly_angle - twist_angle_half ) };
fZneg.B = { trap_rin*cos( -poly_angle - twist_angle_half ), trap_rin*sin( -poly_angle - twist_angle_half ) };

fZpos.C = { trap_rout*cos( poly_angle + twist_angle_half ), trap_rout*sin( poly_angle + twist_angle_half ) };
fZpos.D = { trap_rout*cos( -poly_angle + twist_angle_half ), trap_rout*sin( -poly_angle + twist_angle_half ) };

fZneg.C = { trap_rout*cos( poly_angle - twist_angle_half ), trap_rout*sin( poly_angle - twist_angle_half ) };
fZneg.D = { trap_rout*cos( -poly_angle - twist_angle_half ), trap_rout*sin( -poly_angle - twist_angle_half ) };

std::vector<double> vertices_array = { fZpos.B.x, fZpos.B.y,
fZpos.A.x, fZpos.A.y,
fZpos.C.x, fZpos.C.y,
fZpos.D.x, fZpos.D.y,
fZneg.B.x, fZneg.B.y,
fZneg.A.x, fZneg.A.y,
fZneg.C.x, fZneg.C.y,
fZneg.D.x, fZneg.D.y
};

dd4hep::EightPointSolid gtrap_shape(dz, vertices_array.data() );

//----------------- Hyperboloid -------------
// ROOT hyperboloid require stereoangles stin and stout
//-- stereo for rmin
double stin = DCH_i.stereoangle_z0(cell_rin_z0);
//-- stereo for rour
atolosadelgado marked this conversation as resolved.
Show resolved Hide resolved
double stout = DCH_i.stereoangle_z0(cell_rout_z0);

// make hyperboloid longer, later intersection with gtrap will lead to proper length
double dz_safe = 1.1*dz;
dd4hep::Hyperboloid layer_s(cell_rin_z0, stin, cell_rout_z0, stout, dz_safe);

// create a twisted tube as intersection of the generic trapezoid and the hyperboloid
dd4hep::Solid mytt = dd4hep::IntersectionSolid(gtrap_shape,layer_s);
return mytt;
}

}; // end DCH_v2 namespace


Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ SET( test_name "test_DCH_o1_v02_overlap" )
ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh"
ddsim --compactFile=${CMAKE_CURRENT_SOURCE_DIR}/compact/DCH_standalone_o1_v02.xml --runType run --part.userParticleHandler= --macroFile=${CMAKE_CURRENT_SOURCE_DIR}/../utils/overlap.mac )
SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "Exception;EXCEPTION;ERROR;Error" )
set_tests_properties( t_${test_name} PROPERTIES TIMEOUT 60)
set_tests_properties( t_${test_name} PROPERTIES TIMEOUT 400)
endif()

#--------------------------------------------------
Expand Down
Loading