ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellEnergyCorr2Ntuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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_Hash(0),
23 m_OffId(0),
24 m_eta(0),
25 m_phi(0),
26 m_layer(0),
27 m_detector(0),
28 m_corr(0),
29 m_tree(nullptr)
30{
31}
32
33//__________________________________________________________________________
34//Destructor
38//__________________________________________________________________________
40{
41 ATH_MSG_DEBUG ("CaloCellEnergyCorr2Ntuple initialize()" );
42
43 ATH_CHECK(m_thistSvc.retrieve());
44
45 const CaloIdManager* mgr = nullptr;
46 ATH_CHECK( detStore()->retrieve( mgr ) );
47 m_calo_id = mgr->getCaloCell_ID();
48
49 ATH_CHECK(m_caloMgrKey.initialize());
50 ATH_CHECK(m_attrListCollKey.initialize());
51
52 m_tree = new TTree("mytree","Calo Noise ntuple");
53 m_tree->Branch("iHash",&m_Hash,"iHash/I");
54 m_tree->Branch("iOffId",&m_OffId,"iOffId/I");
55 m_tree->Branch("eta",&m_eta,"eta/F");
56 m_tree->Branch("phi",&m_phi,"phi/F");
57 m_tree->Branch("layer",&m_layer,"layer/I");
58 m_tree->Branch("detector",&m_detector,"detector/I");
59 m_tree->Branch("ECorr",&m_corr,"ECorr/F");
60 ATH_CHECK( m_thistSvc->regTree("/file1/mytree",m_tree) );
61
62 ATH_MSG_INFO ( " end of CaloCellEnergyCorr2Ntuple::initialize " );
63 return StatusCode::SUCCESS;
64
65}
66//__________________________________________________________________________
68{
69 ATH_MSG_DEBUG ("CaloCellEnergyCorr2Ntuple execute()" );
70
71 return StatusCode::SUCCESS;
72}
73
74//__________________________________________________________________________
76{
78 const coral::Blob& blob=(**attrListColl)["CaloCondBlob16M"].data<coral::Blob>();
79 std::unique_ptr<const CaloCondBlobFlt> flt (CaloCondBlobFlt::getInstance(blob));
80
81 int nobj=flt->getNObjs();
82 int nchan=flt->getNChans();
83 ATH_MSG_INFO ( "NObjs: "<<nobj<<" nChans: "<<nchan<<" nGains: "<<flt->getNGains() );
84
86 ATH_CHECK(caloMgrHandle.isValid());
87 const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
88
89 int ncell=m_calo_id->calo_cell_hash_max();
90 ATH_MSG_INFO ( " start loop over Calo cells " << ncell );
91 for (int i=0;i<ncell;i++) {
92 IdentifierHash idHash=i;
93 Identifier id=m_calo_id->cell_id(idHash);
94 const CaloDetDescrElement* calodde = calodetdescrmgr->get_element(id);
95
96 m_Hash = i;
97 m_OffId = (int)(id.get_identifier32().get_compact());
98
99 m_eta = calodde->eta_raw();
100 m_phi = calodde->phi_raw();
101 m_layer = m_calo_id->calo_sample(id);
102 m_detector=-1;
103 if (m_calo_id->is_em(id)) {
104 if(m_calo_id->is_em_barrel(id)) {
105 m_detector=0;
106 } else if(m_calo_id->is_em_endcap_outer(id)) {
107 m_detector=1;
108 } else {
109 m_detector=2;
110 }
111 } else if (m_calo_id->is_hec(id)) {
112 m_detector = 3;
113 } else if (m_calo_id->is_fcal(id)) {
114 m_detector = 4;
115 }
116
117 if(m_Hash >= nchan) break;
118 m_corr = flt->getData(m_Hash,0,0);
119
120
121 m_tree->Fill();
122
123 } // loop over cells
124
125 return StatusCode::SUCCESS;
126 }
127
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
CaloCellEnergyCorr2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
SG::ReadCondHandleKey< AthenaAttributeList > m_attrListCollKey
virtual StatusCode stop() override
standard Athena-Algorithm method
~CaloCellEnergyCorr2Ntuple()
Default Destructor.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode initialize() override
standard Athena-Algorithm method
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.
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.
This is a "hash" representation of an Identifier.