ATLAS Offline Software
Loading...
Searching...
No Matches
CaloNoise2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CaloNoise2Ntuple.h"
8#include "Identifier/Identifier.h"
11
12//Constructor
13CaloNoise2Ntuple::CaloNoise2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
14 AthAlgorithm(name,pSvcLocator)
15{
16}
17
18//__________________________________________________________________________
19//Destructor
20CaloNoise2Ntuple::~CaloNoise2Ntuple() = default;
21
22//__________________________________________________________________________
24{
25 ATH_MSG_DEBUG ("CaloNoise2Ntuple initialize()" );
26
27 ATH_CHECK( m_thistSvc.retrieve() );
28
29 const CaloIdManager* mgr = nullptr;
30 ATH_CHECK( detStore()->retrieve( mgr ) );
31 m_calo_id = mgr->getCaloCell_ID();
32
33 ATH_CHECK( m_totalNoiseKey.initialize() );
34 ATH_CHECK( m_elecNoiseKey.initialize() );
35 ATH_CHECK( m_pileupNoiseKey.initialize() );
36 ATH_CHECK( m_caloMgrKey.initialize() );
37
38 m_tree = new TTree(m_treeName.value().c_str(),"Calo Noise ntuple");
39 m_tree->Branch("iCool",&m_iCool,"iCool/I");
40 m_tree->Branch("iSubHash",&m_SubHash,"iSubHash/I");
41 m_tree->Branch("iHash",&m_Hash,"iHash/I");
42 m_tree->Branch("iOffId",&m_OffId,"iOffId/I");
43 m_tree->Branch("eta",&m_eta,"eta/F");
44 m_tree->Branch("phi",&m_phi,"phi/F");
45 m_tree->Branch("layer",&m_layer,"layer/I");
46 m_tree->Branch("iGain",&m_Gain,"iGain/I");
47 m_tree->Branch("Noise",&m_noise,"Noise/F");
48 m_tree->Branch("ElecNoise",&m_elecNoise,"ElecNoise/F");
49 m_tree->Branch("PileupNoise",&m_pileupNoise,"PileupNoise/F");
50 ATH_CHECK( m_thistSvc->regTree((std::string("/file1/calonoise/")+m_treeName).c_str(),m_tree));
51
52 ATH_MSG_INFO ( " end of CaloNoise2Ntuple::initialize " );
53 return StatusCode::SUCCESS;
54
55}
56//__________________________________________________________________________
58{
59 ATH_MSG_DEBUG ("CaloNoise2Ntuple execute()" );
60
61 const xAOD::EventInfo* eventInfo = nullptr;
62 if (evtStore()->retrieve(eventInfo).isFailure()) {
63 ATH_MSG_WARNING ( " Cannot access to event info " );
64 return StatusCode::SUCCESS;
65 }
66 m_lumiBlock = eventInfo->lumiBlock();
67 m_runNumber = eventInfo->runNumber();
68
69 return StatusCode::SUCCESS;
70}
71
72//__________________________________________________________________________
74{
75 ATH_MSG_INFO ( " Run Number, lumiblock " << m_runNumber << " " << m_lumiBlock );
76
77 const EventContext& ctx = Gaudi::Hive::currentContext();
82 ATH_CHECK(caloMgrHandle.isValid());
83 const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
84
85 int ncell=m_calo_id->calo_cell_hash_max();
86 ATH_MSG_INFO ( " start loop over Calo cells " << ncell );
87 for (int i=0;i<ncell;i++) {
88 IdentifierHash idHash=i;
89 Identifier id=m_calo_id->cell_id(idHash);
90 const CaloDetDescrElement* calodde = calodetdescrmgr->get_element(id);
91 int subCalo;
92 IdentifierHash idSubHash = m_calo_id->subcalo_cell_hash (idHash, subCalo);
93
94 int iCool=-1;
95 if (m_calo_id->is_em(id)) { // EM calo
96 if (m_calo_id->is_em_barrel(id)) {
97 if (m_calo_id->pos_neg(id) > 0 )
98 iCool=2;
99 else
100 iCool=1;
101 }
102 if (m_calo_id->is_em_endcap(id)) {
103 if (m_calo_id->pos_neg(id) > 0 )
104 iCool=3;
105 else
106 iCool=0;
107 }
108
109 }
110 if (m_calo_id->is_hec(id)) { // HEC
111 iCool=16;
112 }
113 if (m_calo_id->is_fcal(id)) { // Fcal
114 iCool=32;
115 }
116 if (m_calo_id->is_tile(id)) { // Tile
117 iCool=48;
118 }
119 int ii = (int) (idSubHash);
120
121 m_iCool = iCool;
122 m_SubHash = ii;
123 m_Hash = i;
124 m_OffId = (int)(id.get_identifier32().get_compact());
125
126 m_eta = calodde->eta_raw();
127 m_phi = calodde->phi_raw();
128 m_layer = m_calo_id->calo_sample(id);
129
130 int ngain;
131 if (subCalo<3) ngain=3;
132 else ngain=4;
133
134 for (int igain=0;igain<ngain;igain++) {
135
137 if (subCalo<3) {
138 if (igain==0) gain=CaloGain::LARHIGHGAIN;
139 if (igain==1) gain=CaloGain::LARMEDIUMGAIN;
140 if (igain==2) gain=CaloGain::LARLOWGAIN;
141 }
142 else {
143 if (igain==0) gain=CaloGain::TILELOWLOW;
144 if (igain==1) gain=CaloGain::TILELOWHIGH;
145 if (igain==2) gain=CaloGain::TILEHIGHLOW;
146 if (igain==3) gain=CaloGain::TILEHIGHHIGH;
147 }
148 m_Gain = igain;
149
150 m_noise = totalNoise->getNoise(id,gain);
151 m_elecNoise = elecNoise->getNoise(id,gain);
152 m_pileupNoise = pileupNoise->getNoise(id,gain);
153
154 m_tree->Fill();
155
156 } // loop over gains
157
158 } // loop over cells
159
160 return StatusCode::SUCCESS;
161 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
This class initializes the Calo (LAr and Tile) offline identifiers.
SG::ReadCondHandleKey< CaloNoise > m_pileupNoiseKey
virtual StatusCode execute() override
standard Athena-Algorithm method
const CaloCell_ID * m_calo_id
Gaudi::Property< std::string > m_treeName
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
virtual StatusCode stop() override
standard Athena-Algorithm method
ServiceHandle< ITHistSvc > m_thistSvc
virtual StatusCode initialize() override
standard Athena-Algorithm method
SG::ReadCondHandleKey< CaloNoise > m_elecNoiseKey
CaloNoise2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
This is a "hash" representation of an Identifier.
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t runNumber() const
The current event's run number.
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ TILELOWLOW
Definition CaloGain.h:12
@ LARLOWGAIN
Definition CaloGain.h:18
@ TILELOWHIGH
Definition CaloGain.h:13
@ TILEHIGHLOW
Definition CaloGain.h:14
@ TILEHIGHHIGH
Definition CaloGain.h:15
@ LARHIGHGAIN
Definition CaloGain.h:18
EventInfo_v1 EventInfo
Definition of the latest event info version.