ATLAS Offline Software
Loading...
Searching...
No Matches
TRTHitAnalysis.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TRTHitAnalysis.h"
6
7// Section of includes for TRT tests
11
12
13
15 ATH_MSG_DEBUG( "Initializing TRTHitAnalysis" );
16
17 // Grab the Ntuple and histogramming service for the tree
18 ATH_CHECK(m_readKey.initialize());
19
21 m_h_TRT_x = new TH1D("h_TRT_x","hits_x", 100,-1100, 1100);
22 m_h_TRT_x->StatOverflows();
23 ATH_CHECK(histSvc()->regHist(m_path + m_h_TRT_x->GetName(), m_h_TRT_x));
24
25 m_h_TRT_y = new TH1D("h_TRT_y", "hits_y", 100,-1100,1100);
26 m_h_TRT_y->StatOverflows();
27 ATH_CHECK(histSvc()->regHist(m_path + m_h_TRT_y->GetName(), m_h_TRT_y));
28
29 m_h_TRT_z = new TH1D("h_TRT_z", "hits_z", 100,-3000,3000);
30 m_h_TRT_z->StatOverflows();
31 ATH_CHECK(histSvc()->regHist(m_path + m_h_TRT_z->GetName(), m_h_TRT_z));
32
33 m_h_TRT_r = new TH1D("h_TRT_r", "hits_r", 100,500,1100);
34 m_h_TRT_r->StatOverflows();
35 ATH_CHECK(histSvc()->regHist(m_path + m_h_TRT_r->GetName(), m_h_TRT_r));
36
37 m_h_TRT_xy = new TH2D("h_TRT_xy", "xy", 100,-1100.,1100.,100, -1100., 1100.);
38 m_h_TRT_xy->StatOverflows();
39 ATH_CHECK(histSvc()->regHist( m_path+m_h_TRT_xy->GetName(), m_h_TRT_xy));
40
41 m_h_TRT_zr = new TH2D("h_TRT_zr", "zr", 100,-3000,3000,100,500.,1100.);
42 m_h_TRT_zr->StatOverflows();
43 ATH_CHECK(histSvc()->regHist( m_path+m_h_TRT_zr->GetName(), m_h_TRT_zr));
44
45 m_h_TRT_time_photons = new TH1D("h_TRT_time_photons", "hits_time_photons", 100,0,500);
46 m_h_TRT_time_photons->StatOverflows();
48
49 m_h_TRT_time_nonphotons = new TH1D("h_TRT_time_nonphotons", "hits_time_nonphotons", 100,0,500);
50 m_h_TRT_time_nonphotons->StatOverflows();
52
53 m_h_TRT_edep_photons = new TH1D("h_TRT_edep_photons", "hits_edep_photons", 100,0,500);
54 m_h_TRT_edep_photons->StatOverflows();
56
57 m_h_TRT_edep_nonphotons = new TH1D("TRT_edep_nonphotons", "hits_edep_nonphotons", 100,0,500);
58 m_h_TRT_edep_nonphotons->StatOverflows();
60
61 m_h_TRT_kine_photons = new TH1D("h_TRT_kine_photons", "hits_kine_photons", 100,0,2);
62 m_h_TRT_kine_photons->StatOverflows();
64
65 m_h_TRT_kine_nonphotons = new TH1D("h_TRT_kine_nonphotons", "hits_kine_nonphotons", 100,0,1000);
66 m_h_TRT_kine_nonphotons->StatOverflows();
68
69 m_h_TRT_barcode = new TH1D("h_TRT_barcode", "hits_barcode", 100,-500,300000);
70 m_h_TRT_barcode->StatOverflows();
71 ATH_CHECK(histSvc()->regHist(m_path + m_h_TRT_barcode->GetName(), m_h_TRT_barcode));
72
74 m_tree = new TTree("TRT","TRT");
75 std::string fullNtupleName = "/" + m_ntupleFileName + "/";
76 ATH_CHECK(histSvc()->regTree(fullNtupleName,m_tree));
77
78 m_tree->Branch("x", &m_TRT_x);
79 m_tree->Branch("y", &m_TRT_y);
80 m_tree->Branch("z", &m_TRT_z);
81 m_tree->Branch("r", &m_TRT_r);
82 m_tree->Branch("time_photons", &m_TRT_time_photons);
83 m_tree->Branch("time_nonphotons", &m_TRT_time_nonphotons);
84 m_tree->Branch("EnergyDeposit_photons", &m_TRT_edep_photons);
85 m_tree->Branch("EnergyDeposit_nonphotons", &m_TRT_edep_nonphotons);
86 m_tree->Branch("KineticEnergy_photons", &m_TRT_kine_photons);
87 m_tree->Branch("KineticEnergy_nonphotons", &m_TRT_kine_nonphotons);
88 m_tree->Branch("barcode", &m_TRT_barcode);
89
90 ATH_CHECK(detStore()->retrieve(m_detMgr,"TRT"));
91
92 return StatusCode::SUCCESS;
93}
94
95
97 ATH_MSG_DEBUG( "In TRTHitAnalysis::execute()" );
98
99 m_TRT_x->clear();
100 m_TRT_y->clear();
101 m_TRT_z->clear();
102 m_TRT_r->clear();
103 m_TRT_time_photons->clear();
104 m_TRT_time_nonphotons->clear();
105 m_TRT_edep_photons->clear();
106 m_TRT_edep_nonphotons->clear();
107 m_TRT_kine_photons->clear();
108 m_TRT_kine_nonphotons->clear();
109 m_TRT_barcode->clear();
110
111 const EventContext& ctx{Gaudi::Hive::currentContext()};
112 const TRTUncompressedHitCollection* p_collection{nullptr};
113 ATH_CHECK(SG::get(p_collection, m_readKey, ctx));
114 for (TRTUncompressedHitConstIter i_hit = p_collection->begin(); i_hit != p_collection->end(); ++i_hit) {
115 GeoTRTUncompressedHit ghit(*i_hit);
116 HepGeom::Point3D<double> p = ghit.getGlobalPosition(m_detMgr);
117
118 m_h_TRT_x->Fill(p.x());
119 m_h_TRT_y->Fill(p.y());
120 m_h_TRT_z->Fill(p.z());
121 m_h_TRT_r->Fill(p.perp());
122 m_h_TRT_xy->Fill(p.x(), p.y());
123 m_h_TRT_zr->Fill(p.z(),sqrt(pow(p.x(),2)+pow(p.y(),2)));
124 m_h_TRT_barcode->Fill(HepMC::barcode(i_hit->particleLink()));
125
126 m_TRT_x->push_back(p.x());
127 m_TRT_y->push_back(p.y());
128 m_TRT_z->push_back(p.z());
129 m_TRT_r->push_back(p.perp());
130 m_TRT_barcode->push_back(HepMC::barcode(i_hit->particleLink()));
131
132 int particleId(i_hit->GetParticleEncoding());
133 if(particleId == 22 || static_cast<int>(std::abs(particleId)/100000)==41 || static_cast<int>(std::abs(particleId)/10000000)==1) {
134 m_h_TRT_time_photons->Fill(i_hit->GetGlobalTime());
135 m_h_TRT_edep_photons->Fill(i_hit->GetEnergyDeposit());
136 m_h_TRT_kine_photons->Fill(i_hit->GetKineticEnergy());
137 m_TRT_time_photons->push_back(i_hit->GetGlobalTime());
138 m_TRT_edep_photons->push_back(i_hit->GetEnergyDeposit());
139 m_TRT_kine_photons->push_back(i_hit->GetKineticEnergy());
140 }
141 else {
142 m_h_TRT_time_nonphotons->Fill(i_hit->GetGlobalTime());
143 m_h_TRT_edep_nonphotons->Fill(i_hit->GetEnergyDeposit());
144 m_h_TRT_kine_nonphotons->Fill(i_hit->GetKineticEnergy());
145 m_TRT_time_nonphotons->push_back(i_hit->GetGlobalTime());
146 m_TRT_edep_nonphotons->push_back(i_hit->GetEnergyDeposit());
147 m_TRT_kine_nonphotons->push_back(i_hit->GetKineticEnergy());
148 }
149 } // End while hits
150
151 m_tree->Fill();
152
153 return StatusCode::SUCCESS;
154}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
AtlasHitsVector< TRTUncompressedHit > TRTUncompressedHitCollection
AtlasHitsVector< TRTUncompressedHit >::const_iterator TRTUncompressedHitConstIter
constexpr int pow(int base, int exp) noexcept
const ServiceHandle< StoreGateSvc > & detStore() const
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
const_iterator begin() const
const_iterator end() const
This adaptor class allows TRT_UncompressedHits to behave as if they knew which detector they were in.
HepGeom::Point3D< double > getGlobalPosition(const InDetDD::TRT_DetectorManager *mgr) const
std::vector< float > * m_TRT_time_photons
std::vector< float > * m_TRT_z
TH1 * m_h_TRT_kine_nonphotons
std::vector< float > * m_TRT_kine_photons
std::vector< float > * m_TRT_edep_photons
TH1 * m_h_TRT_kine_photons
std::vector< float > * m_TRT_edep_nonphotons
TH1 * m_h_TRT_time_nonphotons
virtual StatusCode initialize() override
TH1 * m_h_TRT_edep_nonphotons
Gaudi::Property< std::string > m_ntupleFileName
std::vector< float > * m_TRT_kine_nonphotons
std::vector< float > * m_TRT_x
std::vector< float > * m_TRT_y
Gaudi::Property< std::string > m_path
TH1 * m_h_TRT_time_photons
std::vector< float > * m_TRT_r
std::vector< float > * m_TRT_barcode
const InDetDD::TRT_DetectorManager * m_detMgr
std::vector< float > * m_TRT_time_nonphotons
virtual StatusCode execute() override
TH1 * m_h_TRT_y
Some variables.
SG::ReadHandleKey< TRTUncompressedHitCollection > m_readKey
TH1 * m_h_TRT_edep_photons
int barcode(const T *p)
Definition Barcode.h:16
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.