ATLAS Offline Software
Loading...
Searching...
No Matches
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
12
13#include <TH2D.h>
14#include <TProfile.h>
15
16SiHitsTestTool::SiHitsTestTool(const std::string& type, const std::string& name, const IInterface* parent)
17 : SimTestToolBase(type, name, parent),
18 m_collection("PixelHits"),
21 m_hits_xy(0), m_hits_zr(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}
#define ATH_MSG_ERROR(x)
Helpers for checking error return status codes and reporting errors.
AtlasHitsVector< SiHit > SiHitCollection
#define _TH2D_WEIGHTED(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
#define _TH1D_WEIGHTED(var, name, nbin, xmin, xmax)
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
#define _TH1D(var, name, nbin, xmin, xmax)
#define _SET_TITLE(var, title, xaxis, yaxis)
HepGeom::Point3D< double > getGlobalPosition() const
Definition SiHit.h:19
StatusCode initialize()
std::string m_collection
SiHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
TH1 * m_hits_log_step_length
StatusCode processEvent()
std::string m_path
SimTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)
int barcode(const T *p)
Definition Barcode.h:16