ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasTests
src
TrtHitsTestTool.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 "
TrtHitsTestTool.h
"
6
7
#include "
GeoAdaptors/GeoTRTUncompressedHit.h
"
8
#include "
InDetSimEvent/TRTUncompressedHitCollection.h
"
9
#include "
TRT_ReadoutGeometry/TRT_DetectorManager.h
"
10
#include <TH1D.h>
11
#include <TH2D.h>
12
13
14
TrtHitsTestTool::TrtHitsTestTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent)
15
:
SimTestToolBase
(
type
, name, parent),
16
m_collection
(
"TRTUncompressedHits"
),
17
m_indetBarrel
(0),
m_indetLongView
(0),
18
m_hits_time_photons
(0),
m_hits_edep_photons
(0),
19
m_hits_time_nonphotons
(0),
m_hits_edep_nonphotons
(0),
20
m_hits_xy
(0),
m_hits_zr
(0),
21
m_hits_edep_zr_photons
(0),
m_hits_edep_zr_nonphotons
(0),
22
m_hits_log_barcode
(0)
23
{
24
declareProperty(
"CollectionName"
,
m_collection
=
"TRTUncompressedHits"
);
25
}
26
27
StatusCode
TrtHitsTestTool::initialize
()
28
{
29
// initialise general (if not done yet)
30
m_path
+=
"InDet/"
;
31
_TH2D
(
m_indetBarrel
,
"idet_xy"
,100,-1200.,1200.,100,-1200.,1200.);
32
_SET_TITLE
(
m_indetBarrel
,
"indet hit distribution [All]"
,
"x [mm]"
,
"y [mm]"
);
33
_TH2D
(
m_indetLongView
,
"idet_zr"
,100,-3200.,3200.,100,0.,1200.);
34
_SET_TITLE
(
m_indetLongView
,
"indet hit distribution [All]"
,
"z [mm]"
,
"r [mm]"
);
35
36
if
(
m_collection
==
"TRTUncompressedHits"
)
m_path
+=
"TRT/"
;
37
else
if
(
m_collection
==
"PileupTRTUncompressedHits"
)
m_path
+=
"PileupTRT/"
;
38
else
{ std::cerr<<
"unsupported CollectionName for "
<< this->name()<<std::endl; }
39
40
_TH2D
(
m_hits_xy
,
"trt_xy"
,100,-1200.,1200.,100,-1200.,1200.);
41
_SET_TITLE
(
m_hits_xy
,
"hit distribution [All]"
,
"x [mm]"
,
"y [mm]"
);
42
_TH2D
(
m_hits_zr
,
"trt_zr"
,100,-3200.,3200.,100,0.,1200.);
43
_SET_TITLE
(
m_hits_zr
,
"hit distribution [All]"
,
"z [mm]"
,
"r [mm]"
);
44
_TH1D
(
m_hits_time_photons
,
"trt_edep_time_photons"
,100,0,25);
45
_SET_TITLE
(
m_hits_time_photons
,
"energy weighted hit distribution [Photons]"
,
"t [ns]"
,
"dE/dt"
);
46
_TH1D
(
m_hits_edep_photons
,
"trt_edep_photons"
,100,0.,40.);
47
_SET_TITLE
(
m_hits_edep_photons
,
"TRT hit distribution [Photons]"
,
"edep [MeV]"
,
"dN/dE [1/MeV]"
);
48
_TH2D
(
m_hits_edep_zr_photons
,
"trt_edep_zr_photons"
,100,-3200.,3200.,100,0.,1200.);
49
_SET_TITLE
(
m_hits_edep_zr_photons
,
"TRT energy weighted indet hit distribution [Photons]"
,
"z [mm]"
,
"r [mm]"
);
50
_TH1D
(
m_hits_time_nonphotons
,
"trt_edep_time_nonphotons"
,100,0,25);
51
_SET_TITLE
(
m_hits_time_nonphotons
,
"energy weighted hit distribution [Non-Photons]"
,
"t [ns]"
,
"dE/dt"
);
52
_TH1D
(
m_hits_edep_nonphotons
,
"trt_edep_nonphotons"
,100,0.,5.);
53
_SET_TITLE
(
m_hits_edep_nonphotons
,
"TRT hit distribution [Non-Photons]"
,
"edep [MeV]"
,
"dN/dE [1/MeV]"
);
54
_TH2D
(
m_hits_edep_zr_nonphotons
,
"trt_edep_zr_nonphotons"
,100,-3200.,3200.,100,0.,1200.);
55
_SET_TITLE
(
m_hits_edep_zr_nonphotons
,
"TRT energy weighted indet hit distribution [Non-Photons]"
,
"z [mm]"
,
"r [mm]"
);
56
57
_TH1D
(
m_hits_log_barcode
,
"trt_log_barcode"
,50,0.,16.);
58
_SET_TITLE
(
m_hits_log_barcode
,
"log(barcode)"
,
"log(barcode)"
,
"dN/dlog(barcode)"
);
59
60
ATH_CHECK
(detStore()->retrieve(
m_detMgr
,
"TRT"
));
61
62
return
StatusCode::SUCCESS;
63
}
64
65
66
StatusCode
TrtHitsTestTool::processEvent
() {
67
68
const
TRTUncompressedHitCollection
* p_collection =
nullptr
;
69
if
(evtStore()->retrieve(p_collection,
m_collection
).isSuccess()) {
70
for
(
const
TRTUncompressedHit
&
hit
: *p_collection) {
71
GeoTRTUncompressedHit
ghit(
hit
);
72
HepGeom::Point3D<double> u = ghit.
getGlobalPosition
(
m_detMgr
);
73
m_indetBarrel
->Fill(u.x(),u.y());
74
m_indetLongView
->Fill(u.z(),u.perp());
75
m_hits_xy
->Fill(u.x(),u.y());
76
m_hits_zr
->Fill(u.z(),u.perp());
77
int
barcode =
HepMC::barcode
(
hit
.particleLink());
// FIXME barcode-based
78
m_hits_log_barcode
->Fill( barcode > 0 ? log(barcode) : -1);
79
int
particleId(
hit
.GetParticleEncoding());
80
if
(particleId == 22 ||
static_cast<
int
>
(abs(particleId)/100000) == 41 ||
static_cast<
int
>
(abs(particleId)/10000000) == 1)
81
{
82
//criteria set to match TRT_HitCollectionCnv_p3.cxx
83
//only photon energy is persistified properly.
84
m_hits_time_photons
->Fill(
hit
.GetGlobalTime(),
hit
.GetEnergyDeposit());
85
m_hits_edep_photons
->Fill(
hit
.GetEnergyDeposit());
86
m_hits_edep_zr_photons
->Fill(u.z(),u.perp(),
hit
.GetEnergyDeposit());
87
}
88
else
89
{
90
m_hits_time_nonphotons
->Fill(
hit
.GetGlobalTime(),
hit
.GetEnergyDeposit());
91
m_hits_edep_nonphotons
->Fill(
hit
.GetEnergyDeposit());
92
m_hits_edep_zr_nonphotons
->Fill(u.z(),u.perp(),
hit
.GetEnergyDeposit());
93
}
94
}
95
}
96
else
{
97
ATH_MSG_WARNING
(
"TRT Hit collection not found!"
);
98
}
99
100
return
StatusCode::SUCCESS;
101
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
GeoTRTUncompressedHit.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
_TH2D
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition
SimTestHisto.h:91
_TH1D
#define _TH1D(var, name, nbin, xmin, xmax)
Definition
SimTestHisto.h:52
_SET_TITLE
#define _SET_TITLE(var, title, xaxis, yaxis)
Definition
SimTestHisto.h:107
TRTUncompressedHitCollection.h
TRTUncompressedHitCollection
AtlasHitsVector< TRTUncompressedHit > TRTUncompressedHitCollection
Definition
TRTUncompressedHitCollection.h:16
TRT_DetectorManager.h
TrtHitsTestTool.h
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
SimTestHisto::m_path
std::string m_path
Definition
SimTestHisto.h:34
SimTestToolBase::SimTestToolBase
SimTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
SimTestToolBase.cxx:11
TRTUncompressedHit
Definition
TRTUncompressedHit.h:11
TrtHitsTestTool::m_hits_time_photons
TH1 * m_hits_time_photons
Definition
TrtHitsTestTool.h:29
TrtHitsTestTool::TrtHitsTestTool
TrtHitsTestTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
TrtHitsTestTool.cxx:14
TrtHitsTestTool::m_detMgr
const InDetDD::TRT_DetectorManager * m_detMgr
Definition
TrtHitsTestTool.h:34
TrtHitsTestTool::processEvent
StatusCode processEvent()
Definition
TrtHitsTestTool.cxx:66
TrtHitsTestTool::m_hits_log_barcode
TH1 * m_hits_log_barcode
Definition
TrtHitsTestTool.h:33
TrtHitsTestTool::m_collection
std::string m_collection
Definition
TrtHitsTestTool.h:25
TrtHitsTestTool::m_hits_edep_photons
TH1 * m_hits_edep_photons
Definition
TrtHitsTestTool.h:29
TrtHitsTestTool::m_hits_edep_nonphotons
TH1 * m_hits_edep_nonphotons
Definition
TrtHitsTestTool.h:30
TrtHitsTestTool::m_hits_edep_zr_photons
TH2 * m_hits_edep_zr_photons
Definition
TrtHitsTestTool.h:32
TrtHitsTestTool::m_indetBarrel
TH2 * m_indetBarrel
Definition
TrtHitsTestTool.h:27
TrtHitsTestTool::m_hits_time_nonphotons
TH1 * m_hits_time_nonphotons
Definition
TrtHitsTestTool.h:30
TrtHitsTestTool::m_indetLongView
TH2 * m_indetLongView
Definition
TrtHitsTestTool.h:27
TrtHitsTestTool::m_hits_xy
TH2 * m_hits_xy
Definition
TrtHitsTestTool.h:31
TrtHitsTestTool::m_hits_zr
TH2 * m_hits_zr
Definition
TrtHitsTestTool.h:31
TrtHitsTestTool::m_hits_edep_zr_nonphotons
TH2 * m_hits_edep_zr_nonphotons
Definition
TrtHitsTestTool.h:32
TrtHitsTestTool::initialize
StatusCode initialize()
Definition
TrtHitsTestTool.cxx:27
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
type
Generated on
for ATLAS Offline Software by
1.17.0