ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellEnergyCorr2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "Identifier/Identifier.h"
12
13#include "CoolKernel/types.h"
14#include "CoolKernel/Record.h"
15#include "CoralBase/AttributeListSpecification.h"
16
17
18//Constructor
19CaloCellEnergyCorr2Ntuple::CaloCellEnergyCorr2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
20 AthAlgorithm(name,pSvcLocator),
21 m_calo_id(nullptr),
22 m_key("EnergyCorr"),
23 m_FolderName("/LAR/CellCorrOfl/EnergyCorr"),
24 m_Hash(0),
25 m_OffId(0),
26 m_eta(0),
27 m_phi(0),
28 m_layer(0),
29 m_detector(0),
30 m_corr(0),
31 m_tree(nullptr),
32 m_runNumber(0),
34{
35 declareProperty("InputKey",m_key,"Key for EnergyCorr");
36 declareProperty("FolderName",m_FolderName);
37}
38
39//__________________________________________________________________________
40//Destructor
42{
43 ATH_MSG_DEBUG ( "CaloCellEnergyCorr2Ntuple destructor called" );
44}
45//__________________________________________________________________________
46StatusCode CaloCellEnergyCorr2Ntuple::initialize()
47{
48 ATH_MSG_DEBUG ("CaloCellEnergyCorr2Ntuple initialize()" );
49
50 ATH_CHECK(m_thistSvc.retrieve());
51
52 const CaloIdManager* mgr = nullptr;
53 ATH_CHECK( detStore()->retrieve( mgr ) );
54 m_calo_id = mgr->getCaloCell_ID();
55
57
58 ATH_CHECK( detStore()->regHandle(m_AttrListColl,m_key) );
59
60 m_tree = new TTree("mytree","Calo Noise ntuple");
61 m_tree->Branch("iHash",&m_Hash,"iHash/I");
62 m_tree->Branch("iOffId",&m_OffId,"iOffId/I");
63 m_tree->Branch("eta",&m_eta,"eta/F");
64 m_tree->Branch("phi",&m_phi,"phi/F");
65 m_tree->Branch("layer",&m_layer,"layer/I");
66 m_tree->Branch("detector",&m_detector,"detector/I");
67 m_tree->Branch("ECorr",&m_corr,"ECorr/F");
68 ATH_CHECK( m_thistSvc->regTree("/file1/mytree",m_tree) );
69
70 ATH_MSG_INFO ( " end of CaloCellEnergyCorr2Ntuple::initialize " );
71 return StatusCode::SUCCESS;
72
73}
74//__________________________________________________________________________
76{
77 ATH_MSG_DEBUG ("CaloCellEnergyCorr2Ntuple execute()" );
78
79 const xAOD::EventInfo* eventInfo = nullptr;
80 if (evtStore()->retrieve(eventInfo).isFailure()) {
81 ATH_MSG_WARNING ( " Cannot access to event info " );
82 return StatusCode::SUCCESS;
83 }
84 m_lumiBlock = eventInfo->lumiBlock();
85 m_runNumber = eventInfo->runNumber();
86
87 return StatusCode::SUCCESS;
88}
89
90//__________________________________________________________________________
91StatusCode CaloCellEnergyCorr2Ntuple::stop()
92{
93 ATH_MSG_INFO ( " Run Number, lumiblock " << m_runNumber << " " << m_lumiBlock );
94
95 const coral::Blob& blob=(*m_AttrListColl)["CaloCondBlob16M"].data<coral::Blob>();
96 std::unique_ptr<const CaloCondBlobFlt> flt (CaloCondBlobFlt::getInstance(blob));
97
98 int nobj=flt->getNObjs();
99 int nchan=flt->getNChans();
100 ATH_MSG_INFO ( "NObjs: "<<nobj<<" nChans: "<<nchan<<" nGains: "<<flt->getNGains() );
101
103 ATH_CHECK(caloMgrHandle.isValid());
104 const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
105
106 int ncell=m_calo_id->calo_cell_hash_max();
107 ATH_MSG_INFO ( " start loop over Calo cells " << ncell );
108 for (int i=0;i<ncell;i++) {
109 IdentifierHash idHash=i;
110 Identifier id=m_calo_id->cell_id(idHash);
111 const CaloDetDescrElement* calodde = calodetdescrmgr->get_element(id);
112
113 m_Hash = i;
114 m_OffId = (int)(id.get_identifier32().get_compact());
115
116 m_eta = calodde->eta_raw();
117 m_phi = calodde->phi_raw();
118 m_layer = m_calo_id->calo_sample(id);
119 m_detector=-1;
120 if (m_calo_id->is_em(id)) {
121 if(m_calo_id->is_em_barrel(id)) {
122 m_detector=0;
123 } else if(m_calo_id->is_em_endcap_outer(id)) {
124 m_detector=1;
125 } else {
126 m_detector=2;
127 }
128 } else if (m_calo_id->is_hec(id)) {
129 m_detector = 3;
130 } else if (m_calo_id->is_fcal(id)) {
131 m_detector = 4;
132 }
133
134 if(m_Hash >= nchan) break;
135 m_corr = flt->getData(m_Hash,0,0);
136
137
138 m_tree->Fill();
139
140 } // loop over cells
141
142 return StatusCode::SUCCESS;
143 }
144
146{
147 return StatusCode::SUCCESS;
148}
#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:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode finalize() override
standard Athena-Algorithm method
~CaloCellEnergyCorr2Ntuple() ATLAS_CTORDTOR_NOT_THREAD_SAFE
Default Destructor.
CaloCellEnergyCorr2Ntuple(const std::string &name, ISvcLocator *pSvcLocator) ATLAS_CTORDTOR_NOT_THREAD_SAFE
Standard Athena-Algorithm Constructor.
const DataHandle< AthenaAttributeList > m_AttrListColl
virtual StatusCode execute() override
standard Athena-Algorithm method
ServiceHandle< ITHistSvc > m_thistSvc
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class initializes the Calo (LAr and Tile) offline identifiers.
StatusCode initialize(bool used=true)
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t runNumber() const
The current event's run number.
EventInfo_v1 EventInfo
Definition of the latest event info version.