25 #include "gearimpl/TPCParametersImpl.h"
26 #include "gearimpl/FixedPadSizeDiskLayout.h"
27 #include "gearimpl/ZPlanarParametersImpl.h"
28 #include "gearimpl/FTDParametersImpl.h"
29 #include "gearimpl/CalorimeterParametersImpl.h"
36 using namespace detail ;
49 static long createGearForILD(Detector& description,
int ,
char** ) {
51 std::cout <<
" **** running plugin createGearForILD ! " << std::endl ;
57 double crossing_angle(0.) ;
58 try{ crossing_angle = description.constant<
double>(
"ILC_Main_Crossing_Angle") ; }
catch(std::runtime_error&e) {std::cerr <<
" >>>> " << e.what() << std::endl ;}
64 DetElement tpcDE = description.detector(
"TPC") ;
68 gear::TPCParametersImpl* gearTPC =
new gear::TPCParametersImpl( tpc->driftLength /dd4hep::mm , gear::PadRowLayout2D::POLAR ) ;
70 gearTPC->setPadLayout(
new gear::FixedPadSizeDiskLayout( tpc->rMinReadout/dd4hep::mm , tpc->rMaxReadout/dd4hep::mm, tpc->padHeight/dd4hep::mm,
71 tpc->padWidth/dd4hep::mm , tpc->maxRow, tpc->padGap /dd4hep::mm ) ) ;
73 gearTPC->setDoubleVal(
"tpcInnerRadius", tpc->rMin/dd4hep::mm ) ;
74 gearTPC->setDoubleVal(
"tpcOuterRadius", tpc->rMax/dd4hep::mm ) ;
75 gearTPC->setDoubleVal(
"tpcInnerWallThickness", tpc->innerWallThickness/dd4hep::mm ) ;
76 gearTPC->setDoubleVal(
"tpcOuterWallThickness", tpc->outerWallThickness/dd4hep::mm ) ;
78 tpcDE.addExtension< GearHandle >(
new GearHandle( gearTPC,
"TPCParameters" ) ) ;
80 }
catch( std::runtime_error& e ){
81 std::cerr <<
" >>>> " << e.what() << std::endl ;
87 DetElement vxdDE = description.detector(
"VXD") ;
92 int vxdType = gear::ZPlanarParameters::CMOS ;
93 gear::ZPlanarParametersImpl* gearVXD =
new gear::ZPlanarParametersImpl( vxdType, vxd->rInnerShell/dd4hep::mm, vxd->rOuterShell/dd4hep::mm,
94 vxd->zHalfShell/dd4hep::mm , vxd->gapShell/dd4hep::mm , 0. ) ;
96 for(
unsigned i=0,n=vxd->layers.size() ; i<n; ++i){
98 const rec::ZPlanarData::LayerLayout& l = vxd->layers[i] ;
101 gearVXD->addLayer( l.ladderNumber, l.phi0,
102 l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l.thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. ,
103 l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l.thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ;
107 GearHandle*
handle =
new GearHandle( gearVXD,
"VXDParameters" ) ;
115 const rec::ZPlanarData::LayerLayout& l = vxd->layers[0] ;
120 const MaterialVec& materials = matMgr.materialsBetween( a , b ) ;
122 MaterialData mat = ( materials.size() > 1 ? matMgr.createAveragedMaterial( materials ) : materials[0].first ) ;
131 handle->addMaterial(
"VXDSupportMaterial", mat.A(), mat.Z() , mat.density()/(dd4hep::kg/(dd4hep::g*dd4hep::m3)) , mat.radiationLength()/dd4hep::mm , mat.interactionLength()/dd4hep::mm ) ;
134 vxdDE.addExtension< GearHandle >(
handle ) ;
136 }
catch( std::runtime_error& e ){
137 std::cerr <<
" >>>> " << e.what() << std::endl ;
144 DetElement sitDE = description.detector(
"SIT") ;
149 int sitType = gear::ZPlanarParameters::CCD ;
150 gear::ZPlanarParametersImpl* gearSIT =
new gear::ZPlanarParametersImpl( sitType, sit->rInnerShell/dd4hep::mm, sit->rOuterShell/dd4hep::mm,
151 sit->zHalfShell/dd4hep::mm , sit->gapShell/dd4hep::mm , 0. ) ;
152 std::vector<int> n_sensors_per_ladder ;
154 for(
unsigned i=0,n=sit->layers.size() ; i<n; ++i){
156 const rec::ZPlanarData::LayerLayout& l = sit->layers[i] ;
159 gearSIT->addLayer( l.ladderNumber, l.phi0,
160 l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l. thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. ,
161 l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l. thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ;
164 n_sensors_per_ladder.push_back( l.sensorsPerLadder);
167 gearSIT->setDoubleVal(
"strip_width_mm" , sit->widthStrip / dd4hep::mm ) ;
168 gearSIT->setDoubleVal(
"strip_length_mm" , sit->lengthStrip/ dd4hep::mm ) ;
169 gearSIT->setDoubleVal(
"strip_pitch_mm" , sit->pitchStrip / dd4hep::mm ) ;
170 gearSIT->setDoubleVal(
"strip_angle_deg" , sit->angleStrip / dd4hep::deg ) ;
173 gearSIT->setIntVals(
"n_sensors_per_ladder",n_sensors_per_ladder);
175 sitDE.addExtension< GearHandle >(
new GearHandle( gearSIT,
"SITParameters" ) ) ;
177 }
catch( std::runtime_error& e ){
178 std::cerr <<
" >>>> " << e.what() << std::endl ;
185 DetElement setDE = description.detector(
"SET") ;
190 int setType = gear::ZPlanarParameters::CCD ;
191 gear::ZPlanarParametersImpl* gearSET =
new gear::ZPlanarParametersImpl( setType, set->rInnerShell/dd4hep::mm, set->rOuterShell/dd4hep::mm,
192 set->zHalfShell/dd4hep::mm , set->gapShell/dd4hep::mm , 0. ) ;
193 std::vector<int> n_sensors_per_ladder ;
196 for(
unsigned i=0,n=set->layers.size() ; i<n; ++i){
198 const rec::ZPlanarData::LayerLayout& l = set->layers[i] ;
201 gearSET->addLayer( l.ladderNumber, l.phi0,
202 l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l. thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. ,
203 l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l. thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ;
206 n_sensors_per_ladder.push_back( l.sensorsPerLadder);
209 gearSET->setDoubleVal(
"strip_width_mm" , set->widthStrip / dd4hep::mm ) ;
210 gearSET->setDoubleVal(
"strip_length_mm" , set->lengthStrip/ dd4hep::mm ) ;
211 gearSET->setDoubleVal(
"strip_pitch_mm" , set->pitchStrip / dd4hep::mm ) ;
212 gearSET->setDoubleVal(
"strip_angle_deg" , set->angleStrip / dd4hep::deg ) ;
215 gearSET->setIntVals(
"n_sensors_per_ladder",n_sensors_per_ladder);
217 setDE.addExtension< GearHandle >(
new GearHandle( gearSET,
"SETParameters" ) ) ;
219 }
catch( std::runtime_error& e ){
220 std::cerr <<
" >>>> " << e.what() << std::endl ;
227 DetElement ftdDE = description.detector(
"FTD") ;
231 gear::FTDParametersImpl* gearFTD =
new gear::FTDParametersImpl();
233 for(
unsigned i=0,n=ftd->layers.size() ; i<n; ++i){
235 const rec::ZDiskPetalsData::LayerLayout& l = ftd->layers[i] ;
241 static const int PIXEL = gear::FTDParameters::PIXEL ;
242 static const int STRIP = gear::FTDParameters::STRIP ;
246 double zoffset = fabs( l.zOffsetSupport ) ;
247 double signoffset = l.zOffsetSupport > 0 ? 1. : -1 ;
249 gearFTD->addLayer( l.petalNumber, l.sensorsPerPetal,
250 isDoubleSided, sensorType,
251 l.petalHalfAngle, l.phi0, l.alphaPetal,
252 l.zPosition/dd4hep::mm, zoffset/dd4hep::mm, signoffset,
253 l.distanceSupport/dd4hep::mm, l.thicknessSupport/dd4hep::mm,
254 l.widthInnerSupport/dd4hep::mm, l.widthOuterSupport/dd4hep::mm,
255 l.lengthSupport/dd4hep::mm,
257 l.distanceSensitive/dd4hep::mm, l.thicknessSensitive/dd4hep::mm,
258 l.widthInnerSensitive/dd4hep::mm, l.widthOuterSensitive/dd4hep::mm,
259 l.lengthSensitive/dd4hep::mm,
266 gearFTD->setDoubleVal(
"strip_width_mm" , ftd->widthStrip / dd4hep::mm ) ;
267 gearFTD->setDoubleVal(
"strip_length_mm" , ftd->lengthStrip/ dd4hep::mm ) ;
268 gearFTD->setDoubleVal(
"strip_pitch_mm" , ftd->pitchStrip / dd4hep::mm ) ;
269 gearFTD->setDoubleVal(
"strip_angle_deg" , ftd->angleStrip / dd4hep::deg ) ;
272 ftdDE.addExtension< GearHandle >(
new GearHandle( gearFTD,
"FTDParameters" ) ) ;
274 }
catch( std::runtime_error& e ){
275 std::cerr <<
" >>>> " << e.what() << std::endl ;
282 DetElement coilDE = description.detector(
"Coil") ;
284 gear::GearParametersImpl* gearCOIL =
new gear::GearParametersImpl();
286 Tube coilTube = Tube( coilDE.volume().solid() ) ;
288 gearCOIL->setDoubleVal(
"Coil_cryostat_inner_radius" , coilTube->GetRmin()/ dd4hep::mm ) ;
289 gearCOIL->setDoubleVal(
"Coil_cryostat_outer_radius" , coilTube->GetRmax()/ dd4hep::mm ) ;
290 gearCOIL->setDoubleVal(
"Coil_cryostat_half_z" , coilTube->GetDZ()/ dd4hep::mm ) ;
292 coilDE.addExtension< GearHandle >(
new GearHandle( gearCOIL,
"CoilParameters" ) ) ;
294 }
catch( std::runtime_error& e ){
295 std::cerr <<
" >>>> " << e.what() << std::endl ;
302 DetElement tubeDE = description.detector(
"Tube") ;
306 gear::GearParametersImpl* gearTUBE =
new gear::GearParametersImpl();
308 tube->isSymmetricInZ = true ;
310 unsigned n = tube->sections.size() ;
312 std::vector<double> rInner(n) ;
313 std::vector<double> rOuter(n) ;
314 std::vector<double> zStart(n) ;
316 for(
unsigned i=0 ; i<n ; ++i){
318 const ConicalSupportData::Section& s = tube->sections[i] ;
320 rInner[i] = s.rInner/ dd4hep::mm ;
321 rOuter[i] = s.rOuter/ dd4hep::mm ;
322 zStart[i] = s.zPos / dd4hep::mm ;
327 gearTUBE->setDoubleVals(
"RInner" , rInner ) ;
328 gearTUBE->setDoubleVals(
"ROuter" , rOuter ) ;
329 gearTUBE->setDoubleVals(
"Z" , zStart ) ;
332 tubeDE.addExtension< GearHandle >(
new GearHandle( gearTUBE,
"BeamPipe" ) ) ;
334 }
catch( std::runtime_error& e ){
335 std::cerr <<
" >>>> " << e.what() << std::endl ;
344 std::map< std::string, std::string > caloMap ;
345 caloMap[
"HcalBarrel"] =
"HcalBarrelParameters" ;
346 caloMap[
"EcalBarrel"] =
"EcalBarrelParameters" ;
347 caloMap[
"EcalEndcap"] =
"EcalEndcapParameters" ;
348 caloMap[
"EcalPlug"] =
"EcalPlugParameters" ;
349 caloMap[
"YokeBarrel"] =
"YokeBarrelParameters" ;
350 caloMap[
"YokeEndcap"] =
"YokeEndcapParameters" ;
351 caloMap[
"YokePlug"] =
"YokePlugParameters" ;
352 caloMap[
"HcalBarrel"] =
"HcalBarrelParameters" ;
353 caloMap[
"HcalEndcap"] =
"HcalEndcapParameters" ;
354 caloMap[
"HcalRing"] =
"HcalRingParameters" ;
355 caloMap[
"Lcal"] =
"LcalParameters" ;
356 caloMap[
"LHcal"] =
"LHcalParameters" ;
357 caloMap[
"BeamCal"] =
"BeamCalParameters" ;
359 for( std::map< std::string, std::string >::const_iterator it = caloMap.begin() ; it != caloMap.end() ; ++it ){
365 DetElement caloDE = description.detector( it->first ) ;
369 gear::CalorimeterParametersImpl* gearCalo =
370 ( calo->layoutType == LayeredCalorimeterData::BarrelLayout ?
371 new gear::CalorimeterParametersImpl( calo->extent[0]/dd4hep::mm, calo->extent[3]/dd4hep::mm, calo->inner_symmetry, calo->phi0 ) :
373 new
gear::CalorimeterParametersImpl( calo->extent[0]/
dd4hep::mm, calo->extent[1]/
dd4hep::mm, calo->extent[2]/
dd4hep::mm, calo->outer_symmetry, calo->phi0 ) ) ;
376 for(
unsigned i=0, nL = calo->layers.size() ; i <nL ; ++i ){
378 LayeredCalorimeterData::Layer& l = calo->layers[i] ;
384 gearCalo->layerLayout().positionLayer( l.distance/dd4hep::mm,
385 (l.inner_thickness+l.sensitive_thickness/2.)/dd4hep::mm ,
386 l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm,
387 (l.inner_thickness-l.sensitive_thickness/2.)/dd4hep::mm ) ;
389 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 ,
390 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) ;
402 if( it->first ==
"HcalBarrel" ){
404 gearCalo->setIntVal(
"Hcal_outer_polygon_order" , calo->outer_symmetry ) ;
405 gearCalo->setDoubleVal(
"Hcal_outer_polygon_phi0" , calo->phi0 ) ;
408 if( it->first ==
"BeamCal" ){
413 SensitiveDetector sD = description.sensitiveDetector( it->first ) ;
414 Readout readOut = sD.readout() ;
415 Segmentation seg = readOut.segmentation() ;
423 double offsetPhi = oPPar->typedValue() ;
424 double spanningPhi = 360.*dd4hep::deg - 2.*( offsetPhi + 180.*dd4hep::deg ) ;
426 gearCalo->setDoubleVals(
"phi_segmentation" , pPar->typedValue() );
427 gearCalo->setDoubleVal(
"cylinder_starting_phi", offsetPhi );
428 gearCalo->setDoubleVal(
"cylinder_spanning_phi", spanningPhi );
429 gearCalo->setDoubleVal(
"beam_crossing_angle" , crossing_angle );
433 gearCalo->setDoubleVal(
"dead_area_outer_r" , 0 );
434 gearCalo->setDoubleVal(
"pairsMonitorZ" , 0. );
435 gearCalo->setDoubleVal(
"FIXME_dead_area_outer_r" , -1. );
436 gearCalo->setDoubleVal(
"FIXME_pairsMonitorZ" , -1. );
438 }
catch( std::runtime_error& e ){
439 std::cerr <<
" >>>> BeamCal: " << e.what() << std::endl ;
443 if( it->first ==
"Lcal" || it->first ==
"LHcal" ){
444 gearCalo->setDoubleVal(
"beam_crossing_angle" , crossing_angle );
447 caloDE.addExtension< GearHandle >(
new GearHandle( gearCalo, it->second ) ) ;
449 }
catch( std::runtime_error& e ){
450 std::cerr <<
" >>>> " << e.what() << std::endl ;