ATLAS Offline Software
CaloCellPosition2Ntuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "CaloDetDescr/CaloDetDescrElement.h"
8 #include "Identifier/Identifier.h"
9 
10 
11 //Constructor
12 CaloCellPosition2Ntuple::CaloCellPosition2Ntuple(const std::string& name, ISvcLocator* pSvcLocator):
13  AthAlgorithm(name,pSvcLocator),
14  m_Hash(0),
15  m_OffId(0),
16  m_eta(0),
17  m_phi(0),
18  m_layer(0),
19  m_dx(0),
20  m_dy(0),
21  m_dz(0),
22  m_volume(0),
23  m_tree(nullptr)
24 {}
25 
26 //__________________________________________________________________________
28 {
29  ATH_MSG_DEBUG ("CaloCellPosition2Ntuple initialize()" );
30  ATH_CHECK( service("THistSvc",m_thistSvc) );
31 
32  ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
33 
36 
37  m_tree = new TTree("mytree","Calo Noise ntuple");
38  m_tree->Branch("iHash",&m_Hash,"iHash/I");
39  m_tree->Branch("iOffId",&m_OffId,"iOffId/I");
40  m_tree->Branch("eta",&m_eta,"eta/F");
41  m_tree->Branch("phi",&m_phi,"phi/F");
42  m_tree->Branch("layer",&m_layer,"layer/I");
43  m_tree->Branch("dx",&m_dx,"DeltaX/F");
44  m_tree->Branch("dy",&m_dy,"DeltaY/F");
45  m_tree->Branch("dz",&m_dz,"DeltaZ/F");
46  m_tree->Branch("volume",&m_volume,"volume/F");
47 
48  ATH_CHECK( m_thistSvc->regTree("/file1/cellpos/mytree",m_tree) );
49 
50  ATH_MSG_INFO ( " end of CaloCellPosition2Ntuple::initialize " );
51  return StatusCode::SUCCESS;
52 
53 }
54 
55 //__________________________________________________________________________
57 {
58  ATH_MSG_DEBUG ("CaloCellPosition2Ntuple execute()" );
59  return StatusCode::SUCCESS;
60 }
61 
62 //__________________________________________________________________________
64 {
65  IdentifierHash emmin,emmax,fcalmin,fcalmax;
68  int ncell=fcalmax-emmin;
69 
71  ATH_CHECK(caloMgrHandle.isValid());
72  const CaloDetDescrManager* calodetdescrmgr = *caloMgrHandle;
73 
75  ATH_CHECK(cellPosHdl.isValid());
76  const CaloRec::CaloCellPositionShift* cellPos= *cellPosHdl;
77 
78  int nread = (int)(cellPos->size());
79 
80  if (nread > ncell) {
81  ATH_MSG_WARNING ( " CaloCellPosition size different from max lar hash " << cellPos->size() << " " << ncell );
82  return StatusCode::SUCCESS;
83  }
84  ATH_MSG_INFO ( " start loop over Calo cells " << ncell );
85  for (int i=0;i<ncell;i++) {
86  IdentifierHash idHash=i;
87  Identifier id=m_calo_id->cell_id(idHash);
88  const CaloDetDescrElement* calodde = calodetdescrmgr->get_element(id);
89 
90  m_Hash = i;
91  m_OffId = (int)(id.get_identifier32().get_compact());
92 
93  m_eta = calodde->eta();
94  m_phi = calodde->phi();
96 
97  m_dx = cellPos->deltaX(i);
98  m_dy = cellPos->deltaY(i);
99  m_dz = cellPos->deltaZ(i);
100  m_volume = calodde->volume();
101 
102  m_tree->Fill();
103 
104  } // loop over cells
105 
106  return StatusCode::SUCCESS;
107  }
108 
110 {
111  return StatusCode::SUCCESS;
112 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
CaloCellPosition2Ntuple::m_OffId
int m_OffId
Definition: CaloCellPosition2Ntuple.h:55
CaloCellPosition2Ntuple::m_Hash
int m_Hash
Definition: CaloCellPosition2Ntuple.h:54
CaloCellPosition2Ntuple::m_layer
int m_layer
Definition: CaloCellPosition2Ntuple.h:58
CaloCellPosition2Ntuple::stop
virtual StatusCode stop() override
standard Athena-Algorithm method
Definition: CaloCellPosition2Ntuple.cxx:63
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
CaloCellPosition2Ntuple::m_cellPosKey
SG::ReadCondHandleKey< CaloRec::CaloCellPositionShift > m_cellPosKey
Definition: CaloCellPosition2Ntuple.h:49
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
CaloCellPosition2Ntuple::m_phi
float m_phi
Definition: CaloCellPosition2Ntuple.h:57
CaloCellPosition2Ntuple.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_ID.h
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
CaloCellPosition2Ntuple::m_volume
float m_volume
Definition: CaloCellPosition2Ntuple.h:62
CaloCellPosition2Ntuple::m_tree
TTree * m_tree
Definition: CaloCellPosition2Ntuple.h:63
CaloRec::CaloCellPositionShift
Container for a cell-level rescaling-factors, typically obtained by Z->ee intercalibration.
Definition: CaloCellPositionShift.h:31
CaloCellPosition2Ntuple::m_dz
float m_dz
Definition: CaloCellPosition2Ntuple.h:61
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCell_Base_ID::calo_cell_hash_range
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
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
CaloCellPosition2Ntuple::m_dy
float m_dy
Definition: CaloCellPosition2Ntuple.h:60
CaloCellPosition2Ntuple::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: CaloCellPosition2Ntuple.cxx:109
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCellPosition2Ntuple::m_calo_id
const CaloCell_ID * m_calo_id
Definition: CaloCellPosition2Ntuple.h:47
AthAlgorithm
Definition: AthAlgorithm.h:47
CaloCellPosition2Ntuple::m_eta
float m_eta
Definition: CaloCellPosition2Ntuple.h:56
ReadCellNoiseFromCool.ncell
ncell
Definition: ReadCellNoiseFromCool.py:197
WriteCellNoiseToCool.cellPos
cellPos
Definition: WriteCellNoiseToCool.py:400
CaloDetDescrElement::volume
float volume() const
cell volume
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:381
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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,...
CaloCellPosition2Ntuple::m_dx
float m_dx
Definition: CaloCellPosition2Ntuple.h:59
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
CaloCellPosition2Ntuple::CaloCellPosition2Ntuple
CaloCellPosition2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: CaloCellPosition2Ntuple.cxx:12
CaloCellPosition2Ntuple::m_thistSvc
ITHistSvc * m_thistSvc
Definition: CaloCellPosition2Ntuple.h:45
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
CaloCellPosition2Ntuple::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: CaloCellPosition2Ntuple.cxx:27
IdentifierHash
Definition: IdentifierHash.h:38
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
CaloCellPosition2Ntuple::execute
virtual StatusCode execute() override
standard Athena-Algorithm method
Definition: CaloCellPosition2Ntuple.cxx:56
CaloCellPosition2Ntuple::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: CaloCellPosition2Ntuple.h:51