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{};
126 bool phiSymmetric{
true};
127 bool etaSymmetric{
true};
128 bool depthSymmetric{
true};
155 std::shared_ptr<const PixelDiodeMatrix> fullMatrix =
buildMatrix(pitchPhi, pitchEta,
156 pitchPhiLong, pitchPhiEnd,
157 pitchEtaLong, pitchEtaEnd,
158 nPhiLongPerSide, nPhiEndPerSide,
159 nEtaLongPerSide, nEtaEndPerSide,
160 circuitsPerPhi, circuitsPerEta,
161 columnsPerChip, rowsPerChip);
163 ATH_MSG_DEBUG(
"fullMatrix = buildMatrix(" << pitchPhi <<
", " << pitchEta <<
", "
164 << pitchPhiLong <<
", " << pitchPhiEnd <<
", "
165 << pitchEtaLong <<
", " << pitchEtaEnd <<
", "
166 << nPhiLongPerSide <<
", " << nPhiEndPerSide <<
", "
167 << nEtaLongPerSide <<
", " << nEtaEndPerSide <<
", "
168 << circuitsPerPhi <<
", " << circuitsPerEta <<
", "
169 << columnsPerChip <<
", " << rowsPerChip <<
")");
171 << circuitsPerPhi <<
" " << circuitsPerEta <<
" "
172 << columnsPerChip <<
" " << rowsPerChip <<
" "
173 << columnsPerChip <<
" " << rowsPerChip <<
" "
174 << carrier <<
" " << readoutSide);
179 int detectorTypeEnum = 0;
186 auto design = std::make_unique<PixelModuleDesign>(thickness,
187 phiSymmetric, etaSymmetric, depthSymmetric,
188 circuitsPerPhi, circuitsPerEta,
189 columnsPerChip, rowsPerChip,
190 columnsPerChip, rowsPerChip,
192 readoutSide, is3D, detectorType);
195 ATH_MSG_DEBUG(
"readout geo - design : " << design->width() <<
" " << design->length() <<
" " << design->thickness() <<
" " <<design->rows() <<
" " << design->columns());
205 std::map<std::string, int> &
index,
207 GeoVFullPhysVol *fpv)
213 if (not pixelIdHelper){
214 ATH_MSG_ERROR(
"Failed dynamic_cast to PixelID in PixelGmxInterface::addSensor");
218 index[
"layer_wheel"],
220 index[
"eta_module"]);
231 msg() << MSG::ERROR <<
key <<
" = " <<
value <<
"; ";
234 ATH_MSG_ERROR(
"Refusing to make it into a sensitive element. Incompatible gmx and identifier-xml files.");
244 throw std::runtime_error(
"readout sensor type " +
typeName +
" not found.");
248 if (design ==
nullptr) {
250 throw std::runtime_error(
"readout sensor type " +
typeName +
" not found.");
259 std::string errorMessage(
"");
261 index[
"layer_wheel"],
274 double phiPitchLong,
double phiPitchEnd,
275 double etaPitchLong,
double etaPitchEnd,
276 int nPhiLong,
int nPhiEnd,
277 int nEtaLong,
int nEtaEnd,
278 int circuitsPhi,
int circuitsEta,
279 int diodeColPerCirc,
int diodeRowPerCirc)
const
282 if (circuitsPhi < 1 or circuitsEta < 1) {
286 if (diodeRowPerCirc < 1 or diodeColPerCirc < 1) {
290 if (nPhiLong < 0 or nPhiEnd < 0 or nEtaLong < 0 or nEtaEnd < 0) {
296 if (nPhiLong == 0 and not (phiPitchLong == 0.0 or phiPitchLong == phiPitch)) {
297 ATH_MSG_DEBUG(
"nPhiLong is set to 0, but phiPitchLong is neither 0 nor phiPitch! Setting nPhiLong to 1");
300 if (nPhiEnd == 0 and not (phiPitchEnd == 0.0 or phiPitchEnd == phiPitch)) {
301 ATH_MSG_DEBUG(
"nPhiEnd is set to 0, but phiPitchEnd is neither 0 nor phiPitch! Setting nPhiEnd to 1");
304 if (nEtaLong == 0 and not (etaPitchLong == 0.0 or etaPitchLong == etaPitch)) {
305 ATH_MSG_DEBUG(
"nEtaLong is set to 0, but etaPitchLong is neither 0 nor etaPitch! Setting nEtaLong to 1");
308 if (nEtaEnd == 0 and not (etaPitchEnd == 0.0 or etaPitchEnd == etaPitch)) {
309 ATH_MSG_DEBUG(
"nEtaEnd is set to 0, but etaPitchEnd is neither 0 nor etaPitch! Setting nEtaEnd to 1");
320 std::shared_ptr<const PixelDiodeMatrix> cell_NN{};
321 std::shared_ptr<const PixelDiodeMatrix> cell_NL{};
322 std::shared_ptr<const PixelDiodeMatrix> cell_NE{};
323 std::shared_ptr<const PixelDiodeMatrix> cell_LN{};
324 std::shared_ptr<const PixelDiodeMatrix> cell_LL{};
325 std::shared_ptr<const PixelDiodeMatrix> cell_LE{};
326 std::shared_ptr<const PixelDiodeMatrix> cell_EN{};
327 std::shared_ptr<const PixelDiodeMatrix> cell_EL{};
328 std::shared_ptr<const PixelDiodeMatrix> cell_EE{};
380 std::shared_ptr<const PixelDiodeMatrix> fullChipRow_N{};
381 std::shared_ptr<const PixelDiodeMatrix> fullChipRow_L{};
382 std::shared_ptr<const PixelDiodeMatrix> fullChipRow_E{};
383 if (circuitsEta == 1) {
394 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_LL{};
395 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_LM{};
396 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_LU{};
403 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_EL{};
404 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_EM{};
405 std::shared_ptr<const PixelDiodeMatrix> singleChipRow_EU{};
413 if (circuitsEta == 2) {
426 std::shared_ptr<const PixelDiodeMatrix> fullMatrix{};
427 if (circuitsPhi == 1) {
437 if (circuitsPhi == 2) {
450 const std::array<std::string,2> sensorTypes{
"QuadChip_RD53",
"SingleChip_RD53"};
451 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"};
453 for(
const std::string & sType:sensorTypes){
455 if(rd53->size() !=0){
456 for (
unsigned int iR =0;iR<rd53->size();iR++){
457 std::map<std::string,std::string> rd53_Map;
458 for(
const std::string & paramName:rd53_ParamNames){
459 std::string paramValue = (*rd53)[iR]->getString(paramName);
460 rd53_Map[paramName] = std::move(paramValue);
462 std::string rd35_Name = (*rd53)[iR]->getString(
"SensorType");
471 const std::array<std::string,5>
fields{
"barrel_endcap",
"layer_wheel",
"phi_module",
"eta_module",
"side"};
474 const std::array<std::string,3> publishers({
"ITk",
"ITkPixel",
"GeoModelXML"});
477 std::map<std::string, GeoFullPhysVol*> mapFPV;
478 for (
auto & iPub : publishers){
480 mapFPV = sqlreader->getPublishedNodes<std::string, GeoFullPhysVol*>(iPub,
true);
481 if (!mapFPV.empty()) {
486 if (mapFPV.empty())
ATH_MSG_ERROR(
"Could not find any FPV tables under the expected names: "<<publishers);
488 for (
const auto&[fullPhysVolInfoString, fullPhysVolPointer] : mapFPV){
490 size_t startRG = fullPhysVolInfoString.find(
"RD53_");
491 if(startRG==std::string::npos){
492 ATH_MSG_DEBUG(
"GeoFullPhysVol "<<fullPhysVolInfoString<<
" does not have the expected format. Skipping");
495 std::string
typeName = fullPhysVolInfoString.substr(startRG);
496 std::map<std::string, int>
index;
498 size_t first = fullPhysVolInfoString.find(
field+
"_");
499 size_t last = fullPhysVolInfoString.find(
'_',
first+
field.size()+1);
500 if(
first==std::string::npos || last==std::string::npos){
501 ATH_MSG_DEBUG(
"Could not extract "<<
field<<
" from "<<fullPhysVolInfoString<<
". Skipping");
504 std::string strNew = fullPhysVolInfoString.substr(
first+
field.size()+1,last-(
first+
field.size()+1));
514 std::map<std::string, int> &
index,
515 GeoVFullPhysVol *fpv,
520 if (not pixelIdHelper){
521 ATH_MSG_ERROR(
"Dynamic cast to PixelID failed in PixelGmxInterface::addAlignable");
527 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
528 index[
"layer_wheel"],
534 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
535 index[
"layer_wheel"],
541 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
542 index[
"layer_wheel"],
548 id = pixelIdHelper->wafer_id(
index[
"barrel_endcap"],
555 throw GaudiException(
"Unknown level " +
std::to_string(
level) +
" for alignment in addAlignable",
556 "PixelGmxInterface::addAlignable", StatusCode::FAILURE);