ATLAS Offline Software
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 
7 #include "CaloEvent/CaloCell.h"
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
19 CaloCellEnergyCorr2Ntuple::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),
33  m_lumiBlock(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 //__________________________________________________________________________
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 //__________________________________________________________________________
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 
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();
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloCellEnergyCorr2Ntuple::m_detector
int m_detector
Definition: CaloCellEnergyCorr2Ntuple.h:73
CaloCell_Base_ID::is_em_endcap_outer
bool is_em_endcap_outer(const Identifier id) const
test if the id belongs to the EM Endcap outer wheel
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloCellEnergyCorr2Ntuple::m_phi
float m_phi
Definition: CaloCellEnergyCorr2Ntuple.h:71
CaloCellEnergyCorr2Ntuple::m_calo_id
const CaloCell_ID * m_calo_id
Definition: CaloCellEnergyCorr2Ntuple.h:58
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
CaloCellEnergyCorr2Ntuple::CaloCellEnergyCorr2Ntuple
CaloCellEnergyCorr2Ntuple(const std::string &name, ISvcLocator *pSvcLocator) ATLAS_CTORDTOR_NOT_THREAD_SAFE
Standard Athena-Algorithm Constructor.
Definition: CaloCellEnergyCorr2Ntuple.cxx:19
CaloCell.h
PlotCalibFromCool.nchan
nchan
Definition: PlotCalibFromCool.py:564
CaloCellEnergyCorr2Ntuple::m_AttrListColl
const DataHandle< AthenaAttributeList > m_AttrListColl
Definition: CaloCellEnergyCorr2Ntuple.h:62
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
CaloCellEnergyCorr2Ntuple::m_eta
float m_eta
Definition: CaloCellEnergyCorr2Ntuple.h:70
CaloCell_Base_ID::calo_sample
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
Definition: CaloCell_Base_ID.cxx:141
CaloCellEnergyCorr2Ntuple::~CaloCellEnergyCorr2Ntuple
~CaloCellEnergyCorr2Ntuple() ATLAS_CTORDTOR_NOT_THREAD_SAFE
Default Destructor.
Definition: CaloCellEnergyCorr2Ntuple.cxx:41
AthenaAttributeList.h
CaloCell_Base_ID::is_hec
bool is_hec(const Identifier id) const
test if the id belongs to the HEC
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
CaloCellEnergyCorr2Ntuple::m_OffId
int m_OffId
Definition: CaloCellEnergyCorr2Ntuple.h:69
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CaloCellEnergyCorr2Ntuple::m_corr
float m_corr
Definition: CaloCellEnergyCorr2Ntuple.h:74
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
CaloCellEnergyCorr2Ntuple.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CaloCellEnergyCorr2Ntuple::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: CaloCellEnergyCorr2Ntuple.h:63
CaloCell_Base_ID::is_em
bool is_em(const Identifier id) const
test if the id belongs to LArEM
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCell_Base_ID::is_fcal
bool is_fcal(const Identifier id) const
test if the id belongs to the FCAL - true also for MiniFCAL
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CaloCellEnergyCorr2Ntuple::m_Hash
int m_Hash
Definition: CaloCellEnergyCorr2Ntuple.h:68
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCellEnergyCorr2Ntuple::m_runNumber
int m_runNumber
Definition: CaloCellEnergyCorr2Ntuple.h:77
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
AthAlgorithm
Definition: AthAlgorithm.h:47
CaloCellEnergyCorr2Ntuple::m_layer
int m_layer
Definition: CaloCellEnergyCorr2Ntuple.h:72
CaloCondBlobAlgs_fillNoiseFromASCII.flt
flt
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:97
CaloCellEnergyCorr2Ntuple::m_key
std::string m_key
Definition: CaloCellEnergyCorr2Ntuple.h:60
CaloCell_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
CaloCellEnergyCorr2Ntuple::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: CaloCellEnergyCorr2Ntuple.cxx:145
ReadCellNoiseFromCool.ncell
ncell
Definition: ReadCellNoiseFromCool.py:197
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloCellEnergyCorr2Ntuple::m_lumiBlock
int m_lumiBlock
Definition: CaloCellEnergyCorr2Ntuple.h:78
CaloCellEnergyCorr2Ntuple::m_FolderName
std::string m_FolderName
Definition: CaloCellEnergyCorr2Ntuple.h:61
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CaloCondBlobFlt.h
CaloCellEnergyCorr2Ntuple::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition: CaloCellEnergyCorr2Ntuple.h:56
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCondBlobFlt::getInstance
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
Definition: CaloCondBlobFlt.cxx:12
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCellEnergyCorr2Ntuple::execute
virtual StatusCode execute() override
standard Athena-Algorithm method
Definition: CaloCellEnergyCorr2Ntuple.cxx:75
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloGain.h
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
CaloCellEnergyCorr2Ntuple::m_tree
TTree * m_tree
Definition: CaloCellEnergyCorr2Ntuple.h:75
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
Identifier
Definition: IdentifierFieldParser.cxx:14