ATLAS Offline Software
TRT_ServMatFactory.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 "TRT_ServMatFactory.h"
6 
7 // GeoModel includes
9 #include "GeoModelKernel/GeoDefinitions.h"
10 #include "GeoModelKernel/GeoPhysVol.h"
11 #include "GeoModelKernel/GeoLogVol.h"
12 #include "GeoModelKernel/GeoTube.h"
13 #include "GeoModelKernel/GeoTubs.h"
14 #include "GeoModelKernel/GeoPcon.h"
15 #include "GeoModelKernel/GeoCons.h"
16 #include "GeoModelKernel/GeoMaterial.h"
17 #include "GeoModelKernel/GeoTransform.h"
18 #include "GeoModelKernel/GeoShapeSubtraction.h"
19 
23 
29 #include "GaudiKernel/SystemOfUnits.h"
30 
32 
33 #include <sstream>
34 #include <iostream>
35 
37  : InDetDD::SubDetectorFactoryBase(athenaComps)
38 {
39 }
40 
41 
43 {
44 }
45 
46 
47 
48 //## Other Operations (implementation)
49 void TRT_ServMatFactory::create(GeoPhysVol *mother)
50 {
51 
52  msg(MSG::DEBUG) << "Building TRT Service Material" << endmsg;
53 
54  //double epsilon = 0.002;
55 
56  DecodeVersionKey atlasVersionKey(geoDbTagSvc(),"ATLAS");
57  DecodeVersionKey indetVersionKey(geoDbTagSvc(),"InnerDetector");
58  DecodeVersionKey trtVersionKey(geoDbTagSvc(),"TRT");
59 
60  std::string railversion = rdbAccessSvc()->getChildTag("IDDetailedRail",indetVersionKey.tag(),indetVersionKey.node());
61  if(!railversion.empty()) {
62  // ______________________________________________________________________________________________________________________
63  // Geometry with ID rail
64 
65  IRDBRecordset_ptr atls = rdbAccessSvc()->getRecordsetPtr("AtlasMother", atlasVersionKey.tag(), atlasVersionKey.node());
66  IRDBRecordset_ptr cage = rdbAccessSvc()->getRecordsetPtr("SquirrelCage", indetVersionKey.tag(), indetVersionKey.node());
67  IRDBRecordset_ptr trtGenServices = rdbAccessSvc()->getRecordsetPtr("TRTGenServices", indetVersionKey.tag(), indetVersionKey.node());
68 
69  // Doesn't exist at time of writing but we include it to keep things general
70  IRDBRecordset_ptr weightTable = rdbAccessSvc()->getRecordsetPtr("TrtWeights", trtVersionKey.tag(), trtVersionKey.node());
71 
72  IRDBRecordset_ptr scalingTable = rdbAccessSvc()->getRecordsetPtr("InDetServMatScaling", indetVersionKey.tag(), indetVersionKey.node());
73 
74  // Get the InDet material manager. This is a wrapper around the geomodel one with some extra functionality to deal
75  // with weights table if it exists
76  m_materialManagerUnique = std::make_unique<InDetMaterialManager>("TRT_MaterialManager", getAthenaComps());
78  m_materialManager->addWeightTable(weightTable, "trt");
79  m_materialManager->addScalingTable(scalingTable);
80 
81  //VK 10/09/2005 Construct a gap for rails
82  double outROfIDet = (*atls)[0]->getDouble("IDETOR")*Gaudi::Units::cm;
83  double endZOfIDet = (*atls)[0]->getDouble("IDETZMX")*Gaudi::Units::cm;
84 
85 //VK 26.03.2007 Construct a gap for SquirrelCage ribbon
86  double rminInt = (*cage)[0]->getDouble("RINGRMIN")*Gaudi::Units::mm;
87 
88 //created by Adam Agocs
89  IRDBRecordset_ptr commonParameters = rdbAccessSvc()->getRecordsetPtr("IDDetRailCommon",indetVersionKey.tag(), indetVersionKey.node());
90  if(commonParameters->size()==0)
91  commonParameters = rdbAccessSvc()->getRecordsetPtr("IDDetRailCommon","IDDetRailCommon-00");
92 
93  double yWidthUSP1 = (*commonParameters)[0]->getDouble("YWIDTHUSP1");
94  double yRailSup = (*commonParameters)[0]->getDouble("YRAILSUP");
95  double yRailSupPart3 = (*commonParameters)[0]->getDouble("YRAILSUPPART3");
96  double gapOfRSF = (*commonParameters)[0]->getDouble("GAPOFRSF");
97  double yWidthTRSB = (*commonParameters)[0]->getDouble("YWIDTHTRSB");
98 
99  double coordY = yWidthUSP1/2. - yRailSup + (yRailSupPart3 - gapOfRSF/2.);
100 
101  double phiTop = asin((yWidthTRSB + coordY) / (rminInt));
102  double phiBot = asin((yWidthTRSB/2. - coordY) / (rminInt));
103 
104  GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( rminInt, outROfIDet, endZOfIDet, -phiBot, phiBot + phiTop)};
105  GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( rminInt, outROfIDet, endZOfIDet, M_PI - phiTop, phiBot + phiTop)};
106 
107 
108  for (unsigned int ii =0; ii < trtGenServices->size(); ii++) {
109 
110  InDetDD::GenericTubeMaker tubeHelper((*trtGenServices)[ii]);
111  const GeoShape * serviceTubeTmp = tubeHelper.buildShape();
112 
113  std::string logName = tubeHelper.name();
114  if (logName.empty()) {
115  std::ostringstream o; o << ii;
116  logName = "ServMat"+o.str();
117  }
118  logName = "Trt" + logName;
119 
120  const GeoShape* serviceTube = serviceTubeTmp;
121 
122  if( tubeHelper.volData().maxRadius() > rminInt && tubeHelper.volData().phiDelta() > 359.9*Gaudi::Units::degree)
123  {
124  // Subtract RailGap out of services
125  serviceTube = (GeoShape*) & (*serviceTubeTmp).subtract(*railGap2).subtract(*railGap1);
126  }
127 
128  std::string materialName = tubeHelper.materialName();
129  //const GeoMaterial* material = m_materialManager->getMaterialForVolume(materialName, serviceTube->volume());
130  const GeoMaterial* material = m_materialManager->getMaterial(materialName);
131 
132  const GeoLogVol* servLog = new GeoLogVol(logName,serviceTube,material);
133  GeoVPhysVol* servPhys = new GeoPhysVol(servLog);
134 
135  if (tubeHelper.name() == "FwdServ")
136  {
137  GeoTransform *xform1 = new GeoTransform(GeoTrf::Translate3D(0, 0, tubeHelper.volData().zMid() ));
138  GeoTransform *xform2 = new GeoTransform(GeoTrf::Translate3D(0, 0, -tubeHelper.volData().zMid() ));
139  mother->add(xform1); mother->add(servPhys); mother->add(xform2); mother->add(servPhys);
140  }
141  else {
142  tubeHelper.placeVolume(mother, servPhys);
143  }
144  }
145 
146  }
147  else {
148  // ______________________________________________________________________________________________________________________
149  // Geometry without ID rail
150  IRDBRecordset_ptr atls = rdbAccessSvc()->getRecordsetPtr("AtlasMother", atlasVersionKey.tag(), atlasVersionKey.node());
151  IRDBRecordset_ptr cage = rdbAccessSvc()->getRecordsetPtr("SquirrelCage", indetVersionKey.tag(), indetVersionKey.node());
152  IRDBRecordset_ptr trtGenServices = rdbAccessSvc()->getRecordsetPtr("TRTGenServices", indetVersionKey.tag(), indetVersionKey.node());
153 
154  // Doesn't exist at time of writing but we include it to keep things general
155  IRDBRecordset_ptr weightTable = rdbAccessSvc()->getRecordsetPtr("TrtWeights", trtVersionKey.tag(), trtVersionKey.node());
156 
157  IRDBRecordset_ptr scalingTable = rdbAccessSvc()->getRecordsetPtr("InDetServMatScaling", indetVersionKey.tag(), indetVersionKey.node());
158 
159  // Get the InDet material manager. This is a wrapper around the geomodel one with some extra functionality to deal
160  // with weights table if it exists
161  m_materialManager = new InDetMaterialManager("TRT_MaterialManager", getAthenaComps());
162  m_materialManager->addWeightTable(weightTable, "trt");
163  m_materialManager->addScalingTable(scalingTable);
164 
165  //VK 10/09/2005 Construct a gap for rails
166  double outROfIDet = (*atls)[0]->getDouble("IDETOR")*Gaudi::Units::cm;
167  double endZOfIDet = (*atls)[0]->getDouble("IDETZMX")*Gaudi::Units::cm;
168  double minRofGap = 1050.0;
169  double phiWid=70./outROfIDet; double safetyGap=1.;
170  GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap ,
171  -phiWid/2.,phiWid)};
172  GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap ,
173  -phiWid/2.+M_PI,phiWid)};
174 
175 
176 
177 //VK 26.03.2007 Construct a gap for SquirrelCage ribbon
178  double rminInt = (*cage)[0]->getDouble("RINGRMIN")*Gaudi::Units::mm;
179  double ringThick = (*cage)[0]->getDouble("RINGTHICK")*Gaudi::Units::mm;
180  double ringGap = (*cage)[0]->getDouble("RINGGAP")*Gaudi::Units::mm;
181  double ribWid = (*cage)[0]->getDouble("RIBWIDTH")*Gaudi::Units::mm;
182  double phiWidSQ=ribWid/(rminInt+ringThick+ringGap/2.);
183 
184 
185 
186 
187  // Build general services:
188  //
189 
190  for (unsigned int ii =0; ii < trtGenServices->size(); ii++) {
191 
192  InDetDD::GenericTubeMaker tubeHelper((*trtGenServices)[ii]);
193  const GeoShape * serviceTubeTmp = tubeHelper.buildShape();
194 
195  std::string logName = tubeHelper.name();
196  if (logName.empty()) {
197  std::ostringstream o; o << ii;
198  logName = "ServMat"+o.str();
199  }
200  logName = "Trt" + logName;
201 
202 
203 
204  const GeoShape* serviceTube = serviceTubeTmp;
205 
206 
207  if (tubeHelper.name() == "FwdServ") {
208  const GeoShape* ribSup1 = new GeoTubs( tubeHelper.volData().rmin(), tubeHelper.volData().rmax(), 0.5*tubeHelper.volData().length(),
209  -phiWidSQ/2., phiWidSQ);
210  const GeoShape* ribSup2 = new GeoTubs( tubeHelper.volData().rmin(), tubeHelper.volData().rmax(), 0.5*tubeHelper.volData().length(),
211  -phiWidSQ/2.+M_PI, phiWidSQ);
212  serviceTube = (GeoShape*) & (*serviceTubeTmp).subtract(*ribSup1).subtract(*ribSup2);
213  } else if( tubeHelper.volData().maxRadius() > minRofGap && tubeHelper.volData().phiDelta() > 359.9*Gaudi::Units::degree) {
214  // Subtract RailGap out of services
215  serviceTube = (GeoShape*) & (*serviceTubeTmp).subtract(*railGap2).subtract(*railGap1);
216  }
217 
218  std::string materialName = tubeHelper.materialName();
219  //const GeoMaterial* material = materialManager()->getMaterialForVolume(materialName, serviceTube->volume());
220  const GeoMaterial* material = materialManager()->getMaterial(materialName);
221 
222  const GeoLogVol* servLog = new GeoLogVol(logName,serviceTube,material);
223  GeoVPhysVol* servPhys = new GeoPhysVol(servLog);
224 
225  tubeHelper.placeVolume(mother, servPhys);
226 
227  }
228  }
229 }
230 
InDetDD::GenericTubeMaker::buildShape
const GeoShape * buildShape()
Definition: GenericTubeMaker.cxx:37
InDetMaterialManager::addWeightTable
void addWeightTable(const IRDBRecordset_ptr &weightTable, const std::string &space="")
Definition: InDetMaterialManager.cxx:321
InDetDD::GenericTubeMaker
Definition: GenericTubeMaker.h:29
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.
InDetDD::AthenaComps
Class to hold various Athena components.
Definition: InDetDDAthenaComps.h:21
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDetDD::SubDetectorFactoryBase::getAthenaComps
InDetDD::AthenaComps * getAthenaComps()
Definition: InDetSubDetectorFactoryBase.h:55
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:97
InDetDD::GenericTubeMaker::materialName
std::string materialName() const
Definition: GenericTubeMaker.cxx:27
TRT_ServMatFactory::~TRT_ServMatFactory
~TRT_ServMatFactory()
Definition: TRT_ServMatFactory.cxx:42
InDetDD::TubeVolData::rmax
double rmax() const
Definition: TubeVolData.h:23
InDetDD::GenericTubeMaker::name
std::string name() const
Definition: GenericTubeMaker.cxx:32
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
GeoPrimitives.h
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
InDetDD::SubDetectorFactoryBase::m_materialManager
InDetMaterialManager * m_materialManager
Definition: InDetSubDetectorFactoryBase.h:61
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.
InDetDD::TubeVolData::length
double length() const
Definition: TubeVolData.h:26
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:91
InDetDD::SubDetectorFactoryBase::rdbAccessSvc
IRDBAccessSvc * rdbAccessSvc()
Definition: InDetSubDetectorFactoryBase.h:43
GenericTubeMaker.h
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
InDetMaterialManager
InDetMaterialManager.
Definition: InDetMaterialManager.h:34
InDetMaterialManager.h
InDetDD::TubeVolData::phiDelta
double phiDelta() const
Definition: TubeVolData.h:29
InDetDD::SubDetectorFactoryBase::geoDbTagSvc
const IGeoDbTagSvc * geoDbTagSvc() const
Definition: InDetSubDetectorFactoryBase.h:41
InDetDD::GenericTubeMaker::volData
const TubeVolData & volData() const
Definition: GenericTubeMaker.h:32
InDetDD::SubDetectorFactoryBase::m_materialManagerUnique
std::unique_ptr< InDetMaterialManager > m_materialManagerUnique
Definition: InDetSubDetectorFactoryBase.h:63
InDetMaterialManager::addScalingTable
void addScalingTable(const IRDBRecordset_ptr &scalingTable)
Definition: InDetMaterialManager.cxx:431
DecodeVersionKey.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
InDetDD::SubDetectorFactoryBase::msg
MsgStream & msg(MSG::Level lvl) const
Definition: InDetSubDetectorFactoryBase.h:50
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
DEBUG
#define DEBUG
Definition: page_access.h:11
InDetDD::SubDetectorFactoryBase::materialManager
InDetMaterialManager * materialManager()
Definition: InDetSubDetectorFactoryBase.h:47
InDetDD::TubeVolData::rmin
double rmin() const
Definition: TubeVolData.h:22
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
TRT_ServMatFactory::TRT_ServMatFactory
TRT_ServMatFactory(InDetDD::AthenaComps *athenaComps)
Definition: TRT_ServMatFactory.cxx:36
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
checker_macros.h
Define macros for attributes used to control the static checker.
InDetDD::GenericTubeMaker::placeVolume
void placeVolume(GeoPhysVol *parent, GeoVPhysVol *child, double zParent=0)
Definition: GenericTubeMaker.cxx:75
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
InDetDD::TubeVolData::maxRadius
double maxRadius() const
Definition: TubeVolData.cxx:20
TubeVolData.h
IGeoDbTagSvc.h
TRT_ServMatFactory.h
InDetDD::TubeVolData::zMid
double zMid() const
Definition: TubeVolData.h:27