ATLAS Offline Software
InDetMaterialVeto.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 // Header include
6 
8 #include "GeoModelKernel/GeoTube.h"
11 
13 #include "GaudiKernel/Bootstrap.h"
14 #include "GaudiKernel/IMessageSvc.h"
15 #include "GaudiKernel/ISvcLocator.h"
16 
17 
18 
19 namespace InDet {
20 
21 
23  const InDetDD::PixelDetectorManager* pixelManager) :
24  AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),"InDetMaterialVeto")
25  {
26 
27  ATH_MSG_DEBUG("Building material rejection map from BeamPipe and PixelDetectorManager");
28 
29  static constexpr int nbins_R = 76;
30  double bins_R[nbins_R+1];
31  for(unsigned int i=0; i<=15; i++) bins_R[i] = 2*i - 1.; // 2 mm bin width below R=29 mm, centered on R=24 mm (beampipe)
32  bins_R[16] = 30.; // 29-30 makes junction with pixel bins, veto IPT R=29.3 mm
33  static constexpr double Rbinwidth_pixel = 6.;
34  for(unsigned int i=1; i<=60; i++) bins_R[i+16] = 30 + Rbinwidth_pixel*i; // 6 mm bin width beyond R=30 mm
35 
36  static constexpr int nbins_Z = 1000;
37  static constexpr double zmax = 3000.;
38  static constexpr double zbinwidth = 2*zmax/nbins_Z;
39 
40  std::string mapName = "ITkMaterialMap";
41  m_ITkPixMaterialMap = std::make_unique<TH2D>(mapName.c_str(),mapName.c_str(),nbins_Z,-zmax,zmax,nbins_R,bins_R); // x-axis = global z coordinates, -3240 mm to +3240 mm, 6 mm bin width / y-axis = global R coordinates, variable bin width
42 
43 
44  // Retrieve the beam pipe radius from the SectionC03 volume
45 
46  double beamPipeRadius = 0.;
47  PVConstLink beamPipeTopVolume = beamPipeMgr->getTreeTop(0);
48  const GeoLogVol* beamPipeLogVolume = beamPipeTopVolume->getLogVol();
49  const GeoTube* beamPipeTube = nullptr;
50 
51  if (beamPipeLogVolume){
52  beamPipeTube = dynamic_cast<const GeoTube*>(beamPipeLogVolume->getShape());
53  if (beamPipeTube){
54 
55  for(unsigned int i=0;i<beamPipeTopVolume->getNChildVols();i++){
56 
57  if(beamPipeTopVolume->getNameOfChildVol(i)=="SectionC03"){
58  PVConstLink childTopVolume = beamPipeTopVolume->getChildVol(i);
59  const GeoLogVol* childLogVolume = childTopVolume->getLogVol();
60  const GeoTube* childTube = nullptr;
61 
62  if (childLogVolume){
63  childTube = dynamic_cast<const GeoTube*>(childLogVolume->getShape());
64  if (childTube){
65  beamPipeRadius = 0.5 * (childTube->getRMax()+childTube->getRMin());
66  }
67  }
68 
69  break; //Exit loop after SectionC03 is found
70  }
71 
72  } // Loop over child volumes
73 
74  }
75  } // if(beamPipeLogVolume)
76 
77  ATH_MSG_DEBUG("BeamPipeRadius used for material rejection="<<beamPipeRadius);
78 
79  // Fill map with beam pipe radius for all z
80  for(double z = -zmax + 0.5*zbinwidth; z<zmax; z+=zbinwidth) m_ITkPixMaterialMap->Fill(z,beamPipeRadius);
81 
82 
83  // Retrieve IPT radius
84  // Labelled as anonymous volume so taken as pixel volume with smallest radius
85 
86  double IPTRadius = -1.;
87 
88  PVConstLink pixelTopVolume = pixelManager->getTreeTop(0);
89 
90  for(unsigned int i=0;i<pixelTopVolume->getNChildVols();i++){
91 
92  PVConstLink childTopVolume = pixelTopVolume->getChildVol(i);
93  const GeoLogVol* childLogVolume = childTopVolume->getLogVol();
94  const GeoTube* childTube = nullptr;
95 
96  if (childLogVolume){
97  childTube = dynamic_cast<const GeoTube*>(childLogVolume->getShape());
98  if (childTube){
99  double radius = 0.5*(childTube->getRMin()+childTube->getRMax());
100  if(IPTRadius<0. || radius<IPTRadius) IPTRadius = radius;
101  }
102  }
103 
104  }
105 
106  ATH_MSG_DEBUG("IPTRadius used for material rejection="<<IPTRadius);
107 
108  // Fill map with IPT radius for all z
109  for(double z = -zmax + 0.5*zbinwidth; z<zmax; z+=zbinwidth) m_ITkPixMaterialMap->Fill(z,IPTRadius);
110 
111 
112  InDetDD::SiDetectorElementCollection::const_iterator iter;
113  for (iter = pixelManager->getDetectorElementBegin(); iter != pixelManager->getDetectorElementEnd(); ++iter) {
114  // get the ID
115  Identifier Pixel_ModuleID = (*iter)->identify();
116  // check the validity
117  if (Pixel_ModuleID.is_valid()) {
118  const InDetDD::SiDetectorElement *module = pixelManager->getDetectorElement(Pixel_ModuleID);
119 
120  //Take into account full module extent
121  InDetDD::DetectorType type = module->design().type();
122 
124  double zMin_mod = module->zMin();
125  double zMax_mod = module->zMax();
126  double rMin_mod = module->rMin();
127  double rMax_mod = module->rMax();
128  if(zMin_mod>0){
129  double alpha = (rMin_mod-rMax_mod)/(zMax_mod-zMin_mod);
130  for(double z=zMin_mod; z<=zMax_mod; z+=zbinwidth){
131  double R = rMax_mod + alpha*(z-zMin_mod);
132  m_ITkPixMaterialMap->Fill(z,R);
133  }
134  }
135  else{
136  double alpha = (rMax_mod-rMin_mod)/(zMax_mod-zMin_mod);
137  for(double z=zMin_mod; z<=zMax_mod; z+=zbinwidth){
138  double R = rMin_mod + alpha*(z-zMin_mod);
139  m_ITkPixMaterialMap->Fill(z,R);
140  }
141  }
142  }
143 
144  else if(type==InDetDD::PixelBarrel){
145  double zMin_mod = module->zMin();
146  double zMax_mod = module->zMax();
147  double R = std::hypot(module->center().x(),module->center().y());
148  for(double z=zMin_mod; z<=zMax_mod; z+=zbinwidth) m_ITkPixMaterialMap->Fill(z,R);
149  }
150 
151  else if(type==InDetDD::PixelEndcap){
152  double rMin_mod = module->rMin();
153  double rMax_mod = module->rMax();
154  double z = module->center().z();
155  for(double R=rMin_mod; R<=rMax_mod; R+=Rbinwidth_pixel) m_ITkPixMaterialMap->Fill(z,R);
156  }
157 
158  }
159  } // end loop over pixel modules
160 
161  }
162 
163 }
164 
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
BeamPipeDetectorManager::getTreeTop
virtual PVConstLink getTreeTop(unsigned int i) const
Definition: BeamPipeDetectorManager.cxx:20
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
InDetMaterialVeto.h
InDetDD::PixelInclined
@ PixelInclined
Definition: DetectorDesign.h:46
InDetDD::PixelEndcap
@ PixelEndcap
Definition: DetectorDesign.h:46
python.PyAthena.module
module
Definition: PyAthena.py:134
InDetDD::DetectorType
DetectorType
Definition: DetectorDesign.h:45
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
InDetDD::PixelDetectorManager::getDetectorElementBegin
virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const override
Definition: PixelDetectorManager.cxx:110
InDet::InDetMaterialVeto::InDetMaterialVeto
InDetMaterialVeto(const BeamPipeDetectorManager *beamPipeMgr, const InDetDD::PixelDetectorManager *pixelManager)
Definition: InDetMaterialVeto.cxx:22
InDet::InDetMaterialVeto::m_ITkPixMaterialMap
std::unique_ptr< TH2D > m_ITkPixMaterialMap
Definition: InDetMaterialVeto.h:37
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
InDetDD::PixelBarrel
@ PixelBarrel
Definition: DetectorDesign.h:46
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElementCollection.h
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
SiDetectorElement.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDetDD::PixelDetectorManager::getTreeTop
virtual PVConstLink getTreeTop(unsigned int i) const override
Definition: PixelDetectorManager.cxx:71
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
InDetDD::PixelDetectorManager::getDetectorElementEnd
virtual SiDetectorElementCollection::const_iterator getDetectorElementEnd() const override
Definition: PixelDetectorManager.cxx:115
BeamPipeDetectorManager
Definition: BeamPipeDetectorManager.h:14
InDetDD::PixelDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Definition: PixelDetectorManager.cxx:80