ATLAS Offline Software
Loading...
Searching...
No Matches
LArHECNoise.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
11
15
19
20#include "TTree.h"
21#include "GaudiKernel/MsgStream.h"
22
23
26
27LArHECNoise::LArHECNoise(const std::string& name,
28 ISvcLocator* pSvcLocator)
29 : AthAlgorithm(name, pSvcLocator),
30 m_tree(nullptr),
31 m_LArOnlineIDHelper(nullptr),
32 m_calocell_id(nullptr),
33 m_nt_run(0),
34 m_nt_evtId(0),
36 m_nt_evtTime(0),
38 m_nt_lb(0),
39 m_nt_bcid(0),
40 m_nt_gain(0),
41 m_nt_side(0),
42 m_nt_samp(0),
43 m_nt_reg(0),
44 m_nt_ieta(0),
45 m_nt_iphi(0),
46 m_nt_quality(0),
47 m_nt_digi(),
48 m_nt_max(0),
49 m_nt_min(0),
50 m_nt_OID(0),
51 m_nt_avgMu(0),
52 m_nt_actMu(0),
53 m_nt_e(0),
54 m_nt_t(0),
55 m_nt_eta(0),
56 m_nt_phi(0),
57 m_nt_z(0),
58 m_nt_r(0),
59 m_nt_ped(0),
61 {
62
63 // Trigger
64
66
67 declareProperty("TriggerLines",m_TriggerLines={"L1_J5", "L1_J10", "L1_J12", "L1_J30", "L1_TAU5", "L1_TAU8", "L1_J5_EMPTY", "L1_J10_EMPTY", "L1_J12_EMPTY", "L1_J30_EMPTY", "L1_TAU5_EMPTY", "L1_TAU8_EMPTY", "L1_J5_FIRSTEMPTY", "L1_J10_FIRSTEMPTY", "L1_J12_FIRSTEMPTY", "L1_J30_FIRSTEMPTY", "L1_TAU5_FIRSTEMPTY", "L1_TAU8_FIRSTEMPTY"});
68
69 declareProperty("MinDigitADC",m_MinDigitADC=20);
70 declareProperty("MaxDeltaT",m_MaxDeltaT=5);
71
72
73 }
74
75
77
79
80 ATH_MSG_DEBUG ( "Initializing LArHECNoise" );
81
82 // Trigger Decision Tool
83 CHECK(m_trigDec.retrieve());
84
85 ATH_CHECK( m_cablingKey.initialize() );
86 ATH_CHECK( m_pedKey.initialize() );
87 //resize here, after properties are set
88 m_nt_prescale.resize(m_TriggerLines.size());
89 m_nt_trigger.resize(m_TriggerLines.size());
90
91 // Retrieve online ID helper
92 const LArOnlineID* LArOnlineIDHelper = nullptr;
93 ATH_CHECK( detStore()->retrieve(LArOnlineIDHelper, "LArOnlineID") );
94 m_LArOnlineIDHelper = LArOnlineIDHelper;
95 ATH_MSG_DEBUG( " Found LArOnline Helper");
96
97 // Retrieve ID helpers
98 ATH_CHECK( detStore()->retrieve (m_calocell_id, "CaloCell_ID") );
99 ATH_CHECK(m_caloMgrKey.initialize());
100
102 ATH_CHECK( m_thistSvc.retrieve() );
103
105 m_tree = new TTree( "HECNoise", "HECNoise" );
106
107 // General properties of events
108 m_tree->Branch("iRun",&m_nt_run,"iRun/I");// Event ID
109 m_tree->Branch("iEvent",&m_nt_evtId,"iEvent/I");// Event ID
110 m_tree->Branch("iEventCount",&m_nt_evtCount,"iEventCount/I");
111 m_tree->Branch("iTime",&m_nt_evtTime,"iTime/I");// Event time
112 m_tree->Branch("iTime_ns",&m_nt_evtTime_ns,"iTime_ns/I");// Event time in nanosecond
113 m_tree->Branch("iLB",&m_nt_lb,"iLB/I"); // LB
114 m_tree->Branch("iBCID",&m_nt_bcid,"iBCID/I"); // BCID
115 // prescale and trigger here
116 for(unsigned i=0; i<m_TriggerLines.size(); ++i) {
117 m_tree->Branch((m_TriggerLines[i]+"_Prescale").c_str(),&(m_nt_prescale[i]),(m_TriggerLines[i]+"_Prescale/F").c_str());
118 m_tree->Branch((m_TriggerLines[i]+"_Trigger").c_str(),&(m_nt_trigger[i]),(m_TriggerLines[i]+"_Trigger/I").c_str());
119 }
120 m_tree->Branch("avgMu",&m_nt_avgMu,"avgMu/F");
121 m_tree->Branch("actMu",&m_nt_actMu,"actMu/F");
122 m_tree->Branch("iGain",&m_nt_gain,"iGain/I");
123 m_tree->Branch("iOID",&m_nt_OID,"iOID/L");
124 m_tree->Branch("iSide",&m_nt_side,"iSide/I");
125 m_tree->Branch("iSamp",&m_nt_samp,"iSamp/I");
126 m_tree->Branch("iReg",&m_nt_reg,"iReg/I");
127 m_tree->Branch("iEta",&m_nt_ieta,"iEta/I");
128 m_tree->Branch("iPhi",&m_nt_iphi,"iPhi/I");
129 m_tree->Branch("iQuality",&m_nt_quality,"iQuality/I");
130 m_tree->Branch("e",&m_nt_e,"e/F");
131 m_tree->Branch("t",&m_nt_t,"t/F");
132 m_tree->Branch("eta",&m_nt_eta,"eta/F");
133 m_tree->Branch("phi",&m_nt_phi,"phi/F");
134 m_tree->Branch("z",&m_nt_z,"z/F");
135 m_tree->Branch("r",&m_nt_r,"r/F");
136 m_tree->Branch("Ped",&m_nt_ped,"Ped/F");
137 m_tree->Branch("PedRMS",&m_nt_pedRMS,"PedRMS/F");
138 m_tree->Branch("iDigi",m_nt_digi,"iDigi[32]/S");
139 m_tree->Branch("iMax",&m_nt_max,"iMax/I");
140 m_tree->Branch("iMin",&m_nt_min,"iMin/I");
141
142 std::string treeName = "/HEC/HECNoise" ;
143 ATH_CHECK( m_thistSvc->regTree(treeName, m_tree) );
144
145
146 ATH_MSG_DEBUG ( "End of Initializing LArHECNoise" );
147
148 return StatusCode::SUCCESS;
149}
150
152 ATH_MSG_DEBUG ( "in finalize()" );
153 return StatusCode::SUCCESS;
154}
155
156
157StatusCode LArHECNoise::execute(const EventContext& ctx) {
158
159 ATH_MSG_DEBUG ( "in execute()" );
160
161 for(unsigned i=0; i<m_TriggerLines.size(); ++i){
162 m_nt_prescale[i] = m_trigDec->getPrescale(m_TriggerLines[i]);
163 m_nt_trigger[i] = m_trigDec->isPassed(m_TriggerLines[i]);
164 }
165
166 const xAOD::EventInfo* eventInfo = nullptr;
167 ATH_CHECK( evtStore()->retrieve(eventInfo) );
168
169 m_nt_evtCount = 0;
170 const CaloCellContainer* cc = nullptr;
171 const LArRawChannelContainer* lraw = nullptr;
172 if (evtStore()->contains<CaloCellContainer>("AllCalo")) {
173 ATH_CHECK(evtStore()->retrieve(cc, "AllCalo"));
174 } else if (evtStore()->contains<LArRawChannelContainer>("LArRawChannels")){
175 ATH_CHECK(evtStore()->retrieve(lraw, "LArRawChannels"));
176 }
177
179 const LArOnOffIdMapping* cabling{*cablingHdl};
180 if(!cabling) {
181 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
182 return StatusCode::FAILURE;
183 }
184
185
187 const ILArPedestal* ped{*pedHdl};
188 if(!ped) {
189 ATH_MSG_ERROR("Do not have pedestal object " << m_pedKey.key() );
190 return StatusCode::FAILURE;
191 }
192
194 ATH_CHECK(caloMgrHandle.isValid());
195 const CaloDetDescrManager* caloMgr = *caloMgrHandle;
196
197
198 const LArDigitContainer* ld = nullptr;
199 if (evtStore()->contains<LArDigitContainer>("LArDigitContainer")) {
200 ATH_CHECK(evtStore()->retrieve(ld, "LArDigitContainer"));
201 } else if (evtStore()->contains<LArDigitContainer>("LArDigitContainer_Thinned")) {
202 ATH_CHECK(evtStore()->retrieve(ld, "LArDigitContainer_Thinned"));
203 } else if (evtStore()->contains<LArDigitContainer>("FREE")) {
204 ATH_CHECK(evtStore()->retrieve(ld, "FREE"));
205 } else {
206 msg(MSG::WARNING) << "Neither LArDigitContainer nor LArDigitContainer_Thinned nor FREE present, not filling anything "<<endmsg;
207 return StatusCode::SUCCESS;
208 }
210 LArDigitContainer::const_iterator itDig = ld->begin();
211 LArDigitContainer::const_iterator itDig_e= ld->end();
212 const LArDigit* pLArDigit;
213
214 for ( ; itDig!=itDig_e;++itDig) {
215 pLArDigit = *itDig;
216 HWIdentifier hid = pLArDigit->hardwareID();
217 if(! m_LArOnlineIDHelper->isHECchannel(hid)) continue; //and ld.gain() == 2:
218 int sigmax=0;
219 int sigmin=0;
220 int imax=0;
221 int imin=0;
222 short samp0= pLArDigit->samples()[0];
223 for(unsigned i=0; i<(pLArDigit->samples()).size(); ++i){
224 short samp=pLArDigit->samples()[i];
225 if( i < 32) m_nt_digi[i] = samp;
226 if(samp-samp0 > sigmax) {
227 sigmax = samp-samp0;
228 imax=i;
229 }
230 if( samp-samp0 < sigmin) {
231 sigmin = samp-samp0;
232 imin=i;
233 }
234 }
235 if( sigmax > m_MinDigitADC && sigmin < -m_MinDigitADC && ( (imin-imax) < m_MaxDeltaT || imin < imax)) {
236 m_nt_run = eventInfo->runNumber();
237 m_nt_evtId = eventInfo->eventNumber();
238 m_nt_evtTime = eventInfo->timeStamp();
239 m_nt_evtTime_ns = eventInfo->timeStampNSOffset();
240 m_nt_lb = eventInfo->lumiBlock();
241 m_nt_bcid = eventInfo->bcid();
244
245 m_nt_evtCount += 1;
246 m_nt_gain = pLArDigit->gain();
247 Identifier oid = cabling->cnvToIdentifier(hid);
248 m_nt_OID = pLArDigit->channelID().get_compact();
249 m_nt_ped = ped->pedestal(pLArDigit->channelID(),pLArDigit->gain());
250 m_nt_pedRMS = ped->pedestalRMS(pLArDigit->channelID(),pLArDigit->gain());
251 m_nt_side = m_calocell_id->pos_neg(oid);
252 m_nt_samp = m_calocell_id->sampling(oid);
253 m_nt_reg = m_calocell_id->region(oid);
254 m_nt_ieta = m_calocell_id->eta(oid);
255 m_nt_iphi = m_calocell_id->phi(oid);
256 m_nt_max = imax;
257 m_nt_min = imin;
258 IdentifierHash ihash = m_calocell_id->calo_cell_hash(oid);
259 m_nt_e = 0.0;
260 m_nt_t = 0.0;
261 m_nt_quality = 0;
262 if(cc) {
263 const CaloCell *rcell = cc->findCell(ihash);
264 if(rcell->ID() != oid) {
265 msg(MSG::WARNING) <<"Cell iHash does not match ..."<<endmsg;
266 }else{
267 m_nt_e = rcell->e();
268 m_nt_t = rcell->time();
269 m_nt_quality = rcell->quality();
270 }
271 } else if(lraw) {
272 for(unsigned l=0; l<lraw->size(); ++l) {
273 if((*lraw)[l].identify() == hid) {
274 m_nt_e = (*lraw)[l].energy();
275 m_nt_t = (*lraw)[l].time()*1e-3;
276 m_nt_quality = (*lraw)[l].quality();
277 break;
278 }
279 }
280 }
281 const CaloDetDescrElement *cdde = caloMgr->get_element(oid);
282 if(cdde) {
283 m_nt_eta = cdde->eta();
284 m_nt_phi = cdde->phi();
285 m_nt_z = cdde->z();
286 m_nt_r = cdde->r();
287 }
288 m_tree->Fill();
289 }//found our digit
290 }//over digits
291
292 return StatusCode::SUCCESS;
293}
294
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
Definition of CaloDetDescrManager.
#define CHECK(...)
Evaluate an expression and check for errors.
size_t size() const
Number of registered mappings.
int imax(int i, int j)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float time() const
get time (data member)
Definition CaloCell.h:368
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
uint16_t quality() const
get quality (data member)
Definition CaloCell.h:348
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
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...
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:861
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
Container class for LArDigit.
Liquid Argon digit base class.
Definition LArDigit.h:25
CaloGain::CaloGain gain() const
Definition LArDigit.h:72
const HWIdentifier & hardwareID() const
Definition LArDigit.h:66
const std::vector< short > & samples() const
Definition LArDigit.h:78
const HWIdentifier & channelID() const
Definition LArDigit.h:69
virtual StatusCode initialize() override
SG::ReadCondHandleKey< ILArPedestal > m_pedKey
Definition LArHECNoise.h:48
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
Definition LArHECNoise.h:51
int m_MinDigitADC
Definition LArHECNoise.h:96
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition LArHECNoise.h:55
const LArOnlineID * m_LArOnlineIDHelper
Definition LArHECNoise.h:54
ServiceHandle< ITHistSvc > m_thistSvc
Definition LArHECNoise.h:43
short m_nt_digi[32]
Definition LArHECNoise.h:77
virtual StatusCode finalize() override
float m_nt_ped
Definition LArHECNoise.h:89
std::vector< int > m_nt_trigger
Definition LArHECNoise.h:92
float m_nt_actMu
Definition LArHECNoise.h:82
std::vector< std::string > m_TriggerLines
Definition LArHECNoise.h:95
float m_nt_pedRMS
Definition LArHECNoise.h:90
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
int m_nt_evtCount
Definition LArHECNoise.h:65
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition LArHECNoise.h:47
float m_nt_avgMu
Definition LArHECNoise.h:81
std::vector< float > m_nt_prescale
Definition LArHECNoise.h:91
float m_nt_phi
Definition LArHECNoise.h:86
TTree * m_tree
Definition LArHECNoise.h:45
int m_nt_evtTime_ns
Definition LArHECNoise.h:67
const CaloCell_ID * m_calocell_id
Definition LArHECNoise.h:60
LArHECNoise(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
float m_nt_eta
Definition LArHECNoise.h:85
Container for LArRawChannel (IDC using LArRawChannelCollection).
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
uint32_t runNumber() const
The current event's run number.
uint32_t timeStampNSOffset() const
Nanosecond time offset wrt. the time stamp.
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:116
EventInfo_v1 EventInfo
Definition of the latest event info version.