ATLAS Offline Software
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 
14 #include "TileGeoSectionBuilder.h"
18 
19 #include "CaloIdentifier/TileID.h"
20 
21 #include "GeoModelKernel/GeoVolumeCursor.h"
22 
23 #include "StoreGate/StoreGateSvc.h"
24 
25 #include "GaudiKernel/MsgStream.h"
26 #include "GaudiKernel/SystemOfUnits.h"
27 
31 
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:
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:
61 void 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 -------- ----------
71 
72  // -------- -------- SECTION BUILDER -------- ----------
73  TileGeoSectionBuilder* sectionBuilder = new 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],
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 }
TileDddbManager::SetCurrentEnvByIndex
int SetCurrentEnvByIndex(unsigned int envelope)
Definition: TileDddbManager.cxx:209
TileDetectorFactoryLite::m_log
MsgStream * m_log
Get message SVC.
Definition: TileDetectorFactoryLite.h:75
TileGeoSectionBuilder.h
Definition of TileGeoSectionBuilder class.
MLOG
#define MLOG(x)
Definition: TileDetectorFactoryLite.cxx:35
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
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.
TileDetDescrManager::addTreeTop
void addTreeTop(PVConstLink)
Definition: TileDetDescrManager.cxx:88
DeMoUpdate.errorMsg
string errorMsg
Definition: DeMoUpdate.py:897
TileSwitches::testBeam
bool testBeam
setting up testbeam geometry or ATLAS geometry
Definition: TileSwitches.h:31
TileDddbManager::GetNumberOfEnv
int GetNumberOfEnv() const
Definition: TileDddbManager.cxx:158
TILE_REGION_EXTENDED
#define TILE_REGION_EXTENDED
Definition: TileGeoSectionBuilder.h:23
TileID.h
TileDetDescrManager.h
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TileDetectorFactoryLite::m_switches
TileSwitches m_switches
all switches
Definition: TileDetectorFactoryLite.h:72
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
TileGeoSectionBuilder::fillDescriptor
void fillDescriptor(TileDetDescriptor *&descriptor, unsigned int detector, int side, bool testbeam, bool addPlates, unsigned int nphi, float zshift)
Readout Descriptor parameters are the following:
Definition: TileGeoSectionBuilder.cxx:2454
Tile_Base_ID::region_id
Identifier region_id(int index) const
build single region, module, tower, cell, pmt, adc identifiers
Definition: Tile_Base_ID.cxx:405
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
TileDetDescriptor::set
void set(const Identifier &id)
Definition: TileDetDescriptor.h:244
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
TileDetDescrManager
Definition: TileDetDescrManager.h:33
TileID
Helper class for TileCal offline identifiers.
Definition: TileID.h:68
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:42
MSG
Definition: MsgLevel.h:28
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TileDetDescrRegion
Definition: TileDetDescrRegion.h:40
TileDddbManager::GetEnvZShift
double GetEnvZShift() const
Definition: TileDddbManager.cxx:393
TileDetDescriptor
Definition: TileDetDescriptor.h:46
TileDetectorFactoryLite::create
virtual void create(GeoPhysVol *world)
Creation of Tile geometry.
Definition: TileDetectorFactoryLite.cxx:61
TileDetectorFactoryLite::m_detectorManager
TileDetDescrManager * m_detectorManager
Detector pointer to TileDetDescrManager.
Definition: TileDetectorFactoryLite.h:66
TileSwitches
Definition: TileSwitches.h:15
TileDetectorFactoryLite::~TileDetectorFactoryLite
~TileDetectorFactoryLite()
Destructor.
Definition: TileDetectorFactoryLite.cxx:57
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
TILE_REGION_CENTRAL
#define TILE_REGION_CENTRAL
Definition: TileGeoSectionBuilder.h:22
TileSwitches::addPlatesToCell
bool addPlatesToCell
calculate cell volumes with or without front-plates and end-plates
Definition: TileSwitches.h:34
TileDetectorFactoryLite::m_paramsSvc
IRDBAccessSvc * m_paramsSvc
Pointer to an instance of the RDBAccessSvc to get parameters from the SQLite file.
Definition: TileDetectorFactoryLite.h:69
TILE_REGION_GAP
#define TILE_REGION_GAP
Definition: TileGeoSectionBuilder.h:24
TileGeoSectionBuilder::setBarrelPeriodThickness
void setBarrelPeriodThickness(double val)
Definition: TileGeoSectionBuilder.cxx:3460
TileDetDescrManager::add
void add(TileDetDescrRegion *region)
Definition: TileDetDescrManager.cxx:894
TileDddbManager.h
query_example.cursor
cursor
Definition: query_example.py:21
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
TileDetectorFactoryLite::TileDetectorFactoryLite
TileDetectorFactoryLite(StoreGateSvc *pDetStore, TileDetDescrManager *manager, GeoModelIO::ReadGeoModel *sqliteReader, IRDBAccessSvc *rdbaccess, const TileSwitches &switches, MsgStream *log, bool fullGeo)
Constructor.
Definition: TileDetectorFactoryLite.cxx:39
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TileDetDescriptor.h
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
TileGeoSectionBuilder::setExtendedPeriodThickness
void setExtendedPeriodThickness(double val)
Definition: TileGeoSectionBuilder.cxx:3472
TileDetDescrManager::getDbManager
TileDddbManager * getDbManager() const
Definition: TileDetDescrManager.cxx:94
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
TileDetectorFactoryLite.h
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
TileGeoSectionBuilder::computeCellDim
void computeCellDim(TileDetDescrManager *&manager, int detector, bool addPlates, float zShiftPos, float zShiftNeg)
Cell dimension parameters are the following:
Definition: TileGeoSectionBuilder.cxx:2709
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
TileDddbManager::GetEnvType
int GetEnvType() const
Definition: TileDddbManager.cxx:163
TileDddbManager
This class provides access to constants in the Geometry DB.
Definition: TileDddbManager.h:38
StoreGateSvc.h
TileDddbManager::GetEnvNModules
int GetEnvNModules() const
Definition: TileDddbManager.cxx:262
TileDetDescrManager::get_id
const TileID * get_id() const
Definition: TileDetDescrManager.h:172
TileGeoSectionBuilder
Definition: TileGeoSectionBuilder.h:38
Identifier
Definition: IdentifierFieldParser.cxx:14