File indexing completed on 2025-01-18 09:14:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DD4hep/Detector.h"
0014 #include "DD4hep/Factories.h"
0015 #include "DD4hep/DD4hepUnits.h"
0016
0017 #include "DDRec/DetectorData.h"
0018 #include "DDRec/DDGear.h"
0019 #include "DDRec/MaterialManager.h"
0020
0021 #include "DDRec/Vector3D.h"
0022
0023 #include "gearimpl/TPCParametersImpl.h"
0024 #include "gearimpl/FixedPadSizeDiskLayout.h"
0025 #include "gearimpl/ZPlanarParametersImpl.h"
0026 #include "gearimpl/FTDParametersImpl.h"
0027 #include "gearimpl/CalorimeterParametersImpl.h"
0028
0029 #include <iostream>
0030
0031 namespace dd4hep{
0032 namespace rec{
0033
0034 using namespace detail ;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 static long createGearForCLIC(Detector& description, int , char** ) {
0048
0049 std::cout << " **** running plugin createGearForCLIC ! " << std::endl ;
0050
0051
0052
0053
0054 try{
0055 DetElement vxdDE = description.detector("VertexBarrel") ;
0056
0057 ZPlanarData* vxd = vxdDE.extension<ZPlanarData>() ;
0058
0059
0060 int vxdType = gear::ZPlanarParameters::CMOS ;
0061 gear::ZPlanarParametersImpl* gearVXD = new gear::ZPlanarParametersImpl( vxdType, vxd->rInnerShell/dd4hep::mm, vxd->rOuterShell/dd4hep::mm,
0062 vxd->zHalfShell/dd4hep::mm , vxd->gapShell/dd4hep::mm , 0. ) ;
0063
0064
0065 for(unsigned i=0,n=vxd->layers.size() ; i<n; ++i){
0066
0067
0068 const rec::ZPlanarData::LayerLayout& l = vxd->layers[i] ;
0069
0070
0071 gearVXD->addLayer( l.ladderNumber, l.phi0,
0072 l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l.thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. ,
0073 l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l.thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ;
0074
0075 }
0076
0077 std::cout<<"Added layers"<<std::endl;
0078
0079 GearHandle* handle = new GearHandle( gearVXD, "VXDParameters" ) ;
0080
0081
0082 handle->addMaterial( "VXDSupportMaterial", 2.075865162e+01, 1.039383117e+01, 2.765900000e+02, 1.014262421e+03, 3.341388059e+03) ;
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 vxdDE.addExtension< GearHandle >( handle ) ;
0108
0109 } catch( std::runtime_error& e ){
0110 std::cerr << " >>>> " << e.what() << std::endl ;
0111 }
0112
0113
0114
0115 try{
0116
0117 DetElement sitDE = description.detector("InnerTrackerBarrel") ;
0118
0119 ZPlanarData* sit = sitDE.extension<ZPlanarData>() ;
0120
0121
0122 int sitType = gear::ZPlanarParameters::CCD ;
0123
0124 gear::ZPlanarParametersImpl* gearSIT = new gear::ZPlanarParametersImpl( sitType, sit->rInnerShell/dd4hep::mm, sit->rOuterShell/dd4hep::mm,
0125 sit->zHalfShell/dd4hep::mm , sit->gapShell/dd4hep::mm , 0. ) ;
0126
0127 std::vector<int> n_sensors_per_ladder ;
0128
0129 for(unsigned i=0,n=sit->layers.size() ; i<n; ++i){
0130
0131 const rec::ZPlanarData::LayerLayout& l = sit->layers[i] ;
0132
0133
0134 gearSIT->addLayer( l.ladderNumber, l.phi0,
0135 l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l. thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. ,
0136 l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l. thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ;
0137
0138
0139 n_sensors_per_ladder.push_back( l.sensorsPerLadder);
0140 }
0141
0142 gearSIT->setDoubleVal("strip_width_mm" , sit->widthStrip / dd4hep::mm ) ;
0143 gearSIT->setDoubleVal("strip_length_mm" , sit->lengthStrip/ dd4hep::mm ) ;
0144 gearSIT->setDoubleVal("strip_pitch_mm" , sit->pitchStrip / dd4hep::mm ) ;
0145 gearSIT->setDoubleVal("strip_angle_deg" , sit->angleStrip / dd4hep::deg ) ;
0146
0147
0148 gearSIT->setIntVals("n_sensors_per_ladder",n_sensors_per_ladder);
0149
0150 sitDE.addExtension< GearHandle >( new GearHandle( gearSIT, "SITParameters" ) ) ;
0151
0152 } catch( std::runtime_error& e ){
0153 std::cerr << " >>>> " << e.what() << std::endl ;
0154 }
0155
0156
0157
0158 try {
0159
0160 DetElement setDE = description.detector("OuterTrackerBarrel") ;
0161
0162 ZPlanarData* set = setDE.extension<ZPlanarData>() ;
0163
0164
0165 int setType = gear::ZPlanarParameters::CCD ;
0166 gear::ZPlanarParametersImpl* gearSET = new gear::ZPlanarParametersImpl( setType, set->rInnerShell/dd4hep::mm, set->rOuterShell/dd4hep::mm,
0167 set->zHalfShell/dd4hep::mm , set->gapShell/dd4hep::mm , 0. ) ;
0168 std::vector<int> n_sensors_per_ladder ;
0169
0170
0171 for(unsigned i=0,n=set->layers.size() ; i<n; ++i){
0172
0173 const rec::ZPlanarData::LayerLayout& l = set->layers[i] ;
0174
0175
0176 gearSET->addLayer( l.ladderNumber, l.phi0,
0177 l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l. thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. ,
0178 l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l. thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ;
0179
0180
0181 n_sensors_per_ladder.push_back( l.sensorsPerLadder);
0182 }
0183
0184 gearSET->setDoubleVal("strip_width_mm" , set->widthStrip / dd4hep::mm ) ;
0185 gearSET->setDoubleVal("strip_length_mm" , set->lengthStrip/ dd4hep::mm ) ;
0186 gearSET->setDoubleVal("strip_pitch_mm" , set->pitchStrip / dd4hep::mm ) ;
0187 gearSET->setDoubleVal("strip_angle_deg" , set->angleStrip / dd4hep::deg ) ;
0188
0189
0190 gearSET->setIntVals("n_sensors_per_ladder",n_sensors_per_ladder);
0191
0192 setDE.addExtension< GearHandle >( new GearHandle( gearSET, "SETParameters" ) ) ;
0193
0194 } catch( std::runtime_error& e ){
0195 std::cerr << " >>>> " << e.what() << std::endl ;
0196 }
0197
0198
0199
0200 try {
0201
0202 DetElement iteDE = description.detector("InnerTrackerEndcap") ;
0203
0204 ZDiskPetalsData* iteData = iteDE.extension<ZDiskPetalsData>() ;
0205
0206 gear::GearParametersImpl* gearFTD = new gear::GearParametersImpl();
0207
0208 std::vector<double> thicknesses;
0209 std::vector<double> innerRadii;
0210 std::vector<double> outerRadii;
0211 std::vector<double> zPositions;
0212
0213
0214 for(unsigned i=0,n=iteData->layers.size() ; i<n; ++i){
0215
0216 const rec::ZDiskPetalsData::LayerLayout& l = iteData->layers[i] ;
0217
0218 thicknesses.push_back(l.thicknessSupport/ dd4hep::mm);
0219 innerRadii.push_back( l.distanceSensitive/ dd4hep::mm);
0220 outerRadii.push_back( (l.distanceSensitive + l.lengthSensitive)/ dd4hep::mm);
0221 zPositions.push_back( l.zPosition/ dd4hep::mm);
0222
0223
0224
0225 }
0226
0227
0228
0229 DetElement oteDE = description.detector("OuterTrackerEndcap") ;
0230 ZDiskPetalsData* oteData = oteDE.extension<ZDiskPetalsData>() ;
0231
0232
0233 for(unsigned i=0,n=oteData->layers.size() ; i<n; ++i){
0234
0235 const rec::ZDiskPetalsData::LayerLayout& l = oteData->layers[i] ;
0236
0237 thicknesses.push_back(l.thicknessSupport/ dd4hep::mm);
0238 innerRadii.push_back( l.distanceSensitive/ dd4hep::mm);
0239 outerRadii.push_back( (l.distanceSensitive + l.lengthSensitive)/ dd4hep::mm);
0240 zPositions.push_back( l.zPosition/ dd4hep::mm);
0241
0242
0243
0244 }
0245
0246
0247 gearFTD->setDoubleVals("FTDDiskSupportThickness" , thicknesses) ;
0248 gearFTD->setDoubleVals("FTDInnerRadius" , innerRadii) ;
0249 gearFTD->setDoubleVals("FTDOuterRadius" , outerRadii ) ;
0250 gearFTD->setDoubleVals("FTDZCoordinate" ,zPositions) ;
0251
0252
0253 iteDE.addExtension< GearHandle >( new GearHandle( gearFTD, "FTD" ) ) ;
0254
0255
0256 } catch( std::runtime_error& e ){
0257 std::cerr << " >>>> " << e.what() << std::endl ;
0258 }
0259
0260
0261
0262 try {
0263
0264 DetElement coilDE = description.detector("Solenoid") ;
0265
0266 gear::GearParametersImpl* gearCOIL = new gear::GearParametersImpl();
0267
0268 Tube coilTube = Tube( coilDE.volume().solid() ) ;
0269
0270 gearCOIL->setDoubleVal("Coil_cryostat_inner_radius" , coilTube->GetRmin()/ dd4hep::mm ) ;
0271 gearCOIL->setDoubleVal("Coil_cryostat_outer_radius" , coilTube->GetRmax()/ dd4hep::mm ) ;
0272 gearCOIL->setDoubleVal("Coil_cryostat_half_z" , coilTube->GetDZ()/ dd4hep::mm ) ;
0273
0274 coilDE.addExtension< GearHandle >( new GearHandle( gearCOIL, "CoilParameters" ) ) ;
0275
0276 } catch( std::runtime_error& e ){
0277 std::cerr << " >>>> " << e.what() << std::endl ;
0278 }
0279
0280
0281 try {
0282
0283 DetElement tubeDE = description.detector("Tube") ;
0284
0285 ConicalSupportData* tube = tubeDE.extension<ConicalSupportData>() ;
0286
0287 gear::GearParametersImpl* gearTUBE = new gear::GearParametersImpl();
0288
0289 tube->isSymmetricInZ = true ;
0290
0291 unsigned n = tube->sections.size() ;
0292
0293 std::vector<double> rInner(n) ;
0294 std::vector<double> rOuter(n) ;
0295 std::vector<double> zStart(n) ;
0296
0297 for(unsigned i=0 ; i<n ; ++i){
0298
0299 const ConicalSupportData::Section& s = tube->sections[i] ;
0300
0301 rInner[i] = s.rInner/ dd4hep::mm ;
0302 rOuter[i] = s.rOuter/ dd4hep::mm ;
0303 zStart[i] = s.zPos / dd4hep::mm ;
0304
0305
0306 }
0307
0308 gearTUBE->setDoubleVals("RInner" , rInner ) ;
0309 gearTUBE->setDoubleVals("ROuter" , rOuter ) ;
0310 gearTUBE->setDoubleVals("Z" , zStart ) ;
0311
0312
0313 tubeDE.addExtension< GearHandle >( new GearHandle( gearTUBE, "Beampipe" ) ) ;
0314
0315 } catch( std::runtime_error& e ){
0316 std::cerr << " >>>> " << e.what() << std::endl ;
0317 }
0318
0319
0320
0321
0322
0323
0324
0325 std::map< std::string, std::string > caloMap ;
0326 caloMap["HCalBarrel"] = "HcalBarrelParameters" ;
0327 caloMap["ECalBarrel"] = "EcalBarrelParameters" ;
0328 caloMap["ECalEndcap"] = "EcalEndcapParameters" ;
0329 caloMap["ECalPlug"] = "EcalPlugParameters" ;
0330 caloMap["YokeBarrel"] = "YokeBarrelParameters" ;
0331 caloMap["YokeEndcap"] = "YokeEndcapParameters" ;
0332 caloMap["YokePlug"] = "YokePlugParameters" ;
0333 caloMap["HCalBarrel"] = "HcalBarrelParameters" ;
0334 caloMap["HCalEndcap"] = "HcalEndcapParameters" ;
0335 caloMap["HCalRing"] = "HcalRingParameters" ;
0336 caloMap["LumiCal"] = "LcalParameters" ;
0337
0338 caloMap["BeamCal"] = "BeamCalParameters" ;
0339
0340 for( std::map< std::string, std::string >::const_iterator it = caloMap.begin() ; it != caloMap.end() ; ++it ){
0341
0342
0343
0344 try {
0345
0346 DetElement caloDE = description.detector( it->first ) ;
0347
0348 LayeredCalorimeterData* calo = caloDE.extension<LayeredCalorimeterData>() ;
0349
0350 gear::CalorimeterParametersImpl* gearCalo =
0351 ( calo->layoutType == LayeredCalorimeterData::BarrelLayout ?
0352 new gear::CalorimeterParametersImpl( calo->extent[0]/dd4hep::mm, calo->extent[3]/dd4hep::mm, calo->inner_symmetry, calo->inner_phi0 ) :
0353
0354 new gear::CalorimeterParametersImpl( calo->extent[0]/dd4hep::mm, calo->extent[1]/dd4hep::mm, calo->extent[2]/dd4hep::mm, calo->outer_symmetry, calo->outer_phi0 ) ) ;
0355
0356
0357 for( unsigned i=0, nL = calo->layers.size() ; i <nL ; ++i ){
0358
0359 LayeredCalorimeterData::Layer& l = calo->layers[i] ;
0360
0361
0362
0363
0364
0365 if( i == 0 ) {
0366
0367 gearCalo->layerLayout().positionLayer( l.distance/dd4hep::mm, (l.inner_thickness+l.sensitive_thickness/2.)/dd4hep::mm ,
0368 l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness-l.sensitive_thickness/2.)/dd4hep::mm ) ;
0369 }else if ( i == nL -1 ) {
0370
0371
0372 gearCalo->layerLayout().addLayer((l.inner_thickness+l.outer_thickness+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm ,
0373 l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness+l.outer_thickness-l.sensitive_thickness+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm) ;
0374 }else{
0375
0376 gearCalo->layerLayout().addLayer((l.inner_thickness+l.sensitive_thickness/2.+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm ,
0377 l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness-l.sensitive_thickness/2.+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm) ;
0378 }
0379
0380 }
0381
0382 if( it->first == "HCalBarrel" ){
0383
0384 gearCalo->setIntVal("Hcal_outer_polygon_order" , calo->outer_symmetry ) ;
0385 gearCalo->setDoubleVal("Hcal_outer_polygon_phi0" , calo->outer_phi0 ) ;
0386 }
0387
0388
0389
0390 caloDE.addExtension< GearHandle >( new GearHandle( gearCalo, it->second ) ) ;
0391
0392 } catch( std::runtime_error& e ){
0393 std::cerr << " >>>> " << e.what() << std::endl ;
0394
0395 }
0396
0397 }
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436 return 1;
0437 }
0438 }
0439 }
0440 DECLARE_APPLY( GearForCLIC, dd4hep::rec::createGearForCLIC )
0441
0442