ATLAS Offline Software
Loading...
Searching...
No Matches
LArReadCells.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include "Identifier/Identifier.h"
11
14#include "CaloGeoHelpers/CaloSampling.h"
15#include "CaloEvent/CaloCell.h"
18
21
22#include "GaudiKernel/ITHistSvc.h"
23#include "GaudiKernel/ServiceHandle.h"
24
26
27
28
29LArReadCells::LArReadCells( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ){
30 m_ECell.reserve(250000);
31 m_TCell.reserve(250000);
32 m_EtaCell.reserve(250000);
33 m_PhiCell.reserve(250000);
34 m_LayerCell.reserve(250000);
35 m_ProvCell.reserve(250000);
36 m_QuaCell.reserve(250000);
37 m_GainCell.reserve(250000);
38 m_ChidCell.reserve(250000);
39 m_HwidCell.reserve(250000);
40 m_ADC.reserve(250000);
41}
42
43
45
46
48 ATH_MSG_INFO ("Initializing " << name() << "...");
49
50 ServiceHandle<ITHistSvc> histSvc("THistSvc",name());
51 CHECK( histSvc.retrieve() );
52 m_tree = new TTree("myTree","myTree");
53 std::string out("/"+m_outStream+"/myTree");
54 CHECK( histSvc->regTree(out.c_str(),m_tree) );
55 ATH_MSG_INFO("Registered tree: " << out);
56 m_tree->Branch("RunNumber",&m_runNumber,"RunNumber/I");
57 m_tree->Branch("LBNumber",&m_lbNumber,"LBNumber/I");
58 m_tree->Branch("EventNumber",&m_eventNumber,"EventNumber/I");
59 m_tree->Branch("BCID",&m_bcid,"BCID/I");
60 m_tree->Branch("LArError",&m_error,"LArError/I");
61 m_tree->Branch("ncells",&m_ncells,"ncells/I");
62 m_tree->Branch("ECell",m_ECell.data(),"eCell[ncells]/F");
63 m_tree->Branch("TCell",m_TCell.data(),"tCell[ncells]/F");
64 m_tree->Branch("EtaCell",m_EtaCell.data(),"etaCell[ncells]/F");
65 m_tree->Branch("PhiCell",m_PhiCell.data(),"phiCell[ncells]/F");
66 m_tree->Branch("LayerCell",m_LayerCell.data(),"layerCell[ncells]/I");
67 m_tree->Branch("ProvCell", m_ProvCell.data(),"provCell[ncells]/I");
68 m_tree->Branch("QuaCell", m_QuaCell.data(),"quaCell[ncells]/I");
69 m_tree->Branch("GainCell", m_GainCell.data(),"gainCell[ncells]/I");
70 m_tree->Branch("ChidCell", m_ChidCell.data(),"chidCell[ncells]/I");
71 m_tree->Branch("HwidCell", m_HwidCell.data(),"hwidCell[ncells]/I");
72 m_tree->Branch("ADC",m_ADC.data(),"ADC[ncells][32]/F");
73
74 const CaloIdManager* caloIdMgr = nullptr;
75 ATH_CHECK(detStore()->retrieve(caloIdMgr));
76 m_calo_id = caloIdMgr->getCaloCell_ID();
77 ATH_CHECK( detStore()->retrieve(m_lar_online_id, "LArOnlineID") );
78
79 ATH_CHECK( m_cablingKey.initialize() );
80 ATH_CHECK(m_pedestalKey.initialize());
81 ATH_CHECK(m_caloMgrKey.initialize());
82 ATH_MSG_INFO("Energy cut for time and quality computation: " << m_etcut);
83
84 return StatusCode::SUCCESS;
85}
86
88 ATH_MSG_INFO ("Finalizing " << name() << "...");
89
90 return StatusCode::SUCCESS;
91}
92
93StatusCode LArReadCells::execute() {
94 ATH_MSG_DEBUG ("Executing " << name() << "...");
95
97 const LArOnOffIdMapping* cabling=*cablingHdl;
98 if(!cabling) {
99 ATH_MSG_ERROR( "Do not have cabling object LArOnOffIdMapping" );
100 return StatusCode::FAILURE;
101 }
102
104 const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
105
106 //Get Conditions input
108 const ILArPedestal* larPedestal=*pedHdl;
109
110
111 const xAOD::EventInfo* eventInfo = nullptr;
112 ATH_CHECK( evtStore()->retrieve( eventInfo) );
113 ATH_MSG_INFO( " run number " << eventInfo->runNumber() );
114
115 m_runNumber = eventInfo->runNumber();
116 m_eventNumber = eventInfo->eventNumber();
117 m_lbNumber = eventInfo->lumiBlock();
118 m_bcid = eventInfo->bcid();
119 m_error = 0;
121
122 std::vector<const LArDigit*> IndexDigit;
123 int nCell = m_calo_id->calo_cell_hash_max();
124 IndexDigit.resize(nCell,nullptr);
125
126 const LArDigitContainer* digit_container;
127 if (evtStore()->contains<LArDigitContainer>("FREE")) {
128 CHECK(evtStore()->retrieve(digit_container,"FREE"));
129 LArDigitContainer::const_iterator first_digit = digit_container->begin();
130 LArDigitContainer::const_iterator end_digit = digit_container->end();
131 for (; first_digit != end_digit; ++first_digit)
132 {
133 HWIdentifier hwid = (*first_digit)->hardwareID();
134 Identifier id = cabling->cnvToIdentifier(hwid);
135 int index = (int) (m_calo_id->calo_cell_hash(id));
136 if (index>=0 && index<nCell) IndexDigit[index]=(*first_digit);
137 }
138 }
139
140
141 const CaloCellContainer* cell_container;
142 CHECK( evtStore()->retrieve(cell_container,"AllCalo"));
143
144 std::vector<int> iflag_cell;
145 iflag_cell.resize(nCell,0);
146
147 CaloCellContainer::const_iterator first_cell = cell_container->begin();
148 CaloCellContainer::const_iterator end_cell = cell_container->end();
149 m_ncells=0;
150 for (; first_cell != end_cell; ++first_cell)
151 {
152 Identifier cellID = (*first_cell)->ID();
153 int index = (int) (m_calo_id->calo_cell_hash(cellID));
154 double et = (*first_cell)->et();
155
156 if (et > m_etcut && !(m_calo_id->is_tile(cellID)) ){
157 iflag_cell[index]=1;
158
159 if ((m_calo_id->calo_sample(cellID)==CaloSampling::CaloSample::EMB2 || m_calo_id->calo_sample(cellID)==CaloSampling::CaloSample::EME2)
160 && et>m_etcut2) {
161
162 CaloCellList myList(caloDDMgr, cell_container);
163 myList.select((*first_cell)->eta(),(*first_cell)->phi(),0.10);
164 for (const CaloCell* cell : myList) {
165 Identifier cellID2 =cell->ID();
166 int index2 = (int)(m_calo_id->calo_cell_hash(cellID2));
167 iflag_cell[index2]=1;
168 }
169 }// second layer
170 }// above first etcut
171 }// over cells
172
173 first_cell = cell_container->begin();
174 for (; first_cell != end_cell; ++first_cell) {
175
176 Identifier cellID = (*first_cell)->ID();
177 int index = (int) (m_calo_id->calo_cell_hash(cellID));
178
179 if (iflag_cell[index]==1 ){
180 m_ECell[m_ncells]= (*first_cell)->energy();
181 m_TCell[m_ncells]= (*first_cell)->time();
182 m_EtaCell[m_ncells]= (*first_cell)->eta();
183 m_PhiCell[m_ncells]= (*first_cell)->phi();
184 m_LayerCell[m_ncells]= m_calo_id->calo_sample(cellID);
185 m_ProvCell[m_ncells]=(*first_cell)->provenance();
186 m_QuaCell[m_ncells]=(*first_cell)->quality();
187 m_GainCell[m_ncells]=(*first_cell)->gain();
188
189 for (int i=0;i<32;i++) m_ADC[m_ncells][i]=0.;
190 float pedestal=0.;
191 int myid=0;
192 if (!(m_calo_id->is_tile(cellID))) {
193 HWIdentifier hwid = cabling->createSignalChannelID(cellID);
194 int barrel_ec = m_lar_online_id->barrel_ec(hwid);
195 int pos_neg = m_lar_online_id->pos_neg(hwid);
196 int FT = m_lar_online_id->feedthrough(hwid);
197 int slot = m_lar_online_id->slot(hwid);
198 int channel = m_lar_online_id->channel(hwid);
199 if (barrel_ec<2 && pos_neg<2 && FT<32 && slot<16 && channel<128)
200 myid = (channel) | (slot << 7) | (FT<<11) | (pos_neg << 16) | (barrel_ec << 17);
201 if (myid < 128) {
202 ATH_MSG_WARNING("Why we have such cell: "<<barrel_ec<<" "<<pos_neg<<" "<<FT<<" "<<slot<<" "<<channel<<" | "<<myid);
203 ATH_MSG_WARNING("from: "<<hwid.get_identifier32().get_compact());
204 }
205
206 if (larPedestal) {
207 pedestal = larPedestal->pedestal(hwid,(*first_cell)->gain());
208 }
209
210 m_HwidCell[m_ncells]=myid;
212 int index = (int) (m_calo_id->calo_cell_hash(cellID));
213 if (IndexDigit[index]) {
214 const std::vector<short>& vSamples=(IndexDigit[index])->samples();
215 int nsamples = vSamples.size();
216 for (int i=0;i<std::min(32,nsamples);i++) {
217 m_ADC[m_ncells][i]=(float)(vSamples[i])-pedestal;
218 }
219 }
220 } // not Tile
221 m_ncells++;
222 }// iflag
223 } // over cells
224
225 ATH_MSG_INFO("Number of cells read " << m_ncells );
226
227 m_tree->Fill();
228
229 return StatusCode::SUCCESS;
230}
231
#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)
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
void select(double eta, double phi, double deta, double dphi)
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class provides the client interface for accessing the detector description information common to...
This class initializes the Calo (LAr and Tile) offline identifiers.
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
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.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Container class for LArDigit.
const LArOnlineID * m_lar_online_id
virtual StatusCode finalize()
std::vector< std::array< float,32 > > m_ADC
std::vector< int > m_GainCell
std::vector< int > m_QuaCell
std::vector< int > m_HwidCell
virtual ~LArReadCells()
Gaudi::Property< double > m_etcut
std::vector< int > m_ChidCell
virtual StatusCode initialize()
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< std::string > m_outStream
std::vector< float > m_TCell
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode execute()
std::vector< float > m_EtaCell
std::vector< int > m_ProvCell
std::vector< float > m_PhiCell
std::vector< float > m_ECell
LArReadCells(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< double > m_etcut2
TTree * m_tree
std::vector< int > m_LayerCell
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
const CaloCell_ID * m_calo_id
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.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
Definition index.py:1
EventInfo_v1 EventInfo
Definition of the latest event info version.
Extra patterns decribing particle interation process.