ATLAS Offline Software
CaloCellEnergyCorr2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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_thistSvc(nullptr),
22  m_calo_id(nullptr),
23  m_key("EnergyCorr"),
24  m_FolderName("/LAR/CellCorrOfl/EnergyCorr"),
25  m_Hash(0),
26  m_OffId(0),
27  m_eta(0),
28  m_phi(0),
29  m_layer(0),
30  m_detector(0),
31  m_corr(0),
32  m_tree(nullptr),
33  m_runNumber(0),
34  m_lumiBlock(0)
35 {
36  declareProperty("InputKey",m_key,"Key for EnergyCorr");
37  declareProperty("FolderName",m_FolderName);
38 }
39 
40 //__________________________________________________________________________
41 //Destructor
43 {
44  ATH_MSG_DEBUG ( "CaloCellEnergyCorr2Ntuple destructor called" );
45 }
46 //__________________________________________________________________________
48 {
49  ATH_MSG_DEBUG ("CaloCellEnergyCorr2Ntuple initialize()" );
50 
51  ATH_CHECK( service("THistSvc",m_thistSvc) );
52 
53  const CaloIdManager* mgr = nullptr;
54  ATH_CHECK( detStore()->retrieve( mgr ) );
55  m_calo_id = mgr->getCaloCell_ID();
56 
58 
59  ATH_CHECK( detStore()->regHandle(m_AttrListColl,m_key) );
60 
61  m_tree = new TTree("mytree","Calo Noise ntuple");
62  m_tree->Branch("iHash",&m_Hash,"iHash/I");
63  m_tree->Branch("iOffId",&m_OffId,"iOffId/I");
64  m_tree->Branch("eta",&m_eta,"eta/F");
65  m_tree->Branch("phi",&m_phi,"phi/F");
66  m_tree->Branch("layer",&m_layer,"layer/I");
67  m_tree->Branch("detector",&m_detector,"detector/I");
68  m_tree->Branch("ECorr",&m_corr,"ECorr/F");
69  ATH_CHECK( m_thistSvc->regTree("/file1/mytree",m_tree) );
70 
71  ATH_MSG_INFO ( " end of CaloCellEnergyCorr2Ntuple::initialize " );
72  return StatusCode::SUCCESS;
73 
74 }
75 //__________________________________________________________________________
77 {
78  ATH_MSG_DEBUG ("CaloCellEnergyCorr2Ntuple execute()" );
79 
80  const xAOD::EventInfo* eventInfo = nullptr;
81  if (evtStore()->retrieve(eventInfo).isFailure()) {
82  ATH_MSG_WARNING ( " Cannot access to event info " );
83  return StatusCode::SUCCESS;
84  }
85  m_lumiBlock = eventInfo->lumiBlock();
86  m_runNumber = eventInfo->runNumber();
87 
88  return StatusCode::SUCCESS;
89 }
90 
91 //__________________________________________________________________________
93 {
94  ATH_MSG_INFO ( " Run Number, lumiblock " << m_runNumber << " " << m_lumiBlock );
95 
96  const coral::Blob& blob=(*m_AttrListColl)["CaloCondBlob16M"].data<coral::Blob>();
97  std::unique_ptr<const CaloCondBlobFlt> flt (CaloCondBlobFlt::getInstance(blob));
98 
99  int nobj=flt->getNObjs();
100  int nchan=flt->getNChans();
101  ATH_MSG_INFO ( "NObjs: "<<nobj<<" nChans: "<<nchan<<" nGains: "<<flt->getNGains() );
102 
104  ATH_CHECK(caloMgrHandle.isValid());
105  const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
106 
108  ATH_MSG_INFO ( " start loop over Calo cells " << ncell );
109  for (int i=0;i<ncell;i++) {
110  IdentifierHash idHash=i;
111  Identifier id=m_calo_id->cell_id(idHash);
112  const CaloDetDescrElement* calodde = calodetdescrmgr->get_element(id);
113 
114  m_Hash = i;
115  m_OffId = (int)(id.get_identifier32().get_compact());
116 
117  m_eta = calodde->eta_raw();
118  m_phi = calodde->phi_raw();
120  m_detector=-1;
121  if (m_calo_id->is_em(id)) {
122  if(m_calo_id->is_em_barrel(id)) {
123  m_detector=0;
124  } else if(m_calo_id->is_em_endcap_outer(id)) {
125  m_detector=1;
126  } else {
127  m_detector=2;
128  }
129  } else if (m_calo_id->is_hec(id)) {
130  m_detector = 3;
131  } else if (m_calo_id->is_fcal(id)) {
132  m_detector = 4;
133  }
134 
135  if(m_Hash >= nchan) break;
136  m_corr = flt->getData(m_Hash,0,0);
137 
138 
139  m_tree->Fill();
140 
141  } // loop over cells
142 
143  return StatusCode::SUCCESS;
144  }
145 
147 {
148  return StatusCode::SUCCESS;
149 }
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
CaloCellEnergyCorr2Ntuple::m_thistSvc
ITHistSvc * m_thistSvc
Definition: CaloCellEnergyCorr2Ntuple.h:56
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:42
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:92
CaloCell_Base_ID::is_fcal
bool is_fcal(const Identifier id) const
test if the id belongs to the FCAL - true also for MiniFCAL
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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:146
ReadCellNoiseFromCool.ncell
ncell
Definition: ReadCellNoiseFromCool.py:197
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
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:76
IdentifierHash
Definition: IdentifierHash.h:38
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