ATLAS Offline Software
Loading...
Searching...
No Matches
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
12CaloCellPosition2Ntuple::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( m_thistSvc.retrieve() );
31
32 ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
33
34 ATH_CHECK( m_caloMgrKey.initialize() );
35 ATH_CHECK( m_cellPosKey.initialize() );
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;
66 m_calo_id->calo_cell_hash_range(CaloCell_ID::LAREM,emmin,emmax);
67 m_calo_id->calo_cell_hash_range(CaloCell_ID::LARFCAL,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();
95 m_layer = m_calo_id->calo_sample(id);
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
CaloCellPosition2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
virtual StatusCode finalize() override
standard Athena-Algorithm method
ServiceHandle< ITHistSvc > m_thistSvc
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode execute() override
standard Athena-Algorithm method
virtual StatusCode initialize() override
standard Athena-Algorithm method
virtual StatusCode stop() override
standard Athena-Algorithm method
SG::ReadCondHandleKey< CaloRec::CaloCellPositionShift > m_cellPosKey
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...
Container for a cell-level rescaling-factors, typically obtained by Z->ee intercalibration.
This is a "hash" representation of an Identifier.