ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
HeavyIonPhys
HIClusterGeoWeights
src
ExtractCaloGeoConstants.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
HIClusterGeoWeights/ExtractCaloGeoConstants.h
"
6
7
ExtractCaloGeoConstants::ExtractCaloGeoConstants
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthAlgorithm
(name, pSvcLocator)
8
{
9
}
10
11
StatusCode
ExtractCaloGeoConstants::initialize
()
12
{
13
ATH_CHECK
(
m_tower_container_key
.initialize());
14
ATH_CHECK
(
m_cell_container_key
.initialize());
15
16
CHECK
(
m_thistSvc
.retrieve() );
17
18
m_h3_w
=
new
TH3F(
"h3_w"
,
"; #it{#eta}; #it{phi}; Sampling"
,100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
19
m_h3_eta
=
new
TH3F(
"h3_eta"
,
"; #it{#eta}; #it{phi}; Sampling"
,100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
20
m_h3_phi
=
new
TH3F(
"h3_phi"
,
"; #it{#eta}; #it{phi}; Sampling"
,100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
21
m_h3_R
=
new
TH3F(
"h3_R"
,
"; #it{#eta}; #it{phi}; Sampling"
,100,-5,5,64,-TMath::Pi(),TMath::Pi(),24,-0.5,23.5);
22
m_h1_events
=
new
TH1F(
"h1_events"
,
"; Processed Events"
,1,0,1);
23
CHECK
(
m_thistSvc
->regHist(
"/"
+
m_hist_stream
+
"/"
+
m_h3_w
->GetName(),
m_h3_w
));
24
CHECK
(
m_thistSvc
->regHist(
"/"
+
m_hist_stream
+
"/"
+
m_h3_eta
->GetName(),
m_h3_eta
));
25
CHECK
(
m_thistSvc
->regHist(
"/"
+
m_hist_stream
+
"/"
+
m_h3_phi
->GetName(),
m_h3_phi
));
26
CHECK
(
m_thistSvc
->regHist(
"/"
+
m_hist_stream
+
"/"
+
m_h3_R
->GetName(),
m_h3_R
));
27
CHECK
(
m_thistSvc
->regHist(
"/"
+
m_hist_stream
+
"/"
+
m_h1_events
->GetName(),
m_h1_events
));
28
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
ExtractCaloGeoConstants::execute
(
const
EventContext& ctx)
33
{
34
// retrieve the tower container
35
SG::ReadHandle<CaloTowerContainer>
navInColl(
m_tower_container_key
, ctx);
36
if
(!navInColl.
isValid
()) {
37
ATH_MSG_ERROR
(
"Could not find CaloTowerContainer "
<<
m_tower_container_key
);
38
return
(StatusCode::FAILURE);
39
}
40
41
// retrieve cell container
42
SG::ReadHandle<CaloCellContainer>
cellColl(
m_cell_container_key
, ctx);
43
if
(!cellColl.
isValid
()) {
44
ATH_MSG_ERROR
(
"Could not find CaloCellContainer "
<<
m_cell_container_key
);
45
return
(StatusCode::FAILURE);
46
}
47
48
// record number of processed events
49
m_h1_events
->Fill(0.5);
50
51
// loop on towers
52
for
(
auto
towerItr : *navInColl)
53
{
54
// navigate back to cells
55
// Default is to sort the cells by either pointer values leading to irreproducible output
56
// CaloCellIDFcn ensures cells are ordered by their IDs
57
NavigationToken<CaloCell,double,CaloCellIDFcn>
cellToken;
58
towerItr->fillToken(cellToken,
double
(1.));
59
if
( cellToken.
size
() == 0 )
continue
;
60
for
(
NavigationToken<CaloCell,double,CaloCellIDFcn>::const_iterator
cellItr = cellToken.
begin
();
61
cellItr != cellToken.
end
(); ++cellItr )
62
{
63
double
geoWeight = cellToken.
getParameter
(*cellItr);
64
int
layer = (*cellItr)->caloDDE()->getSampling();
65
double
cell_x=(*cellItr)->caloDDE()->x();
66
double
cell_y=(*cellItr)->caloDDE()->y();
67
double
cell_z=(*cellItr)->caloDDE()->z();
68
double
cell_r2=cell_x*cell_x+cell_y*cell_y+cell_z*cell_z;
69
float
deta=(*cellItr)->caloDDE()->deta();
70
float
dphi=(*cellItr)->caloDDE()->dphi();
71
float
area
= std::abs(deta*dphi)*geoWeight;
72
m_h3_w
->Fill(towerItr->eta(),towerItr->phi(),layer,
area
);
73
m_h3_eta
->Fill(towerItr->eta(),towerItr->phi(),layer,
area
*(*cellItr)->eta());
74
m_h3_phi
->Fill(towerItr->eta(),towerItr->phi(),layer,
area
*(*cellItr)->phi());
75
m_h3_R
->Fill(towerItr->eta(),towerItr->phi(),layer,
area
*
area
*cell_r2);
76
77
}
//end cell loop
78
}
//end tower loop
79
return
StatusCode::SUCCESS;
80
}
81
82
StatusCode
ExtractCaloGeoConstants::finalize
()
83
{
84
return
StatusCode::SUCCESS;
85
}
86
87
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
area
double area(double R)
Definition
ConvertStaveServices.cxx:42
ExtractCaloGeoConstants.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
ExtractCaloGeoConstants::initialize
virtual StatusCode initialize()
Definition
ExtractCaloGeoConstants.cxx:11
ExtractCaloGeoConstants::m_h3_w
TH3F * m_h3_w
Definition
ExtractCaloGeoConstants.h:37
ExtractCaloGeoConstants::m_h3_R
TH3F * m_h3_R
Definition
ExtractCaloGeoConstants.h:40
ExtractCaloGeoConstants::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition
ExtractCaloGeoConstants.h:34
ExtractCaloGeoConstants::finalize
virtual StatusCode finalize()
Definition
ExtractCaloGeoConstants.cxx:82
ExtractCaloGeoConstants::m_tower_container_key
SG::ReadHandleKey< CaloTowerContainer > m_tower_container_key
Definition
ExtractCaloGeoConstants.h:31
ExtractCaloGeoConstants::m_hist_stream
Gaudi::Property< std::string > m_hist_stream
Definition
ExtractCaloGeoConstants.h:35
ExtractCaloGeoConstants::m_cell_container_key
SG::ReadHandleKey< CaloCellContainer > m_cell_container_key
Definition
ExtractCaloGeoConstants.h:32
ExtractCaloGeoConstants::ExtractCaloGeoConstants
ExtractCaloGeoConstants(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ExtractCaloGeoConstants.cxx:7
ExtractCaloGeoConstants::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
ExtractCaloGeoConstants.cxx:32
ExtractCaloGeoConstants::m_h1_events
TH1F * m_h1_events
Definition
ExtractCaloGeoConstants.h:41
ExtractCaloGeoConstants::m_h3_phi
TH3F * m_h3_phi
Definition
ExtractCaloGeoConstants.h:39
ExtractCaloGeoConstants::m_h3_eta
TH3F * m_h3_eta
Definition
ExtractCaloGeoConstants.h:38
NavigationToken
Definition
NavigationToken.h:50
NavigationToken::begin
const_iterator begin() const
Definition
NavigationToken.h:229
NavigationToken::getParameter
CHILDPAR getParameter(const_child_ptr data) const
NavigationToken::const_iterator
NavigationTokenIterator const_iterator
Definition
NavigationToken.h:153
NavigationToken::end
const_iterator end() const
Definition
NavigationToken.h:230
NavigationToken::size
unsigned int size()
Definition
NavigationToken.h:231
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Generated on
for ATLAS Offline Software by
1.17.0