19 #include <GeoModelRead/ReadGeoModel.h>
20 #include <GeoModelKernel/GeoFullPhysVol.h>
24 constexpr
int PixelHitIndex{0};
38 m_detectorManager(detectorManager),
39 m_commonItems(commonItems),
40 m_moduleTree(moduleTree)
51 if (not pixelIdHelper){
52 ATH_MSG_ERROR(
"Failed dynamic_cast to PixelID in PixelGmxInterface::sensorId");
62 <<
index[
"eta_module"] <<
" " <<
index[
"phi_module"] <<
" " <<
index[
"side"]);
68 index[
"barrel_endcap"],
75 <<
index[
"eta_module"] <<
" " <<
index[
"phi_module"] <<
" " <<
index[
"side"]);
76 ATH_MSG_DEBUG(
"hitIdOfModule = " << std::hex << hitIdOfModule << std::dec);
89 const std::map<std::string, std::string>&
parameters)
93 if (clas ==
"SingleChip_RD53" || clas ==
"QuadChip_RD53") {
96 ATH_MSG_ERROR(
"addSensorType: unrecognised module class: " << clas);
103 const std::map<std::string, std::string> &
parameters)
105 int circuitsPerEta{2};
106 int circuitsPerPhi{2};
107 double thickness{0.150};
110 double pitchEtaLong{};
111 double pitchPhiLong{};
112 double pitchEtaEnd{};
113 double pitchPhiEnd{};
114 int nEtaLongPerSide{};
115 int nPhiLongPerSide{};
116 int nEtaEndPerSide{};
117 int nPhiEndPerSide{};
119 int columnsPerChip{};
147 std::shared_ptr<const PixelDiodeMatrix> fullMatrix =
buildMatrix(pitchPhi, pitchEta,
148 pitchPhiLong, pitchPhiEnd,
149 pitchEtaLong, pitchEtaEnd,
150 nPhiLongPerSide, nPhiEndPerSide,
151 nEtaLongPerSide, nEtaEndPerSide,
152 circuitsPerPhi, circuitsPerEta,
153 columnsPerChip, rowsPerChip);
155 ATH_MSG_DEBUG(
"fullMatrix = buildMatrix(" << pitchPhi <<
", " << pitchEta <<
", "
156 << pitchPhiLong <<
", " << pitchPhiEnd <<
", "
157 << pitchEtaLong <<
", " << pitchEtaEnd <<
", "
158 << nPhiLongPerSide <<
", " << nPhiEndPerSide <<
", "
159 << nEtaLongPerSide <<
", " << nEtaEndPerSide <<
", "
160 << circuitsPerPhi <<
", " << circuitsPerEta <<
", "
161 << columnsPerChip <<
", " << rowsPerChip <<
")");
163 << circuitsPerPhi <<
" " << circuitsPerEta <<
" "
164 << columnsPerChip <<
" " << rowsPerChip <<
" "
165 << columnsPerChip <<
" " << rowsPerChip <<
" "
166 << carrier <<
" " << readoutSide);
171 int detectorTypeEnum = 0;
178 auto design = std::make_unique<PixelModuleDesign>(thickness,
179 circuitsPerPhi, circuitsPerEta,
180 columnsPerChip, rowsPerChip,
181 columnsPerChip, rowsPerChip,
183 readoutSide, is3D, detectorType);
186 ATH_MSG_DEBUG(
"readout geo - design : " << design->width() <<
" " << design->length() <<
" " << design->thickness() <<
" " <<design->rows() <<
" " << design->columns());
196 std::map<std::string, int> &
index,
198 GeoVFullPhysVol *fpv)
204 if (not pixelIdHelper){
205 ATH_MSG_ERROR(
"Failed dynamic_cast to PixelID in PixelGmxInterface::addSensor");
209 index[
"layer_wheel"],
211 index[
"eta_module"]);
222 msg() << MSG::ERROR <<
key <<
" = " <<
value <<
"; ";
225 ATH_MSG_ERROR(
"Refusing to make it into a sensitive element. Incompatible gmx and identifier-xml files.");
235 throw std::runtime_error(
"readout sensor type " +
typeName +
" not found.");
239 if (design ==
nullptr) {
241 throw std::runtime_error(
"readout sensor type " +
typeName +
" not found.");
250 std::string errorMessage(
"");
252 index[
"layer_wheel"],
265 double phiPitchLong,
double phiPitchEnd,
266 double etaPitchLong,
double etaPitchEnd,
267 int nPhiLong,
int nPhiEnd,
268 int nEtaLong,
int nEtaEnd,
269 int circuitsPhi,
int circuitsEta,
270 int diodeColPerCirc,
int diodeRowPerCirc)
const
273 if (circuitsPhi < 1 or circuitsEta < 1) {
277 if (diodeRowPerCirc < 1 or diodeColPerCirc < 1) {
281 if (nPhiLong < 0 or nPhiEnd < 0 or nEtaLong < 0 or nEtaEnd < 0) {
287 if (nPhiLong == 0 and not (phiPitchLong == 0.0 or phiPitchLong == phiPitch)) {
288 ATH_MSG_DEBUG(
"nPhiLong is set to 0, but phiPitchLong is neither 0 nor phiPitch! Setting nPhiLong to 1");
291 if (nPhiEnd == 0 and not (phiPitchEnd == 0.0 or phiPitchEnd == phiPitch)) {
292 ATH_MSG_DEBUG(
"nPhiEnd is set to 0, but phiPitchEnd is neither 0 nor phiPitch! Setting nPhiEnd to 1");
295 if (nEtaLong == 0 and not (etaPitchLong == 0.0 or etaPitchLong == etaPitch)) {
296 ATH_MSG_DEBUG(
"nEtaLong is set to 0, but etaPitchLong is neither 0 nor etaPitch! Setting nEtaLong to 1");
299 if (nEtaEnd == 0 and not (etaPitchEnd == 0.0 or etaPitchEnd == etaPitch)) {
300 ATH_MSG_DEBUG(
"nEtaEnd is set to 0, but etaPitchEnd is neither 0 nor etaPitch! Setting nEtaEnd to 1");
311 std::shared_ptr<const PixelDiodeMatrix> cell_NN{};
312 std::shared_ptr<const PixelDiodeMatrix> cell_NL{};
313 std::shared_ptr<const PixelDiodeMatrix> cell_NE{};
314 std::shared_ptr<const PixelDiodeMatrix> cell_LN{};
315 std::shared_ptr<const PixelDiodeMatrix> cell_LL{};
316 std::shared_ptr<const PixelDiodeMatrix> cell_LE{};
317 std::shared_ptr<const PixelDiodeMatrix> cell_EN{};
318 std::shared_ptr<const PixelDiodeMatrix> cell_EL{};
319 std::shared_ptr<const PixelDiodeMatrix> cell_EE{};
371 std::shared_ptr<const PixelDiodeMatrix> fullChipRow_N{};
372 std::shared_ptr<const PixelDiodeMatrix> fullChipRow_L{};
373 std::shared_ptr<const PixelDiodeMatrix> fullChipRow_E{};
374 if (circuitsEta == 1) {
385 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_LL{};
386 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_LM{};
387 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_LU{};
394 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_EL{};
395 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_EM{};
396 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_EU{};
404 if (circuitsEta == 2) {
417 std::shared_ptr<const PixelDiodeMatrix> fullMatrix{};
418 if (circuitsPhi == 1) {
428 if (circuitsPhi == 2) {
441 const std::array<std::string,2> sensorTypes{
"QuadChip_RD53",
"SingleChip_RD53"};
442 const std::array<std::string,17> rd53_ParamNames{
"circuitsPerEta",
"circuitsPerPhi",
"columns",
"detectorType",
"is3D",
"nEtaEndPerSide",
"nEtaLongPerSide",
"nPhiEndPerSide",
"nPhiLongPerSide",
"pitchEta",
"pitchEtaEnd",
"pitchEtaLong",
"pitchPhi",
"pitchPhiEnd",
"pitchPhiLong",
"rows",
"thickness"};
444 for(
const std::string & sType:sensorTypes){
446 if(rd53->size() !=0){
447 for (
unsigned int iR =0;iR<rd53->size();iR++){
448 std::map<std::string,std::string> rd53_Map;
449 for(
const std::string & paramName:rd53_ParamNames){
450 std::string paramValue = (*rd53)[iR]->getString(paramName);
451 rd53_Map[paramName] = std::move(paramValue);
453 std::string rd35_Name = (*rd53)[iR]->getString(
"SensorType");
462 const std::array<std::string,5>
fields{
"barrel_endcap",
"layer_wheel",
"phi_module",
"eta_module",
"side"};
465 const std::array<std::string,3> publishers({
"ITk",
"ITkPixel",
"GeoModelXML"});
468 std::map<std::string, GeoFullPhysVol*> mapFPV;
469 for (
auto & iPub : publishers){
471 mapFPV = sqlreader->getPublishedNodes<std::string, GeoFullPhysVol*>(iPub,
true);
472 if (!mapFPV.empty()) {
477 if (mapFPV.empty())
ATH_MSG_ERROR(
"Could not find any FPV tables under the expected names: "<<publishers);
479 for (
const auto&[fullPhysVolInfoString, fullPhysVolPointer] : mapFPV){
481 size_t startRG = fullPhysVolInfoString.find(
"RD53_");
482 if(startRG==std::string::npos){
483 ATH_MSG_DEBUG(
"GeoFullPhysVol "<<fullPhysVolInfoString<<
" does not have the expected format. Skipping");
486 std::string
typeName = fullPhysVolInfoString.substr(startRG);
487 std::map<std::string, int>
index;
489 size_t first = fullPhysVolInfoString.find(
field+
"_");
490 size_t last = fullPhysVolInfoString.find(
'_',
first+
field.size()+1);
491 if(
first==std::string::npos || last==std::string::npos){
492 ATH_MSG_DEBUG(
"Could not extract "<<
field<<
" from "<<fullPhysVolInfoString<<
". Skipping");
495 std::string strNew = fullPhysVolInfoString.substr(
first+
field.size()+1,last-(
first+
field.size()+1));
505 std::map<std::string, int> &
index,
506 GeoVFullPhysVol *fpv,
511 if (not pixelIdHelper){
512 ATH_MSG_ERROR(
"Dynamic cast to PixelID failed in PixelGmxInterface::addAlignable");
518 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
519 index[
"layer_wheel"],
525 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
526 index[
"layer_wheel"],
532 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
533 index[
"layer_wheel"],
539 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
546 throw GaudiException(
"Unknown level " +
std::to_string(
level) +
" for alignment in addAlignable",
547 "PixelGmxInterface::addAlignable", StatusCode::FAILURE);