ATLAS Offline Software
GeoPixelSiCrystal.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // This class builds one Si Crystal to be placed in one module
7 //
8 // The information on which layer to build is retrieved by the Geometry Manager
9 //
10 // Contained by: PixelModule_log
11 //
12 // Contains: nothing
13 //
14 #include "GeoPixelSiCrystal.h"
15 #include "GeoModelKernel/GeoBox.h"
16 #include "GeoModelKernel/GeoLogVol.h"
17 #include "GeoModelKernel/GeoFullPhysVol.h"
18 #include "GeoModelKernel/GeoMaterial.h"
19 #include "GaudiKernel/SystemOfUnits.h"
20 #include "Identifier/Identifier.h"
23 
30 
31 #include <algorithm> //for std::min, std::max
32 #include <utility>
33 #include <vector>
34 
35 #include "PixelGeoUtils.h"
36 namespace {
37  InDetDD::PixelReadoutTechnology getPixelReadoutTechnology(int rowsPerCircuit, int columnsPerCircuit) {
38  if (rowsPerCircuit*columnsPerCircuit>26000) { return InDetDD::PixelReadoutTechnology::FEI4; }
40  }
41 }
42 using namespace InDetDD;
43 
46  GeoModelIO::ReadGeoModel* sqliteReader,
47  std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
48  std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX,
49  bool isBLayer, bool isModule3D)
50  : GeoVPixelFactory (ddmgr, mgr, sqliteReader, std::move(mapFPV), std::move(mapAX))
51 {
52  //
53  //Builds the design for this crystal
54  m_isBLayer = isBLayer;
55  m_isModule3D = isModule3D;
56 
57  // Dimensions
58  const double thickness = m_gmt_mgr->PixelBoardThickness(m_isModule3D);
61 
62  int circuitsPerPhi = m_gmt_mgr->DesignCircuitsPhi(m_isModule3D); // Warning col/row naming opposite to chip
63  int circuitsPerEta = m_gmt_mgr->DesignCircuitsEta(m_isModule3D); // Warning col/row naming opposite to chip
64  int cellRowPerCirc = m_gmt_mgr->DesignCellRowsPerCircuit(m_isModule3D);
65  int cellColPerCirc = m_gmt_mgr->DesignCellColumnsPerCircuit(m_isModule3D);
66  int rowsPerCircuit = m_gmt_mgr->DesignDiodeRowsPerCircuit(m_isModule3D);
67  int columnsPerCircuit = m_gmt_mgr->DesignDiodeColumnsPerCircuit(m_isModule3D);
68  int readoutSide = m_gmt_mgr->DesignReadoutSide(m_isModule3D);
69 
70  double pitchEtaLongEnd = m_gmt_mgr->DesignPitchZLongEnd(m_isModule3D);
71  double pitchEtaLong = m_gmt_mgr->DesignPitchZLong(m_isModule3D);
72  double pitchPhi = m_gmt_mgr->DesignPitchRP(m_isModule3D);
73  double pitchEta = m_gmt_mgr->DesignPitchZ(m_isModule3D);
74 
75  auto readoutTechnology = getPixelReadoutTechnology(rowsPerCircuit,columnsPerCircuit );
76  auto circuitsPerPhi_corr = circuitsPerPhi;
77  auto rowsPerCircuit_corr = rowsPerCircuit;
78  if (readoutTechnology==InDetDD::PixelReadoutTechnology::FEI3 && circuitsPerPhi==1 && rowsPerCircuit==328) {
79  // FEI3 has 2x8 circuits and 160 + 4 rows per circuit not 1x8 circuits with 328 rows
80  // without this correction it is not possible to use the attribute associated to sub-matrices
81  // to assign FE numbers to sub-matrices.
82  circuitsPerPhi_corr*=2;
83  rowsPerCircuit_corr/=2;
84  }
88  readoutTechnology,
89  std::array<int,kNDirections>{circuitsPerPhi_corr,circuitsPerEta}, // [0]=phi/row, [1]=eta/column
90  std::array<int,kNDirections>{rowsPerCircuit_corr,columnsPerCircuit}, // [0]=phi/row, [1]=eta/column
91  std::array<std::array<double,kNDirections>,kNPixelLocations>{ // regular/central,longEnd/outer,long/inner
92  std::array<double,kNDirections>{pitchPhi,pitchEta},
93  std::array<double,kNDirections>{0.,pitchEtaLongEnd},
94  std::array<double,kNDirections>{0.,pitchEtaLong}});
95 
96  std::unique_ptr<PixelModuleDesign> p_barrelDesign2 = std::make_unique<PixelModuleDesign>(thickness,
97  circuitsPerPhi,
98  circuitsPerEta,
99  cellColPerCirc,
100  cellRowPerCirc,
101  columnsPerCircuit,
102  rowsPerCircuit,
103  std::move(diode_tree),
105  readoutSide,
106  false, /* 3D */
107  InDetDD::Undefined, /* detector type */
108  readoutTechnology);
109 
110  // Multiple connections (ganged pixels)
111  if (m_gmt_mgr->NumberOfEmptyRows() > 0) {
112  int minRow = m_gmt_mgr->EmptyRows(0);
113  int maxRow = minRow;
114  for (int iConnect = 0; iConnect < m_gmt_mgr->NumberOfEmptyRows(); iConnect++){
115  minRow = std::min(minRow, m_gmt_mgr->EmptyRows(iConnect));
116  minRow = std::min(minRow, m_gmt_mgr->EmptyRowConnections(iConnect));
117  maxRow = std::max(maxRow, m_gmt_mgr->EmptyRows(iConnect));
118  maxRow = std::max(maxRow, m_gmt_mgr->EmptyRowConnections(iConnect));
119  }
120 
121  std::vector <int> connections(maxRow-minRow+1);
122 
123  // We fill them all with a one to one correspondence first.
124  for (unsigned int iRow = 0; iRow < connections.size(); iRow++){
125  connections[iRow] = iRow + minRow;
126  }
127 
128  // Now make the connections.
129  for (int iConnect = 0; iConnect < m_gmt_mgr->NumberOfEmptyRows(); iConnect++){
130  connections[m_gmt_mgr->EmptyRows(iConnect)-minRow] = m_gmt_mgr->EmptyRowConnections(iConnect);
131  }
132 
133  p_barrelDesign2->addMultipleRowConnection(minRow, connections);
134 
135  } else {
136  // No empty rows.
137  if (!m_gmt_mgr->ibl()) {
138  m_gmt_mgr->msg(MSG::WARNING) << "GeoPixelSiCrystal: No ganged pixels" << endmsg;
139  } else {
140  if (m_gmt_mgr->msgLvl(MSG::DEBUG)) m_gmt_mgr->msg(MSG::DEBUG) << "GeoPixelSiCrystal: No ganged pixels" << endmsg;
141  }
142  }
143 
144  // Check that the active area seems reasonable
145 
150  m_gmt_mgr->msg(MSG::WARNING) << "GeoPixelSiCrystal: Active area not consistent with sensor size. Sensor: "
151  << width/Gaudi::Units::mm << " x " << length/Gaudi::Units::mm << ", Active: "
153  << endmsg;
154  } else {
156  << "GeoPixelSiCrystal: Sensor: "
157  << width/Gaudi::Units::mm << " x " << length/Gaudi::Units::mm << ", Active: "
159  << endmsg;
160  }
161 
162 
163  m_design = m_DDmgr->addDesign(std::move(p_barrelDesign2));
164 
165 
166 }
167 GeoVPhysVol* GeoPixelSiCrystal::Build() {
168 
169  GeoFullPhysVol* siPhys{nullptr};
170  int brl_ec= m_gmt_mgr->isEndcap() ? 2*m_gmt_mgr->GetSide() : 0;
171 
172  if(m_sqliteReader) {
173  std::string siName ="SiPhys_" + std::to_string(brl_ec) +"_"+ std::to_string(m_gmt_mgr->GetLD()) +"_"+ std::to_string(m_gmt_mgr->Phi()) +"_"+ std::to_string(m_gmt_mgr->Eta());
174  siPhys = (*m_mapFPV)[siName];
175  }
176  else {
177  //(sar) code moved from c'tor..
178  const double thickness = m_gmt_mgr->PixelBoardThickness(m_isModule3D);
180  const double width = m_gmt_mgr->PixelBoardWidth(m_isModule3D);
181  //
182  std::string matName = m_gmt_mgr->getMaterialName("Sensor");
183  const GeoMaterial* siMat = m_mat_mgr->getMaterial(matName);
184  const GeoBox* siBox = new GeoBox(thickness*0.5,width*0.5,length*0.5);
185  std::string logname{"siLog"};
186  // There is not a strong need to give the blayer a different name but leave it for now.
187  if(m_isBLayer) logname = "siBLayLog";
188  auto *logVolume = new GeoLogVol(logname,siBox,siMat);
189  //(sar) ...to here
190 
191 
192  siPhys = new GeoFullPhysVol(logVolume);
193  }
194 
195  // Build the Identifier for the silicon:
196  //
197  const PixelID * idHelper = m_gmt_mgr->getIdHelper();
198  m_id = idHelper->wafer_id(brl_ec,m_gmt_mgr->GetLD(),m_gmt_mgr->Phi(),m_gmt_mgr->Eta());
200 
201  // add the element to the manager
202  m_DDmgr->addDetectorElement(element);
203  return siPhys;
204 }
PixelGeometryManager::DesignCellRowsPerCircuit
virtual int DesignCellRowsPerCircuit(bool isModule3D=false)=0
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
PixelGeometryManager::NumberOfEmptyRows
virtual int NumberOfEmptyRows(bool isModule3D=false)=0
InDetDD::PixelDiodeTree
Tree structure to find the position, index or pitch of a pixel on a semi-regular grid The grid is con...
Definition: PixelDiodeTree.h:33
GeoPixelSiCrystal::m_id
Identifier m_id
Definition: GeoPixelSiCrystal.h:30
GeoPixelSiCrystal::m_design
const InDetDD::SiDetectorDesign * m_design
Definition: GeoPixelSiCrystal.h:34
InDetDD::PixelReadoutTechnology
PixelReadoutTechnology
Definition: PixelReadoutDefinitions.h:37
python.SystemOfUnits.mm
float mm
Definition: SystemOfUnits.py:98
PixelGeometryManager
Definition: PixelGeometryManager.h:28
PixelGeometryManager::msg
MsgStream & msg(MSG::Level lvl) const
Definition: PixelGeometryManager.h:611
PixelGeometryManager::DesignDiodeColumnsPerCircuit
virtual int DesignDiodeColumnsPerCircuit(bool isModule3D=false)=0
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
InDetDD::detail::kNPixelLocations
@ kNPixelLocations
Definition: PixelGeoUtils.h:19
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
PixelGeometryManager::DesignPitchZLongEnd
virtual double DesignPitchZLongEnd(bool isModule3D=false)=0
PixelGeometryManager::ibl
virtual bool ibl() const =0
GeoPixelSiCrystal::m_isModule3D
bool m_isModule3D
Definition: GeoPixelSiCrystal.h:36
PixelGeometryManager::DesignCircuitsEta
virtual int DesignCircuitsEta(bool isModule3D=false)=0
GeoPixelSiCrystal.h
PixelGeometryManager::DesignZActiveArea
virtual double DesignZActiveArea(bool isModule3D=false)=0
InDetDD::PixelReadoutTechnology::FEI3
@ FEI3
InDetDD::SiDetectorManager::addDesign
const SiDetectorDesign * addDesign(std::unique_ptr< const SiDetectorDesign > &&)
Access to module design; returns an observer pointer.
Definition: SiDetectorManager.cxx:134
PixelGeometryManager::msgLvl
bool msgLvl(MSG::Level lvl) const
Definition: PixelGeometryManager.h:614
PixelGeometryManager::EmptyRowConnections
virtual int EmptyRowConnections(int index)=0
PixelGeometryManager::GetSide
virtual int GetSide()=0
GeoPixelSiCrystal::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelSiCrystal.cxx:167
GeoVPixelFactory::m_sqliteReader
GeoModelIO::ReadGeoModel * m_sqliteReader
Definition: GeoVPixelFactory.h:46
PixelGeometryManager::DesignPitchZ
virtual double DesignPitchZ(bool isModule3D=false)=0
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:360
GeoVPixelFactory::m_DDmgr
InDetDD::PixelDetectorManager * m_DDmgr
Definition: GeoVPixelFactory.h:45
GeoVPixelFactory::m_gmt_mgr
PixelGeometryManager * m_gmt_mgr
Definition: GeoVPixelFactory.h:43
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
PixelGeometryManager::DesignRPActiveArea
virtual double DesignRPActiveArea(bool isModule3D=false)=0
InDetDD_Defs.h
PixelDetectorManager.h
PixelGeoUtils.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
SiCommonItems.h
PixelGeometryManager::DesignDiodeRowsPerCircuit
virtual int DesignDiodeRowsPerCircuit(bool isModule3D=false)=0
PixelGeometryManager::PixelBoardThickness
virtual double PixelBoardThickness(bool isModule3D=false)=0
PixelGeometryManager::Eta
virtual int Eta()=0
PixelGeometryManager::DesignCircuitsPhi
virtual int DesignCircuitsPhi(bool isModule3D=false)=0
PixelGeometryManager::DesignPitchZLong
virtual double DesignPitchZLong(bool isModule3D=false)=0
PixelGeometryManager::isEndcap
virtual bool isEndcap()=0
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
GeoVPixelFactory::m_mat_mgr
InDetMaterialManager * m_mat_mgr
Definition: GeoVPixelFactory.h:44
PixelGeometryManager::DesignReadoutSide
virtual int DesignReadoutSide(bool isModule3D=false)=0
SiDetectorElement.h
PixelGeometryManager::PixelBoardLength
virtual double PixelBoardLength(bool isModule3D=false)=0
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
PixelModuleDesign.h
DEBUG
#define DEBUG
Definition: page_access.h:11
GeoVPixelFactory
This is the base class for all the pieces of the Pixel detector.
Definition: GeoVPixelFactory.h:31
PixelGeometryManager::getIdHelper
virtual const PixelID * getIdHelper()=0
PixelGeometryManager::PixelBoardWidth
virtual double PixelBoardWidth(bool isModule3D=false)=0
PixelGeometryManager::getMaterialName
virtual std::string getMaterialName(const std::string &volumeName, int layerdisk=0, int typenum=0)=0
InDetDD::Undefined
@ Undefined
Definition: DetectorDesign.h:46
PixelDiodeTreeBuilder.h
PixelGeometryManager::commonItems
virtual InDetDD::SiCommonItems * commonItems()=0
InDetDD::detail::kNDirections
@ kNDirections
Definition: PixelGeoUtils.h:20
PixelGeometryManager::EmptyRows
virtual int EmptyRows(int index)=0
InDetMaterialManager::getMaterial
const GeoMaterial * getMaterial(const std::string &materialName)
Get material. First looks for locally defined material and if not found looks in GeoModel material ma...
Definition: InDetMaterialManager.cxx:96
InDetDD::detail::makePixelDiodeTree
PixelDiodeTree makePixelDiodeTree(T_MsgParent *gmt_mgr, InDetDD::PixelReadoutTechnology readoutTechnology, const std::array< int, kNDirections > &circuits, const std::array< int, kNDirections > &dimPerCircuit, const std::array< std::array< double, kNDirections >, kNPixelLocations > &pitch)
Definition: PixelGeoUtils.h:46
PixelID
Definition: PixelID.h:67
PixelDiodeTree.h
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
PixelGeometryManager::DesignPitchRP
virtual double DesignPitchRP(bool isModule3D=false)=0
MakeSliceSet.logname
logname
Definition: MakeSliceSet.py:34
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
InDetDD::PixelDetectorManager::addDetectorElement
virtual void addDetectorElement(SiDetectorElement *element) override
Add elememts.
Definition: PixelDetectorManager.cxx:128
PixelGeometryManager::DesignCellColumnsPerCircuit
virtual int DesignCellColumnsPerCircuit(bool isModule3D=false)=0
GeoPixelSiCrystal::GeoPixelSiCrystal
GeoPixelSiCrystal(InDetDD::PixelDetectorManager *ddmgr, PixelGeometryManager *mgr, GeoModelIO::ReadGeoModel *sqliteReader, std::shared_ptr< std::map< std::string, GeoFullPhysVol * >> mapFPV, std::shared_ptr< std::map< std::string, GeoAlignableTransform * >> mapAX, bool isBLayer, bool isModule3D=false)
Definition: GeoPixelSiCrystal.cxx:44
GeoPixelSiCrystal::m_isBLayer
bool m_isBLayer
Definition: GeoPixelSiCrystal.h:35
PixelGeometryManager::GetLD
virtual int GetLD()=0
PixelGeometryManager::Phi
virtual int Phi()=0