ATLAS Offline Software
Loading...
Searching...
No Matches
TileDetectorFactoryLite.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/*
6 * author: Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch> , Aug 2021
7 *
8 * updates:
9 * - 2022 Jan, Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch>
10 * Added Readout geometry
11 */
12
17
19
20#include "GeoModelKernel/GeoVolumeCursor.h"
21
23
24#include "GaudiKernel/MsgStream.h"
25#include "GaudiKernel/SystemOfUnits.h"
26
30
31#include <memory>
32#include <stdexcept>
33#include <string>
34
35#define MLOG(x) if (m_log->level()<=MSG::x) *m_log << MSG::x
36
37
38// Constructor:
40 TileDetDescrManager *manager,
41 GeoModelIO::ReadGeoModel* /*sqliteReader*/,
42 IRDBAccessSvc* paramsSvc,
43 const TileSwitches & switches,
44 MsgStream *log,
45 bool /*fullGeo*/)
46 : m_detectorManager(manager)
47 , m_paramsSvc(paramsSvc)
48 , m_switches(switches)
49 , m_log(log)
50 , m_verbose(log->level()<=MSG::VERBOSE)
51{
52 m_switches.testBeam = false;
53}
54
55
56// Destructor:
58
59
60// Creation of geometry:
61void TileDetectorFactoryLite::create(GeoPhysVol *world)
62{
63 (*m_log) << MSG::INFO <<" Entering TileDetectorFactoryLite::create()" << endmsg;
64
65 // -------- -------- MATERIAL MANAGER -------- ----------
66 // TODO: fix this, doesn't get access at runtime!!
67 StoredMaterialManager* theMaterialManager = nullptr; // dummy matManager, only used to instantiate a 'sectionBuilder'
68
69 // -------- -------- DB MANAGER -------- ----------
70 TileDddbManager* dbManager = m_detectorManager->getDbManager();
71
72 // -------- -------- SECTION BUILDER -------- ----------
73 auto sectionBuilder = std::make_unique<TileGeoSectionBuilder>(theMaterialManager,dbManager,m_switches,m_log);
74
75
76 // --- Get data from SQLite
77 (*m_log) << MSG::INFO << "Getting auxiliary data from SQLite..." << endmsg;
78 // get table
79 IRDBRecordset_ptr tileReadoutDataRecordSet = m_paramsSvc->getRecordsetPtr("TileReadoutData", "", "");
80 (*m_log) << MSG::DEBUG << "data rows in the 'TileReadoutData' RecordSet: " << tileReadoutDataRecordSet->size() << endmsg;
81 // get data
82 double barrelPeriodThickness = 0., extendedPeriodThickness = 0.;
83 if (tileReadoutDataRecordSet->size()>0) {
84 if ( (*tileReadoutDataRecordSet)[0]->getString("NAME") == "barrelPeriodThickness" ) {
85 barrelPeriodThickness = (*tileReadoutDataRecordSet)[0]->getDouble("VALUE");
86 } else {
87 std::string errMsg = "barrelPeriodThickness not found in position [0] in the TileReadoutData' RecordSet!!!";
88 (*m_log) << MSG::ERROR << errMsg << endmsg;
89 throw std::runtime_error(errMsg);
90 }
91 if ( (*tileReadoutDataRecordSet)[1]->getString("NAME") == "extendedPeriodThickness" ) {
92 extendedPeriodThickness = (*tileReadoutDataRecordSet)[1]->getDouble("VALUE");
93 } else {
94 std::string errMsg = "extendedPeriodThickness not found in position [1] in the TileReadoutData' RecordSet!!!";
95 (*m_log) << MSG::ERROR << errMsg << endmsg;
96 throw std::runtime_error(errMsg);
97 }
98 } else {
99 std::string errorMsg = "The 'TileReadoutData' recordSet is empty!!!";
100 (*m_log) << MSG::FATAL << errorMsg << endmsg;
101 throw std::runtime_error(errorMsg);
102 }
103 (*m_log) << MSG::DEBUG << "barrelPeriodThickness: " << barrelPeriodThickness << ", extendedPeriodThickness: " << extendedPeriodThickness << endmsg;
104
105 // set data used to build the readout geometry
106 sectionBuilder->setBarrelPeriodThickness(barrelPeriodThickness);
107 sectionBuilder->setExtendedPeriodThickness(extendedPeriodThickness);
108
109
110 //
111 // creating Descriptors and CaloDetDescrElements
112 //
113
114 int nModulesInSection[6] = {0,0,0,0,0,0};
115 double zShiftInSection[6] = {0.0,0.0,0.0,0.0,0.0,0.0,};
116
117 int NumberOfEnv = dbManager->GetNumberOfEnv();
118 MLOG(DEBUG) << "NumberOfEnv: " << NumberOfEnv << endmsg;
119
120 for (int EnvCounter = 0; EnvCounter < NumberOfEnv; ++EnvCounter) { //Loop over Envelopes
121
122 dbManager->SetCurrentEnvByIndex(EnvCounter);
123 int EnvType = dbManager->GetEnvType();
124 int NumberOfMod = dbManager->GetEnvNModules();
125 double Zshift = dbManager->GetEnvZShift()*Gaudi::Units::cm;
126
127 if (m_log->level()<=MSG::DEBUG)
128 (*m_log) << MSG::DEBUG
129 << " EnvCounter is " << EnvCounter
130 << " EnvType is " << EnvType
131 << " Zshift is " << Zshift*(1./Gaudi::Units::cm) << " cm"
132 << endmsg;
133
134 // Central barrel
135 if (EnvType == 1 || EnvType == 0) {
136 nModulesInSection[0] = nModulesInSection[1] = NumberOfMod;
137 zShiftInSection[0] = zShiftInSection[1] = Zshift;
138 } else if (EnvType>0 and EnvType < 6) {
139 nModulesInSection[EnvType] = NumberOfMod;
140 zShiftInSection[EnvType] = Zshift;
141 }
142 }
143
144
145 // Build Regions
146 const TileID* tileID = m_detectorManager->get_id();
147
148 unsigned int dete[6] = {TILE_REGION_CENTRAL,TILE_REGION_CENTRAL,
151 int side[6] = {0,1,0,1,0,1};
152
153 (*m_log) << MSG::DEBUG << "Loop over Tile detector regions, and call computeCellDim() when needed..." << endmsg;
154 for (int ii=0; ii<6; ++ii) {
155
156 (*m_log) << MSG::DEBUG << "ii: " << ii << ", region: " << dete[ii] << endmsg;
157
158 if (ii%2 == 0) {
159 (*m_log) << MSG::DEBUG << "ii: " << ii << ", region: " << dete[ii] << " --> calling computeCellDim()..." << endmsg;
160 sectionBuilder->computeCellDim(m_detectorManager, dete[ii],
161 m_switches.addPlatesToCell,
162 zShiftInSection[ii+1], // zShiftPos
163 zShiftInSection[ii]); // zShiftNeg
164 }
165
166 (*m_log) << MSG::DEBUG << "Get TileDetDescriptor and call fillDescriptor()..." << endmsg;
167 TileDetDescriptor* descriptor = new TileDetDescriptor();
168 sectionBuilder->fillDescriptor(descriptor, dete[ii], side[ii],
169 m_switches.testBeam, // set to false - ATLAS geometry
170 m_switches.addPlatesToCell, // add front/end plates to cell volume
171 nModulesInSection[ii], // 0-64 modules
172 zShiftInSection[ii]); // Z-shift
173
174 (*m_log) << MSG::DEBUG << "Get an Identifier for the region and add it to the detectorManager..." << endmsg;
175 Identifier idRegion = tileID->region_id(ii);
176 descriptor->set(idRegion);
177 m_detectorManager->add(descriptor);
178 m_detectorManager->add(new TileDetDescrRegion(idRegion, descriptor));
179 }
180
181
182 // Set geometry Tree Tops
183 GeoVolumeCursor cursor(world);
184 while (!cursor.atEnd()) {
185 std::string volName = cursor.getName();
186 if (volName.compare(0,4,"Tile")==0) {
187 (*m_log) << MSG::DEBUG << "Adding vol '" << volName << "' to detManager" << endmsg;
188 m_detectorManager->addTreeTop(cursor.getVolume());
189 }
190 cursor.next();
191 }
192
193 (*m_log) << MSG::DEBUG << "Tile geometry from SQLite has been created." << endmsg;
194
195}
#define endmsg
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
#define MLOG(x)
Definition of TileGeoSectionBuilder class.
#define TILE_REGION_GAP
#define TILE_REGION_CENTRAL
#define TILE_REGION_EXTENDED
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
virtual unsigned int size() const =0
The Athena Transient Store API.
This class holds one or more material managers and makes them storeable, under StoreGate.
This class provides access to constants in the Geometry DB.
int GetNumberOfEnv() const
double GetEnvZShift() const
int GetEnvNModules() const
int SetCurrentEnvByIndex(unsigned int envelope)
void set(const Identifier &id)
TileSwitches m_switches
all switches
virtual void create(GeoPhysVol *world)
Creation of Tile geometry.
IRDBAccessSvc * m_paramsSvc
Pointer to an instance of the RDBAccessSvc to get parameters from the SQLite file.
TileDetDescrManager * m_detectorManager
Detector pointer to TileDetDescrManager.
TileDetectorFactoryLite(StoreGateSvc *pDetStore, TileDetDescrManager *manager, GeoModelIO::ReadGeoModel *sqliteReader, IRDBAccessSvc *rdbaccess, const TileSwitches &switches, MsgStream *log, bool fullGeo)
Constructor.
bool m_verbose
Flag for activation verbose level for debugging.
MsgStream * m_log
Get message SVC.
Helper class for TileCal offline identifiers.
Definition TileID.h:67
Identifier region_id(int index) const
build single region, module, tower, cell, pmt, adc identifiers
Definition MsgLevel.h:28
#define DEBUG
Definition page_access.h:11