13 #include "DD4hep/Detector.h"
14 #include "DD4hep/Factories.h"
15 #include "DD4hep/DD4hepUnits.h"
23 #include "DDSegmentation/Segmentation.h"
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 ;
57 double crossing_angle(0.) ;
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 ) ;
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. ) ;
115 const rec::ZPlanarData::LayerLayout& l = vxd->layers[0] ;
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. ) ;
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);
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. ) ;
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);
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 ) ;
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 ) ;
302 DetElement tubeDE = description.detector(
"Tube") ;
306 gear::GearParametersImpl* gearTUBE =
new gear::GearParametersImpl();
308 tube->isSymmetricInZ = true ;
310 unsigned n = tube->sections.size() ;
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 ) ;
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" ;
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() ;
418 DDSegmentation::DoubleVecParameter pPar =
dynamic_cast<DDSegmentation::DoubleVecParameter
>( seg.parameter(
"grid_phi_values"));
419 DDSegmentation::DoubleParameter oPPar=
dynamic_cast<DDSegmentation::DoubleParameter
>( seg.parameter(
"offset_phi"));
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. );
443 if( it->first ==
"Lcal" || it->first ==
"LHcal" ){
444 gearCalo->setDoubleVal(
"beam_crossing_angle" , crossing_angle );
virtual double radiationLength() const
radiation length - tgeo units
virtual double interactionLength() const
interaction length - tgeo units
static long createGearForILD(Detector &description, int, char **)
Plugin that creates Gear objects for DetElements and attaches them as extensions. ...
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
void addMaterial(const std::string nam, double A, double Z, double density, double radLen, double intLen)
add a SimpleMaterial object
const MaterialVec & materialsBetween(const Vector3D &p0, const Vector3D &p1, double epsilon=1e-4)
Get a vector with all the materials between the two points p0 and p1 with the corresponding thickness...
Simple wrapper class for objects of type GearParametersImpl that can be added to DetElements with the...
MaterialData createAveragedMaterial(const MaterialVec &materials)
Create a material with averaged properties from all materials in the list.
static Cylindrical cylindrical()
virtual double density() const
density
Wrapper class for adding structs or pods as extensions to DetElements.
virtual double A() const
averaged atomic number
Simple data class that implements the IMaterial interface and is used in the Surface implementation...
virtual double Z() const
averaged proton number
Material manager provides access to the material properties of the detector.