ATLAS Offline Software
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"
17 #include "CaloUtils/CaloCellList.h"
18 
19 #include "LArRawEvent/LArDigit.h"
21 
22 #include "GaudiKernel/ITHistSvc.h"
23 #include "GaudiKernel/ServiceHandle.h"
24 
26 
27 
28 
29 LArReadCells::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 
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 
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 
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();
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ILArPedestal::pedestal
virtual float pedestal(const HWIdentifier &id, int gain) const =0
et
Extra patterns decribing particle interation process.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CaloCellList
Definition: CaloCellList.h:40
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
LArReadCells::m_etcut
Gaudi::Property< double > m_etcut
Definition: LArReadCells.h:32
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellList::select
void select(double eta, double phi, double deta, double dphi)
Definition: CaloCellList.cxx:67
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArReadCells::m_runNumber
int m_runNumber
Definition: LArReadCells.h:40
LArReadCells.h
index
Definition: index.py:1
CaloCellList.h
ILArPedestal
Definition: ILArPedestal.h:12
LArReadCells::m_GainCell
std::vector< int > m_GainCell
Definition: LArReadCells.h:53
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArReadCells::m_lar_online_id
const LArOnlineID * m_lar_online_id
Definition: LArReadCells.h:62
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LArOnlineID_Base::slot
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
Definition: LArOnlineID_Base.cxx:1957
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
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
LArReadCells::m_pedestalKey
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
Definition: LArReadCells.h:59
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
LArReadCells::m_ncells
int m_ncells
Definition: LArReadCells.h:45
LArReadCells::m_bcid
int m_bcid
Definition: LArReadCells.h:43
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::barrel_ec
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
Definition: LArOnlineID_Base.cxx:1938
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
LArReadCells::m_ADC
std::vector< std::array< float,32 > > m_ADC
Definition: LArReadCells.h:56
LArReadCells::m_error
int m_error
Definition: LArReadCells.h:44
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
LArReadCells::execute
virtual StatusCode execute()
Definition: LArReadCells.cxx:93
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
LArReadCells::LArReadCells
LArReadCells(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArReadCells.cxx:29
LArReadCells::m_outStream
Gaudi::Property< std::string > m_outStream
Definition: LArReadCells.h:34
LArReadCells::m_ProvCell
std::vector< int > m_ProvCell
Definition: LArReadCells.h:51
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1963
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArReadCells::m_ECell
std::vector< float > m_ECell
Definition: LArReadCells.h:46
LArDigit.h
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
LArReadCells::~LArReadCells
virtual ~LArReadCells()
Definition: LArReadCells.cxx:44
LArReadCells::m_LayerCell
std::vector< int > m_LayerCell
Definition: LArReadCells.h:50
LArOnlineID_Base::pos_neg
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
Definition: LArOnlineID_Base.cxx:1950
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LArReadCells::m_lbNumber
int m_lbNumber
Definition: LArReadCells.h:41
LArReadCells::m_tree
TTree * m_tree
Definition: LArReadCells.h:39
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
AthAlgorithm
Definition: AthAlgorithm.h:47
LArReadCells::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArReadCells.h:60
min
#define min(a, b)
Definition: cfImp.cxx:40
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
HWIdentifier.h
LArReadCells::m_ChidCell
std::vector< int > m_ChidCell
Definition: LArReadCells.h:54
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArReadCells::m_calo_id
const CaloCell_ID * m_calo_id
Definition: LArReadCells.h:36
CaloIdManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
Definition: CaloIdManager.cxx:63
LArReadCells::finalize
virtual StatusCode finalize()
Definition: LArReadCells.cxx:87
LArReadCells::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArReadCells.h:58
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArReadCells::m_EtaCell
std::vector< float > m_EtaCell
Definition: LArReadCells.h:48
LArDigitContainer.h
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
LArReadCells::initialize
virtual StatusCode initialize()
Definition: LArReadCells.cxx:47
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
LArReadCells::m_TCell
std::vector< float > m_TCell
Definition: LArReadCells.h:47
LArReadCells::m_eventNumber
int m_eventNumber
Definition: LArReadCells.h:42
ReadOfcFromCool.nsamples
nsamples
Definition: ReadOfcFromCool.py:115
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:123
DeMoScan.index
string index
Definition: DeMoScan.py:364
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1944
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ILArPedestal.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArReadCells::m_HwidCell
std::vector< int > m_HwidCell
Definition: LArReadCells.h:55
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
CaloIdManager.h
LArReadCells::m_QuaCell
std::vector< int > m_QuaCell
Definition: LArReadCells.h:52
LArReadCells::m_PhiCell
std::vector< float > m_PhiCell
Definition: LArReadCells.h:49
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
readCCLHist.float
float
Definition: readCCLHist.py:83
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
LArReadCells::m_etcut2
Gaudi::Property< double > m_etcut2
Definition: LArReadCells.h:33
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
ServiceHandle< ITHistSvc >
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14