ATLAS Offline Software
SiHitsTestTool.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 #include "SiHitsTestTool.h"
8 
9 #include "GeoAdaptors/GeoSiHit.h"
11 #include "AtlasHepMC/GenParticle.h"
12 
13 #include <TH2D.h>
14 #include <TProfile.h>
15 
16 SiHitsTestTool::SiHitsTestTool(const std::string& type, const std::string& name, const IInterface* parent)
18  m_collection("PixelHits"),
19  m_indetBarrel(0), m_indetLongView(0),
20  m_hits_time(0), m_hits_edep(0), m_hits_log_edep(0),
21  m_hits_xy(0), m_hits_zr(0),
22  m_hits_edep_zr(0),
23  m_hits_edep_z(0), m_hits_edep_r(0),
24  m_hits_log_barcode(0),
25  m_hits_step_length(0),
26  m_hits_log_step_length(0)
27 {
28  declareProperty("CollectionName", m_collection="PixelHits");
29 }
30 
32 {
33  // initialise general (if not done yet)
34  m_path+="InDet/";
35  _TH2D(m_indetBarrel,"idet_xy",100,-1200.,1200.,100,-1200.,1200.);
36  _SET_TITLE(m_indetBarrel, "indet hit distribution","x [mm]","y [mm]");
37  // perhaps better make r-phi?
38  _TH2D(m_indetLongView,"idet_zr",100,-3200.,3200.,100,0.,1200.);
39  _SET_TITLE(m_indetLongView, "indet hit distribution","z [mm]","r [mm]");
40 
41  std::string detName("Pixel"); std::string detpathName("Pixel");
42  // initialise pixel or SCT variables:
43  if (m_collection=="PixelHits") {
44  detName = "Pixel"; detpathName = "Pixel";
45  }
46  else if (m_collection=="PileupPixelHits") {
47  detName = "PileupPixel"; detpathName = "Pixel";
48  }
49  else if (m_collection=="SCT_Hits") {
50  detName = "SCT"; detpathName = "SCT";
51  }
52  else if (m_collection=="PileupSCT_Hits") {
53  detName = "PileupSCT"; detpathName = "SCT";
54  }
55  else {
56  ATH_MSG_ERROR("collection: "<<m_collection<<", SiHitsTestTool for "<<name()<<" not supported !!!\n");
57  return StatusCode::FAILURE;
58  }
59  m_path+=detpathName+"/";
60  _TH2D(m_hits_xy,(detName+"_xy").c_str(),100,-1200.,1200.,100,-1200.,1200.);
61  _SET_TITLE(m_hits_xy, "hit distribution","x [mm]","y [mm]");
62  _TH2D(m_hits_zr,(detName+"_zr").c_str(),100,-3200.,3200.,100,0.,1200.);
63  _SET_TITLE(m_hits_zr, "hit distribution","z [mm]","r [mm]");
64  _TH1D_WEIGHTED(m_hits_time,(detName+"_edep_time").c_str(),100,0, 25);
65  _SET_TITLE(m_hits_time, "energy weighted hit distribution","t [ns]","dE/dt");
66  _TH1D(m_hits_edep,(detName+"_edep").c_str(),100,0.,1.);
67  _SET_TITLE(m_hits_edep, "hit distribution","edep [MeV]","dN/dE [1/MeV]");
68  _TH1D(m_hits_log_edep,(detName+"_log_edep").c_str(),100,-15.,2.);
69  _SET_TITLE(m_hits_log_edep, "log hit distribution","log(edep [MeV])","dN/dlog(E) [1/log(MeV)]");
70 
71  _TH2D_WEIGHTED(m_hits_edep_zr,(detName+"_edep_zr").c_str(),100,-3200.,3200.,100,0.,1200.);
72  _SET_TITLE(m_hits_edep_zr, "energy weighted indet hit distribution","z [mm]","r [mm]");
73 
74  _TH1D_WEIGHTED(m_hits_edep_z,(detName+"_edep_z").c_str(),100,-3200.,3200.);
75  _SET_TITLE(m_hits_edep_z, "energy weighted indet hit distribution (barrel only)","z [mm]","dE/dz [MeV/mm]");
76  _TH1D_WEIGHTED(m_hits_edep_r,(detName+"_edep_r").c_str(),100,0.,1200.);
77  _SET_TITLE(m_hits_edep_r, "energy weighted indet hit distribution (endcap only)","r [mm]","dE/dr [MeV/mm]");
78 
79  _TH1D(m_hits_log_barcode,(detName+"_log_barcode").c_str(),50,0.,16.);
80  _SET_TITLE(m_hits_log_barcode, "log(barcode)","log(barcode)","dN/dlog(barcode)");
81 
82  _TH1D(m_hits_step_length,(detName+"_step_length").c_str(),100,0.,2.);
83  _SET_TITLE(m_hits_step_length, "Step Length","Step Length l","dN/dl");
84  _TH1D(m_hits_log_step_length,(detName+"_log_step_length").c_str(), 100, -13, 2.);
85  _SET_TITLE(m_hits_log_step_length, "Logarithm of Step Length","log(l [mm])","dN/dlog(l)");
86 
87  return StatusCode::SUCCESS;
88 }
89 
91 
92  const SiHitCollection* p_collection = nullptr;
93  if (evtStore()->retrieve(p_collection,m_collection).isSuccess()) {
94  for (const SiHit& hit : *p_collection) {
95  GeoSiHit ghit(hit);
96  HepGeom::Point3D<double> u = ghit.getGlobalPosition();
97  if (m_hits_xy) {
98  m_hits_xy->Fill(u.x(),u.y());
99  m_hits_zr->Fill(u.z(),u.perp());
100  }
101  m_indetBarrel->Fill(u.x(),u.y());
102  m_indetLongView->Fill(u.z(),u.perp());
103 
104  m_hits_time->Fill(hit.meanTime(),hit.energyLoss());
105  m_hits_edep->Fill(hit.energyLoss());
106  m_hits_log_edep->Fill( log(hit.energyLoss()) );
107  m_hits_edep_zr->Fill(u.z(),u.perp(),hit.energyLoss());
108  int barcode = HepMC::barcode(hit.particleLink()); // FIXME barcode-based
109  m_hits_log_barcode->Fill( barcode > 0 ? log(barcode) : -1 );
110  double step_length = ( hit.localStartPosition()-hit.localEndPosition() ).mag();
111  m_hits_step_length->Fill(step_length);
112  m_hits_log_step_length->Fill( log(step_length));
113 
114  if (hit.getBarrelEndcap()==0) {
115  // barrel
116  m_hits_edep_z->Fill(u.z(),hit.energyLoss());
117  }
118  else {
119  // discs
120  m_hits_edep_r->Fill(u.perp(),hit.energyLoss());
121  }
122 
123  // debuging only:
124  //hit.print();
125  /*
126  *** SCT Hit
127  Barrel/ EndCap Number -2
128  Layer/Disk Number 5
129  Eta Number 0
130  Phi Number 43
131  Side Number 1
132  */
133 
134  }
135  }
136 
137  return StatusCode::SUCCESS;
138 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SiHitsTestTool::m_hits_log_step_length
TH1 * m_hits_log_step_length
Definition: SiHitsTestTool.h:32
TH2::Fill
int Fill(double, double)
Definition: rootspy.cxx:382
SiHitsTestTool::m_hits_edep
TH1 * m_hits_edep
Definition: SiHitsTestTool.h:27
SiHitsTestTool.h
SiHitsTestTool::m_hits_xy
TH2 * m_hits_xy
Definition: SiHitsTestTool.h:28
SiHitsTestTool::initialize
StatusCode initialize()
Definition: SiHitsTestTool.cxx:31
AthMsgStreamMacros.h
SiHitsTestTool::m_hits_step_length
TH1 * m_hits_step_length
Definition: SiHitsTestTool.h:32
AtlasHitsVector
Definition: AtlasHitsVector.h:33
_SET_TITLE
#define _SET_TITLE(var, title, xaxis, yaxis)
Definition: SimTestHisto.h:93
GenParticle.h
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
_TH1D
#define _TH1D(var, name, nbin, xmin, xmax)
Definition: SimTestHisto.h:47
GeoSiHit
Definition: GeoSiHit.h:30
SiHit
Definition: SiHit.h:19
SiHitsTestTool::m_hits_edep_zr
TH2 * m_hits_edep_zr
Definition: SiHitsTestTool.h:29
SiHitsTestTool::m_hits_zr
TH2 * m_hits_zr
Definition: SiHitsTestTool.h:28
SimTestToolBase
Definition: SimTestToolBase.h:20
GeoSiHit.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SiHitsTestTool::m_hits_time
TH1 * m_hits_time
Definition: SiHitsTestTool.h:27
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
SiHitsTestTool::processEvent
StatusCode processEvent()
Definition: SiHitsTestTool.cxx:90
test_pyathena.parent
parent
Definition: test_pyathena.py:15
_TH2D
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition: SimTestHisto.h:81
_TH2D_WEIGHTED
#define _TH2D_WEIGHTED(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition: SimTestHisto.h:89
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
_TH1D_WEIGHTED
#define _TH1D_WEIGHTED(var, name, nbin, xmin, xmax)
Definition: SimTestHisto.h:67
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
SiHitsTestTool::m_hits_log_edep
TH1 * m_hits_log_edep
Definition: SiHitsTestTool.h:27
SiHitsTestTool::SiHitsTestTool
SiHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SiHitsTestTool.cxx:16
SiHitsTestTool::m_hits_log_barcode
TH1 * m_hits_log_barcode
Definition: SiHitsTestTool.h:31
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SiHitsTestTool::m_indetBarrel
TH2 * m_indetBarrel
Definition: SiHitsTestTool.h:25
SiHitsTestTool::m_indetLongView
TH2 * m_indetLongView
Definition: SiHitsTestTool.h:25
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
GeoSiHit::getGlobalPosition
HepGeom::Point3D< double > getGlobalPosition() const
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
SiHitsTestTool::m_hits_edep_r
TH1 * m_hits_edep_r
Definition: SiHitsTestTool.h:30
SiHitsTestTool::m_hits_edep_z
TH1 * m_hits_edep_z
Definition: SiHitsTestTool.h:30
SimTestHisto::m_path
std::string m_path
Definition: SimTestHisto.h:34
python.LArCondContChannels.detName
detName
Definition: LArCondContChannels.py:665
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:25
SiHitsTestTool::m_collection
std::string m_collection
Definition: SiHitsTestTool.h:23
SiHitCollection.h