ATLAS Offline Software
HEC2WheelConstruction.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // HEC2WheelConstruction.cxx
7 //
8 // This should only be TEMPORARY!
9 // It is a way of placing the individual HEC Wheels into the Endcap cryostat.
10 // (Needs a modificatio in LArGeoEndcap/EndcpcrypstatConstruction, where
11 // the present HECConstruction get the old HEC; replace HECConstruction by
12 // HEC2WheelConstruction there and you should get this construciotnof 2 separate wheels.)
13 // What we really want is placing the HEC wheels individually into the Endcap cryostat.
14 //
15 // When placing the wheel we have to take into account that they are fastened
16 // to the cryostat at their rear ends.
17 // This means that, longitudinally, they will shrink from front to back as the cryostat
18 // cools down.
19 // The number given in the database at the moment (Oct 2007) are still the warm
20 // dimensions!...
21 //
22 // In here, use hard coded numbers for the placement (outch!....)
23 // but then this is hopefully only very, very temporary!!!!
24 //
25 // mgf.
26 //
30 
31 #include "GeoModelKernel/GeoElement.h"
32 #include "GeoModelKernel/GeoMaterial.h"
33 #include "GeoModelKernel/GeoFullPhysVol.h"
34 #include "GeoModelKernel/GeoPhysVol.h"
35 #include "GeoModelKernel/GeoVPhysVol.h"
36 #include "GeoModelKernel/GeoLogVol.h"
37 #include "GeoModelKernel/GeoPcon.h"
38 #include "GeoModelKernel/GeoTubs.h"
39 #include "GeoModelKernel/GeoNameTag.h"
40 #include "GeoModelKernel/GeoTransform.h"
41 #include "GeoModelKernel/GeoAlignableTransform.h"
42 #include "GeoModelKernel/GeoIdentifierTag.h"
43 #include "GeoModelKernel/GeoSerialTransformer.h"
44 #include "GeoModelKernel/GeoSerialIdentifier.h"
45 #include "GeoModelKernel/GeoXF.h"
46 #include "GeoModelKernel/GeoDefinitions.h"
47 #include "GeoGenericFunctions/Variable.h"
48 #include "StoreGate/StoreGateSvc.h"
52 #include "GaudiKernel/MsgStream.h"
53 #include "GaudiKernel/Bootstrap.h"
54 #include "GaudiKernel/SystemOfUnits.h"
56 
62 
63 #include <string>
64 #include <cmath>
65 #include <iostream>
66 
67 
68 using Gaudi::Units::cm;
69 using Gaudi::Units::mm;
70 using Gaudi::Units::deg;
72 using GeoTrf::Translate3D;
73 
74 GeoIntrusivePtr<GeoFullPhysVol> LArGeo::HEC2WheelConstruction::GetEnvelope(bool fullGeo, bool posZSide)
75 {
76  m_posZSide = posZSide;
77 
78  if(m_physiHEC) return m_physiHEC->clone();
79 
80  // Get access to the material manager:
81  ISvcLocator *svcLocator = Gaudi::svcLocator();
82 
83  MsgStream log(Athena::getMessageSvc(),"HEC2WheelConstruction " );
84 
85 
86  log << MSG::DEBUG << "+++++++++++++++++++++++++++++++++++++++++++++++++++++" << endmsg;
87  log << MSG::DEBUG << "+ +" << endmsg;
88  log << MSG::DEBUG << "+ Start of HEC2Wheel GeoModel definition +" << endmsg;
89  log << MSG::DEBUG << "+ +" << endmsg;
90  log << MSG::DEBUG << "+++++++++++++++++++++++++++++++++++++++++++++++++++++" << endmsg;
91 
92 
93  SmartIF<StoreGateSvc> detStore{svcLocator->service("DetectorStore")};
94  if(!detStore.isValid()) {
95  throw std::runtime_error("Error in HEC2WheelConstruction, cannot access DetectorStore");
96  }
97 
98  StoredMaterialManager* materialManager = nullptr;
99  if (StatusCode::SUCCESS != detStore->retrieve(materialManager, std::string("MATERIALS"))) {
100  throw std::runtime_error("Error in HEC2WheelConstruction, cannot access Material Manager");
101  }
102 
103  SmartIF<IRDBAccessSvc> pAccessSvc{svcLocator->service("RDBAccessSvc")};
104  if(!pAccessSvc.isValid()) {
105  throw std::runtime_error ("Cannot locate RDBAccessSvc!!");
106  }
107 
108  SmartIF<IGeoModelSvc> geoModel{svcLocator->service("GeoModelSvc")};
109  if(!geoModel.isValid()) {
110  throw std::runtime_error ("Cannot locate GeoModelSvc!!");
111  }
112 
113  std::string AtlasVersion = geoModel->atlasVersion();
114  std::string LArVersion = geoModel->LAr_VersionOverride();
115  std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion;
116  std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr";
117 
118  IRDBRecordset_ptr hadronicEndcap = pAccessSvc->getRecordsetPtr("HadronicEndcap",detectorKey, detectorNode);
119  if(hadronicEndcap->size()>0)
120  log << MSG::ALWAYS << "Using numbers from HadronicEndcap tag: " << hadronicEndcap->tagName() << endmsg;
121  else
122  throw std::runtime_error("Error in HECConstruction: hadronicEendcap not found");
123 
124  IRDBRecordset_ptr hecLongitudinalBlock = pAccessSvc->getRecordsetPtr("HecLongitudinalBlock",detectorKey, detectorNode);
125  if(hecLongitudinalBlock->size()>0)
126  log << MSG::ALWAYS << "Using numbers from HecLongitudinalBlock tag: " << hecLongitudinalBlock->tagName() << endmsg;
127  else
128  throw std::runtime_error("Error in HECConstruction: hecLongitudinalBlock not found");
129 
130  IRDBRecordset_ptr larPosition = pAccessSvc->getRecordsetPtr("LArPosition",detectorKey, detectorNode);
131  if (larPosition->size()==0 ) {
132  larPosition = pAccessSvc->getRecordsetPtr("LArPosition", "LArPosition-00");
133  if (larPosition->size()==0 ) {
134  throw std::runtime_error("Error, no lar position table in database!");
135  }
136  }
137 
138  // This is a start for letting everyhting go cold (shrinkCold = 1.0 means warm; = 0.997 means cold)
139  double shrinkCold = 1.0 ;
140 
141  double rInner1 = shrinkCold * (*hecLongitudinalBlock)[0]->getDouble("BLRMN")*cm;
142  double rInner2 = shrinkCold * (*hecLongitudinalBlock)[1]->getDouble("BLRMN")*cm;
143  double rOuter = shrinkCold * (*hecLongitudinalBlock)[0]->getDouble("BLRMX")*cm;
144  double wheelGap = shrinkCold * (*hadronicEndcap)[0]->getDouble("GAPWHL")*cm;
145 
146 
147  const GeoMaterial *LAr = materialManager->getMaterial("std::LiquidArgon");
148  if (!LAr) throw std::runtime_error("Error in HEC2WheelConstruction, std::LiquidArgon is not found.");
149 
150  GeoPcon* solidHEC; //pointer to the solid HEC
151  const GeoLogVol* logicHEC; //pointer to the logical HEC
152  GeoIntrusivePtr<GeoFullPhysVol> physiHEC; //pointer to the physical HEC
153 
154 
155 
156  // YIKES! Hard-coded numbers!!!
157 
158  if (rOuter<2100.*mm) rOuter = shrinkCold *2130*mm; // Needs fixing in database to make room for HEC Clamping bars!
159  // Caution: We'll need 2 Routers - One for Wheel, one for Module!
160 
161  double HEC1length = shrinkCold * 816.5*mm;
162  double HEC2length = shrinkCold * 961.0*mm;
163  double TotalWarmHEC = HEC1length + wheelGap + HEC2length ; // For the moment, this defines the HEC rear face
164  double TotalHECLength = TotalWarmHEC; // (where is that -cold- in the cryostat?
165 
166  double zCoordinate[4];
167  zCoordinate[0]=shrinkCold * 0.0*cm;
168  zCoordinate[1]=shrinkCold * 28.05*cm;
169  zCoordinate[2]=shrinkCold * 28.051*cm;
170  zCoordinate[3]=shrinkCold * (181.9*cm+4.0*mm); // JFB, MGF: more room in the mother fiducal volume for misalignment.
171  // 37.2, 47.5, 203 cm for R
172 
173  solidHEC = new GeoPcon(0., 2.*M_PI);
174  for (int i=0; i< 4; i++)
175  {
176  if (i<2) solidHEC->addPlane(zCoordinate[i],rInner1 - shrinkCold*1.*mm,rOuter);
177  else solidHEC->addPlane(zCoordinate[i],rInner2 - shrinkCold*1.*mm,rOuter);
178  }
179 
180  std::string hecName = "LAr::HEC::Mother";
181  logicHEC = new GeoLogVol(hecName, solidHEC , LAr);
182  physiHEC = new GeoFullPhysVol(logicHEC);
183 
184  //--- Make the Front Wheel alignable:
185 
186  const IRDBRecord *posHec1 = GeoDBUtils::getTransformRecord(larPosition, m_posZSide ? "HEC1_POS":"HEC1_NEG");
187  Transform3D xfPosHec1 = posHec1 ? GeoDBUtils::getTransform(posHec1) : Translate3D(0.,0.,0.);
188  GeoAlignableTransform *xfHec1 = new GeoAlignableTransform(xfPosHec1);
189 
190  std::string tag1 = m_posZSide? std::string("HEC1_POS") : std::string("HEC1_NEG");
191 
192  HECWheelConstruction theFrontHEC(fullGeo,"front",false,m_posZSide) ;
193  GeoIntrusivePtr<GeoFullPhysVol> EnvelopeF = theFrontHEC.GetEnvelope();
194 
195  StoredPhysVol *sPhysVolHec1 = new StoredPhysVol(EnvelopeF);
196  StatusCode sc=detStore->record(sPhysVolHec1,tag1);
197  if(!sc.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag1).c_str());
198 
199  StoredAlignX *sAlignX1 = new StoredAlignX(xfHec1);
200  sc=detStore->record(sAlignX1,tag1);
201  if(!sc.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag1).c_str());
202 
203  physiHEC->add(xfHec1);
204  physiHEC->add(new GeoIdentifierTag(0));
205  physiHEC->add(EnvelopeF);
206 
207  //--- Now the Rear Wheel:
208 
209  double Zpos = TotalHECLength - HEC2length ; // It is fixed at its end; position it from there.
210  const IRDBRecord *posHec2 = GeoDBUtils::getTransformRecord(larPosition, m_posZSide ? "HEC2_POS":"HEC2_NEG");
211  Transform3D xfPosHec2 = posHec2 ? GeoDBUtils::getTransform(posHec2):Translate3D(0.,0.,Zpos);
212 
213 
214  GeoAlignableTransform *xfHec2 = new GeoAlignableTransform(xfPosHec2);
215 
216  std::string tag2 = m_posZSide? std::string("HEC2_POS") : std::string("HEC2_NEG");
217 
218  HECWheelConstruction theRearHEC(fullGeo,"rear",false,m_posZSide);
219  GeoIntrusivePtr<GeoFullPhysVol> EnvelopeR = theRearHEC.GetEnvelope();
220 
221  StoredPhysVol *sPhysVolHec2 = new StoredPhysVol(EnvelopeR);
222  sc=detStore->record(sPhysVolHec2,tag2);
223  if(!sc.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag2).c_str());
224 
225  StoredAlignX *sAlignX2 = new StoredAlignX(xfHec2);
226  sc=detStore->record(sAlignX2,tag2);
227  if(!sc.isSuccess()) throw std::runtime_error ((std::string("Cannot store")+tag2).c_str());
228 
229  physiHEC->add(xfHec2);
230  physiHEC->add(new GeoIdentifierTag(1));
231  physiHEC->add(EnvelopeR);
232 
233  return physiHEC;
234 }
LArGeo::HEC2WheelConstruction::GetEnvelope
GeoIntrusivePtr< GeoFullPhysVol > GetEnvelope(bool fullGeo, bool posZSide=true)
Definition: HEC2WheelConstruction.cxx:74
LArGeo::HECWheelConstruction::GetEnvelope
GeoIntrusivePtr< GeoFullPhysVol > GetEnvelope()
Definition: HECWheelConstruction.cxx:75
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
GeoDBUtils::getTransformRecord
static const IRDBRecord * getTransformRecord(IRDBRecordset_ptr positionRecSet, const std::string &key)
Definition: GeoDBUtils.h:23
LAr
Definition: LArVolumeBuilder.h:36
StoredAlignX
Definition: StoredAlignX.h:23
M_PI
#define M_PI
Definition: ActiveFraction.h:11
deg
#define deg
Definition: SbPolyhedron.cxx:17
StoredAlignX.h
GeoDBUtils::getTransform
static GeoTrf::Transform3D getTransform(const IRDBRecord *currentRec)
Definition: GeoDBUtils.h:33
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
StoredPhysVol
Definition: StoredPhysVol.h:27
HECWheelConstruction.h
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
EventInfoWrite.AtlasVersion
AtlasVersion
Definition: EventInfoWrite.py:17
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
lumiFormat.i
int i
Definition: lumiFormat.py:85
GeoDBUtils.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
plotBeamSpotCompare.tag1
string tag1
Definition: plotBeamSpotCompare.py:75
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
LArGeo::HEC2WheelConstruction::m_posZSide
bool m_posZSide
Definition: HEC2WheelConstruction.h:36
plotBeamSpotCompare.tag2
string tag2
Definition: plotBeamSpotCompare.py:76
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
StoredMaterialManager.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
LArGeo::HECWheelConstruction
Definition: HECWheelConstruction.h:23
HEC2WheelConstruction.h
Declaration of HEC2WheelConstruction class.
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
IGeoModelSvc.h
StoreGateSvc.h
LArGeo::HEC2WheelConstruction::m_physiHEC
GeoIntrusivePtr< GeoFullPhysVol > m_physiHEC
Definition: HEC2WheelConstruction.h:35
StoredPhysVol.h