ATLAS Offline Software
Loading...
Searching...
No Matches
TileFatherMonTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ********************************************************************//
6//
7// NAME: TileFatherMonTool.cxx
8// PACKAGE: TileMonitoring
9//
10// AUTHOR: Luca Fiorini (Luca.Fiorini@cern.ch)
11//
12// July 2006
13// ********************************************************************//
14
15#include "TileFatherMonTool.h"
16
18
21
22
26#include "TileEvent/TileCell.h"
27
29
30#include "TH1C.h"
31#include "TH2C.h"
32#include "TH1S.h"
33#include "TH2S.h"
34#include "TH1I.h"
35#include "TH2I.h"
36#include "TH1F.h"
37#include "TH2F.h"
38#include "TH1D.h"
39#include "TH2D.h"
40#include "TTree.h"
41#include "TGraph.h"
42#include "TGraphErrors.h"
43#include "TGraphAsymmErrors.h"
44#include "TMultiGraph.h"
45#include "TProfile.h"
46#include "TProfile2D.h"
47#include "TString.h"
48#include "TDirectory.h"
49#include "TAxis.h"
50
51
53/*---------------------------------------------------------*/
54TileFatherMonTool::TileFatherMonTool(const std::string & type, const std::string & name, const IInterface* parent)
55 : TilePaterMonTool(type, name, parent)
56 , m_lvl1info(0)
57 , m_evtNum(0)
58 , m_lumiBlock(0)
59 , m_evtBCID(0)
60 , m_runNum(0)
61 , m_trigDec("Trig::TrigDecisionTool/TrigDecisionTool")
62 , m_fillHistogramsForL1Triggers{0,1,2,3,4,5,6,7}
63 , m_allowedL1TriggerBits(8, false)
64
65/*---------------------------------------------------------*/
66{
67 declareInterface<IMonitorToolBase>(this);
68
69 declareProperty("MBTSCellContainerID", m_MBTSCellContainerID = "MBTSContainer");
70 declareProperty("CellsContainerID" , m_cellsContainerID = "AllCalo"); //SG Cell Container
71 declareProperty("FillHistogramsForL1Triggers" , m_fillHistogramsForL1Triggers);
72
73 // conversion from ROS index to partition index
79
80 // conversion from partition index to ROS index
86
87 m_path = "/Tile";
88}
89
90/*---------------------------------------------------------*/
92/*---------------------------------------------------------*/
93
94}
95
98/*---------------------------------------------------------*/
100/*---------------------------------------------------------*/
101
102 m_SampStrNames[SampA] = "SampA";
103 m_SampStrNames[SampB] = "SampB";
104 m_SampStrNames[SampD] = "SampD";
105 m_SampStrNames[SampE] = "SampE";
106 m_SampStrNames[AllSamp] = "AllSamp";
107
108 m_PartNames[PartEBA] = "EBA";
109 m_PartNames[PartLBA] = "LBA";
110 m_PartNames[PartLBC] = "LBC";
111 m_PartNames[PartEBC] = "EBC";
112 m_PartNames[NumPart] = "AllPart";
113
114 m_GainNames[0] = "LG";
115 m_GainNames[1] = "HG";
116
117 m_TrigNames[Trig_b0] = "bit0_RNDM";
118 m_TrigNames[Trig_b1] = "bit1_ZeroBias";
119 m_TrigNames[Trig_b2] = "bit2_L1CAL";
120 m_TrigNames[Trig_b3] = "bit3_Muon";
121 m_TrigNames[Trig_b4] = "bit4_RPC";
122 m_TrigNames[Trig_b5] = "bit5_FTK";
123 m_TrigNames[Trig_b6] = "bit6_CTP";
124 m_TrigNames[Trig_b7] = "bit7_Calib";
125 m_TrigNames[AnyTrig] = "AnyPhysTrig";
126
136
137 //done explicitly
138 //ToolRootHistSvc();
139
140 for (unsigned int bit : m_fillHistogramsForL1Triggers) {
141 if (bit < 8) m_allowedL1TriggerBits[bit] = true;
142 }
143
144
145 //SetBookStatus(false);
147
148 return StatusCode::SUCCESS;
149}
150
151
156/*---------------------------------------------------------*/
158 /*---------------------------------------------------------*/
159
160 if (cell == 0) {
161 return NumPart;
162 }
163
164 Identifier id = cell->ID();
165 int section = m_tileID->section(id);
166 int side = m_tileID->side(id);
167 int partition = NumPart; // default is gap, ITC or non Tile cell
168
169 if ((section == 2 || section == 3) && side == 1) {
170 partition = PartEBA;
171 } else if (section == 1 && side == 1) {
172 partition = PartLBA;
173 } else if (section == 1 && side == -1) {
174 partition = PartLBC;
175 } else if ((section == 2 || section == 3) && side == -1) {
176 partition = PartEBC;
177 } else {
178 partition = NumPart;
179 } //what are you? get off!
180
181 return partition;
182}
183
184
185
186
190/*---------------------------------------------------------*/
192/*---------------------------------------------------------*/
193{
194
195 uint32_t lvl1info = 0;
196
197 const xAOD::EventInfo* eventInfo = nullptr;
198
199 if (evtStore()->retrieve(eventInfo).isFailure()) {
200
201 m_lvl1info = lvl1info;
202 m_evtNum = 0;
203 m_lumiBlock = 0;
204 m_evtBCID = 0;
205 m_runNum = 0;
206 m_tileFlag = 0;
208
209 } else {
210
211 m_lvl1info = eventInfo->level1TriggerType();
212 m_evtNum = eventInfo->eventNumber();
213 m_lumiBlock = eventInfo->lumiBlock();
214 m_evtBCID = eventInfo->bcid();
215 m_runNum = eventInfo->runNumber();
216
219
220// const std::vector< xAOD::EventInfo::StreamTag >& evtStreamTags = eventInfo->streamTags();
221// for (const auto& evtStreamTag : evtStreamTags) {
222// m_streamTagTypes.push_back(evtStreamTag.type());
223// m_streamTagNames.push_back(evtStreamTag.name());
224// }
225
226 }
227
231 }
232
233}
234
235
237/*---------------------------------------------------------*/
239/*---------------------------------------------------------*/
240
241
242 std::ostringstream ss; ss.str("");
243 ss << m_runNum;
244 return ss.str();
245}
246
247
248
254/*---------------------------------------------------------*/
255void TileFatherMonTool::get_eventTrigs(uint32_t lvl1info) {
256 /*---------------------------------------------------------*/
257
258 m_eventTrigs.clear(); // clear vector
259
260 if (lvl1info != 0) {
261
262 if ((lvl1info >> Trig_b7) & 1) { // first bit tells if physics (=1) or calibration (=0) event
263 // format is 0x1aaaaaaa
264 m_eventTrigs.push_back(AnyTrig); //adding the AnyPhysTrig trigger
265 for (int exp = 0; exp < Trig_b7; exp++) { // adding the phys triggers one by one
266
267 if (((lvl1info >> exp) & 1) and (m_allowedL1TriggerBits[exp])) m_eventTrigs.push_back(exp); // store active trigger
268
269 }
270 } else { //calibration event foramt is 0x0aaaaaaa
271 m_eventTrigs.push_back(Trig_b7);
272 }
273
274 } else {//close if lvl1 word not empty
275
276 m_eventTrigs.push_back(AnyTrig); //always store at least AnyPhysTrig (=8)
277 }
278}
279
280/*---------------------------------------------------------*/
282 /*---------------------------------------------------------*/
283
286
287 if (m_MBTSCellContainerID.size() > 0) {
288
289 const TileCellContainer* mbts_container;
290
291 if (evtStore()->retrieve(mbts_container, m_MBTSCellContainerID).isFailure()) {
292 ATH_MSG_INFO( "Can't find TileCellContainer with name " << m_MBTSCellContainerID
293 << " in TES. No checking if it is collision possible!" );
294
295 ATH_MSG_INFO( "Will not try to read this container anymore!" );
296
298
299 } else {
300
301 int nHitsA = 0;
302 int nHitsC = 0;
303 double timeA = 0.;
304 double timeC = 0.;
305
306 for (const TileCell* mbts_cell : *mbts_container) {
307 if (mbts_cell->energy() < 0.27 || TMath::Abs(mbts_cell->time()) < 1.e-5) continue; //threshold approx 60./222.
308
309 if (m_tileTBID->side(mbts_cell->ID()) > 0) {
310 ++nHitsA;
311 timeA += mbts_cell->time();
312 } else {
313 ++nHitsC;
314 timeC += mbts_cell->time();
315 }
316
317 } // end Cell loop
318
319 if (nHitsA > 1 && nHitsC > 1) {
320 TileFatherMonTool::m_time_difference = timeA / nHitsA - timeC / nHitsC;
321 if (TMath::Abs(TileFatherMonTool::m_time_difference) < 7.5) {
323 }
324 }
325 }
326 }
327
329
330 const CaloCellContainer* cell_container;
331
332 if (evtStore()->retrieve(cell_container, m_cellsContainerID).isFailure()) {
333 ATH_MSG_INFO( "TileCellMonTool: Retrieval of Tile cells from container " << m_cellsContainerID
334 << " failed! No checking if it is collision possible!" );
335 ATH_MSG_INFO( "Will not try to read this container anymore!" );
336
338
339 } else {
340 int nHitsA = 0;
341 int nHitsC = 0;
342 double timeA = 0.0;
343 double timeC = 0.0;
344
345 for (const CaloCell* cell : *cell_container) {
346
347 Identifier id = cell->ID();
348
349 if (m_tileID->is_tile(id)) {
350
351 const TileCell* tile_cell = dynamic_cast<const TileCell*>(cell);
352 if (!tile_cell) continue;
353
354 // get the cell energy, time
355 double time = tile_cell->time();
356 double energy = tile_cell->energy();
357
358 if (energy < 500.0 || TMath::Abs(time) < 1.e-5) continue;
359
360 if (m_tileID->sample(id) == TileID::SAMP_E) {
361 if (m_tileID->side(id) == TileID::POSITIVE) {
362 ++nHitsA;
363 timeA += time;
364 } else {
365 ++nHitsC;
366 timeC += time;
367 }
368 } //if partition
369 } // end if tile_cell
370 } // end of loop over the Cells
371
372 if (nHitsA > 1 && nHitsC > 1) {
373 TileFatherMonTool::m_time_difference = timeA / nHitsA - timeC / nHitsC;
374
375 if (TMath::Abs(TileFatherMonTool::m_time_difference) < 7.5) {
377 }
378 }
379 } //sc1 else
380
381 }
382}
383
384//Generic Method to set the bin labels of an axis
385template<class T>
386void TileFatherMonTool::SetBinLabel(T* axis, const std::vector<std::string>& labels) {
387 unsigned int bin(1);
388 for (const std::string& label : labels) {
389 axis->SetBinLabel(bin, label.c_str());
390 ++bin;
391 }
392}
393
394//Generic Method to set the bin labels of an axis
395template<class T>
396void TileFatherMonTool::SetBinLabel(T* axis, const std::string* labels, int nLabels) {
397 if (nLabels < 0) return;
398 for (unsigned int bin = 1; bin <= (unsigned int) nLabels; ++bin) {
399 axis->SetBinLabel(bin, (labels[bin - 1]).c_str());
400 }
401}
402
403// Method to move bins of TProfile histogra,
404// Used for online to display only latest 100 LB
405void TileFatherMonTool::ShiftTprofile(TProfile* histo, int delta_lb) {
406
407 if (delta_lb < 1) return;
408 int Nbins = histo->GetNbinsX();
409 double total_entries = 0.;
410 int i;
411 for (i = 1; i <= Nbins - delta_lb; i++) {
412 double entries = histo->GetBinEntries(i + delta_lb);
413 double content = histo->GetBinContent(i + delta_lb);
414 total_entries += entries;
415 histo->SetBinEntries(i, entries);
416 histo->SetBinContent(i, content * entries);
417 histo->SetBinError(i, content * sqrt(entries));
418 }
419
420 for (; i <= 100; i++) { // set rest to zero
421
422 histo->SetBinEntries(i, 0.);
423 histo->SetBinContent(i, 0.);
424 histo->SetBinError(i, 0.);
425 }
426
427 histo->ResetStats();
428 histo->SetEntries(total_entries);
429}
430
431
433unsigned int TileFatherMonTool::m_lastevent = 0;
435
436template void TileFatherMonTool::SetBinLabel<TAxis>(TAxis*, const std::vector<std::string>&);
437template void TileFatherMonTool::SetBinLabel<TAxis>(TAxis*, const std::string*, int);
438
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
void section(const std::string &sec)
TileContainer< TileCell > TileCellContainer
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
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
double energy() const
get energy (data member)
Definition CaloCell.h:327
ToolHandle< Trig::TrigDecisionTool > m_trigDec
std::string m_MBTSCellContainerID
std::string m_GainNames[2]
std::string getRunNumStr()
Method to get the run Number in words:
static unsigned int m_lastevent
std::string m_cellsContainerID
static float m_time_difference
void ShiftTprofile(TProfile *, int)
int m_ros2partition[NPartHisto]
int m_activeTrigs[9]
this array doesn't simply say if the trigger has ever fired for this run, but it also contains the po...
TileFatherMonTool(const std::string &type, const std::string &name, const IInterface *parent)
Base class for TileCal monitoring tools.
std::vector< bool > m_allowedL1TriggerBits
std::vector< unsigned int > m_fillHistogramsForL1Triggers
int m_partition2ros[NPartHisto]
std::string m_TrigNames[NTrigHisto]
void SetBinLabel(T *axis, const std::vector< std::string > &labels)
std::string m_SampStrNames[TotalSamp]
int getPartition(const CaloCell *cell)
Method to navigate from a cell to its Tile partition EBA, LBA, LBC, EBC.
virtual StatusCode initialize() override
The initialize will set some navigation variables and retrieve basic services.
std::string m_PartNames[NPartHisto]
void get_eventTrigs(uint32_t lvl1info)
Method to get the list of all Level1 trigger passed by the event.
void fillEvtInfo()
Method to fill the lvl1Info variable, evtNumber, evtBCID and lumi_block.
std::vector< int > m_eventTrigs
Vector containing the list of triggers passed by the event.
@ BARREL_POS
Definition TileHWID.h:68
@ EXTBAR_NEG
Definition TileHWID.h:71
@ BEAM_ROS
Definition TileHWID.h:67
@ BARREL_NEG
Definition TileHWID.h:69
@ EXTBAR_POS
Definition TileHWID.h:70
const TileTBID * m_tileTBID
const TileID * m_tileID
virtual StatusCode initialize() override
TilePaterMonTool(const std::string &type, const std::string &name, const IInterface *parent)
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
@ Tile
The Tile calorimeter.
uint16_t level1TriggerType() const
The Level-1 trigger type.
@ Error
The sub-detector issued an error.
uint32_t eventFlags(EventFlagSubDet subDet) const
Get the event flags for a particular sub-detector.
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.
std::string label(const std::string &format, int i)
Definition label.h:19
double entries
Definition listroot.cxx:49
EventInfo_v1 EventInfo
Definition of the latest event info version.