ATLAS Offline Software
InDetServMatFactory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "InDetServMatFactory.h"
6 
7 // Pixel, SCT and TRT factories
8 #include "PixelServMatFactory.h"
9 #include "SCT_ServMatFactory.h"
10 #include "TRT_ServMatFactory.h"
11 #include "EndPlateFactory.h"
12 #include "SupportRailFactory.h"
13 #include "SquirrelCageFactory.h"
14 
15 // Extra material
18 
19 // Material manager
21 
22 // GeoModel includes
23 #include "GeoModelKernel/GeoNameTag.h"
24 #include "GeoModelKernel/GeoPhysVol.h"
25 #include "GeoModelKernel/GeoPcon.h"
26 #include "GeoModelKernel/GeoShapeUnion.h"
30 
31 // RDBAccessSvc includes
35 
36 // StoreGate includes
37 #include "StoreGate/StoreGateSvc.h"
38 #include "GaudiKernel/PhysicalConstants.h"
39 
41 
42 #include <iostream>
43 
45  : InDetDD::DetectorFactoryBase(athenaComps)
46 {
47 }
48 
49 //## Other Operations (implementation)
50 void InDetServMatFactory::create(GeoPhysVol *world )
51 {
52 
53  // create a new det manager
55 
56  // Get the material manager:
57  DecodeVersionKey sctVersionKey(geoDbTagSvc(),"SCT");
58  DecodeVersionKey trtVersionKey(geoDbTagSvc(),"TRT");
59  DecodeVersionKey indetVersionKey(geoDbTagSvc(),"InnerDetector");
60  DecodeVersionKey atlasVersionKey(geoDbTagSvc(),"ATLAS");
61 
62 
63  msg(MSG::DEBUG) << "Building InDet Service Material with ATLAS Version Tag: " << atlasVersionKey.tag() << endmsg;
64  msg(MSG::DEBUG) << " with InDet Version Tag: " << indetVersionKey.tag() << " at Node: "
65  << indetVersionKey.node() << endmsg;
66  msg(MSG::DEBUG) << " with TRT Version Tag: " << trtVersionKey.tag() << " at Node: "
67  << trtVersionKey.node() << endmsg;
68  msg(MSG::DEBUG) << " with SCT Version Tag: " << sctVersionKey.tag() << " at Node: "
69  << sctVersionKey.node() << endmsg;
70  msg(MSG::DEBUG) << " InDetServices Version " << rdbAccessSvc()->getChildTag("InDetServices", indetVersionKey.tag(), indetVersionKey.node()) << endmsg;
71  msg(MSG::DEBUG) << " TRT Version " << rdbAccessSvc()->getChildTag("TRT", trtVersionKey.tag(), trtVersionKey.node()) << endmsg;
72  msg(MSG::DEBUG) << " SCT Version " << rdbAccessSvc()->getChildTag("SCT", sctVersionKey.tag(), sctVersionKey.node()) << endmsg;
73 
74  IRDBRecordset_ptr atls = rdbAccessSvc()->getRecordsetPtr("AtlasMother", atlasVersionKey.tag(), atlasVersionKey.node());
75 
76  IRDBRecordset_ptr servEnvelopeTable =
77  rdbAccessSvc()->getRecordsetPtr("InDetServEnvelope", indetVersionKey.tag(), indetVersionKey.node());
78  const IRDBRecord *envelopes = (*servEnvelopeTable)[0];
79 
80  IRDBRecordset_ptr scalingTable = rdbAccessSvc()->getRecordsetPtr("InDetServMatScaling", indetVersionKey.tag(), indetVersionKey.node());
81 
82  InDetMaterialManager * materialManager = new InDetMaterialManager("InDetServMatMaterialManager", getAthenaComps());
83  materialManager->addScalingTable(scalingTable);
84 
85  double safety = 0.001 * Gaudi::Units::mm;
86 
87  double ZMaxBrlTRT = envelopes->getDouble("ZMAXBRLTRT") * Gaudi::Units::mm;
88  double ZMaxBrlSCT = envelopes->getDouble("ZMAXBRLSCT") * Gaudi::Units::mm;
89  double ZMinFwdSCTandTRT = envelopes->getDouble("ZMINFWDSCTANDTRT") * Gaudi::Units::mm;
90  double ZMinSCTServInTRT = envelopes->getDouble("ZMINSCTSERVINTRT") * Gaudi::Units::mm;
91  double ZMaxSCTServInTRT = envelopes->getDouble("ZMAXSCTSERVINTRT") * Gaudi::Units::mm;
92  double ZMinPixServ = envelopes->getDouble("ZMINPIXSERV") * Gaudi::Units::mm;
93  double ZMaxFwdTRTC = envelopes->getDouble("ZMAXFWDTRTC") * Gaudi::Units::mm;
94  double ZMaxIDet = (*atls)[0]->getDouble("IDETZMX") * Gaudi::Units::cm + safety; // 3470 mm
95 
96  double RMinBrlSCT = envelopes->getDouble("RMINBRLSCT") * Gaudi::Units::mm;
97  double RMaxBrlTRT = envelopes->getDouble("RMAXBRLTRT") * Gaudi::Units::mm;
98  double RMinBrlTRT = envelopes->getDouble("RMINBRLTRT") * Gaudi::Units::mm;
99  double RMaxFwdTRT = envelopes->getDouble("RMAXFWDTRT") * Gaudi::Units::mm;
100  double RMaxFwdSCT = envelopes->getDouble("RMAXFWDSCT") * Gaudi::Units::mm;
101  double RMaxFwdTRTC = envelopes->getDouble("RMAXFWDTRTC") * Gaudi::Units::mm;
102  double RMinPixServ = envelopes->getDouble("RMINPIXSERV") * Gaudi::Units::mm;
103  double RMaxPixServ = envelopes->getDouble("RMAXPIXSERV") * Gaudi::Units::mm;
104  double RMaxIDet = (*atls)[0]->getDouble("IDETOR") * Gaudi::Units::cm + safety; // 1147 mm
105 
106  // Since the TRT Wheel C space is not used in some versions and is used by some
107  // other services we simplify the volume.
108  // The 1mm is just to ensure the dimensions are considered equal if they differ
109  // by less than 1mm.
110 
111  // join1 is True if the pixel service volume and SCT/TRT volume are joined
112  // (ie boolean volume not needed)
113  // join2 is True if RMaxFwdTRTC and RMaxPixServ are ~ the same as RMinPixServ
114  // in which case a couple of planes are not needed in the PCON.
115 
116  bool join1 = false;
117  bool join2 = false;
118 
119  if (std::abs(RMaxFwdTRTC - RMinPixServ) <= 1*Gaudi::Units::mm){
120  join1 = true;
121  join2 = true;
122  RMaxFwdTRTC = RMinPixServ;
123  RMaxPixServ = RMinPixServ;
124  } else if ((RMaxFwdTRTC - 1*Gaudi::Units::mm) <= RMaxPixServ) {
125  join1 = true;
126  RMaxPixServ = RMaxFwdTRTC;
127  }
128 
129 
130  //
131  // Create the envelope for the Pixel Services:
132  // Only need if join1 if false.
133 
134  const GeoShapeUnion *ServVolAux = nullptr;
135 
136  if (!join1) {
137  GeoPcon* pixServP = new GeoPcon(0.,2*Gaudi::Units::pi);
138  GeoPcon* pixServM = new GeoPcon(0.,2*Gaudi::Units::pi);
139 
140  // Plane 1: Start at the end of the SCT endcap
141  pixServP->addPlane(ZMinPixServ, RMinPixServ, RMaxPixServ);
142  pixServM->addPlane(-ZMinPixServ, RMinPixServ, RMaxPixServ);
143 
144  // Plane 2 and 3: at the end of the TRT endcap
145  pixServP->addPlane(ZMaxFwdTRTC, RMinPixServ, RMaxPixServ);
146  pixServP->addPlane(ZMaxFwdTRTC, RMinPixServ, RMaxIDet);
147  pixServM->addPlane(-ZMaxFwdTRTC, RMinPixServ, RMaxPixServ);
148  pixServM->addPlane(-ZMaxFwdTRTC, RMinPixServ, RMaxIDet);
149 
150  // Plane 4 at the end of the ID
151  pixServP->addPlane(ZMaxIDet, RMinPixServ, RMaxIDet);
152  pixServM->addPlane(-ZMaxIDet, RMinPixServ, RMaxIDet);
153 
154  ServVolAux = new GeoShapeUnion(pixServP, pixServM);
155  }
156 
157  // This is the volume for the TRT/SCT services
158  GeoPcon *sctTrtServ = new GeoPcon(0.,2*Gaudi::Units::pi);
159 
160  // Pixel Services
161  if (join1) {
162  // THE BEGINNING
163  sctTrtServ->addPlane(-ZMaxIDet, RMinPixServ, RMaxIDet);
164  // PP1 region.
165  if (!join2) {
166  sctTrtServ->addPlane(-ZMinPixServ, RMinPixServ, RMaxIDet);
167  sctTrtServ->addPlane(-ZMinPixServ, RMaxPixServ, RMaxIDet);
168  }
169  } else {
170  // THE BEGINNING
171  sctTrtServ->addPlane(-ZMaxIDet, RMaxFwdTRTC, RMaxIDet);
172  }
173 
174  // SCT services in TRT endcap
175  sctTrtServ->addPlane(-ZMaxSCTServInTRT, RMaxFwdTRTC, RMaxIDet);
176  sctTrtServ->addPlane(-ZMaxSCTServInTRT, RMaxFwdSCT, RMaxIDet);
177  sctTrtServ->addPlane(-ZMinSCTServInTRT, RMaxFwdSCT, RMaxIDet);
178  sctTrtServ->addPlane(-ZMinSCTServInTRT, RMaxFwdTRT, RMaxIDet);
179 
180  // Beginning of Ecap SCT and TRT
181  sctTrtServ->addPlane(-ZMinFwdSCTandTRT, RMaxFwdTRT, RMaxIDet);
182  sctTrtServ->addPlane(-ZMinFwdSCTandTRT, RMinBrlSCT, RMaxIDet);
183 
184  // End of Barrel SCT (SCT barrel services)
185  sctTrtServ->addPlane(-ZMaxBrlSCT, RMinBrlSCT, RMaxIDet);
186  sctTrtServ->addPlane(-ZMaxBrlSCT, RMinBrlTRT, RMaxIDet);
187 
188  // Plane, end of barrel TRT (TRT barrel services)
189  sctTrtServ->addPlane(-ZMaxBrlTRT, RMinBrlTRT, RMaxIDet);
190  sctTrtServ->addPlane(-ZMaxBrlTRT, RMaxBrlTRT, RMaxIDet);
191 
192 
193  // THE OTHER SIDE
194  // Plane, end of barrel TRT (TRT barrel services)
195  sctTrtServ->addPlane(ZMaxBrlTRT, RMaxBrlTRT, RMaxIDet);
196  sctTrtServ->addPlane(ZMaxBrlTRT, RMinBrlTRT, RMaxIDet);
197 
198  // End of Barrel SCT (SCT barrel services)
199  sctTrtServ->addPlane(ZMaxBrlSCT, RMinBrlTRT, RMaxIDet);
200  sctTrtServ->addPlane(ZMaxBrlSCT, RMinBrlSCT, RMaxIDet);
201 
202  // Beginning of Ecap SCT and TRT
203  sctTrtServ->addPlane(ZMinFwdSCTandTRT, RMinBrlSCT, RMaxIDet);
204  sctTrtServ->addPlane(ZMinFwdSCTandTRT, RMaxFwdTRT, RMaxIDet);
205 
206  // SCT services in TRT endcap
207  sctTrtServ->addPlane(ZMinSCTServInTRT, RMaxFwdTRT, RMaxIDet);
208  sctTrtServ->addPlane(ZMinSCTServInTRT, RMaxFwdSCT, RMaxIDet);
209  sctTrtServ->addPlane(ZMaxSCTServInTRT, RMaxFwdSCT, RMaxIDet);
210  sctTrtServ->addPlane(ZMaxSCTServInTRT, RMaxFwdTRTC, RMaxIDet);
211 
212  // Pixel Services
213  if (join1) {
214  // PP1 region
215  if (!join2) {
216  sctTrtServ->addPlane(ZMinPixServ, RMaxPixServ, RMaxIDet);
217  sctTrtServ->addPlane(ZMinPixServ, RMinPixServ, RMaxIDet);
218  }
219  // The end
220  sctTrtServ->addPlane(ZMaxIDet, RMinPixServ, RMaxIDet);
221  } else {
222 
223  // The end
224  sctTrtServ->addPlane(ZMaxIDet, RMaxFwdTRTC, RMaxIDet);
225  }
226 
227  const GeoShape * ServVol = nullptr;
228  if (ServVolAux == nullptr) {
229  ServVol = sctTrtServ;
230  } else {
231  ServVol = new GeoShapeUnion(sctTrtServ, ServVolAux);
232  }
233  const GeoMaterial* air = materialManager->getMaterial("std::Air");
234  const GeoLogVol* ServLog = new GeoLogVol("ServLog",ServVol,air);
235  GeoPhysVol* ServPhys = new GeoPhysVol(ServLog);
236 
237  // Add this to the world and register it to the manager so GeoG4 will
238  // find it.
239  //
240  GeoNameTag *tag = new GeoNameTag("InDetServMat");
241  world->add(tag);
242  world->add(ServPhys);
243  m_manager->addTreeTop(ServPhys);
244  // Pixel Services:
246  PSMF.create(ServPhys);
247 
248  // SCT Services:
250  SSMF.create(ServPhys);
251 
252  // TRT Services:
254  TSMF.create(ServPhys);
255 
256  // EP:
257  EndPlateFactory EPMF(getAthenaComps(), materialManager);
258  EPMF.create(ServPhys);
259 
260  // Rails:
261  SupportRailFactory RAMF(getAthenaComps(), materialManager);
262  RAMF.create(ServPhys);
263 
264  // SquirrelCage:
265  SquirrelCageFactory SQCF(getAthenaComps(), materialManager);
266  SQCF.create(ServPhys);
267 
268  // Extra material
270  InDetDD::ExtraMaterial xMat(&xMatManager);
271  xMat.add(ServPhys, "InDetServMat");
272 
273  delete materialManager;
274 
275 }
276 
277 
279  return m_manager;
280 }
281 
PixelServMatFactory.h
InDetServMatFactory::InDetServMatFactory
InDetServMatFactory(InDetDD::AthenaComps *athenaComps)
Definition: InDetServMatFactory.cxx:44
IRDBAccessSvc::getRecordsetPtr
virtual IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD")=0
Provides access to the Recordset object containing HVS-tagged data.
EndPlateFactory.h
InDetDD::AthenaComps
Class to hold various Athena components.
Definition: InDetDDAthenaComps.h:21
InDetDD::DistortedMaterialManager
Definition: DistortedMaterialManager.h:14
SCT_ServMatFactory
Definition: SCT_ServMatFactory.h:15
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:99
ExtraMaterial.h
InDetDD::DetectorFactoryBase::msg
MsgStream & msg(MSG::Level lvl) const
Definition: InDetDetectorFactoryBase.h:37
InDetServMatFactory::m_manager
InDetDD::InDetServMatManager * m_manager
Definition: InDetServMatFactory.h:36
InDetDD::ExtraMaterial::add
void add(GeoPhysVol *parent, const std::string &parentName, double zPos=0)
Definition: ExtraMaterial.cxx:42
pi
#define pi
Definition: TileMuonFitter.cxx:65
SupportRailFactory::create
void create(GeoPhysVol *mother)
Definition: SupportRailFactory.cxx:48
SupportRailFactory
Definition: SupportRailFactory.h:12
EndPlateFactory
Definition: EndPlateFactory.h:12
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
InDetServMatFactory::getDetectorManager
virtual const InDetDD::InDetServMatManager * getDetectorManager() const override
Definition: InDetServMatFactory.cxx:278
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
IRDBAccessSvc::getChildTag
virtual std::string getChildTag(const std::string &childNode, const std::string &parentTag, const std::string &parentNode, const std::string &connName="ATLASDD")=0
Gets the tag name for the node by giving its parent node tag.
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:93
EndPlateFactory::create
void create(GeoPhysVol *mother)
Definition: EndPlateFactory.cxx:46
SCT_ServMatFactory::create
void create(GeoPhysVol *mother)
Definition: SCT_ServMatFactory.cxx:47
SupportRailFactory.h
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
TRT_ServMatFactory
Definition: TRT_ServMatFactory.h:15
InDetMaterialManager
InDetMaterialManager.
Definition: InDetMaterialManager.h:34
InDetMaterialManager.h
InDetDD::DetectorFactoryBase::geoDbTagSvc
const IGeoDbTagSvc * geoDbTagSvc() const
Definition: InDetDetectorFactoryBase.h:30
StoredMaterialManager.h
InDetMaterialManager::addScalingTable
void addScalingTable(const IRDBRecordset_ptr &scalingTable)
Definition: InDetMaterialManager.cxx:431
DecodeVersionKey.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
TRT_ServMatFactory::create
void create(GeoPhysVol *mother)
Definition: TRT_ServMatFactory.cxx:49
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
SquirrelCageFactory::create
void create(GeoPhysVol *mother)
Definition: SquirrelCageFactory.cxx:47
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
SquirrelCageFactory
Definition: SquirrelCageFactory.h:12
InDetDD::DetectorFactoryBase::rdbAccessSvc
IRDBAccessSvc * rdbAccessSvc()
Definition: InDetDetectorFactoryBase.h:32
DEBUG
#define DEBUG
Definition: page_access.h:11
IRDBRecord::getDouble
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
InDetMaterialManager::getMaterial
const GeoMaterial * getMaterial(const std::string &materialName)
Get material. First looks for locally defined material and if not found looks in GeoModel material ma...
Definition: InDetMaterialManager.cxx:96
SCT_ServMatFactory.h
PixelServMatFactory::create
void create(GeoPhysVol *mother)
Definition: PixelServMatFactory.cxx:44
checker_macros.h
Define macros for attributes used to control the static checker.
InDetDD::ExtraMaterial
Definition: ExtraMaterial.h:23
InDetDD::InDetServMatManager::addTreeTop
void addTreeTop(const PVConstLink &)
Definition: InDetServMatManager.cxx:37
InDetServMatFactory.h
StoreGateSvc.h
IGeoDbTagSvc.h
DistortedMaterialManager.h
TRT_ServMatFactory.h
InDetDD::DetectorFactoryBase::getAthenaComps
InDetDD::AthenaComps * getAthenaComps()
Definition: InDetDetectorFactoryBase.h:42
SquirrelCageFactory.h
InDetServMatFactory::create
virtual void create(GeoPhysVol *world) override
Definition: InDetServMatFactory.cxx:50
InDetDD::InDetServMatManager
Definition: InDetServMatManager.h:22
PixelServMatFactory
Definition: PixelServMatFactory.h:13