Commit a3decb2a authored by ldufour's avatar ldufour
Browse files

First step in fixing quadrants, ddx and matids

parent 6ffd25bc
Pipeline #4347762 failed with stages
in 2 minutes and 19 seconds
......@@ -76,9 +76,10 @@ namespace {
struct Module {
double sign = 1.0, leftHoleSizeY = 0, rightHoleSizeY = 0;
bool will_be_rotated = false;
std::string left, right;
Module( double sgn, double hl, double hr, const std::string& l, const std::string& r )
: sign( sgn ), leftHoleSizeY( hl ), rightHoleSizeY( hr ), left( l ), right( r ) {}
Module( double sgn, double hl, double hr, const std::string& l, const std::string& r, bool rotation=false )
: sign( sgn ), leftHoleSizeY( hl ), rightHoleSizeY( hr ), left( l ), right( r ), will_be_rotated(rotation) {}
HELPER_CLASS_DEFAULTS( Module );
};
std::map<std::string, Module> m_modules;
......@@ -173,13 +174,19 @@ namespace {
Module( 1., 0, dd4hep::_toDouble( "FT:HoleRightVSizeY" ), "lvFibreMat", "lvFibreShortMatRightV" );
m_modules["LeftU"] =
Module( -1., dd4hep::_toDouble( "FT:HoleLeftUSizeY" ), 0, "lvFibreShortMatLeftU", "lvFibreMat" );
m_modules["LeftX"] =
Module( -1., dd4hep::_toDouble( "FT:HoleLeftXSizeY" ), 0, "lvFibreShortMatLeftX", "lvFibreMat" );
Module( -1., dd4hep::_toDouble( "FT:HoleLeftUSizeY" ), 0, "lvFibreShortMatLeftU", "lvFibreMat", true );
m_modules["RightU"] =
Module( 1., 0, dd4hep::_toDouble( "FT:HoleRightUSizeY" ), "lvFibreMat", "lvFibreShortMatRightU" );
m_modules["RightX"] =
Module( 1., 0, dd4hep::_toDouble( "FT:HoleRightXSizeY" ), "lvFibreMat", "lvFibreShortMatRightX" );
Module( 1., 0, dd4hep::_toDouble( "FT:HoleRightUSizeY" ), "lvFibreMat", "lvFibreShortMatRightU", true );
m_modules["LeftX1"] =
Module( -1., dd4hep::_toDouble( "FT:HoleLeftXSizeY" ), 0, "lvFibreShortMatLeftX1", "lvFibreMat", true );
m_modules["RightX1"] =
Module( 1., 0, dd4hep::_toDouble( "FT:HoleRightXSizeY" ), "lvFibreMat", "lvFibreShortMatRightX1", true );
m_modules["LeftX2"] =
Module( -1., dd4hep::_toDouble( "FT:HoleLeftXSizeY" ), 0, "lvFibreShortMatLeftX2", "lvFibreMat" );
m_modules["RightX2"] =
Module( 1., 0, dd4hep::_toDouble( "FT:HoleRightXSizeY" ), "lvFibreMat", "lvFibreShortMatRightX2" );
}
FTBuild::~FTBuild() {
......@@ -340,6 +347,7 @@ namespace {
dd4hep::printout( m_local_debug ? dd4hep::ALWAYS : dd4hep::DEBUG, "FT-geo", "+++ Building module %s",
mod_vol.name() );
registerDetElement( mod_vol.name(), de_mod );
if ( m_build_passive ) {
pos =
dd4hep::Position( 0, -0.5 * ( mod_size_y - skin_size_y ), -0.5 * ( mat_size_z + skin_size_z ) - core_size_z );
......@@ -354,38 +362,49 @@ namespace {
de_mat.setPlacement( pv );
pos = dd4hep::Position( -0.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv.addPhysVolID( "mat", 1 );
de_mat = DetElement( de_mod, "Mat1", 1 );
de_mat.setPlacement( pv );
pos = dd4hep::Position( 0.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv.addPhysVolID( "mat", 2 );
de_mat = DetElement( de_mod, "Mat2", 2 );
de_mat.setPlacement( pv );
pos = dd4hep::Position( 1.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv.addPhysVolID( "mat", 3 );
de_mat = DetElement( de_mod, "Mat3", 3 );
de_mat.setPlacement( pv );
if ( m_build_passive ) {
pos = dd4hep::Position( 0, -0.5 * ( mod_size_y - core_size_y ), 0.5 * ( mat_size_z + core_size_z ) );
pv = mod_vol.placeVolume( volume( "lvCore" ), dd4hep::Transform3D( rot_Y, pos ) );
pv = mod_vol.placeVolume( volume( "lvCore" ), pos );
pos =
dd4hep::Position( 0, -0.5 * ( mod_size_y - skin_size_y ), 0.5 * ( mat_size_z + skin_size_z ) + core_size_z );
pv = mod_vol.placeVolume( volume( "lvSkin" ), dd4hep::Transform3D( rot_Y, pos ) );
pv = mod_vol.placeVolume( volume( "lvSkin" ), pos );
pos = dd4hep::Position( -0.5 * ( mod_size_x - wall_thick ), -0.5 * ( mod_size_y - skin_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvSideWall" ), pos );
pos = dd4hep::Position( 0.5 * ( mod_size_x - wall_thick ), -0.5 * ( mod_size_y - skin_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvSideWall" ), pos );
}
for ( const auto& m : m_modules ) {
/**
This part of the mat construction code takes care of the inner parts
of the layers, meaning the mats that are of a specific length to
go in the U,V, X1 or X2 layers of the detector.
There is a distinction between X1 and X2 solely because the mat itself
is oriented differently.
**/
for ( const auto& m : m_modules )
{
const auto& p = m.second;
double hole_size_y = dd4hep::_toDouble( "FT:Hole" + m.first + "SizeY" );
dd4hep::RotationZYX flip_around( 0, M_PI, 0 );
auto increment_func = [&](const unsigned int& mat_id){ return (p.will_be_rotated ? mat_id-1 : mat_id+1); };
de_mod = DetElement( "module", id );
mod_vol = volume( "lvFTModuleHole" + m.first );
......@@ -401,28 +420,32 @@ namespace {
pos = dd4hep::Position( 0.0, -0.5 * ( mod_size_y - core_size_y ), -0.5 * ( mat_size_z + core_size_z ) );
pv = mod_vol.placeVolume( volume( "lvCoreHoleFront" + m.first ), pos );
}
pos = dd4hep::Position( -1.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y + p.leftHoleSizeY ), 0.0 );
pv = mod_vol.placeVolume( volume( p.left ), pos );
pv.addPhysVolID( "mat", 0 );
de_mat = DetElement( de_mod, "Mat0", 0 );
pos = dd4hep::Position( (p.will_be_rotated ? -1. : 1.)*-1.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y + p.leftHoleSizeY ), 0.0 );
pv = mod_vol.placeVolume( volume( p.left ), pos );
unsigned int mat_id = (p.will_be_rotated ? 3 : 0);
pv.addPhysVolID( "mat", mat_id );
de_mat = DetElement( de_mod, "Mat" + std::to_string(mat_id), mat_id );
de_mat.setPlacement( pv );
pos = dd4hep::Position( -0.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
mat_id = increment_func(mat_id);
pos = dd4hep::Position( (p.will_be_rotated ? -1. : 1.)*-0.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv.addPhysVolID( "mat", 1 );
de_mat = DetElement( de_mod, "Mat1", 1 );
pv.addPhysVolID( "mat", mat_id );
de_mat = DetElement( de_mod, "Mat" + std::to_string(mat_id), mat_id );
de_mat.setPlacement( pv );
pos = dd4hep::Position( 0.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
mat_id = increment_func(mat_id);
pos = dd4hep::Position( (p.will_be_rotated ? -1. : 1.)*0.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y ), 0.0 );
pv = mod_vol.placeVolume( volume( "lvFibreMat" ), pos );
pv.addPhysVolID( "mat", 2 );
de_mat = DetElement( de_mod, "Mat2", 2 );
pv.addPhysVolID( "mat", mat_id );
de_mat = DetElement( de_mod, "Mat" + std::to_string(mat_id), mat_id );
de_mat.setPlacement( pv );
pos = dd4hep::Position( 1.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y + p.rightHoleSizeY ), 0.0 );
mat_id = increment_func(mat_id);
pos = dd4hep::Position( (p.will_be_rotated ? -1. : 1.)*1.5 * mat_pitch_x, 0.5 * ( mod_size_y - mat_size_y + p.rightHoleSizeY ), 0.0 );
pv = mod_vol.placeVolume( volume( p.right ), pos );
pv.addPhysVolID( "mat", 3 );
de_mat = DetElement( de_mod, "Mat3", 3 );
pv.addPhysVolID( "mat", mat_id );
de_mat = DetElement( de_mod, "Mat" + std::to_string(mat_id), mat_id );
de_mat.setPlacement( pv );
if ( m_build_passive ) {
......@@ -450,8 +473,9 @@ namespace {
struct Quarter {
double sign = 0;
double stereo = 0;
double is_rotated_wrt_x2 = 1;
std::string special;
Quarter( double sgn, double st, const std::string& s ) : sign( sgn ), stereo( st ), special( s ) {}
Quarter( double sgn, double st, double reflection, const std::string& s ) : sign( sgn ), stereo( st ), special( s ), is_rotated_wrt_x2(reflection) {}
HELPER_CLASS_DEFAULTS( Quarter );
};
dd4hep::Position pos;
......@@ -462,19 +486,26 @@ namespace {
double stereo_u = dd4hep::_toDouble( "FT:StereoAngleU" );
double stereo_v = dd4hep::_toDouble( "FT:StereoAngleV" );
double stereo_x = dd4hep::_toDouble( "FT:StereoAngleX" );
quarters["UNeg"] = Quarter( -1., stereo_u, "RightU" );
quarters["UPos"] = Quarter( 1., stereo_u, "LeftU" );
quarters["VNeg"] = Quarter( -1., stereo_v, "RightV" );
quarters["VPos"] = Quarter( 1., stereo_v, "LeftV" );
quarters["XNeg"] = Quarter( -1., stereo_x, "RightX" );
quarters["XPos"] = Quarter( 1., stereo_x, "LeftX" );
for ( int i = 5, nmod = 6; i <= nmod; ++i ) {
quarters["UNeg"] = Quarter( -1., stereo_u, 0, "RightU" );
quarters["UPos"] = Quarter( 1., stereo_u, 0, "LeftU" );
quarters["VNeg"] = Quarter( -1., stereo_v, 1, "RightV" );
quarters["VPos"] = Quarter( 1., stereo_v, 1, "LeftV" );
quarters["X1Neg"] = Quarter( -1., stereo_x, 1, "RightX1" );
quarters["X1Pos"] = Quarter( 1., stereo_x, 1, "LeftX1" );
quarters["X2Neg"] = Quarter( -1., stereo_x, 0, "RightX2" );
quarters["X2Pos"] = Quarter( 1., stereo_x, 0, "LeftX2" );
for ( int stationType = 5, nmod = 6; stationType <= nmod; ++stationType ) {
for ( const auto& q : quarters ) {
const auto& p = q.second;
dd4hep::Assembly vol_quarter( dd4hep::_toString( i, "lvQuarter%d" ) + q.first );
dd4hep::Assembly vol_quarter( dd4hep::_toString( stationType, "lvQuarter%d" ) + q.first );
double sin_stereo = std::sin( p.stereo );
double cos_stereo = std::cos( p.stereo );
dd4hep::RotationZYX rot( p.stereo, 0, 0 );
dd4hep::RotationZYX my_reflection( 0, p.is_rotated_wrt_x2*M_PI, 0 );
dd4hep::DetElement de_quarter( "quarter", id );
dd4hep::DetElement de, de_module;
......@@ -486,46 +517,51 @@ namespace {
"+++ Building quarter: %s sign:%c stereo:%.3f special:%s", vol_quarter.name(),
p.sign ? '+' : '-', p.stereo, p.special.c_str() );
pos = dd4hep::Position( p.sign * 0.5 * mod_pitch_x / cos_stereo - 0.5 * mod_size_y * sin_stereo,
mod_size_y * cos_stereo / 2.0, 0.0 );
pv = vol_quarter.placeVolume( volume( "lvFTModuleHole" + p.special ), dd4hep::Transform3D( rot, pos ) );
// do not rotate this one: that is the responsibility of the 'special'
// mat maker (@see build_modules)
pv = vol_quarter.placeVolume( volume( "lvFTModuleHole" + p.special ), dd4hep::Transform3D( my_reflection*rot, pos ) );
de = detElement( pv.volume().name() );
pv.addPhysVolID( "module", 0 );
de_module = de.clone( "M0", 0 );
de_module.setPlacement( pv );
de_quarter.add( de_module );
pos.SetX( pos.X() + p.sign * mod_pitch_x / cos_stereo );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( rot, pos ) );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( my_reflection*rot, pos ) );
pv.addPhysVolID( "module", 1 );
de_module = de_full.clone( "M1", 1 );
de_module.setPlacement( pv );
de_quarter.add( de_module );
pos.SetX( pos.X() + p.sign * mod_pitch_x / cos_stereo );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( rot, pos ) );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( my_reflection*rot, pos ) );
pv.addPhysVolID( "module", 2 );
de_module = de_full.clone( "M2", 2 );
de_module.setPlacement( pv );
de_quarter.add( de_module );
pos.SetX( pos.X() + p.sign * mod_pitch_x / cos_stereo );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( rot, pos ) );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( my_reflection*rot, pos ) );
pv.addPhysVolID( "module", 3 );
de_module = de_full.clone( "M3", 3 );
de_module.setPlacement( pv );
de_quarter.add( de_module );
pos.SetX( pos.X() + p.sign * mod_pitch_x / cos_stereo );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( rot, pos ) );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( my_reflection*rot, pos ) );
pv.addPhysVolID( "module", 4 );
de_module = de_full.clone( "M4", 4 );
de_module.setPlacement( pv );
de_quarter.add( de_module );
if ( i == 5 ) continue; // Distinguish between the quarters with 5 and 6 modules
if ( stationType == 5 ) continue; // Distinguish between the quarters with 5 and 6 modules
pos.SetX( pos.X() + p.sign * mod_pitch_x / cos_stereo );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( rot, pos ) );
pv = vol_quarter.placeVolume( vol_full, dd4hep::Transform3D( my_reflection*rot, pos ) );
pv.addPhysVolID( "module", 5 );
de_module = de_full.clone( "M5", 5 );
de_module.setPlacement( pv );
......@@ -541,27 +577,30 @@ namespace {
std::string A, B;
std::string Side;
HalfLayerType( double rotY, const std::string& a, const std::string& b, const std::string& side )
: rotY( rotY ), A( a ), B( b ), Side( side ) {}
: rotY( 0 ), A( a ), B( b ), Side( side ) {}
HELPER_CLASS_DEFAULTS( HalfLayerType );
};
std::map<std::string, HalfLayerType> halflayers;
halflayers["5UR"] = HalfLayerType( 0, "lvQuarter5UPos", "lvQuarter5UNeg", "R" );
halflayers["5UL"] = HalfLayerType( 0, "lvQuarter5UPos", "lvQuarter5UNeg", "L" );
halflayers["5VR"] = HalfLayerType( M_PI, "lvQuarter5VNeg", "lvQuarter5VPos", "R" );
halflayers["5VL"] = HalfLayerType( M_PI, "lvQuarter5VNeg", "lvQuarter5VPos", "L" );
halflayers["5X1R"] = HalfLayerType( M_PI, "lvQuarter5XNeg", "lvQuarter5XPos", "R" );
halflayers["5X1L"] = HalfLayerType( M_PI, "lvQuarter5XNeg", "lvQuarter5XPos", "L" );
halflayers["5X2R"] = HalfLayerType( 0, "lvQuarter5XPos", "lvQuarter5XNeg", "R" );
halflayers["5X2L"] = HalfLayerType( 0, "lvQuarter5XPos", "lvQuarter5XNeg", "L" );
halflayers["5VR"] = HalfLayerType( 0, "lvQuarter5VPos", "lvQuarter5VNeg", "R" );
halflayers["5VL"] = HalfLayerType( 0, "lvQuarter5VPos", "lvQuarter5VNeg", "L" );
halflayers["5X1R"] = HalfLayerType( 0, "lvQuarter5X1Pos", "lvQuarter5X1Neg", "R" );
halflayers["5X1L"] = HalfLayerType( 0, "lvQuarter5X1Pos", "lvQuarter5X1Neg", "L" );
halflayers["5X2R"] = HalfLayerType( 0, "lvQuarter5X2Pos", "lvQuarter5X2Neg", "R" );
halflayers["5X2L"] = HalfLayerType( 0, "lvQuarter5X2Pos", "lvQuarter5X2Neg", "L" );
halflayers["6UR"] = HalfLayerType( 0, "lvQuarter6UPos", "lvQuarter6UNeg", "R" );
halflayers["6UL"] = HalfLayerType( 0, "lvQuarter6UPos", "lvQuarter6UNeg", "L" );
halflayers["6VR"] = HalfLayerType( M_PI, "lvQuarter6VNeg", "lvQuarter6VPos", "R" );
halflayers["6VL"] = HalfLayerType( M_PI, "lvQuarter6VNeg", "lvQuarter6VPos", "L" );
halflayers["6X1R"] = HalfLayerType( M_PI, "lvQuarter6XNeg", "lvQuarter6XPos", "R" );
halflayers["6X1L"] = HalfLayerType( M_PI, "lvQuarter6XNeg", "lvQuarter6XPos", "L" );
halflayers["6X2R"] = HalfLayerType( 0, "lvQuarter6XPos", "lvQuarter6XNeg", "R" );
halflayers["6X2L"] = HalfLayerType( 0, "lvQuarter6XPos", "lvQuarter6XNeg", "L" );
halflayers["6VR"] = HalfLayerType( 0, "lvQuarter6VNeg", "lvQuarter6VPos", "R" );
halflayers["6VL"] = HalfLayerType( 0, "lvQuarter6VNeg", "lvQuarter6VPos", "L" );
halflayers["6X1R"] = HalfLayerType( 0, "lvQuarter6X1Neg", "lvQuarter6X1Pos", "R" );
halflayers["6X1L"] = HalfLayerType( 0, "lvQuarter6X1Neg", "lvQuarter6X1Pos", "L" );
halflayers["6X2R"] = HalfLayerType( 0, "lvQuarter6X2Pos", "lvQuarter6X2Neg", "R" );
halflayers["6X2L"] = HalfLayerType( 0, "lvQuarter6X2Pos", "lvQuarter6X2Neg", "L" );
dd4hep::PlacedVolume pv;
dd4hep::Volume vol;
......@@ -682,6 +721,7 @@ namespace {
station_size_z / ( 2.0 * cos( beam_angle ) ) + tan( beam_angle ) * beam_hole_radius + eps );
dd4hep::RotationZYX rot( 0, 0, -beam_angle );
dd4hep::Position pos0( 0, 0, 0 );
dd4hep::SubtractionSolid solid( box, tub, dd4hep::Transform3D( rot, pos0 ) );
dd4hep::PlacedVolume pv;
dd4hep::Position pos;
......
......@@ -82,6 +82,12 @@
<constant name="FT:HoleSizeX" value="130.8*mm"/> <!-- variable -->
<constant name="FT:HoleLeftXSizeY" value="115.0*mm"/> <!-- variable -->
<constant name="FT:HoleRightXSizeY" value="FT:HoleLeftXSizeY"/> <!-- 115.0*mm -->
<constant name="FT:HoleLeftX1SizeY" value="FT:HoleLeftXSizeY"/> <!-- variable -->
<constant name="FT:HoleRightX1SizeY" value="FT:HoleLeftXSizeY"/> <!-- 115.0*mm -->
<constant name="FT:HoleLeftX2SizeY" value="FT:HoleLeftXSizeY"/> <!-- variable -->
<constant name="FT:HoleRightX2SizeY" value="FT:HoleLeftXSizeY"/> <!-- 115.0*mm -->
<constant name="FT:HoleLeftUSizeY" value="(115.0-23.0)*mm"/> <!-- 92.0*mm -->
<constant name="FT:HoleRightUSizeY" value="(115.0+23.0)*mm"/> <!-- 138.0*mm -->
<!-- Not in DDDB ======================================================================== -->
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment