ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
HeavyIonPhys
HIClusterGeoWeights
src
HIClusterGeo_HistoFiller.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 "
HIClusterGeoWeights/HIClusterGeo_HistoFiller.h
"
6
7
HIClusterGeo_HistoFiller::HIClusterGeo_HistoFiller
(
const
std::string& name, ISvcLocator* pSvcLocator) :
8
AthAlgorithm
(name, pSvcLocator),
m_etaPhiMapping
(nullptr)
9
{
10
}
11
12
TH1 *
HIClusterGeo_HistoFiller::regAndGetTHF
(
const
std::string& histName,
const
std::string& histTitle,
int
numBinsX,
double
xMin,
double
xMax,
int
numBinsY,
double
yMin,
double
yMax)
13
{
14
auto
hist = std::make_unique<TH2F>(histName.c_str(), histTitle.c_str(), numBinsX, xMin, xMax, numBinsY, yMin, yMax);
15
if
(
m_thistSvc
->regHist(
"/"
+
m_histStream
+
"/"
+ histName, std::unique_ptr<TH1>(std::move(hist))).isFailure())
16
{
17
return
nullptr
;
18
}
19
20
TH1 * tmpHist =
nullptr
;
21
if
(
m_thistSvc
->getHist(
"/"
+
m_histStream
+
"/"
+ histName, tmpHist).isFailure())
22
{
23
return
nullptr
;
24
}
25
26
return
static_cast<
TH1*
>
(tmpHist);
27
}
28
29
StatusCode
HIClusterGeo_HistoFiller::initialize
()
30
{
31
ATH_CHECK
(
m_eventInfoKey
.initialize() );
32
ATH_CHECK
(
m_vertexContainerKey
.initialize() );
33
ATH_CHECK
(
m_caloClusterContainerKey
.initialize() );
34
ATH_CHECK
(
m_hiEventShapeKey
.initialize() );
35
36
ATH_CHECK
(
m_thistSvc
.retrieve() );
37
38
m_histTileWeights
.clear();
39
40
m_etaPhiMapping
=
static_cast<
TH2F*
>
(
regAndGetTHF
(
"h_etaPhiMapping"
,
";eta;phi"
,
m_etaBins
, -5, 5,
m_phiBins
, -TMath::Pi(), TMath::Pi()));
41
if
(
m_etaPhiMapping
==
nullptr
)
42
{
43
return
StatusCode::FAILURE;
44
}
45
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode
HIClusterGeo_HistoFiller::execute
(
const
EventContext& ctx)
50
{
51
52
SG::ReadHandle<xAOD::EventInfo>
eventInfo{
m_eventInfoKey
, ctx};
53
if
(!eventInfo.
isValid
())
54
{
55
ATH_MSG_WARNING
(
"Cannot get EventInfo with key "
<<
m_eventInfoKey
.key());
56
return
StatusCode::SUCCESS;
57
}
58
59
if
((eventInfo->errorState(
xAOD::EventInfo::LAr
) ==
xAOD::EventInfo::Error
) ||
60
(eventInfo->errorState(
xAOD::EventInfo::Tile
) ==
xAOD::EventInfo::Error
) ||
61
(eventInfo->isEventFlagBitSet(
xAOD::EventInfo::Core
, 18)) )
62
{
63
return
StatusCode::SUCCESS;
64
}
65
66
// GRL selection will be done later by "makeHIResponse",
67
// here, we just save everything into separate histograms for each LB
68
69
// trigger decision tool is not needed if we use CC and PC streams
70
71
SG::ReadHandle<xAOD::VertexContainer>
vertices{
m_vertexContainerKey
, ctx};
72
if
(!vertices.
isValid
())
73
{
74
ATH_MSG_WARNING
(
"Cannot get VertexContainer with key "
<<
m_vertexContainerKey
.key());
75
return
StatusCode::SUCCESS;
76
}
77
if
(vertices->size() <= 1)
78
{
79
// no vertex
80
return
StatusCode::SUCCESS;
81
}
82
83
SG::ReadHandle<xAOD::CaloClusterContainer>
caloClusters{
m_caloClusterContainerKey
, ctx};
84
if
(!caloClusters.
isValid
())
85
{
86
ATH_MSG_WARNING
(
"Cannot get CaloClusterContainer with key "
<<
m_caloClusterContainerKey
.key());
87
return
StatusCode::SUCCESS;
88
}
89
90
SG::ReadHandle<xAOD::HIEventShapeContainer>
hiEventShape{
m_hiEventShapeKey
, ctx};
91
if
(!hiEventShape.
isValid
())
92
{
93
ATH_MSG_WARNING
(
"Cannot get HIEventShapeContainer with key "
<<
m_hiEventShapeKey
.key());
94
return
StatusCode::SUCCESS;
95
}
96
97
int
currentLB = eventInfo->lumiBlock();
98
int
currentRun = eventInfo->runNumber();
99
100
if
(
auto
search
=
m_histTileWeights
.find(currentLB);
search
==
m_histTileWeights
.end())
101
{
102
// if m_histTileWeights does not already have histogram forthis LB, allocate a new TH2F
103
// bins in Y: sum FCalET, sum ClusterET, sum FCalET^2, sum ClusterET^2, sum FCalET*ClusterET, number of events
104
TH2F * newHistTileWeights =
static_cast<
TH2F*
>
(
regAndGetTHF
(Form(
"h_clusterET_fcalET_%d_%d"
,currentRun,currentLB),
";bin ID;sum FCalET/clusterET/FCalET^2/clusterET^2/FCalET*clusterET/n_{events}"
,
m_totalBins
, -0.5,
m_totalBins
-0.5, 6,0.5,6.5));
105
if
(newHistTileWeights ==
nullptr
)
106
{
107
ATH_MSG_WARNING
(
"Could not create histogram "
<<Form(
"h_clusterET_fcalET_%d_%d"
,currentRun,currentLB)<<
" that was supposed to be used for Run "
<<currentRun<<
" LB "
<<currentLB);
108
return
StatusCode::SUCCESS;
109
}
110
111
m_histTileWeights
[currentLB] = std::move(newHistTileWeights);
112
}
113
114
auto
currentHistTileWeights =
m_histTileWeights
.at(currentLB);
115
116
float
fcalEt = hiEventShape->at(5)->et()*1e-6;
117
if
(fcalEt<
m_minFCalET
||
m_maxFCalET
<fcalEt)
118
{
119
// remove in-time and out-of-time pile-up
120
return
StatusCode::SUCCESS;
121
}
122
123
for
(
const
auto
* cluster : *caloClusters)
124
{
125
float
eta
= cluster->eta();
126
float
phi
= cluster->phi();
127
int
binID =
m_etaPhiMapping
->FindBin(
eta
,
phi
);
128
float
ET = cluster->e() * 1e-3 / std::cosh(
eta
);
129
130
currentHistTileWeights->Fill(binID, 1, fcalEt);
131
currentHistTileWeights->Fill(binID, 2, ET);
132
currentHistTileWeights->Fill(binID, 3, fcalEt*fcalEt);
133
currentHistTileWeights->Fill(binID, 4, ET*ET);
134
currentHistTileWeights->Fill(binID, 5, fcalEt*ET);
135
currentHistTileWeights->Fill(binID, 6, 1.);
136
}
137
138
return
StatusCode::SUCCESS;
139
}
140
141
StatusCode
HIClusterGeo_HistoFiller::finalize
()
142
{
143
return
StatusCode::SUCCESS;
144
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
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
HIClusterGeo_HistoFiller.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
HIClusterGeo_HistoFiller::m_vertexContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
Definition
HIClusterGeo_HistoFiller.h:43
HIClusterGeo_HistoFiller::HIClusterGeo_HistoFiller
HIClusterGeo_HistoFiller(const std::string &name, ISvcLocator *pSvcLocator)
Definition
HIClusterGeo_HistoFiller.cxx:7
HIClusterGeo_HistoFiller::initialize
virtual StatusCode initialize() override
Definition
HIClusterGeo_HistoFiller.cxx:29
HIClusterGeo_HistoFiller::m_hiEventShapeKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_hiEventShapeKey
Definition
HIClusterGeo_HistoFiller.h:45
HIClusterGeo_HistoFiller::regAndGetTHF
TH1 * regAndGetTHF(const std::string &histName, const std::string &histTitle, int numBinsX, double xMin, double xMax, int numBinsY, double yMin, double yMax)
Definition
HIClusterGeo_HistoFiller.cxx:12
HIClusterGeo_HistoFiller::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition
HIClusterGeo_HistoFiller.h:37
HIClusterGeo_HistoFiller::m_histStream
Gaudi::Property< std::string > m_histStream
Definition
HIClusterGeo_HistoFiller.h:38
HIClusterGeo_HistoFiller::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
HIClusterGeo_HistoFiller.cxx:49
HIClusterGeo_HistoFiller::m_minFCalET
Gaudi::Property< float > m_minFCalET
Definition
HIClusterGeo_HistoFiller.h:39
HIClusterGeo_HistoFiller::m_phiBins
const int m_phiBins
Definition
HIClusterGeo_HistoFiller.h:48
HIClusterGeo_HistoFiller::m_etaBins
const int m_etaBins
Definition
HIClusterGeo_HistoFiller.h:48
HIClusterGeo_HistoFiller::finalize
virtual StatusCode finalize() override
Definition
HIClusterGeo_HistoFiller.cxx:141
HIClusterGeo_HistoFiller::m_maxFCalET
Gaudi::Property< float > m_maxFCalET
Definition
HIClusterGeo_HistoFiller.h:40
HIClusterGeo_HistoFiller::m_totalBins
const int m_totalBins
Definition
HIClusterGeo_HistoFiller.h:49
HIClusterGeo_HistoFiller::m_etaPhiMapping
TH2F * m_etaPhiMapping
Definition
HIClusterGeo_HistoFiller.h:50
HIClusterGeo_HistoFiller::m_caloClusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusterContainerKey
Definition
HIClusterGeo_HistoFiller.h:44
HIClusterGeo_HistoFiller::m_histTileWeights
std::unordered_map< int, TH2F * > m_histTileWeights
Definition
HIClusterGeo_HistoFiller.h:47
HIClusterGeo_HistoFiller::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
HIClusterGeo_HistoFiller.h:42
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::EventInfo_v1::Tile
@ Tile
The Tile calorimeter.
Definition
EventInfo_v1.h:336
xAOD::EventInfo_v1::Core
@ Core
Core flags describing the event.
Definition
EventInfo_v1.h:339
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition
EventInfo_v1.h:335
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition
EventInfo_v1.h:349
search
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
Definition
hcg.cxx:743
Generated on
for ATLAS Offline Software by
1.17.0