ATLAS Offline Software
PLRGmxInterface.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 #include "PLRGmxInterface.h"
6 
16 
17 
18 namespace InDetDD
19 {
20 
22  SiCommonItems *commonItems,
23  WaferTree *moduleTree)
24  : PixelGmxInterface(detectorManager, commonItems, moduleTree)
25 {}
26 
27 int PLRGmxInterface::sensorId(std::map<std::string, int> &index) const
28 {
29  // Return the Simulation HitID (nothing to do with "ATLAS Identifiers" aka "Offline Identifiers")
30 
31  // Check if identifier is valid
32  // TODO: drop this check in the future
33  const PLR_ID *pixelIdHelper = dynamic_cast<const PLR_ID *>(m_commonItems->getIdHelper());
34  if (not pixelIdHelper){
35  ATH_MSG_ERROR("Failed dynamic_cast to PLR_ID in PLRGmxInterface::sensorId");
36  return -1;
37  }
38  Identifier id = pixelIdHelper->wafer_id(index["barrel_endcap"],
39  index["layer_wheel"],
40  index["phi_module"],
41  index["eta_module"]);
42  IdentifierHash hashId = pixelIdHelper->wafer_hash(id);
43  if (!hashId.is_valid()) {
44  ATH_MSG_WARNING("PLR Invalid hash for Index list: " << index["barrel_endcap"] << " " << index["layer_wheel"] << " "
45  << index["eta_module"] << " " << index["phi_module"] << " " << index["side"]);
46  return -1;
47  }
48  // Compute the actuall SiHitId, first number is the part number: lumi=2
49  int hitIdOfModule = SiHitIdHelper::GetHelper()->buildHitId(2,
50  index["barrel_endcap"],
51  index["layer_wheel"],
52  index["eta_module"],
53  index["phi_module"],
54  index["side"]);
55  ATH_MSG_DEBUG("Index list: " << index["barrel_endcap"] << " " << index["layer_wheel"] << " "
56  << index["eta_module"] << " " << index["phi_module"] << " " << index["side"]);
57  ATH_MSG_DEBUG("hitIdOfModule = " << std::hex << hitIdOfModule << std::dec);
58  ATH_MSG_DEBUG(" bec = " << SiHitIdHelper::GetHelper()->getBarrelEndcap(hitIdOfModule)
59  << " lay = " << SiHitIdHelper::GetHelper()->getLayerDisk(hitIdOfModule)
60  << " eta = " << SiHitIdHelper::GetHelper()->getEtaModule(hitIdOfModule)
61  << " phi = " << SiHitIdHelper::GetHelper()->getPhiModule(hitIdOfModule)
62  << " side = " << SiHitIdHelper::GetHelper()->getSide(hitIdOfModule));
63 
64  return hitIdOfModule;
65 }
66 
67 
68 void PLRGmxInterface::addSensorType(const std::string& clas,
69  const std::string& typeName,
70  const std::map<std::string, std::string>& parameters)
71 {
72  ATH_MSG_DEBUG("addSensorType called for class " << clas << ", typeName " << typeName);
73  // only load the sensor type that the PLR will use
74  if (clas == "SingleChip_RD53" && typeName == "RD53_20x19_Single_25x100") {
76  }
77 }
78 
79 
80 void PLRGmxInterface::addSensor(const std::string& typeName,
81  std::map<std::string, int> &index,
82  int /*sensitiveId*/,
83  GeoVFullPhysVol *fpv)
84 {
85  //
86  // Get the ATLAS "Offline" wafer identifier
87  //
88  const PLR_ID *pixelIdHelper = dynamic_cast<const PLR_ID *>(m_commonItems->getIdHelper());
89  if (not pixelIdHelper){
90  ATH_MSG_ERROR("Failed dynamic_cast to PLR_ID in PLRGmxInterface::addSensor");
91  return;
92  }
93  Identifier id = pixelIdHelper->wafer_id(index["barrel_endcap"],
94  index["layer_wheel"],
95  index["phi_module"],
96  index["eta_module"]);
97  IdentifierHash hashId = pixelIdHelper->wafer_hash(id);
98  //
99  // Now do our best to check if this is a valid id. If either the gmx file is wrong, or the xml file
100  // defining the allowed id's is wrong, you can get disallowed id's. These cause a crash later
101  // if allowed through. To do the check, we ask for the hash-id of this id. Invalid ids give a
102  // special invalid hash-id (0xFFFFFFFF). But we don't exit the run, to help debug things quicker.
103  //
104  if (!hashId.is_valid()) {
105  ATH_MSG_ERROR("Invalid id for sensitive module " << typeName << " volume with indices");
106  for (const auto& [key, value] : index) {
107  msg() << MSG::ERROR << key << " = " << value << "; ";
108  }
109  msg() << MSG::ERROR << endmsg;
110  ATH_MSG_ERROR("Refusing to make it into a sensitive element. Incompatible gmx and identifier-xml files.");
111  return;
112  }
113 
114  //
115  // Create the detector element and add to the DetectorManager
116  //
117  auto it = m_geometryMap.find(typeName);
118  if(it == m_geometryMap.end()) {
119  ATH_MSG_ERROR("addSensor: Error: Readout sensor type " << typeName << " not found.");
120  throw std::runtime_error("readout sensor type " + typeName + " not found.");
121  }
122  const SiDetectorDesign *design = m_detectorManager->getDesign(it->second);
123  ATH_MSG_VERBOSE("Adding sensor with design: " << typeName << " " << design);
124  if (design == nullptr) {
125  ATH_MSG_ERROR("addSensor: Error: Readout sensor type " << typeName << " not found.");
126  throw std::runtime_error("readout sensor type " + typeName + " not found.");
127  }
128 
130 
131  //
132  // Build up a map-structure for numerology
133  //
134  Wafer module((unsigned int) hashId);
135  std::string errorMessage("");
136  if (!m_moduleTree->add(index["barrel_endcap"],
137  index["layer_wheel"],
138  index["eta_module"],
139  index["phi_module"],
140  module,
141  errorMessage)) {
142  ATH_MSG_ERROR(errorMessage);
143  }
144 
145  return;
146 }
147 
148 
149 void PLRGmxInterface::makePLRModule(const std::string &typeName,
150  const std::map<std::string, std::string> &parameters)
151 {
152  int circuitsPerEta{1}; // row
153  int circuitsPerPhi{1}; // column
154  double thickness{0.150};
155  double pitchEta{};
156  double pitchPhi{};
157  double pitchEtaLong{};
158  double pitchPhiLong{};
159  double pitchEtaEnd{};
160  double pitchPhiEnd{};
161  int nEtaLongPerSide{};
162  int nPhiLongPerSide{};
163  int nEtaEndPerSide{};
164  int nPhiEndPerSide{};
165  int rowsPerChip{};
166  int columnsPerChip{};
167 
168  // unused
170  int readoutSide{1};
171  bool is3D{true};
172 
173  // read parameters
174  getParameter(typeName, parameters, "circuitsPerEta", circuitsPerEta);
175  getParameter(typeName, parameters, "circuitsPerPhi", circuitsPerPhi);
176  getParameter(typeName, parameters, "thickness", thickness);
177  getParameter(typeName, parameters, "is3D", is3D);
178  getParameter(typeName, parameters, "rows", rowsPerChip);
179  getParameter(typeName, parameters, "columns", columnsPerChip);
180  getParameter(typeName, parameters, "pitchEta", pitchEta);
181  getParameter(typeName, parameters, "pitchPhi", pitchPhi);
182  getParameter(typeName, parameters, "pitchEtaLong", pitchEtaLong);
183  getParameter(typeName, parameters, "pitchPhiLong", pitchPhiLong);
184  getParameter(typeName, parameters, "pitchEtaEnd", pitchEtaEnd);
185  getParameter(typeName, parameters, "pitchPhiEnd", pitchPhiEnd);
186  getParameter(typeName, parameters, "nPhiLongPerSide", nPhiLongPerSide);
187  getParameter(typeName, parameters, "nEtaLongPerSide", nEtaLongPerSide);
188  getParameter(typeName, parameters, "nPhiEndPerSide", nPhiEndPerSide);
189  getParameter(typeName, parameters, "nEtaEndPerSide", nEtaEndPerSide);
190 
191  //
192  // Make Module Design and add to DetectorManager
193  //
194  std::shared_ptr<const PixelDiodeMatrix> fullMatrix = buildMatrix(pitchPhi, pitchEta,
195  pitchPhiLong, pitchPhiEnd,
196  pitchEtaLong, pitchEtaEnd,
197  nPhiLongPerSide, nPhiEndPerSide,
198  nEtaLongPerSide, nEtaEndPerSide,
199  circuitsPerPhi, circuitsPerEta,
200  columnsPerChip, rowsPerChip);
201 
202  ATH_MSG_DEBUG("fullMatrix = buildMatrix(" << pitchPhi << ", " << pitchEta << ", "
203  << pitchPhiLong << ", " << pitchPhiEnd << ", "
204  << pitchEtaLong << ", " << pitchEtaEnd << ", "
205  << nPhiLongPerSide << ", " << nPhiEndPerSide << ", "
206  << nEtaLongPerSide << ", " << nEtaEndPerSide << ", "
207  << circuitsPerPhi << ", " << circuitsPerEta << ", "
208  << columnsPerChip << ", " << rowsPerChip << ")");
209  ATH_MSG_DEBUG("readout geo - design " << thickness << " "
210  << circuitsPerPhi << " " << circuitsPerEta << " "
211  << columnsPerChip << " " << rowsPerChip << " "
212  << columnsPerChip << " " << rowsPerChip << " "
213  << carrier << " " << readoutSide);
214 
215  // Setting module identifier to InDetDD::PLR
216  // (so far) primarily useful to avoid orientation warnings
217  InDetDD::DetectorType detectorType{InDetDD::PLR};
218 
219  auto design = std::make_unique<PixelModuleDesign>(thickness,
220  circuitsPerPhi, circuitsPerEta,
221  columnsPerChip, rowsPerChip,
222  columnsPerChip, rowsPerChip,
223  fullMatrix, carrier,
224  readoutSide, is3D, detectorType);
225 
226 
227  ATH_MSG_DEBUG("readout geo - design : " << design->width() << " " << design->length() << " " << design->thickness() << " " <<design->rows() << " " << design->columns());
228 
229  [[maybe_unused]] auto observedPtr = m_detectorManager->addDesign(std::move(design));
230 
231  // Add to map for addModule routine
233 }
234 
235 } // namespace InDetDD
InDetDD::PLR
@ PLR
Definition: DetectorDesign.h:46
InDetDD::SiCommonItems::getIdHelper
const AtlasDetectorID * getIdHelper() const
Definition: SiCommonItems.h:83
index
Definition: index.py:1
InDetDD::SiDetectorManager::numDesigns
int numDesigns() const
Definition: SiDetectorManager.cxx:140
PLR_ID.h
This is an Identifier helper class for the PLR subdetector. This class inherits from PicelID.
skel.it
it
Definition: skel.GENtoEVGEN.py:423
PLR_ID
This is an Identifier helper class for the PLR subdetector. This class inherits from PixelID.
Definition: PLR_ID.h:24
InDetDD::SiDetectorManager::addDesign
const SiDetectorDesign * addDesign(std::unique_ptr< const SiDetectorDesign > &&)
Access to module design; returns an observer pointer.
Definition: SiDetectorManager.cxx:134
athena.value
value
Definition: athena.py:122
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
InDetDD::ITk::PixelGmxInterface::m_moduleTree
WaferTree * m_moduleTree
Definition: PixelGmxInterface.h:68
InDetDD::ITk::PixelGmxInterface::m_geometryMap
std::map< std::string, int > m_geometryMap
Definition: PixelGmxInterface.h:61
PixelConditionsData::getParameter
std::vector< T > getParameter(const std::string &varName, const std::vector< std::string > &buffer)
Definition: PixelConditionsDataStringUtils.h:51
InDetDD::PLRGmxInterface::addSensorType
virtual void addSensorType(const std::string &clas, const std::string &typeName, const std::map< std::string, std::string > &parameters) override final
Definition: PLRGmxInterface.cxx:68
SiHitIdHelper.h
python.PyAthena.module
module
Definition: PyAthena.py:134
InDetDD::PLRGmxInterface::addSensor
virtual void addSensor(const std::string &typeName, std::map< std::string, int > &index, int sequentialId, GeoVFullPhysVol *fpv) override final
Definition: PLRGmxInterface.cxx:80
PixelDetectorManager.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetDD::DetectorType
DetectorType
Definition: DetectorDesign.h:45
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
SiCommonItems.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Wafer
Definition: WaferTree.h:27
BarrelEndcap::add
bool add(int bec, int ld, int eta, int phi, int side, Wafer &wafer, std::string &errorMessage)
Definition: WaferTree.cxx:55
InDetDD::SiDetectorManager::getDesign
const SiDetectorDesign * getDesign(int i) const
Definition: SiDetectorManager.cxx:146
InDetDD::PLRGmxInterface::makePLRModule
void makePLRModule(const std::string &typeName, const std::map< std::string, std::string > &parameters)
Definition: PLRGmxInterface.cxx:149
InDetDD::ITk::PixelGmxInterface::m_commonItems
SiCommonItems * m_commonItems
Definition: PixelGmxInterface.h:67
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
IdentifierHash::is_valid
bool is_valid() const
Check if id is in a valid state.
WaferTree.h
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
InDetDD::SiCommonItems
Definition: SiCommonItems.h:45
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElement.h
PLRGmxInterface.h
InDetDD::ITk::PixelGmxInterface::buildMatrix
std::shared_ptr< const PixelDiodeMatrix > buildMatrix(double phiPitch, double etaPitch, double phiPitchLong, double phiPitchEnd, double etaPitchLong, double etaPitchEnd, int nPhiLong, int nPhiEnd, int nEtaLong, int nEtaEnd, int circuitsPhi, int circuitsEta, int diodeColPerCirc, int diodeRowPerCirc) const
Definition: PixelGmxInterface.cxx:264
InDetDD::ITk::PixelGmxInterface::m_detectorManager
PixelDetectorManager * m_detectorManager
Definition: PixelGmxInterface.h:66
PixelDiodeMatrix.h
InDetDD::CarrierType
CarrierType
Definition: InDetDD_Defs.h:17
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
PixelModuleDesign.h
SiHitIdHelper::GetHelper
static const SiHitIdHelper * GetHelper()
Definition: SiHitIdHelper.cxx:19
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
IdentifierHash
Definition: IdentifierHash.h:38
InDetDD::SiDetectorDesign
Definition: SiDetectorDesign.h:50
InDetDD::PLRGmxInterface::sensorId
virtual int sensorId(std::map< std::string, int > &index) const override final
Definition: PLRGmxInterface.cxx:27
SiHitIdHelper::buildHitId
int buildHitId(const int, const int, const int, const int, const int, const int) const
Definition: SiHitIdHelper.cxx:118
InDetDD::PLRGmxInterface::PLRGmxInterface
PLRGmxInterface(PixelDetectorManager *detectorManager, SiCommonItems *commonItems, WaferTree *moduleTree)
Definition: PLRGmxInterface.cxx:21
SiDetectorDesign.h
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
InDetDD::PixelDetectorManager::addDetectorElement
virtual void addDetectorElement(SiDetectorElement *element) override
Add elememts.
Definition: PixelDetectorManager.cxx:121
WaferTree
Definition: WaferTree.h:74
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37