ATLAS Offline Software
CaloNoise2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CaloNoise2Ntuple.h"
7 #include "CaloEvent/CaloCell.h"
8 #include "Identifier/Identifier.h"
11 
12 //Constructor
13 CaloNoise2Ntuple::CaloNoise2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
14  AthAlgorithm(name,pSvcLocator),
15  m_thistSvc(nullptr),
16  m_calo_id(nullptr),
17  m_iCool(0),
18  m_SubHash(0),
19  m_Hash(0),
20  m_OffId(0),
21  m_eta(0),
22  m_phi(0),
23  m_layer(0),
24  m_Gain(0),
25  m_noise(0),
26  m_elecNoise(0),
27  m_pileupNoise(0),
28  m_tree(nullptr),
29  m_runNumber(0),
30  m_lumiBlock(0)
31 {
32  declareProperty("TreeName",m_treeName="mytree");
33 }
34 
35 //__________________________________________________________________________
36 //Destructor
38 {
39  ATH_MSG_DEBUG ( "CaloNoise2Ntuple destructor called" );
40 }
41 //__________________________________________________________________________
43 {
44  ATH_MSG_DEBUG ("CaloNoise2Ntuple initialize()" );
45 
46  ATH_CHECK( service("THistSvc",m_thistSvc) );
47 
48  const CaloIdManager* mgr = nullptr;
49  ATH_CHECK( detStore()->retrieve( mgr ) );
50  m_calo_id = mgr->getCaloCell_ID();
51 
56 
57  m_tree = new TTree(m_treeName.c_str(),"Calo Noise ntuple");
58  m_tree->Branch("iCool",&m_iCool,"iCool/I");
59  m_tree->Branch("iSubHash",&m_SubHash,"iSubHash/I");
60  m_tree->Branch("iHash",&m_Hash,"iHash/I");
61  m_tree->Branch("iOffId",&m_OffId,"iOffId/I");
62  m_tree->Branch("eta",&m_eta,"eta/F");
63  m_tree->Branch("phi",&m_phi,"phi/F");
64  m_tree->Branch("layer",&m_layer,"layer/I");
65  m_tree->Branch("iGain",&m_Gain,"iGain/I");
66  m_tree->Branch("Noise",&m_noise,"Noise/F");
67  m_tree->Branch("ElecNoise",&m_elecNoise,"ElecNoise/F");
68  m_tree->Branch("PileupNoise",&m_pileupNoise,"PileupNoise/F");
69  ATH_CHECK( m_thistSvc->regTree((std::string("/file1/calonoise/")+m_treeName).c_str(),m_tree));
70 
71  ATH_MSG_INFO ( " end of CaloNoise2Ntuple::initialize " );
72  return StatusCode::SUCCESS;
73 
74 }
75 //__________________________________________________________________________
77 {
78  ATH_MSG_DEBUG ("CaloNoise2Ntuple 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 EventContext& ctx = Gaudi::Hive::currentContext();
101  ATH_CHECK(caloMgrHandle.isValid());
102  const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
103 
105  ATH_MSG_INFO ( " start loop over Calo cells " << ncell );
106  for (int i=0;i<ncell;i++) {
107  IdentifierHash idHash=i;
108  Identifier id=m_calo_id->cell_id(idHash);
109  const CaloDetDescrElement* calodde = calodetdescrmgr->get_element(id);
110  int subCalo;
111  IdentifierHash idSubHash = m_calo_id->subcalo_cell_hash (idHash, subCalo);
112 
113  int iCool=-1;
114  if (m_calo_id->is_em(id)) { // EM calo
115  if (m_calo_id->is_em_barrel(id)) {
116  if (m_calo_id->pos_neg(id) > 0 )
117  iCool=2;
118  else
119  iCool=1;
120  }
121  if (m_calo_id->is_em_endcap(id)) {
122  if (m_calo_id->pos_neg(id) > 0 )
123  iCool=3;
124  else
125  iCool=0;
126  }
127 
128  }
129  if (m_calo_id->is_hec(id)) { // HEC
130  iCool=16;
131  }
132  if (m_calo_id->is_fcal(id)) { // Fcal
133  iCool=32;
134  }
135  if (m_calo_id->is_tile(id)) { // Tile
136  iCool=48;
137  }
138  int ii = (int) (idSubHash);
139 
140  m_iCool = iCool;
141  m_SubHash = ii;
142  m_Hash = i;
143  m_OffId = (int)(id.get_identifier32().get_compact());
144 
145  m_eta = calodde->eta_raw();
146  m_phi = calodde->phi_raw();
148 
149  int ngain;
150  if (subCalo<3) ngain=3;
151  else ngain=4;
152 
153  for (int igain=0;igain<ngain;igain++) {
154 
156  if (subCalo<3) {
160  }
161  else {
166  }
167  m_Gain = igain;
168 
169  m_noise = totalNoise->getNoise(id,gain);
170  m_elecNoise = elecNoise->getNoise(id,gain);
171  m_pileupNoise = pileupNoise->getNoise(id,gain);
172 
173  m_tree->Fill();
174 
175  } // loop over gains
176 
177  } // loop over cells
178 
179  return StatusCode::SUCCESS;
180  }
181 
183 {
184  return StatusCode::SUCCESS;
185 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloNoise2Ntuple::m_iCool
int m_iCool
Definition: CaloNoise2Ntuple.h:66
CaloNoise2Ntuple::m_SubHash
int m_SubHash
Definition: CaloNoise2Ntuple.h:67
CaloNoise2Ntuple::m_elecNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_elecNoiseKey
Definition: CaloNoise2Ntuple.h:58
CaloNoise2Ntuple::m_phi
float m_phi
Definition: CaloNoise2Ntuple.h:71
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloNoise2Ntuple::m_lumiBlock
int m_lumiBlock
Definition: CaloNoise2Ntuple.h:80
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCell_Base_ID::is_em_endcap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
CaloCell_Base_ID::pos_neg
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
CaloNoise2Ntuple::m_noise
float m_noise
Definition: CaloNoise2Ntuple.h:74
CaloCell.h
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
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
CaloNoise2Ntuple.int
int
Definition: CaloNoise2Ntuple.py:29
CaloNoise::getNoise
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition: CaloNoise.h:34
CaloNoise2Ntuple::m_runNumber
int m_runNumber
Definition: CaloNoise2Ntuple.h:79
CaloGain::TILELOWLOW
@ TILELOWLOW
Definition: CaloGain.h:12
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.
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
CaloGain::TILEHIGHHIGH
@ TILEHIGHHIGH
Definition: CaloGain.h:15
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CaloNoise2Ntuple::m_totalNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
Definition: CaloNoise2Ntuple.h:56
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
CaloNoise2Ntuple::m_calo_id
const CaloCell_ID * m_calo_id
Definition: CaloNoise2Ntuple.h:53
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
CaloNoise2Ntuple::m_OffId
int m_OffId
Definition: CaloNoise2Ntuple.h:69
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
CaloNoise2Ntuple::m_layer
int m_layer
Definition: CaloNoise2Ntuple.h:72
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloNoise2Ntuple::execute
virtual StatusCode execute() override
standard Athena-Algorithm method
Definition: CaloNoise2Ntuple.cxx:76
CaloCell_Base_ID::subcalo_cell_hash
IdentifierHash subcalo_cell_hash(const Identifier cellId, int &subCalo) const
create hash id from 'global' cell id
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
CaloGain::TILEHIGHLOW
@ TILEHIGHLOW
Definition: CaloGain.h:14
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
AthAlgorithm
Definition: AthAlgorithm.h:47
CaloNoise2Ntuple::m_eta
float m_eta
Definition: CaloNoise2Ntuple.h:70
CaloNoise2Ntuple::m_treeName
std::string m_treeName
Definition: CaloNoise2Ntuple.h:64
CaloCell_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
ReadCellNoiseFromCool.ncell
ncell
Definition: ReadCellNoiseFromCool.py:197
CaloGain::TILELOWHIGH
@ TILELOWHIGH
Definition: CaloGain.h:13
CaloNoise2Ntuple::m_elecNoise
float m_elecNoise
Definition: CaloNoise2Ntuple.h:75
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloNoise.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloNoise2Ntuple::m_tree
TTree * m_tree
Definition: CaloNoise2Ntuple.h:77
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloNoise2Ntuple::m_Hash
int m_Hash
Definition: CaloNoise2Ntuple.h:68
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
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
CaloNoise2Ntuple::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: CaloNoise2Ntuple.cxx:42
CaloNoise2Ntuple::m_Gain
int m_Gain
Definition: CaloNoise2Ntuple.h:73
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloNoise2Ntuple::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: CaloNoise2Ntuple.cxx:182
CaloNoise2Ntuple::~CaloNoise2Ntuple
virtual ~CaloNoise2Ntuple()
Default Destructor.
Definition: CaloNoise2Ntuple.cxx:37
PlotCalibFromCool.ngain
ngain
Definition: PlotCalibFromCool.py:565
CaloNoise2Ntuple::m_pileupNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_pileupNoiseKey
Definition: CaloNoise2Ntuple.h:60
CaloNoise2Ntuple.h
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
IdentifierHash
Definition: IdentifierHash.h:38
CaloNoise2Ntuple::stop
virtual StatusCode stop() override
standard Athena-Algorithm method
Definition: CaloNoise2Ntuple.cxx:92
CaloGain.h
CaloNoise2Ntuple::m_thistSvc
ITHistSvc * m_thistSvc
Definition: CaloNoise2Ntuple.h:51
CaloNoise2Ntuple::m_pileupNoise
float m_pileupNoise
Definition: CaloNoise2Ntuple.h:76
CaloNoise2Ntuple::CaloNoise2Ntuple
CaloNoise2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: CaloNoise2Ntuple.cxx:13
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
CaloNoise2Ntuple::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: CaloNoise2Ntuple.h:62