ATLAS Offline Software
LayerMaterialInspector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  ITHistSvc* tHistSvc = nullptr;
127  if (service("THistSvc",tHistSvc).isFailure()) {
128  ATH_MSG_FATAL( "initialize() Could not find Hist Service! Aborting." );
129  return StatusCode::FAILURE;
130  }
131 
132  if ( (tHistSvc->regTree(std::string(regTreeName.Data()),lTreeInformation)).isFailure() ){
133  ATH_MSG_WARNING("Could not register TTree with name " << hName);
134  }
135  lTreeInformation->Fill();
136 
137  if ( (tHistSvc->regHist(std::string(regHistName.Data()),lMaterialHist)).isFailure() ){
138  ATH_MSG_WARNING("Could not register THist with name " << hName);
139  }
140 
141  if (lMaterial){
142  // fill the material into the bins
143  for ( int ib0 = 0; ib0 < bins0; ++ib0 )
144  for ( int ib1 = 0; ib1 < bins1; ++ib1 ){
145  // get the material
146  const Trk::MaterialProperties* mps = lMaterial->material(size_t(ib0),size_t(ib1));
147  if (mps)
148  lMaterialHist->SetBinContent(ib0+1,ib1+1,mps->thicknessInX0());
149  }
150  }
151 
152  return StatusCode::SUCCESS;
153 }
154 
156 {
157  return StatusCode::SUCCESS;
158 }
159 
160 
161 
162 
grepfile.info
info
Definition: grepfile.py:38
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
DiscBounds.h
Surface.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MaterialProperties.h
TH2F
Definition: rootspy.cxx:420
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
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
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.
TH2F::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:426
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