ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
Tools
HitAnalysis
src
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
8
#include "
GeoAdaptors/GeoTRTUncompressedHit.h
"
9
#include "
TRT_ReadoutGeometry/TRT_DetectorManager.h
"
10
#include "
StoreGate/ReadHandle.h
"
11
12
13
14
StatusCode
TRTHitAnalysis::initialize
() {
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();
47
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_TRT_time_photons
->GetName(),
m_h_TRT_time_photons
));
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();
51
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_TRT_time_nonphotons
->GetName(),
m_h_TRT_time_nonphotons
));
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();
55
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_TRT_edep_photons
->GetName(),
m_h_TRT_edep_photons
));
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();
59
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_TRT_edep_nonphotons
->GetName(),
m_h_TRT_edep_nonphotons
));
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();
63
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_TRT_kine_photons
->GetName(),
m_h_TRT_kine_photons
));
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();
67
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_TRT_kine_nonphotons
->GetName(),
m_h_TRT_kine_nonphotons
));
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
96
StatusCode
TRTHitAnalysis::execute
(
const
EventContext& ctx) {
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
TRTUncompressedHitCollection
* p_collection{
nullptr
};
112
ATH_CHECK
(
SG::get
(p_collection,
m_readKey
, ctx));
113
for
(
TRTUncompressedHitConstIter
i_hit = p_collection->
begin
(); i_hit != p_collection->
end
(); ++i_hit) {
114
GeoTRTUncompressedHit
ghit(*i_hit);
115
HepGeom::Point3D<double> p = ghit.
getGlobalPosition
(
m_detMgr
);
116
117
m_h_TRT_x
->Fill(p.x());
118
m_h_TRT_y
->Fill(p.y());
119
m_h_TRT_z
->Fill(p.z());
120
m_h_TRT_r
->Fill(p.perp());
121
m_h_TRT_xy
->Fill(p.x(), p.y());
122
m_h_TRT_zr
->Fill(p.z(),sqrt(pow(p.x(),2)+pow(p.y(),2)));
123
m_h_TRT_barcode
->Fill(
HepMC::barcode
(i_hit->particleLink()));
124
125
m_TRT_x
->push_back(p.x());
126
m_TRT_y
->push_back(p.y());
127
m_TRT_z
->push_back(p.z());
128
m_TRT_r
->push_back(p.perp());
129
m_TRT_barcode
->push_back(
HepMC::barcode
(i_hit->particleLink()));
130
131
int
particleId(i_hit->GetParticleEncoding());
132
if
(particleId == 22 ||
static_cast<
int
>
(std::abs(particleId)/100000)==41 ||
static_cast<
int
>
(std::abs(particleId)/10000000)==1) {
133
m_h_TRT_time_photons
->Fill(i_hit->GetGlobalTime());
134
m_h_TRT_edep_photons
->Fill(i_hit->GetEnergyDeposit());
135
m_h_TRT_kine_photons
->Fill(i_hit->GetKineticEnergy());
136
m_TRT_time_photons
->push_back(i_hit->GetGlobalTime());
137
m_TRT_edep_photons
->push_back(i_hit->GetEnergyDeposit());
138
m_TRT_kine_photons
->push_back(i_hit->GetKineticEnergy());
139
}
140
else
{
141
m_h_TRT_time_nonphotons
->Fill(i_hit->GetGlobalTime());
142
m_h_TRT_edep_nonphotons
->Fill(i_hit->GetEnergyDeposit());
143
m_h_TRT_kine_nonphotons
->Fill(i_hit->GetKineticEnergy());
144
m_TRT_time_nonphotons
->push_back(i_hit->GetGlobalTime());
145
m_TRT_edep_nonphotons
->push_back(i_hit->GetEnergyDeposit());
146
m_TRT_kine_nonphotons
->push_back(i_hit->GetKineticEnergy());
147
}
148
}
// End while hits
149
150
m_tree
->Fill();
151
152
return
StatusCode::SUCCESS;
153
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
GeoTRTUncompressedHit.h
ReadHandle.h
Handle class for reading from StoreGate.
TRTHitAnalysis.h
TRTUncompressedHitCollection
AtlasHitsVector< TRTUncompressedHit > TRTUncompressedHitCollection
Definition
TRTUncompressedHitCollection.h:16
TRTUncompressedHitConstIter
AtlasHitsVector< TRTUncompressedHit >::const_iterator TRTUncompressedHitConstIter
Definition
TRTUncompressedHitCollection.h:18
TRT_DetectorManager.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition
AthHistogramAlgorithm.h:113
AtlasHitsVector::begin
const_iterator begin() const
Definition
AtlasHitsVector.h:130
AtlasHitsVector::end
const_iterator end() const
Definition
AtlasHitsVector.h:133
GeoTRTUncompressedHit
This adaptor class allows TRT_UncompressedHits to behave as if they knew which detector they were in.
Definition
GeoTRTUncompressedHit.h:23
GeoTRTUncompressedHit::getGlobalPosition
HepGeom::Point3D< double > getGlobalPosition(const InDetDD::TRT_DetectorManager *mgr) const
TRTHitAnalysis::m_TRT_time_photons
std::vector< float > * m_TRT_time_photons
Definition
TRTHitAnalysis.h:45
TRTHitAnalysis::m_h_TRT_xy
TH2 * m_h_TRT_xy
Definition
TRTHitAnalysis.h:31
TRTHitAnalysis::m_TRT_z
std::vector< float > * m_TRT_z
Definition
TRTHitAnalysis.h:43
TRTHitAnalysis::m_h_TRT_kine_nonphotons
TH1 * m_h_TRT_kine_nonphotons
Definition
TRTHitAnalysis.h:38
TRTHitAnalysis::m_h_TRT_r
TH1 * m_h_TRT_r
Definition
TRTHitAnalysis.h:30
TRTHitAnalysis::m_TRT_kine_photons
std::vector< float > * m_TRT_kine_photons
Definition
TRTHitAnalysis.h:49
TRTHitAnalysis::m_TRT_edep_photons
std::vector< float > * m_TRT_edep_photons
Definition
TRTHitAnalysis.h:47
TRTHitAnalysis::m_h_TRT_kine_photons
TH1 * m_h_TRT_kine_photons
Definition
TRTHitAnalysis.h:37
TRTHitAnalysis::m_TRT_edep_nonphotons
std::vector< float > * m_TRT_edep_nonphotons
Definition
TRTHitAnalysis.h:48
TRTHitAnalysis::m_h_TRT_time_nonphotons
TH1 * m_h_TRT_time_nonphotons
Definition
TRTHitAnalysis.h:34
TRTHitAnalysis::initialize
virtual StatusCode initialize() override
Definition
TRTHitAnalysis.cxx:14
TRTHitAnalysis::m_tree
TTree * m_tree
Definition
TRTHitAnalysis.h:53
TRTHitAnalysis::m_h_TRT_edep_nonphotons
TH1 * m_h_TRT_edep_nonphotons
Definition
TRTHitAnalysis.h:36
TRTHitAnalysis::m_h_TRT_z
TH1 * m_h_TRT_z
Definition
TRTHitAnalysis.h:29
TRTHitAnalysis::m_ntupleFileName
Gaudi::Property< std::string > m_ntupleFileName
Definition
TRTHitAnalysis.h:56
TRTHitAnalysis::m_TRT_kine_nonphotons
std::vector< float > * m_TRT_kine_nonphotons
Definition
TRTHitAnalysis.h:50
TRTHitAnalysis::m_TRT_x
std::vector< float > * m_TRT_x
Definition
TRTHitAnalysis.h:41
TRTHitAnalysis::m_TRT_y
std::vector< float > * m_TRT_y
Definition
TRTHitAnalysis.h:42
TRTHitAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition
TRTHitAnalysis.h:55
TRTHitAnalysis::m_h_TRT_x
TH1 * m_h_TRT_x
Definition
TRTHitAnalysis.h:28
TRTHitAnalysis::m_h_TRT_time_photons
TH1 * m_h_TRT_time_photons
Definition
TRTHitAnalysis.h:33
TRTHitAnalysis::m_TRT_r
std::vector< float > * m_TRT_r
Definition
TRTHitAnalysis.h:44
TRTHitAnalysis::m_TRT_barcode
std::vector< float > * m_TRT_barcode
Definition
TRTHitAnalysis.h:51
TRTHitAnalysis::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
TRTHitAnalysis.cxx:96
TRTHitAnalysis::m_detMgr
const InDetDD::TRT_DetectorManager * m_detMgr
Definition
TRTHitAnalysis.h:58
TRTHitAnalysis::m_TRT_time_nonphotons
std::vector< float > * m_TRT_time_nonphotons
Definition
TRTHitAnalysis.h:46
TRTHitAnalysis::m_h_TRT_y
TH1 * m_h_TRT_y
Some variables.
Definition
TRTHitAnalysis.h:27
TRTHitAnalysis::m_readKey
SG::ReadHandleKey< TRTUncompressedHitCollection > m_readKey
Definition
TRTHitAnalysis.h:57
TRTHitAnalysis::m_h_TRT_barcode
TH1 * m_h_TRT_barcode
Definition
TRTHitAnalysis.h:39
TRTHitAnalysis::m_h_TRT_edep_photons
TH1 * m_h_TRT_edep_photons
Definition
TRTHitAnalysis.h:35
TRTHitAnalysis::m_h_TRT_zr
TH2 * m_h_TRT_zr
Definition
TRTHitAnalysis.h:32
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Generated on
for ATLAS Offline Software by
1.17.0