ATLAS Offline Software
Loading...
Searching...
No Matches
LArReadSC.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include "Identifier/Identifier.h"
11
12#include "CaloGeoHelpers/CaloSampling.h"
16#include "GaudiKernel/ITHistSvc.h"
17#include "GaudiKernel/ServiceHandle.h"
18
20
21
22
23LArReadSC::LArReadSC( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ){
24 m_ECell.reserve(35000);
25 m_EtaCell.reserve(35000);
26 m_PhiCell.reserve(35000);
27 m_LayerCell.reserve(35000);
28 m_ProvCell.reserve(35000);
29 m_ChidCell.reserve(35000);
30 m_HwidCell.reserve(35000);
31 m_ADC.reserve(35000);
32 m_TCell.reserve(35000);
33 m_ErecoCell.reserve(35000);
34}
35
36
38
39
41 ATH_MSG_INFO ("Initializing " << name() << "...");
42
43 ServiceHandle<ITHistSvc> histSvc("THistSvc",name());
44 CHECK( histSvc.retrieve() );
45 m_tree = new TTree("myTree","myTree");
46 std::string out("/"+m_outStream+"/myTree");
47 CHECK( histSvc->regTree(out.c_str(),m_tree) );
48 ATH_MSG_INFO("Registered tree: " << out);
49 m_tree->Branch("RunNumber",&m_runNumber,"RunNumber/I");
50 m_tree->Branch("LBNumber",&m_lbNumber,"LBNumber/I");
51 m_tree->Branch("EventNumber",&m_eventNumber,"EventNumber/I");
52 m_tree->Branch("BCID",&m_bcid,"BCID/I");
53 m_tree->Branch("LArError",&m_error,"LArError/I");
54 m_tree->Branch("ncells",&m_ncells,"ncells/I");
55 m_tree->Branch("ECell",m_ECell.data(),"eCell[ncells]/F");
56 m_tree->Branch("EtaCell",m_EtaCell.data(),"etaCell[ncells]/F");
57 m_tree->Branch("PhiCell",m_PhiCell.data(),"phiCell[ncells]/F");
58 m_tree->Branch("LayerCell",m_LayerCell.data(),"layerCell[ncells]/I");
59 m_tree->Branch("ProvCell", m_ProvCell.data(),"provCell[ncells]/I");
60 m_tree->Branch("ChidCell", m_ChidCell.data(),"chidCell[ncells]/I");
61 m_tree->Branch("HwidCell", m_HwidCell.data(),"hwidCell[ncells]/I");
62 if(m_contKey.key().size()) m_tree->Branch("ADC",m_ADC.data(),"ADC[ncells][32]/F");
63 if(m_SCRecoKey.key().size()) {
64 m_tree->Branch("TCell",m_TCell.data(),"tCell[ncells]/F");
65 m_tree->Branch("ErecoCell",m_ErecoCell.data(),"ErecoCell[ncells]/F");
66 }
67
68 const CaloIdManager* caloIdMgr = nullptr;
69 ATH_CHECK(detStore()->retrieve(caloIdMgr));
71 ATH_CHECK( detStore()->retrieve(m_lar_online_id, "LArOnline_SuperCellID") );
72
73 ATH_CHECK( m_cablingKey.initialize() );
74 ATH_CHECK(m_pedestalKey.initialize());
75 ATH_CHECK(m_caloMgrKey.initialize());
76
77 ATH_CHECK(m_contKey.initialize(m_contKey.key().size()));
78 ATH_CHECK(m_SCKey.initialize(m_SCKey.key().size()));
79 ATH_CHECK(m_SCRecoKey.initialize(m_SCRecoKey.key().size()));
80
81 ATH_MSG_INFO("Energy cut for time computation: " << m_etcut);
82
83 return StatusCode::SUCCESS;
84}
85
86StatusCode LArReadSC::finalize() {
87 ATH_MSG_INFO ("Finalizing " << name() << "...");
88
89 return StatusCode::SUCCESS;
90}
91
92StatusCode LArReadSC::execute(const EventContext& ctx) {
93 ATH_MSG_DEBUG ("Executing " << name() << "...");
94
96 const LArOnOffIdMapping* cabling=*cablingHdl;
97 if(!cabling) {
98 ATH_MSG_ERROR( "Do not have cabling object LArOnOffIdMapping" );
99 return StatusCode::FAILURE;
100 }
101
103 const CaloSuperCellDetDescrManager* caloDDMgr = *caloMgrHandle;
104
105 //Get Conditions input
107 const ILArPedestal* larPedestal=*pedHdl;
108
109
110 const xAOD::EventInfo* eventInfo = nullptr;
111 ATH_CHECK( evtStore()->retrieve( eventInfo) );
112
113 m_runNumber = eventInfo->runNumber();
114 m_eventNumber = eventInfo->eventNumber();
115 m_lbNumber = eventInfo->lumiBlock();
116 m_bcid = eventInfo->bcid();
117 m_error = 0;
119
120 std::vector<const LArDigit*> IndexDigit;
121 int nCell = m_calo_id->calo_cell_hash_max();
122 IndexDigit.resize(nCell,nullptr);
123
124 const LArDigitContainer* digit_container=nullptr;
125 if( m_contKey.key().size() ) { // fill from standard digits
127 if(!hdlDigit.isValid()) {
128 ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key " << m_contKey.key() << " from EventStore. " );
129 } else {
130 digit_container = hdlDigit.cptr();
131 }
132 }
133
134 if(digit_container) { // build digits index
135 LArDigitContainer::const_iterator first_digit = digit_container->begin();
136 LArDigitContainer::const_iterator end_digit = digit_container->end();
137 for (; first_digit != end_digit; ++first_digit) {
138 HWIdentifier hwid = (*first_digit)->hardwareID();
139 Identifier id = cabling->cnvToIdentifier(hwid);
140 int index = (int) (m_calo_id->calo_cell_hash(id));
141 if (index>=0 && index<nCell) IndexDigit[index]=(*first_digit);
142 }
143 }
144
145
147 if(!cells.isValid()){
148 ATH_MSG_ERROR("Could not get SC container with key "<<m_SCKey.key());
149 return StatusCode::FAILURE;
150 }
151 const CaloCellContainer* cell_container=cells.cptr();
152
153 const CaloCellContainer* recocell_container=nullptr;
154 if(m_SCRecoKey.key().size()){
156 if(recocells.isValid()) recocell_container=recocells.cptr();
157 }
158
159 std::vector<int> iflag_cell;
160 iflag_cell.resize(nCell,0);
161
162 CaloCellList myList(caloDDMgr, cell_container);
163
164 m_ncells=0;
165 for (CaloCellContainer::const_iterator cell = cell_container->begin();
166 cell != cell_container->end(); ++cell) {
167 Identifier cellID = (*cell)->ID();
168 int index = (int) (m_calo_id->calo_cell_hash(cellID));
169 double et = (*cell)->et();
170
171 if (et > m_etcut ){
172 iflag_cell[index]=1;
173
174
175 myList.select((*cell)->eta(),(*cell)->phi(),0.10);
176 for (const CaloCell* cell : myList) {
177 Identifier cellID2 =cell->ID();
178 int index2 = (int)(m_calo_id->calo_cell_hash(cellID2));
179 iflag_cell[index2]=1;
180 }
181 }// above first etcut
182 }// over cells
183
184 for (CaloCellContainer::const_iterator cell = cell_container->begin();
185 cell != cell_container->end(); ++cell) {
186
187 Identifier cellID = (*cell)->ID();
188 IdentifierHash hcell=m_calo_id->calo_cell_hash(cellID);
189 unsigned int index = hcell.value();
190
191 if (iflag_cell[index]==1 ){
192 m_ECell[m_ncells]= (*cell)->energy();
193 m_EtaCell[m_ncells]= (*cell)->eta();
194 m_PhiCell[m_ncells]= (*cell)->phi();
195 m_LayerCell[m_ncells]= m_calo_id->calo_sample(cellID);
196 m_ProvCell[m_ncells]=(*cell)->provenance();
197
198 HWIdentifier hwid=cabling->createSignalChannelID(cellID);
201
202 if(m_contKey.key().size()) { // fill samples
203 for (int i=0;i<32;i++) m_ADC[m_ncells][i]=0.;
204 float pedestal=0.;
205 if (larPedestal) {
206 pedestal = larPedestal->pedestal(hwid,(*cell)->gain());
207 }
208
209 unsigned int index = (m_calo_id->calo_cell_hash(cellID)).value();
210 if (IndexDigit[index]) {
211 const std::vector<short>& vSamples=(IndexDigit[index])->samples();
212 int nsamples = vSamples.size();
213 for (int i=0;i<std::min(32,nsamples);i++) {
214 m_ADC[m_ncells][i]=(float)(vSamples[i])-pedestal;
215 }
216 }
217 } // samples
218 m_TCell[m_ncells]=0.;
220 if(recocell_container) {
221 const CaloCell *rcell= recocell_container->findCell(hcell);
222 if(rcell) {
223 m_TCell[m_ncells]=rcell->time();
224 m_ErecoCell[m_ncells]=rcell->energy();
225 }
226 }
227 m_ncells++;
228 }// iflag
229 } // over cells
230
231 ATH_MSG_INFO("Number of cells read " << m_ncells );
232
233 m_tree->Fill();
234
235 return StatusCode::SUCCESS;
236}
237
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helper class for offline supercell identifiers.
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
void select(double eta, double phi, double deta, double dphi)
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float time() const
get time (data member)
Definition CaloCell.h:368
double energy() const
get energy (data member)
Definition CaloCell.h:327
This class initializes the Calo (LAr and Tile) offline identifiers.
const CaloCell_SuperCell_ID * getCaloCell_SuperCell_ID(void) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual float pedestal(const HWIdentifier &id, int gain) const =0
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
constexpr value_type value() const
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Container class for LArDigit.
std::vector< int > m_LayerCell
Definition LArReadSC.h:59
std::vector< float > m_TCell
Definition LArReadSC.h:64
const LArOnline_SuperCellID * m_lar_online_id
Definition LArReadSC.h:39
int m_error
Definition LArReadSC.h:54
std::vector< float > m_PhiCell
Definition LArReadSC.h:58
virtual StatusCode finalize()
Definition LArReadSC.cxx:86
int m_runNumber
Definition LArReadSC.h:50
int m_bcid
Definition LArReadSC.h:53
const CaloCell_SuperCell_ID * m_calo_id
Definition LArReadSC.h:38
std::vector< float > m_ECell
Definition LArReadSC.h:56
SG::ReadHandleKey< CaloCellContainer > m_SCKey
Definition LArReadSC.h:46
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloMgrKey
Definition LArReadSC.h:43
int m_eventNumber
Definition LArReadSC.h:52
SG::ReadHandleKey< LArDigitContainer > m_contKey
Definition LArReadSC.h:45
std::vector< float > m_EtaCell
Definition LArReadSC.h:57
std::vector< std::array< float,32 > > m_ADC
Definition LArReadSC.h:63
TTree * m_tree
Definition LArReadSC.h:49
virtual StatusCode initialize()
Definition LArReadSC.cxx:40
std::vector< int > m_HwidCell
Definition LArReadSC.h:62
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition LArReadSC.h:41
LArReadSC(const std::string &name, ISvcLocator *pSvcLocator)
Definition LArReadSC.cxx:23
Gaudi::Property< std::string > m_outStream
Definition LArReadSC.h:36
std::vector< int > m_ChidCell
Definition LArReadSC.h:61
SG::ReadHandleKey< CaloCellContainer > m_SCRecoKey
Definition LArReadSC.h:47
std::vector< float > m_ErecoCell
Definition LArReadSC.h:65
virtual ~LArReadSC()
Definition LArReadSC.cxx:37
int m_lbNumber
Definition LArReadSC.h:51
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition LArReadSC.cxx:92
Gaudi::Property< double > m_etcut
Definition LArReadSC.h:35
int m_ncells
Definition LArReadSC.h:55
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
Definition LArReadSC.h:42
std::vector< int > m_ProvCell
Definition LArReadSC.h:60
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
uint32_t runNumber() const
The current event's run number.
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
uint64_t eventNumber() const
The current event's event number.
Definition index.py:1
EventInfo_v1 EventInfo
Definition of the latest event info version.
Extra patterns decribing particle interation process.