12 #include "GeoModelKernel/GeoElement.h"
13 #include "GeoModelKernel/GeoMaterial.h"
14 #include "GeoModelKernel/GeoFullPhysVol.h"
15 #include "GeoModelKernel/GeoPhysVol.h"
16 #include "GeoModelKernel/GeoVPhysVol.h"
17 #include "GeoModelKernel/GeoLogVol.h"
18 #include "GeoModelKernel/GeoBox.h"
19 #include "GeoModelKernel/GeoTube.h"
20 #include "GeoModelKernel/GeoNameTag.h"
21 #include "GeoModelKernel/GeoTransform.h"
22 #include "GeoModelKernel/GeoAlignableTransform.h"
23 #include "GeoModelKernel/GeoIdentifierTag.h"
24 #include "GeoModelKernel/GeoDefinitions.h"
28 #include "GeoModelKernel/GeoShapeUnion.h"
29 #include "GeoModelKernel/GeoShapeShift.h"
37 #include "GaudiKernel/MsgStream.h"
38 #include "GaudiKernel/Bootstrap.h"
39 #include "GaudiKernel/SystemOfUnits.h"
69 SmartIF<StoreGateSvc>
detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
70 if(!
detStore.isValid())
throw std::runtime_error(
"LArDetectorConstructionTBEC: cannot initialize StoreGate interface");
74 log << MSG::WARNING <<
"Can't access LArGeoTBGeometricOptions, using default values" <<
endmsg;
92 if (m_tbecEnvelopePhysical)
return m_tbecEnvelopePhysical;
95 SmartIF<StoreGateSvc>
detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
97 throw std::runtime_error(
"LArDetectorConstructionTBEC: cannot initialize StoreGate interface");
101 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
103 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
105 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, std::Air is not found.");
108 SmartIF<IRDBAccessSvc> accessSvc{Gaudi::svcLocator()->service(
"RDBAccessSvc")};
109 if(!accessSvc.isValid()) {
110 throw std::runtime_error (
"Cannot locate RDBAccessSvc!!");
114 const std::string& detectorKey = larVersion.
tag();
115 const std::string& detectorNode = larVersion.
node();
118 m_hasLeadCompensator =
false;
119 m_hasPresampler =
false;
123 IRDBRecordset_ptr tbecGeometry = accessSvc->getRecordsetPtr(
"TBECGeometry",detectorKey, detectorNode);
124 if ((*tbecGeometry).size()!=0) {
125 m_hasLeadCompensator = (*tbecGeometry)[0]->getInt(
"LEADCOMPENSATOR");
126 m_hasPresampler = (*tbecGeometry)[0]->getInt(
"PRESAMPLER");
127 m_ModuleRotation = (*tbecGeometry)[0]->getDouble(
"MODULEROTATION");
128 m_YShift = (*tbecGeometry)[0]->getDouble(
"YSHIFT");
131 log << MSG::INFO <<
"LeadCompensator = ";
132 if(m_hasLeadCompensator)
log <<
"true";
136 log << MSG::INFO <<
"Presampler = ";
137 if(m_hasPresampler)
log <<
"true";
142 getSimulationParameters();
144 std::string baseName =
"LAr::TBEC::MotherVolume";
148 const GeoLogVol* tbecMotherLogical =
149 new GeoLogVol(baseName, tbecMotherShape, Air);
151 m_tbecEnvelopePhysical =
new GeoPhysVol(tbecMotherLogical);
153 m_tbecEnvelopePhysical->add(
new GeoNameTag(
"LArEndcapPos") );
154 m_tbecEnvelopePhysical->add( createEnvelope() );
155 return m_tbecEnvelopePhysical;
164 SmartIF<StoreGateSvc>
detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
166 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, cannot access DetectorStore");
172 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
174 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
175 if (!Air)
throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, std::Air is not found.");
177 const GeoMaterial *Lead = materialManager->
getMaterial(
"std::Lead");
178 if (!Lead)
throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, std::Lead is not found.");
191 std::string baseName =
"LAr::TBEC";
202 std::string tbecMotherName = baseName +
"::MotherVolume";
204 const GeoLogVol* tbecMotherLogical =
new GeoLogVol( tbecMotherName, tbecMotherShape, Air );
205 GeoIntrusivePtr<GeoFullPhysVol> tbecMotherPhysical =
new GeoFullPhysVol( tbecMotherLogical );
210 if ( m_eta_pos > 5. ) m_eta_pos = 0.;
211 else m_eta_pos = 2*
atan(
exp( -m_eta_pos ) );
212 log <<
", positioning cryostat with angle " << m_eta_pos*(1./
Gaudi::Units::deg) <<
" Gaudi::Units::deg";
224 std::string XAxisName = baseName +
"::XAxis";
225 const GeoLogVol* XAxisLogical =
new GeoLogVol( XAxisName, axisShape, Air );
226 GeoIntrusivePtr<GeoPhysVol> XAxisPhysVol =
new GeoPhysVol( XAxisLogical );
228 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
230 tbecMotherPhysical->add( XAxisPhysVol );
233 std::string YAxisName = baseName +
"::YAxis";
234 const GeoLogVol* YAxisLogical =
new GeoLogVol( YAxisName, axisShape, Air );
235 GeoIntrusivePtr<GeoPhysVol> YAxisPhysVol =
new GeoPhysVol( YAxisLogical );
237 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
239 tbecMotherPhysical->add( YAxisPhysVol );
242 std::string ZAxisName = baseName +
"::ZAxis";
243 const GeoLogVol* ZAxisLogical =
new GeoLogVol( ZAxisName, axisShape, Air );
244 GeoIntrusivePtr<GeoPhysVol> ZAxisPhysVol =
new GeoPhysVol( ZAxisLogical );
246 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
247 tbecMotherPhysical->add(
new GeoTransform( GeoTrf::TranslateZ3D( axisZHalfLength ) ) );
248 tbecMotherPhysical->add( ZAxisPhysVol );
253 if ( m_hasLeadCompensator ) {
254 std::string CompensatorName = baseName +
"::LeadCompensator";
256 const GeoLogVol* CompensatorLogical =
new GeoLogVol( CompensatorName, CompensatorShape, Lead );
257 GeoIntrusivePtr<GeoPhysVol> CompensatorPhysical =
new GeoPhysVol( CompensatorLogical );
259 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
263 GeoTrf::Translate3D tmpxf1(tmpvec1Rotated.x(),tmpvec1Rotated.y(),tmpvec1Rotated.z());
264 tbecMotherPhysical->add(
new GeoTransform( tmpxf1 * GeoTrf::RotateY3D(m_eta_pos)));
265 tbecMotherPhysical->add( CompensatorPhysical );
271 GeoIntrusivePtr<GeoVFullPhysVol> cryoPhys = cryoConstruction.
GetEnvelope();
272 GeoIntrusivePtr<GeoPhysVol> LArPhysical = cryoConstruction.
GetLArPhysical();
274 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
277 GeoTrf::Translate3D tmpxf2(tmpvec2Rotated.x(),tmpvec2Rotated.y(),tmpvec2Rotated.z());
278 tbecMotherPhysical->add(
new GeoTransform( tmpxf2 * GeoTrf::RotateY3D(m_eta_pos)));
279 tbecMotherPhysical->add( cryoPhys );
288 GeoBox* BeamCShape =
new GeoBox( beamCSize, beamCSize, beamCTh );
289 for (
int i = 0;
i < 4;
i++ ) {
290 std::string BeamCName = baseName +
"::BeamChamber";
291 BeamCName+=
char(
i ) +
'0';
292 GeoLogVol* BeamCLogical =
new GeoLogVol( BeamCName, BeamCShape, Air );
293 GeoIntrusivePtr<GeoPhysVol> BeamCPhysical =
new GeoPhysVol( BeamCLogical );
295 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
297 tbecMotherPhysical->add( BeamCPhysical );
302 <<
"Module deviation: " << m_ModuleRotation * (1./
Gaudi::Units::deg) <<
" Gaudi::Units::deg" << std::endl
303 <<
"Phi position: " << m_phi_pos * (1./
Gaudi::Units::deg) <<
" Gaudi::Units::deg" << std::endl
310 GeoIntrusivePtr<GeoFullPhysVol>emecEnvelope= (GeoIntrusivePtr<GeoFullPhysVol>) emecModuleConstruction.GetEnvelope();
313 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store EMEC_POS");
320 LArPhysical->add(
new GeoIdentifierTag( 1 ) );
322 LArPhysical->add( emecEnvelope );
327 if ( m_hasPresampler ) {
330 GeoIntrusivePtr<GeoFullPhysVol> PresamplerEnvelope = PresamplerConstruction.
Envelope();
334 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store PRESAMPLER_EC_POS");
338 LArPhysical->add(
new GeoIdentifierTag( 1 ) );
340 LArPhysical->add( PresamplerEnvelope );
344 return tbecMotherPhysical;