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"
66 m_hasLeadCompensator(false),
67 m_hasPresampler(false),
70 m_tbecEnvelopePhysical(nullptr),
83 ISvcLocator* svcLocator = Gaudi::svcLocator();
85 if(svcLocator->service(
"MessageSvc",
msgSvc,
true) == StatusCode::FAILURE){
86 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, cannot access MessageSvc");
88 MsgStream
log(
msgSvc,
"LArGeo::LArDetectorConstructionTBEC");
93 status =
detStore->retrieve(largeotbgeometricoptions,
"LArGeoTBGeometricOptions");
99 <<
"Can't access LArGeoTBGeometricOptions, using default values"
103 throw std::runtime_error(
"LArDetectorConstructionTBEC: cannot initialize \
104 StoreGate interface");
107 if ( m_eta_cell < 0.5 ) m_eta_pos = 0.05*( m_eta_cell + 0.5 ) + 1.375;
108 else if ( m_eta_cell > 43.5 ) m_eta_pos = 0.1*( m_eta_cell - 43.5 ) + 2.5;
109 else m_eta_pos = 0.025*( m_eta_cell - 0.5 ) + 1.425;
111 if ( m_eta_cell <= 43.5 ) m_phi_pos = -( ( m_phi_cell - 16. )*1.40625 + 0.46875 )*
Gaudi::Units::deg;
121 if (m_tbecEnvelopePhysical)
return m_tbecEnvelopePhysical;
123 ISvcLocator *svcLocator = Gaudi::svcLocator();
125 if(svcLocator->service(
"MessageSvc",
msgSvc,
true) == StatusCode::FAILURE){
126 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, cannot access MessageSvc");
129 MsgStream
log(
msgSvc,
"LArGeo::LArDetectorConstructionTBEC");
131 if (svcLocator->service(
"DetectorStore",
detStore,
false )==StatusCode::FAILURE) {
132 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, cannot access DetectorStore");
135 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
137 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
139 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, std::Air is not found.");
143 sc=svcLocator->service(
"RDBAccessSvc",m_pAccessSvc);
144 if (
sc != StatusCode::SUCCESS) {
145 throw std::runtime_error (
"Cannot locate RDBAccessSvc!!");
149 const std::string& detectorKey = larVersion.
tag();
150 const std::string& detectorNode = larVersion.
node();
153 m_hasLeadCompensator =
false;
154 m_hasPresampler =
false;
158 IRDBRecordset_ptr tbecGeometry = m_pAccessSvc->getRecordsetPtr(
"TBECGeometry",detectorKey, detectorNode);
159 if ((*tbecGeometry).size()!=0) {
160 m_hasLeadCompensator = (*tbecGeometry)[0]->getInt(
"LEADCOMPENSATOR");
161 m_hasPresampler = (*tbecGeometry)[0]->getInt(
"PRESAMPLER");
162 m_ModuleRotation = (*tbecGeometry)[0]->getDouble(
"MODULEROTATION");
163 m_YShift = (*tbecGeometry)[0]->getDouble(
"YSHIFT");
166 log << MSG::INFO <<
"LeadCompensator = ";
167 if(m_hasLeadCompensator)
log <<
"true";
171 log << MSG::INFO <<
"Presampler = ";
172 if(m_hasPresampler)
log <<
"true";
177 getSimulationParameters();
179 std::string baseName =
"LAr::TBEC::MotherVolume";
183 const GeoLogVol* tbecMotherLogical =
184 new GeoLogVol(baseName, tbecMotherShape, Air);
186 m_tbecEnvelopePhysical =
new GeoPhysVol(tbecMotherLogical);
188 m_tbecEnvelopePhysical->add(
new GeoNameTag(
"LArEndcapPos") );
189 m_tbecEnvelopePhysical->add( createEnvelope() );
190 return m_tbecEnvelopePhysical;
197 ISvcLocator *svcLocator = Gaudi::svcLocator();
199 if (svcLocator->service(
"MessageSvc",
msgSvc,
true )==StatusCode::FAILURE) {
200 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, cannot access MessageSvc");
203 MsgStream
log(
msgSvc,
"LArGeo::LArDetectorConstructionTBEC");
208 if (svcLocator->service(
"DetectorStore",
detStore,
false )==StatusCode::FAILURE) {
209 throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, cannot access DetectorStore");
215 if (StatusCode::SUCCESS !=
detStore->retrieve(materialManager, std::string(
"MATERIALS")))
return nullptr;
217 const GeoMaterial *Air = materialManager->
getMaterial(
"std::Air");
218 if (!Air)
throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, std::Air is not found.");
220 const GeoMaterial *Lead = materialManager->
getMaterial(
"std::Lead");
221 if (!Lead)
throw std::runtime_error(
"Error in LArDetectorConstructionTBEC, std::Lead is not found.");
234 std::string baseName =
"LAr::TBEC";
245 std::string tbecMotherName = baseName +
"::MotherVolume";
247 const GeoLogVol* tbecMotherLogical =
new GeoLogVol( tbecMotherName, tbecMotherShape, Air );
248 GeoIntrusivePtr<GeoFullPhysVol> tbecMotherPhysical =
new GeoFullPhysVol( tbecMotherLogical );
253 if ( m_eta_pos > 5. ) m_eta_pos = 0.;
254 else m_eta_pos = 2*
atan(
exp( -m_eta_pos ) );
255 log <<
", positioning cryostat with angle " << m_eta_pos*(1./
Gaudi::Units::deg) <<
" Gaudi::Units::deg";
267 std::string XAxisName = baseName +
"::XAxis";
268 const GeoLogVol* XAxisLogical =
new GeoLogVol( XAxisName, axisShape, Air );
269 GeoIntrusivePtr<GeoPhysVol> XAxisPhysVol =
new GeoPhysVol( XAxisLogical );
271 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
273 tbecMotherPhysical->add( XAxisPhysVol );
276 std::string YAxisName = baseName +
"::YAxis";
277 const GeoLogVol* YAxisLogical =
new GeoLogVol( YAxisName, axisShape, Air );
278 GeoIntrusivePtr<GeoPhysVol> YAxisPhysVol =
new GeoPhysVol( YAxisLogical );
280 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
282 tbecMotherPhysical->add( YAxisPhysVol );
285 std::string ZAxisName = baseName +
"::ZAxis";
286 const GeoLogVol* ZAxisLogical =
new GeoLogVol( ZAxisName, axisShape, Air );
287 GeoIntrusivePtr<GeoPhysVol> ZAxisPhysVol =
new GeoPhysVol( ZAxisLogical );
289 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
290 tbecMotherPhysical->add(
new GeoTransform( GeoTrf::TranslateZ3D( axisZHalfLength ) ) );
291 tbecMotherPhysical->add( ZAxisPhysVol );
296 if ( m_hasLeadCompensator ) {
297 std::string CompensatorName = baseName +
"::LeadCompensator";
299 const GeoLogVol* CompensatorLogical =
new GeoLogVol( CompensatorName, CompensatorShape, Lead );
300 GeoIntrusivePtr<GeoPhysVol> CompensatorPhysical =
new GeoPhysVol( CompensatorLogical );
302 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
306 GeoTrf::Translate3D tmpxf1(tmpvec1Rotated.x(),tmpvec1Rotated.y(),tmpvec1Rotated.z());
307 tbecMotherPhysical->add(
new GeoTransform( tmpxf1 * GeoTrf::RotateY3D(m_eta_pos)));
308 tbecMotherPhysical->add( CompensatorPhysical );
314 GeoIntrusivePtr<GeoVFullPhysVol> cryoPhys = cryoConstruction.
GetEnvelope();
315 GeoIntrusivePtr<GeoPhysVol> LArPhysical = cryoConstruction.
GetLArPhysical();
317 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
320 GeoTrf::Translate3D tmpxf2(tmpvec2Rotated.x(),tmpvec2Rotated.y(),tmpvec2Rotated.z());
321 tbecMotherPhysical->add(
new GeoTransform( tmpxf2 * GeoTrf::RotateY3D(m_eta_pos)));
322 tbecMotherPhysical->add( cryoPhys );
331 GeoBox* BeamCShape =
new GeoBox( beamCSize, beamCSize, beamCTh );
332 for (
int i = 0;
i < 4;
i++ ) {
333 std::string BeamCName = baseName +
"::BeamChamber";
334 BeamCName+=
char(
i ) +
'0';
335 GeoLogVol* BeamCLogical =
new GeoLogVol( BeamCName, BeamCShape, Air );
336 GeoIntrusivePtr<GeoPhysVol> BeamCPhysical =
new GeoPhysVol( BeamCLogical );
338 tbecMotherPhysical->add(
new GeoIdentifierTag( 1 ) );
340 tbecMotherPhysical->add( BeamCPhysical );
345 <<
"Module deviation: " << m_ModuleRotation * (1./
Gaudi::Units::deg) <<
" Gaudi::Units::deg" << std::endl
346 <<
"Phi position: " << m_phi_pos * (1./
Gaudi::Units::deg) <<
" Gaudi::Units::deg" << std::endl
353 GeoIntrusivePtr<GeoFullPhysVol>emecEnvelope= (GeoIntrusivePtr<GeoFullPhysVol>) emecModuleConstruction.GetEnvelope();
356 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store EMEC_POS");
363 LArPhysical->add(
new GeoIdentifierTag( 1 ) );
365 LArPhysical->add( emecEnvelope );
370 if ( m_hasPresampler ) {
373 GeoIntrusivePtr<GeoFullPhysVol> PresamplerEnvelope = PresamplerConstruction.
Envelope();
377 if(!
status.isSuccess())
throw std::runtime_error (
"Cannot store PRESAMPLER_EC_POS");
381 LArPhysical->add(
new GeoIdentifierTag( 1 ) );
383 LArPhysical->add( PresamplerEnvelope );
387 return tbecMotherPhysical;