ATLAS Offline Software
LayerMaterialInspector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // LayerMaterialInspector.cxx, (c) ATLAS Detector software
8 
14 #include "TrkGeometry/Layer.h"
15 #include "TrkSurfaces/Surface.h"
17 #include "TrkSurfaces/DiscBounds.h"
19 // Root
20 #include "TH2F.h"
21 #include "TTree.h"
22 #include "TString.h"
23 // Gaudi
24 #include "GaudiKernel/ITHistSvc.h"
25 
26 // constructor
27 Trk::LayerMaterialInspector::LayerMaterialInspector(const std::string& t, const std::string& n, const IInterface* p) :
29  m_treeFolder("/val/")
30 {}
31 
32 // destructor
34 = default;
35 
37 {
38  return StatusCode::SUCCESS;
39 }
40 
42 {
43 
44  const Trk::TrackingVolume* tvol = lay.enclosingTrackingVolume();
45  TString folderId = tvol ? tvol->volumeName() : std::string("Unknown");
46  TString folderName = m_treeFolder+folderId;
47  folderName.ReplaceAll("::","_");
48 
49  // prepare the information
50  int lIndex = lay.layerIndex().value();
51  const Amg::Vector3D& lCenter = lay.surfaceRepresentation().center();
53 
54  // skip navigation layers
55  if (!lMaterial) return StatusCode::SUCCESS;
56 
57  int lType = 0; // 1 - cylinder, 2 - disc
58  float dim0 = 0.;
59  float dim1 = 0.;
60 
61  int bins0 = 1;
62  int bins1 = 1;
63 
64  float centerX = lCenter.x();
65  float centerY = lCenter.y();
66  float centerZ = lCenter.z();
67 
68  // cylinder bounds
70  lType = 1;
71  // cylinder bounds
72  const Trk::CylinderBounds* cb = dynamic_cast<const Trk::CylinderBounds*>(&(lay.surfaceRepresentation().bounds()));
73  if (cb){
74  dim0 = cb->r();
75  dim1 = cb->halflengthZ();
76  }
77  } else if ( lay.surfaceRepresentation().type() == Trk::SurfaceType::Disc ) {
78  lType = 2;
79  // disc bounds
80  const Trk::DiscBounds* db = dynamic_cast<const Trk::DiscBounds*>(&(lay.surfaceRepresentation().bounds()));
81  if (db){
82  dim0 = db->rMin();
83  dim1 = db->rMax();
84  }
85  }
86 
87  if (lMaterial){
88  const Trk::BinUtility* lBinUtility = lMaterial->binUtility();
89  bins0 = lBinUtility ? lBinUtility->max(0)+1 : 1;
90  bins1 = lBinUtility ? lBinUtility->max(1)+1 : 1;
91  }
92 
93 
94  // -------------------------------------------------------------------------------------
95  TString hName = ( lType == 1 ) ? "CylinderLayer_" : "DiscLayer_";
96  hName += int(lIndex);
97 
98  TString pXo = "_pX0";
99  TString info = "_Information";
100 
101  TH2F* lMaterialHist = lType == 1 ?
102  new TH2F(hName+pXo, hName, bins0, -M_PI*dim0, M_PI*dim0, bins1, -dim1, dim1) :
103  new TH2F(hName+pXo, hName, bins0, dim0, dim1, bins1, -M_PI, M_PI);
104 
105  TTree* lTreeInformation = new TTree(hName+info,hName);
106  lTreeInformation->Branch("LayerCenterX", &centerX, "cX/F");
107  lTreeInformation->Branch("LayerCenterY", &centerY, "cY/F");
108  lTreeInformation->Branch("LayerCenterZ", &centerZ, "cZ/F");
109  lTreeInformation->Branch("LayerIndex", &lIndex, "idx/I");
110  if (lType == 1){
111  lTreeInformation->Branch("Radius", &dim0, "r/F");
112  lTreeInformation->Branch("HalflengthZ", &dim1, "hz/F");
113  lTreeInformation->Branch("BinsRPhi", &bins0, "bin0/I");
114  lTreeInformation->Branch("BinsHalfZ", &bins1, "bin1/I");
115  } else if (lType == 2){
116  lTreeInformation->Branch("InnerRadius", &dim0, "rmin/F");
117  lTreeInformation->Branch("OuterRadius", &dim1, "rmax/F");
118  lTreeInformation->Branch("BinsR", &bins0, "bin0/I");
119  lTreeInformation->Branch("BinsPhi", &bins1, "bin1/I");
120  }
121 
122  // --------------- registration for histogram and tree ---------------------------------
123  TString regHistName = folderName+"/"+hName+"/"+hName+pXo;
124  TString regTreeName = folderName+"/"+hName+"/"+hName+info;
125 
126  SmartIF<ITHistSvc> tHistSvc{service("THistSvc")};
127  ATH_CHECK( tHistSvc.isValid() );
128 
129  if ( (tHistSvc->regTree(std::string(regTreeName.Data()),lTreeInformation)).isFailure() ){
130  ATH_MSG_WARNING("Could not register TTree with name " << hName);
131  }
132  lTreeInformation->Fill();
133 
134  if ( (tHistSvc->regHist(std::string(regHistName.Data()),lMaterialHist)).isFailure() ){
135  ATH_MSG_WARNING("Could not register THist with name " << hName);
136  }
137 
138  if (lMaterial){
139  // fill the material into the bins
140  for ( int ib0 = 0; ib0 < bins0; ++ib0 )
141  for ( int ib1 = 0; ib1 < bins1; ++ib1 ){
142  // get the material
143  const Trk::MaterialProperties* mps = lMaterial->material(size_t(ib0),size_t(ib1));
144  if (mps)
145  lMaterialHist->SetBinContent(ib0+1,ib1+1,mps->thicknessInX0());
146  }
147  }
148 
149  return StatusCode::SUCCESS;
150 }
151 
153 {
154  return StatusCode::SUCCESS;
155 }
156 
157 
158 
159 
grepfile.info
info
Definition: grepfile.py:38
DiscBounds.h
Surface.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MaterialProperties.h
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition: BinUtility.h:215
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
Trk::MaterialProperties::thicknessInX0
float thicknessInX0() const
Return the radiationlength fraction.
BinUtility.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Layer.h
Trk::LayerMaterialProperties::material
virtual const MaterialProperties * material(size_t ib0, size_t ib1) const =0
Direct access via bins to the MaterialProperties.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::Layer::surfaceRepresentation
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
LayerMaterialInspector.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::CylinderBounds
Definition: CylinderBounds.h:46
Trk::LayerMaterialProperties
Definition: LayerMaterialProperties.h:62
Trk::LayerMaterialInspector::LayerMaterialInspector
LayerMaterialInspector(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: LayerMaterialInspector.cxx:27
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::LayerIndex::value
int value() const
layerIndex expressed in an integer
Definition: LayerIndex.h:71
Trk::LayerMaterialProperties::binUtility
virtual const BinUtility * binUtility() const =0
Return the BinUtility.
Trk::BinUtility
Definition: BinUtility.h:39
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::TrackingVolume::volumeName
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
CaloCellTimeCorrFiller.folderName
string folderName
Definition: CaloCellTimeCorrFiller.py:20
Trk::Surface::bounds
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
Trk::LayerMaterialInspector::~LayerMaterialInspector
virtual ~LayerMaterialInspector()
Destructor.
Trk::RecursiveGeometryProcessor
Definition: RecursiveGeometryProcessor.h:39
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CylinderBounds.h
Trk::MaterialProperties
Definition: MaterialProperties.h:40
TrackingVolume.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::SurfaceType::Disc
@ Disc
Trk::Layer::enclosingTrackingVolume
const TrackingVolume * enclosingTrackingVolume() const
get the confining TrackingVolume
Trk::SurfaceType::Cylinder
@ Cylinder
Trk::Layer::layerMaterialProperties
const LayerMaterialProperties * layerMaterialProperties() const
getting the LayerMaterialProperties including full/pre/post update
Trk::LayerMaterialInspector::processNode
virtual StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Processor Action to work on TrackingVolumes - the level is for the hierachy tree.
Definition: LayerMaterialInspector.cxx:36
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
LayerMaterialProperties.h
Trk::DiscBounds
Definition: DiscBounds.h:44
Trk::CylinderBounds::halflengthZ
double halflengthZ() const
This method returns the halflengthZ.
Trk::CylinderBounds::r
virtual double r() const override final
This method returns the radius.
Trk::Layer
Definition: Layer.h:73
Trk::Layer::layerIndex
const LayerIndex & layerIndex() const
get the layerIndex