ATLAS Offline Software
MistimedStreamMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
8 #include <iostream>
9 #include <vector>
10 #include <TMath.h>
11 
12 MistimedStreamMonitorAlgorithm::MistimedStreamMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
13  : AthMonitorAlgorithm(name,pSvcLocator)
14 {
15 }
16 
18 
19  ATH_MSG_DEBUG("MistimedStreamMonitorAlgorith::initialize");
20  ATH_MSG_DEBUG("Package Name "<< m_packageName);
21  ATH_MSG_DEBUG("m_xAODTriggerTowerContainerName "<< m_xAODTriggerTowerContainerName);
22 
23  ATH_MSG_INFO("m_eFexEMContainer: "<< m_eFexEMContainerKey);
24  ATH_MSG_INFO("m_eFexEMOutContainer: "<< m_eFexEMOutContainerKey);
25  ATH_MSG_INFO("m_eFexTauContainer: "<< m_eFexTauContainerKey);
26 
27  // we initialise all the containers that we need
30  ATH_CHECK( m_cpmTowerLocation.initialize());
31  ATH_CHECK( m_jetElementLocation.initialize());
32  ATH_CHECK( m_trigDec.retrieve() );
33  ATH_CHECK( m_ttTool.retrieve());
36 
37  // eFex Container
38  ATH_CHECK( m_eFexEMContainerKey.initialize() );
39  ATH_CHECK( m_eFexEMOutContainerKey.initialize() );
40  ATH_CHECK( m_eFexTauContainerKey.initialize() );
41 
42  // jFex Container
43  ATH_CHECK( m_jFexLRJetContainerKey.initialize() );
44  ATH_CHECK( m_jFexSRJetContainerKey.initialize() );
45  ATH_CHECK( m_jFexTauContainerKey.initialize() );
46  ATH_CHECK( m_jFexDataTowerKey.initialize() );
47  ATH_CHECK( m_EmulTowerKey.initialize() );
48 
49  // gFex Container
50  ATH_CHECK( m_gFexJetTobKeyList.initialize() ) ;
51 
53 }
54 
56 
57  ATH_MSG_DEBUG("MistimedStreamMonitorAlgorith::fillHistograms");
58 
59  // Retrieve L1CaloRunParametersContainer
61  ATH_CHECK(runParameters.isValid());
62 
63  unsigned int readoutConfigID = runParameters->runParameters(1)->readoutConfigID();
64  ATH_MSG_DEBUG("RunParameters:: readoutConfigID " << readoutConfigID);
65 
67 
68  unsigned int channelID = 0;
69  unsigned int numFadcSlices = 0;
70  unsigned int l1aFadcSlice = 0;
71  unsigned int readout80ModePpm = 0;
72 
73  //the readout config ID tells you, which readoutConfig is loaded. now you can retrieve the l1aFadcSlice from this DB entry
74  if ( readoutConfigJSON->readoutConfigJSON(readoutConfigID)->channelId() == readoutConfigID){
75  ATH_MSG_DEBUG("readoutConfigID " << readoutConfigID);
76  channelID = readoutConfigJSON->readoutConfigJSON(readoutConfigID)->channelId();
77  numFadcSlices = readoutConfigJSON->readoutConfigJSON(readoutConfigID)->numFadcSlices();
78  l1aFadcSlice = readoutConfigJSON->readoutConfigJSON(readoutConfigID)->l1aFadcSlice();
79  readout80ModePpm = readoutConfigJSON->readoutConfigJSON(readoutConfigID)->readout80ModePpm();
80  ATH_MSG_DEBUG("channelID :: " << channelID);
81  ATH_MSG_DEBUG("numFadcSlices :: " << numFadcSlices);
82  ATH_MSG_DEBUG("l1aFadcSlice :: " << l1aFadcSlice);
83  ATH_MSG_DEBUG("readout80ModePpm :: " << readout80ModePpm);
84  }
85 
86  // Retrieve jetElementfrom SG
88  if(!jetElementTES.isValid()){
89  ATH_MSG_ERROR("No JetElement container found in TES "<< m_jetElementLocation);
90  return StatusCode::FAILURE;
91  }
92 
93  // Retrieve Core CPM Towers from SG
95  if(!cpmTowerTES.isValid()){
96  ATH_MSG_ERROR("No CPMTower container found in TES "<< m_cpmTowerLocation);
97  return StatusCode::FAILURE;
98  }
99 
100  // Retrieve Trigger Towers from SG
102  if(!triggerTowerTES.isValid()){
103  ATH_MSG_ERROR("No Trigger Tower container found in TES "<< m_xAODTriggerTowerContainerName);
104  return StatusCode::FAILURE;
105  }
106 
107  // Retrieve EventInfo from SG and save lumi block number, global event number and run number
108  unsigned int lumiNo = GetEventInfo(ctx)->lumiBlock();
109  unsigned int currentRunNo = ctx.eventID().run_number();
110  unsigned int currentEventNo = ctx.eventID().event_number();
111 
112  ATH_MSG_DEBUG("Lumi Block :: " << lumiNo);
113  ATH_MSG_DEBUG("Run Number :: " << currentRunNo);
114  ATH_MSG_DEBUG("Event Number :: " << currentEventNo);
115 
116  Monitored::Scalar<int> cutFlowX = Monitored::Scalar<int>("cutFlowX", 0);
117 
118  // fill first bin in cutflow
119  cutFlowX=All;
120  fill(m_packageName,cutFlowX);
121 
122  //for the algorithm to run, we need the 2 adc slices before and after the l1a-slice
123  //readout compatibility checks of the algo here
124  if(readout80ModePpm){
125  if(numFadcSlices < 9){
126  ATH_MSG_DEBUG("Number of ADC slices < 9 for 80 MHz readout, algorithm cannot run, aborting...");
127  return StatusCode::SUCCESS;
128  }
129  if(l1aFadcSlice < 4){
130  ATH_MSG_DEBUG("L1a readout pointer < 4 for 80 MHz readout, algorithm cannot run, aborting...");
131  return StatusCode::SUCCESS;
132  }
133  if(numFadcSlices - l1aFadcSlice < 4){
134  ATH_MSG_DEBUG("L1a readout pointer is at "<< l1aFadcSlice << " with "<< numFadcSlices << "slices at 80 MHz readout mode, algorithm cannot run, aborting...");
135  return StatusCode::SUCCESS;
136  }
137  }
138  else {
139  if(numFadcSlices < 5){
140  ATH_MSG_DEBUG("Number of ADC slices < 5 for 40 MHz readout, algorithm cannot run, aborting...");
141  return StatusCode::SUCCESS;
142  }
143  if(l1aFadcSlice < 2){
144  ATH_MSG_DEBUG("L1a readout pointer < 2 for 40 MHz readout, algorithm cannot run, aborting...");
145  return StatusCode::SUCCESS;
146  }
147  if(numFadcSlices - l1aFadcSlice < 2){
148  ATH_MSG_DEBUG("L1a readout pointer is at "<< l1aFadcSlice << " with "<< numFadcSlices << "slices at 40 MHz readout mode, algorithm cannot run, aborting...");
149  return StatusCode::SUCCESS;
150  }
151  }
152  cutFlowX=UnsuitableReadout;
153  fill(m_packageName,cutFlowX);
154 
155  //Select events that fired HLT_mistimedmonj400
156  if(! (m_trigDec->isPassed("HLT_mistimemonj400_L1All",TrigDefs::requireDecision))){
157  ATH_MSG_DEBUG("TrigDec don't pass HLT_mistimemonj400_L1All");
158  return StatusCode::SUCCESS;
159  }
160 
161  cutFlowX=HLT_mistimemonj400;
162  fill(m_packageName,cutFlowX);
163 
164  //Only select events which passed the L1_J100, L1_jJ160, L1_eEM26M, L1_jJ400 or L1_gJ400p0ETA25
165  //Adjustable depending on which trigger we are interested
166  if(! ( (m_trigDec->isPassed("L1_J100")) or
167  (m_trigDec->isPassed("L1_jJ160")) or
168  (m_trigDec->isPassed("L1_eEM26M")) or
169  (m_trigDec->isPassed("L1_gJ100p0ETA25")) or
170  (m_trigDec->isPassed("L1_gJ400p0ETA25")) or
171  (m_trigDec->isPassed("L1_jJ400"))
172  ) ){
173  ATH_MSG_DEBUG("TrigDec doesn't pass");
174  return StatusCode::SUCCESS;
175  }
176 
177  //Define trigger for subsequent cuts
178  std::string trigger= "legacy";;
179 
180  if (m_trigDec->isPassed("L1_eEM26M")) {
181  trigger = "eFex";
182  }
183  else if ((m_trigDec->isPassed("L1_jJ160"))or (m_trigDec->isPassed("L1_jJ400"))) {
184  trigger = "jFex";
185  }
186  else if ( (m_trigDec->isPassed("L1_gJ400p0ETA25")) or (m_trigDec->isPassed("L1_gJ100p0ETA25")) ) {
187  trigger = "gFex";
188  }
189 
190  cutFlowX=L1_Trigger;
191  fill(m_packageName,cutFlowX);
192 
193 
194  // now classify the tower signals by looking at their FADC counts, if it exceeds 70
195  int badCounter = 0; // category 2 really bad
196  int bad2Counter = 0; // category 4 bad peak 2
197  int bad3Counter = 0; // category 6 bad peak 3
198  int good3Counter = 0; // category 5 good peak 3
199  int good2Counter = 0; // category 5 good peak 3
200  int eFexintimeCounter = 0; // in-time TOBs
201  int eFexoutoftimeCounter = 0; // out-of-time TOBs
202  int jFexCounter = 0; // in-time TOBs
203  int gFexCounter = 0; // in-time TOBs
204  int emActivityCounter = 0; //count number of TT in EM layer with ADC > 70
205 
206  // =====================================================================
207  // ================= Container: TriggerTower ===========================
208  // =====================================================================
209 
210  // Creating a new container for saving pulseClassification
211  std::unique_ptr<xAOD::TriggerTowerContainer> ttContainer = std::make_unique<xAOD::TriggerTowerContainer>();
212  std::unique_ptr<xAOD::TriggerTowerAuxContainer> ttContainerAux = std::make_unique<xAOD::TriggerTowerAuxContainer>();
213  ttContainer->setStore(ttContainerAux.get());
214 
215  static const SG::Accessor<float> pulseClassificationAcc("pulseClassification");
216 
217  // Creating a new container for TT with pulseClassification
218  for (const xAOD::TriggerTower* tt : *triggerTowerTES) {
219 
220  float ttPulseCategory = 0;
221  const std::vector<uint16_t>& ttADC = (tt)->adc();
222  std::vector<uint16_t> readoutCorrectedADC; //this is the standard readout ADC vector: 5 40MHz samples with l1A in the middle
223  if(!readout80ModePpm){//40 MHz
224  //just acess the acd vector, as the sanity checks where done above
225  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
226  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
227  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
228  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
229  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
230  }
231  else{//80 MHz
232  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-4));
233  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
234  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
235  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
236  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+4));
237  }
238 
239  // retrieve max ADC value and position, this seems to be buggy in the DAOD
240  auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
241  int maxADCval = *maxValIterator;
242  int adcPeakPositon = std::distance(std::begin(readoutCorrectedADC), maxValIterator);
243 
244  if(maxADCval < 70){
245  ttPulseCategory = 0.1;
246  }
247  else if(maxADCval == 1023) {
248  ttPulseCategory = 1;
249  if(! (tt)->layer()) emActivityCounter++;
250  }
251  else{
252  bool goodQual = pulseQuality(readoutCorrectedADC, adcPeakPositon);
253  if(! (tt)->layer()) emActivityCounter++;
254  //look at any of the five FADC values
255  if(adcPeakPositon == 2){ // can be class 3 or 4 now
256  if(goodQual){
257  //nicely peaking TT in BCID0
258  good2Counter++;
259  ttPulseCategory = 3;
260  }
261  else{
262  //badly peaking TT in BCID0
263  bad2Counter++;
264  ttPulseCategory = 4;
265  }
266  }
267  else if(adcPeakPositon == 3){ // can be class 5 or 6 now
268  if(goodQual){
269  //nicely peaking TT in BCID+1
270  good3Counter++;
271  ttPulseCategory = 5;
272  }
273  else{
274  //badly peaking TT in BCID+1
275  bad3Counter++;
276  ttPulseCategory = 6;
277  }
278  }
279  else{
280  //TT peaking in BCID-1,-2 or +2
281  badCounter++;
282  ttPulseCategory = 2;
283  }
284  }
285 
286  // decorate the TT in order to have to recompute the pulse categorisation
287  xAOD::TriggerTower* newTT = new xAOD::TriggerTower; //create a new TT object
288  ttContainer->push_back(newTT); // add the newTT to new output TT container (at the end of it)
289  *newTT = *(tt);// copy over all information from TT to newTT
290  pulseClassificationAcc(*newTT) = ttPulseCategory; //decorate
291  }
292 
293  // count all eFex in-time and out-of-time TOBs with at least 5GeV
294  for(auto key : {"L1_eEMxRoI","L1_eEMxRoIOutOfTime"}) {
295 
296  const xAOD::eFexEMRoIContainer* emTobs;
297  CHECK( evtStore()->retrieve( emTobs, key ) );
298 
299  for(auto tob : *emTobs) {
300  if (tob->et() > 5000) { //eFex TOB energy in MeV
301  if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
302  eFexintimeCounter++;
303  }
304  else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
305  eFexoutoftimeCounter++;
306  }
307  }
308  }
309 
310  }
311 
312  // count all gFex in-time TOBs with at least 5GeV
313  const xAOD::gFexJetRoIContainer* gFexLRJetRoI;
314  CHECK( evtStore()->retrieve( gFexLRJetRoI, "L1_gFexLRJetRoI" ) );
315  for(auto tob : *gFexLRJetRoI) {
316  if (tob->et() > 50) { //gFex TOB energy in 0.1GeV
317  gFexCounter++;
318  }
319  }
320 
321  // count all jFex in-time TOBs with at least 5GeV
322  const xAOD::jFexSRJetRoIContainer* jFexJetRoI;
323  CHECK( evtStore()->retrieve( jFexJetRoI, "L1_jFexSRJetRoI" ) );
324  for(auto tob : *jFexJetRoI) {
325  if (tob->et() > 25) { //jFex TOB energy in 0.2GeV
326  jFexCounter++;
327  }
328  }
329 
330  if(badCounter > 4){
331  //reject events with more than 4 wrongly peaked towers
332  return StatusCode::SUCCESS;
333  }
334  cutFlowX=badpeakTT;
335  fill(m_packageName,cutFlowX);
336 
337  if(bad2Counter > 4){
338  //reject events with more than 4 pulses peaking in slice 2 that are badly timed or mis-shapen
339  return StatusCode::SUCCESS;
340  }
341  cutFlowX=badCentralTT;
342  fill(m_packageName,cutFlowX);
343 
344  if(bad3Counter > 4){
345  //reject events with more than 4 pulses peaking in slice 3 that are badly timed or mis-shapen
346  return StatusCode::SUCCESS;
347  }
348  cutFlowX=badLateTT;
349  fill(m_packageName,cutFlowX);
350 
351  if( (good3Counter < 2) or ((trigger == "eFex") and (eFexoutoftimeCounter < 2)) ){
352  //reject events with less than 2 pulses nicely peaking in slice 3
353  return StatusCode::SUCCESS;
354  }
355  cutFlowX=lateTT;
356  fill(m_packageName,cutFlowX);
357 
358  if( (good2Counter > 3) or
359  ((trigger == "eFex") and (eFexintimeCounter > 3)) or
360  ((trigger == "jFex") and (jFexCounter > 3)) or
361  ((trigger == "gFex") and (gFexCounter > 3)) ){
362  //reject events with more than 3 pulses nicely peaking/ 3 TOBs in slice 2 to avoid event being triggered by pileup
363  return StatusCode::SUCCESS;
364  }
365  cutFlowX= InTime;
366  fill(m_packageName,cutFlowX);
367 
368  if(!emActivityCounter){
369  //reject events with no activity in the EM layer
370  return StatusCode::SUCCESS;
371  }
372  cutFlowX= TTEMLayer;
373  fill(m_packageName,cutFlowX);
374 
375  double dEta = 0., dPhi = 0., dPhi1 = 0., dR = 0.;
376  double etaIn = 0., phiIn = 0;
377  double etaOut = 0., phiOut = 0;
378  bool overlap = false;
379 
380  if (trigger == "eFex") {
381  const xAOD::eFexEMRoIContainer* emTobs;
382  CHECK( evtStore()->retrieve( emTobs, "L1_eEMxRoI" ) );
383  const xAOD::eFexEMRoIContainer* emTobsOut;
384  CHECK( evtStore()->retrieve( emTobsOut, "L1_eEMxRoIOutOfTime" ) );
385 
386  for(auto tob : *emTobs) {
387  etaIn = tob->eta();
388  phiIn = tob->phi();
389 
390  for(auto tobOut : *emTobsOut) {
391  etaOut = tobOut->eta();
392  phiOut = tobOut->phi();
393  dEta = std::abs(etaIn-etaOut);
394  dPhi = std::abs(phiIn-phiOut);
395  if ((phiIn < 0) and (phiOut > 0)){
396  dPhi1 = std::abs((phiIn+2*M_PI)-phiOut);
397  if (dPhi1 < dPhi) {
398  dPhi = dPhi1;
399  }
400  }
401  else if ((phiIn > 0) and (phiOut < 0)){
402  dPhi1 = std::abs(phiIn-(phiOut+2*M_PI));
403  if (dPhi1 < dPhi) {
404  dPhi = dPhi1;
405  }
406  }
407  dR = TMath::Sqrt(dEta*dEta+dPhi*dPhi);
408  if ((dR < .2) ){
409  overlap = true;
410  }
411  }
412  }
413  }
414 
416  if(!jFexSRJetContainer.isValid()) {
417  ATH_MSG_WARNING("No jFex SR Jet container found in storegate "<< m_jFexSRJetContainerKey<<". Will be skipped!");
418  }
419 
420  if (trigger == "jFex") {
422  CHECK( evtStore()->retrieve( jFexSRJetRoI, "L1_jFexSRJetRoI" ) );
423  for(auto tob : *jFexSRJetRoI) {
424  etaIn = tob->eta();
425  phiIn = tob->phi();
426 
427  for (const xAOD::TriggerTower* tt : *triggerTowerTES) {
428  const std::vector<uint16_t>& ttADC = (tt)->adc();
429  std::vector<uint16_t> readoutCorrectedADC; //this is the standard readout ADC vector: 5 40MHz samples with l1A in the middle
430  if(!readout80ModePpm){//40 MHz
431  //just acess the acd vector, as the sanity checks where done above
432  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
433  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
434  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
435  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
436  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
437  }
438 
439  // retrieve max ADC value and position, this seems to be buggy in the DAOD
440  auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
441  int adcPeakPositon = std::distance(std::begin(readoutCorrectedADC), maxValIterator);
442  bool goodQual = pulseQuality(readoutCorrectedADC, adcPeakPositon);
443 
444  if( (adcPeakPositon == 3) and (goodQual) ) {
445  etaOut = tt->eta();
446  phiOut = tt->phi()-M_PI;
447  dEta = std::abs(etaIn-etaOut);
448  dPhi = std::abs(phiIn-phiOut);
449  if ((phiIn < 0) and (phiOut > 0)){
450  dPhi1 = std::abs((phiIn+2*M_PI)-phiOut);
451  if (dPhi1 < dPhi) {
452  dPhi = dPhi1;
453  }
454  }
455  else if ((phiIn > 0) and (phiOut < 0)){
456  dPhi1 = std::abs(phiIn-(phiOut+2*M_PI));
457  if (dPhi1 < dPhi) {
458  dPhi = dPhi1;
459  }
460  }
461  dR = TMath::Sqrt(dEta*dEta+dPhi*dPhi);
462  if (dR < .2) {
463  overlap = true;
464  }
465  }
466  }
467  }
468  }
469 
470  if (trigger == "gFex") {
471 
472  for (const auto& key : m_gFexJetTobKeyList){
474  // Check that this container is present
475  if ( !jetContainer.isValid() ) {
476  ATH_MSG_WARNING("No gFex jet container found in storegate: "<< key.key());
477  }
478  else {
480  CHECK( evtStore()->retrieve( gFexJetRoI, key.key() ) );
481  for(auto tob : *gFexJetRoI) {
482  etaIn = tob->eta();
483  phiIn = tob->phi();
484 
485  for (const xAOD::TriggerTower* tt : *triggerTowerTES) {
486  const std::vector<uint16_t>& ttADC = (tt)->adc();
487  std::vector<uint16_t> readoutCorrectedADC; //this is the standard readout ADC vector: 5 40MHz samples with l1A in the middle
488  if(!readout80ModePpm){//40 MHz
489  //just acess the acd vector, as the sanity checks where done above
490  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-2));
491  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice-1));
492  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice));
493  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+1));
494  readoutCorrectedADC.push_back(ttADC.at(l1aFadcSlice+2));
495  }
496 
497  // retrieve max ADC value and position, this seems to be buggy in the DAOD
498  auto maxValIterator = std::max_element(readoutCorrectedADC.begin(), readoutCorrectedADC.end());
499  int adcPeakPositon = std::distance(std::begin(readoutCorrectedADC), maxValIterator);
500  bool goodQual = pulseQuality(readoutCorrectedADC, adcPeakPositon);
501 
502  if( (adcPeakPositon == 3) and (goodQual) ) {
503  etaOut = tt->eta();
504  phiOut = tt->phi()-M_PI;
505  dEta = std::abs(etaIn-etaOut);
506  dPhi = std::abs(phiIn-phiOut);
507  if ((phiIn < 0) and (phiOut > 0)){
508  dPhi1 = std::abs((phiIn+2*M_PI)-phiOut);
509  if (dPhi1 < dPhi) {
510  dPhi = dPhi1;
511  }
512  }
513  else if ((phiIn > 0) and (phiOut < 0)){
514  dPhi1 = std::abs(phiIn-(phiOut+2*M_PI));
515  if (dPhi1 < dPhi) {
516  dPhi = dPhi1;
517  }
518  }
519  dR = TMath::Sqrt(dEta*dEta+dPhi*dPhi);
520  if (dR < .2) {
521  overlap = true;
522  }
523  }
524  }
525  }
526  }
527  }
528  }
529 
530  if(overlap==false){
531  //reject events where BCID and BCID+1 are spatially separated
532  return StatusCode::SUCCESS;
533  }
534  cutFlowX= EtaPhiOverlap;
535  fill(m_packageName,cutFlowX);
536 
537 
538  // scope for mutable error event per lumi block tt counter
539  // it allows only one event per lumiblock
540  std::lock_guard<std::mutex> lock(m_mutex);
541  m_event_counter[lumiNo]+=1;
542  const int eventCounter = m_eventCounter++;
543 
544  if( (m_event_counter[lumiNo] <m_maxEvents) && (eventCounter < m_maxEvents) ){
545  ATH_MSG_DEBUG( "EventID :: " << m_event_counter[lumiNo]);
546 
547  // Saving the lumiblock and event number of the events with mistimed
548  auto eventMonitor_legacy= Monitored::Scalar<std::string>("eventMonitor_legacy", "Event"+std::to_string(eventCounter)+"="+std::to_string(currentEventNo));
549  auto eventMonitor_phaseI= Monitored::Scalar<std::string>("eventMonitor_phaseI", "Event"+std::to_string(eventCounter)+"_"+trigger+"="+std::to_string(currentEventNo));
550  auto lbMonitor= Monitored::Scalar<std::string>("lbMonitor", std::to_string(lumiNo));
551  std::string groupName = "Event_";
552  if (trigger == "legacy") {
553  fill(groupName, eventMonitor_legacy, lbMonitor );
554  }
555  else {
556  fill(groupName, eventMonitor_phaseI, lbMonitor );
557  }
558 
559  // Create a vector of trigger towers with quantities to be monitored
560  std::vector<MonitorTT> vecMonTTDecor; // All towers
561 
562  // Loop over trigger tower container
563  //Create the trigger tower objects and calculate scaled phi
564  for (const xAOD::TriggerTower* tt : *ttContainer) {
565  ATH_CHECK( makeTowerPPM(tt, vecMonTTDecor) );
566  ATH_MSG_DEBUG( "tt->pulseClassification :: " << pulseClassificationAcc(*tt));
567  }
568 
569  groupName = "EventofInterest_" + std::to_string(eventCounter) + "_";
570  auto bcidWord = Monitored::Scalar<uint8_t>("bcidWord", 0);
571  auto pulseCat = Monitored::Scalar<float>("pulseCat", 0);
572 
573  for (auto& myTower : vecMonTTDecor) {
574  ATH_MSG_DEBUG(" looping over TTs");
575  const int layer = (myTower.tower)->layer();
576  pulseCat = pulseClassificationAcc(*myTower.tower);
577  bcidWord = (myTower.tower)->bcidVec()[0]; // look at the status bit in the central time slice
578  ATH_MSG_DEBUG("groupName :: " << groupName);
579 
580  // Check if TT is in EM or HAD layer:
581  if (layer == 0) { //========== ELECTROMAGNETIC LAYER =========================
582  ATH_CHECK( fillPPMEtaPhi(myTower, groupName+"TT_EM", "pulseCat", pulseCat) );
583  if(pulseCat > 0.5 && bcidWord > 0) {
584  ATH_CHECK( fillPPMEtaPhi(myTower, groupName+"TT_EM", "bcidWord", bcidWord) );
585  }
586  }
587  else if(layer == 1 ) { //========== HADRONIC LAYER ===============================
588  ATH_CHECK( fillPPMEtaPhi(myTower, groupName+"TT_HAD", "pulseCat", pulseCat) );
589  if(pulseCat > 0.5 && bcidWord > 0 ) ATH_CHECK( fillPPMEtaPhi(myTower, groupName+"TT_HAD", "bcidWord", bcidWord) );
590  }
591  }
592 
593  //Loop over CPM tower container
594  //Create the CPM objects and calculate scaled phi
595  std::vector<MonitorCPM> vecMonCPM; // All towers
596  for (const xAOD::CPMTower* cpm : *cpmTowerTES) {
597  ATH_CHECK( makeTowerCPM(cpm, vecMonCPM) );
598  }
599 
600  // Coordinates for CPM tower and JetElement containers
601  auto etalut = Monitored::Scalar<double>("etalut", 0);
602  auto philut = Monitored::Scalar<double>("philut", 0);
603 
604  // lut variables
605  auto emLUT0 = Monitored::Scalar<int>("emLUT0", 0);
606  auto emLUT1 = Monitored::Scalar<int>("emLUT1", 0);
607  auto emLUT2 = Monitored::Scalar<int>("emLUT2", 0);
608  auto hadLUT0 = Monitored::Scalar<int>("hadLUT0", 0);
609  auto hadLUT1 = Monitored::Scalar<int>("hadLUT1", 0);
610  auto hadLUT2 = Monitored::Scalar<int>("hadLUT2", 0);
611 
612  //loop over the cpm tower container to fill the lut histos
613  for (auto& myTower : vecMonCPM) {
614 
615  std::vector<uint8_t> cpmEMenergy = (myTower.tower)->emEnergyVec();
616  std::vector<uint8_t> cpmHADenergy = (myTower.tower)->hadEnergyVec();
617  // eta scaled
618  etalut = myTower.etaScaled;
619 
620  for (auto phi: myTower.phiScaled) {
621  // phi scaled
622  philut = phi;
623 
624  if(cpmEMenergy.size() > 2){ // expect 3 slices to be read out
625  ATH_MSG_DEBUG("CPM :: emLUT0 :: " << static_cast<unsigned>(cpmEMenergy.at(0)) << ":: emLUT1 :: " << static_cast<unsigned>(cpmEMenergy.at(1)) << ":: emLUT2 :: " << static_cast<unsigned>(cpmEMenergy.at(2)));
626 
627  emLUT0 = static_cast<int>(cpmEMenergy.at(0));
628  if(cpmEMenergy.at(0) > 0) fill(groupName+"lut_EM0",etalut,philut, emLUT0);
629 
630  emLUT1 = static_cast<int>(cpmEMenergy.at(1));
631  if(cpmEMenergy.at(1) > 0) fill(groupName+"lut_EM1",etalut,philut, emLUT1);
632 
633  emLUT2 = static_cast<int>(cpmEMenergy.at(2));
634  if(cpmEMenergy.at(2) > 0) fill(groupName+"lut_EM2",etalut,philut, emLUT2);
635  }
636  if(cpmHADenergy.size() > 2){
637  ATH_MSG_DEBUG("CPM :: hadLUT0 :: " << static_cast<unsigned>(cpmHADenergy.at(0)) << ":: hadLUT1 :: " << static_cast<unsigned>(cpmHADenergy.at(1)) << ":: hadLUT2 :: " << static_cast<unsigned>(cpmHADenergy.at(2)));
638 
639  hadLUT0 = static_cast<int>(cpmHADenergy.at(0));
640  if(cpmHADenergy.at(0) > 0) fill(groupName+"lut_HAD0",etalut,philut, hadLUT0);
641  hadLUT1 = static_cast<int>(cpmHADenergy.at(1));
642  if(cpmHADenergy.at(1) > 0) fill(groupName+"lut_HAD1",etalut,philut, hadLUT1);
643  hadLUT2 = static_cast<int>(cpmHADenergy.at(2));
644  if(cpmHADenergy.at(2) > 0)fill(groupName+"lut_HAD2",etalut,philut, hadLUT2);
645  }
646  }
647  }
648 
649  std::vector<MonitorJE> vecMonJE; // All elements
650 
651  //Create the JetElement objects and calculate scaled phi
652  for (const xAOD::JetElement* je : *jetElementTES) {
653  ATH_CHECK( makeTowerJE(je, vecMonJE) );
654  }
655 
656  //loop over the jet element container to fill the lut histos
657  for (auto& jet : vecMonJE) {
658 
659  std::vector<uint16_t> jepEMenergy = (jet.element)->emJetElementETVec();
660  std::vector<uint16_t> jepHADenergy = (jet.element)->hadJetElementETVec();
661 
662  for (auto eta: jet.etaScaled) {
663  etalut = eta;
664  if ( std::abs(eta) > 2.5){
665  for (auto phi: jet.phiScaled) {
666  philut = phi;
667  if(jepEMenergy.size() > 2){
668  ATH_MSG_DEBUG("JetElement :: emLUT0 :: " << static_cast<unsigned>(jepEMenergy.at(0)) << ":: emLUT1 :: " << static_cast<unsigned>(jepEMenergy.at(1)) << ":: emLUT2 :: " << static_cast<unsigned>(jepEMenergy.at(2)));
669 
670  emLUT0 = static_cast<int>(jepEMenergy.at(0));
671  if(jepEMenergy.at(0) > 0) fill(groupName+"lut_EM0",etalut,philut, emLUT0);
672 
673  emLUT1 = static_cast<int>(jepEMenergy.at(1));
674  if(jepEMenergy.at(1) > 0) fill(groupName+"lut_EM1",etalut,philut, emLUT1);
675 
676  emLUT2 = static_cast<int>(jepEMenergy.at(2));
677  if(jepEMenergy.at(2) > 0) fill(groupName+"lut_EM2",etalut,philut, emLUT2);
678  }
679  if(jepHADenergy.size()> 2){
680  ATH_MSG_DEBUG("JetElement :: hadLUT0 :: " << static_cast<unsigned>(jepHADenergy.at(0)) << ":: hadLUT1 :: " << static_cast<unsigned>(jepHADenergy.at(1)) << ":: hadLUT2 :: " << static_cast<unsigned>(jepHADenergy.at(2)));
681 
682  hadLUT0 = static_cast<int>(jepHADenergy.at(0));
683  if(jepHADenergy.at(0) > 0) fill(groupName+"lut_HAD0",etalut,philut, hadLUT0);
684 
685  hadLUT1 = static_cast<int>(jepHADenergy.at(1));
686  if(jepHADenergy.at(1) > 0) fill(groupName+"lut_HAD1",etalut,philut, hadLUT1);
687 
688  hadLUT2 = static_cast<int>(jepHADenergy.at(2));
689  if(jepHADenergy.at(2) > 0) fill(groupName+"lut_HAD2",etalut,philut, hadLUT2);
690  }
691  }
692  }
693  }
694  }
695 
697  if ( !eFexContainer.isValid() ) {
698  ATH_MSG_WARNING("No eFex EM container found in storegate "<< eFexContainer.key());
699  }
700 
701  // monitored variables for histograms
702  auto TOBeT = Monitored::Scalar<float>("TOBTransverseEnergy",0.0);
703  auto TOBeta = Monitored::Scalar<float>("TOBEta",0.0);
704  auto TOBphi = Monitored::Scalar<float>("TOBPhi",0.0);
705  auto TOBeT_max = Monitored::Scalar<float>("TOBTransverseEnergy_max",0.0);
706  auto TOBeta_max = Monitored::Scalar<float>("TOBEta_max",0.0);
707  auto TOBphi_max = Monitored::Scalar<float>("TOBPhi_max",0.0);
708  auto TOBeT_max_in = Monitored::Scalar<float>("TOBTransverseEnergy_max",0.0);
709  auto TOBeta_max_in = Monitored::Scalar<float>("TOBEta_max",0.0);
710  auto TOBphi_max_in = Monitored::Scalar<float>("TOBPhi_max",0.0);
711 
712  TOBeT_max = 0;
713  TOBeT_max_in = 0;
714 
715  for(auto key : {"L1_eEMxRoI","L1_eEMxRoIOutOfTime"}) {
716 
717  const xAOD::eFexEMRoIContainer* emTobs;
718  CHECK( evtStore()->retrieve( emTobs, key ) );
719 
720  for(auto tob : *emTobs) {
721  TOBeT = tob->et()/1000; //eT in GeV
722  TOBeta = tob->eta();
723 
724  // adjust the phi to 0 to 2 pi
725  if (tob->phi() < 0) {
726  TOBphi = tob->phi()+2*M_PI;
727  }
728  else {
729  TOBphi = tob->phi();
730  }
731 
732  // fill the eFex histograms in the right time slice
733  if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())-1) & 0xf )) {
734  if (TOBeT > 0.0){
735  fill(groupName+"Efex0", TOBeta, TOBphi, TOBeT);
736  }
737  }
738  else if (tob->bcn4() == ((ctx.eventID().bunch_crossing_id()) & 0xf )) {
739  if (TOBeT > 0.0){
740  if (TOBeT_max_in < TOBeT) {
741  TOBeT_max_in = tob->et()/1000;
742  TOBeta_max_in = tob->eta();
743  if (tob->phi() < 0) {
744  TOBphi_max_in = tob->phi()+2*M_PI;
745  }
746  else {
747  TOBphi_max_in = tob->phi();
748  }
749  }
750  fill(groupName+"Efex1", TOBeta, TOBphi, TOBeT);
751  if (trigger == "eFex") {
752  fill("Efex_maxTOB_in", TOBeT);
753  }
754  }
755  }
756  else if (tob->bcn4() == (((ctx.eventID().bunch_crossing_id())+1) & 0xf )) {
757  if (TOBeT > 0.0){
758  if (TOBeT_max < TOBeT) {
759  TOBeT_max = tob->et()/1000;
760  TOBeta_max = tob->eta();
761  if (tob->phi() < 0) {
762  TOBphi_max = tob->phi()+2*M_PI;
763  }
764  else {
765  TOBphi_max = tob->phi();
766  }
767  }
768  fill(groupName+"Efex2", TOBeta, TOBphi, TOBeT);
769  if (trigger == "eFex") {
770  fill("Efex_maxTOB_out", TOBeT);
771  }
772  }
773  }
774  }
775  }
776  if (trigger == "eFex") {
777  fill("Efex_maxTOB_out", TOBeta_max, TOBphi_max);
778  fill("Efex_maxTOB_in", TOBeta_max_in, TOBphi_max_in);
779  }
780 
781  // variables for histograms
782  auto jFexEt = Monitored::Scalar<int> ("jFexEt",0);
783  auto jFexeta = Monitored::Scalar<float>("jFexEta",0.0);
784  auto jFexphi = Monitored::Scalar<float>("jFexPhi",0.0);
785 
786  // Access jFex tower container
788  if(!jFexTowerContainer.isValid()) {
789  ATH_MSG_WARNING("No jFex Tower container valid in storegate with key: "<< m_jFexDataTowerKey<<". Will be skipped!");
790  }
791 
792  //SG::ReadHandle<xAOD::jFexTowerContainer> jFexEmulatedTowerContainer{m_jFexEmulatedTowerKey, ctx};
793  SG::ReadHandle<xAOD::jFexTowerContainer> jEmulatedTowerContainer;
794  jEmulatedTowerContainer = SG::ReadHandle<xAOD::jFexTowerContainer>(m_EmulTowerKey,ctx);
795  if(!jEmulatedTowerContainer.isValid()) {
796  ATH_MSG_WARNING("No jFex Tower container valid in storegate with key: "<< jEmulatedTowerContainer.key()<<". Will be skipped!");
797  }
798  else {
799  for(const xAOD::jFexTower* emulTower : *jEmulatedTowerContainer) {
800  jFexEt=emulTower->et_count().at(0);
801  //Adding 1e-5 for plotting style
802  jFexeta=emulTower->eta()+1e-5;
803  if (emulTower->phi() < 0) {
804  jFexphi=emulTower->phi()+2*M_PI;
805  }
806  else {
807  jFexphi=emulTower->phi();
808  }
809  if (jFexEt > 175) {
810  fill(groupName+"JfexEmulated",jFexeta,jFexphi, jFexEt);
811  }
812  }
813  }
814 
815  TOBeT_max = 0;
816  for(const xAOD::jFexSRJetRoI* jFexSRJetRoI : *jFexSRJetContainer) {
817  if(jFexSRJetRoI->tobWord()==0) continue; //remove empty TOBs
818  jFexEt=jFexSRJetRoI->tobEt()/5;
819  jFexeta=jFexSRJetRoI->eta();
820  if (jFexSRJetRoI->phi() < 0) {
821  jFexphi=jFexSRJetRoI->phi()+2*M_PI;
822  }
823  else {
824  jFexphi=jFexSRJetRoI->phi();
825  }
826  if (TOBeT_max < jFexEt) {
827  TOBeT_max = jFexSRJetRoI->tobEt()/5;
828  TOBeta_max = jFexSRJetRoI->eta();
829  if (jFexSRJetRoI->phi() < 0) {
830  TOBphi_max =jFexSRJetRoI->phi()+2*M_PI;
831  }
832  else {
833  TOBphi_max =jFexSRJetRoI->phi();
834  }
835  }
836  fill(groupName+"JfexSRJet", jFexeta, jFexphi, jFexEt);
837  if (trigger == "jFex") {
838  fill("Jfex_maxTOB", jFexEt);
839  }
840  }
841  if (trigger == "jFex") {
842  fill("Jfex_maxTOB", TOBeta_max, TOBphi_max);
843  }
844 
846  if(!jFexTauContainer.isValid()) {
847  ATH_MSG_WARNING("No jFex Tau container found in storegate "<< m_jFexTauContainerKey<<". Will be skipped!");
848  }
849  else {
850  for(const xAOD::jFexTauRoI* jFexTauRoI : *jFexTauContainer) {
851  if(jFexTauRoI->tobWord()==0) continue; //remove empty TOBs
852  jFexEt =jFexTauRoI->tobEt()/5;
853  jFexeta=jFexTauRoI->eta();
854  if (jFexTauRoI->phi() < 0) {
855  jFexphi=jFexTauRoI->phi()+2*M_PI;
856  }
857  else {
858  jFexphi=jFexTauRoI->phi();
859  }
860  fill(groupName+"JfexTau", jFexeta, jFexphi, jFexEt);
861  }
862  }
863 
864  auto gFexEt = Monitored::Scalar<int> ("gFexEt",0);
865  auto gFexEta = Monitored::Scalar<float>("gFexEta",0.0);
866  auto gFexPhi = Monitored::Scalar<float>("gFexPhi",0.0);
867  int key_index = 0;
868 
869  TOBeT_max = 0;
870  // Small-R and large-R jets container loop
871  for (const auto& key : m_gFexJetTobKeyList){
873  // Check that this container is present
874  if ( !jetContainer.isValid() ) {
875  ATH_MSG_WARNING("No gFex jet container found in storegate: "<< key.key());
876  }
877  else {
879  gFexEt =gFexJetRoIContainer->gFexTobEt()/10;
880  gFexEta=gFexJetRoIContainer->eta();
881  if (gFexJetRoIContainer->phi() < 0) {
882  gFexPhi=gFexJetRoIContainer->phi()+2*M_PI;
883  }
884  else {
885  gFexPhi=gFexJetRoIContainer->phi();
886  }
887  if (TOBeT_max < gFexEt) {
888  TOBeT_max = gFexJetRoIContainer->gFexTobEt()/10;
889  TOBeta_max = gFexJetRoIContainer->eta();
890  if (gFexJetRoIContainer->phi() < 0) {
891  TOBphi_max=gFexJetRoIContainer->phi()+2*M_PI;
892  }
893  else {
894  TOBphi_max=gFexJetRoIContainer->phi();
895  }
896  }
897  if (key_index == 0) {
898  fill(groupName+"GfexSRJet",gFexEta, gFexPhi, gFexEt);
899  }
900  else if (key_index == 1) {
901  fill(groupName+"GfexLRJet",gFexEta, gFexPhi, gFexEt);
902  }
903  if (trigger == "gFex") {
904  fill("Gfex_maxTOB", gFexEt);
905  }
906  }
907  }
908  key_index++;
909  }
910  if (trigger == "gFex") {
911  fill("Gfex_maxTOB", TOBeta_max, TOBphi_max);
912  }
913 
914  }
915  else {
916  auto eventMonitor_all_legacy= Monitored::Scalar<std::string>("eventMonitor_all_legacy", std::to_string(currentEventNo));
917  auto eventMonitor_all_phaseI= Monitored::Scalar<std::string>("eventMonitor_all_phaseI", trigger+"="+std::to_string(currentEventNo));
918  auto lbMonitor_all= Monitored::Scalar<std::string>("lbMonitor_all", std::to_string(lumiNo));
919  if (trigger == "legacy") {
920  fill("Event_all_", eventMonitor_all_legacy, lbMonitor_all );
921  }
922  else {
923  fill("Event_all_", eventMonitor_all_phaseI, lbMonitor_all );
924  }
925  }
926 
927  return StatusCode::SUCCESS;
928 }
929 
930 
932  std::vector<MonitorTT> &vecMonTT) const
933 {
934  // Geometry
935  const double phi = tt->phi();
936  double phiMod = phi * m_phiScaleTT;
937 
938 
939 
940  // Fill TT quantities
941  MonitorTT monTT;
942  monTT.tower = tt;
943  monTT.phiScaled = phiMod;
944  monTT.phi1d = 0;
945  vecMonTT.push_back(monTT);
946 
947  return StatusCode::SUCCESS;
948 }
949 
950 
952  std::vector<MonitorCPM> &vecMonCPM) const
953 {
954  // Geometry
955  const double phi = cpm->phi();
956  double phiMod = phi * m_phiScaleTT;
957 
958 
959  // Fill CPM quantities
960  MonitorCPM monCPM;
961  monCPM.tower = cpm;
962 
963  double etaMod = monCPM.tower->eta();
964  const double absEta = std::abs(etaMod);
965 
966  const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
967  const std::vector<double> offset25 = {0.5, -0.5};
968  std::vector<double> offset = {};
969 
970  if (absEta > 3.2) {
971  // Fill four bins in phi
972  phiMod = std::floor(phiMod/4)*4. + 2.;
973  offset = offset32;
974  }
975  else if (absEta > 2.5) {
976  // Fill two bins in phi
977  phiMod = std::floor(phiMod/2)*2. + 1.;
978  offset = offset25;
979  }
980  else {
981  offset = {0.};
982  }
983 
984 
985 
986  // Fill the histograms
987  for (auto phiOffset : offset) {
988  monCPM.phiScaled.push_back(phiMod + phiOffset);
989  }
990 
991  monCPM.etaScaled = etaMod;
992 
993 
994  vecMonCPM.push_back(monCPM);
995 
996  return StatusCode::SUCCESS;
997 }
998 
1000  std::vector<MonitorJE> &vecMonJE) const
1001 {
1002 
1003  // Use JEP info to fill the forward part of the lut plots, but since this has TT granularity we have to play some tricks
1004 
1005  // Geometry
1006  const double phi = je->phi();
1007  double phiMod = phi * m_phiScaleTT;
1008 
1009  // Fill JE quantities
1010  MonitorJE monJE;
1011  monJE.element = je;
1012 
1013  double etaMod = monJE.element->eta();
1014  const double absEta = std::abs(etaMod);
1015  int signeta = 1;
1016  if( etaMod < 0) signeta = -1;
1017 
1018 
1019  const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1020  const std::vector<double> offset25 = {0.5, -0.5};
1021  std::vector<double> offset = {};
1022 
1023  if (absEta > 3.2) {
1024  // Fill four bins in phi
1025  phiMod = std::floor(phiMod/4)*4. + 2.;
1026  offset = offset32;
1027  monJE.etaScaled.push_back(signeta*4.7);
1028  monJE.etaScaled.push_back(signeta*3.7);
1029  monJE.etaScaled.push_back(signeta*3.5);
1030 
1031  }
1032  else if(absEta > 2.9) {
1033  phiMod = std::floor(phiMod/2)*2. + 1.;
1034  offset = offset25;
1035  monJE.etaScaled.push_back(signeta*3.15);
1036  }
1037 
1038 
1039  if (absEta > 2.5) {
1040  // Fill two bins in phi
1041  phiMod = std::floor(phiMod/2)*2. + 1.;
1042  offset = offset25;
1043  monJE.etaScaled.push_back(etaMod);
1044  }
1045  else {
1046  offset = {0.};
1047  monJE.etaScaled.push_back(etaMod);
1048  }
1049 
1050 
1051  // Fill the histograms
1052  for (auto phiOffset : offset) {
1053  monJE.phiScaled.push_back(phiMod + phiOffset);
1054  }
1055 
1056  vecMonJE.push_back(monJE);
1057 
1058  return StatusCode::SUCCESS;
1059 }
1060 
1061 
1063  const std::string& groupName,
1064  const std::string& weightName,
1065  double weight) const {
1066 
1067 
1068  double phiMod = monTT.phiScaled; // Integer binning for 2D plots
1069  double etaMod = monTT.tower->eta();
1070  const double absEta = std::abs(etaMod);
1071 
1072  const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
1073  const std::vector<double> offset25 = {0.5, -0.5};
1074  std::vector<double> offset = {};
1075 
1076  if (absEta > 3.2) {
1077  // Fill four bins in phi
1078  phiMod = std::floor(phiMod/4)*4. + 2.;
1079  offset = offset32;
1080  }
1081  else if (absEta > 2.5) {
1082  // Fill two bins in phi
1083  phiMod = std::floor(phiMod/2)*2. + 1.;
1084  offset = offset25;
1085  }
1086  else {
1087  offset = {0.};
1088  }
1089 
1090  ATH_MSG_DEBUG("absEta: " << absEta << "offset.size(): " << offset.size());
1091 
1092  // Fill the histograms
1093  for (auto phiOffset : offset) {
1094 
1095  auto etaTT_2D = Monitored::Scalar<double>("etaTT_2D", etaMod);
1096  auto phiTT_2D = Monitored::Scalar<double>("phiTT_2D", phiMod + phiOffset);
1097 
1098  auto weight_2D = Monitored::Scalar<double>(weightName, weight); // Weight for filling 2D profile histograms; name must be included in python histogram definition
1099  ATH_MSG_DEBUG("groupName: weight_2D" << weight_2D);
1100 
1101  fill(groupName, etaTT_2D, phiTT_2D, weight_2D);
1102 
1103  }
1104 
1105  return StatusCode::SUCCESS;
1106 }
1107 
1108 
1109 bool MistimedStreamMonitorAlgorithm::pulseQuality(const std::vector<uint16_t>& ttPulse, int peakSlice) const {
1110 
1111  bool goodPulse = true;
1112  int size = ttPulse.size();
1113  if (peakSlice > size) {
1114  ATH_MSG_ERROR("Peak Slice " << peakSlice << " supress the ttPulse vector size " << size );
1115  }
1116 
1117  int a = ttPulse[peakSlice-1];
1118  int b = ttPulse[peakSlice];
1119  int c = ttPulse[peakSlice+1];
1120  double tim = (0.5*a-0.5*c)/(a+c-2*b);
1121  double wid = (a+c-64.0)/(b-32.0);
1122  if ( tim < 0.0 ) goodPulse = false;
1123  else if ( tim > 0.3 ) goodPulse = false;
1124  if ( wid < 1.0 ) goodPulse = false;
1125  else if ( wid > 1.6 ) goodPulse = false;
1126 
1127  ATH_MSG_DEBUG("Pulse qual= "<< goodPulse<<" tim = "<<tim<<" wid = "<<wid);
1128  ATH_MSG_DEBUG("a = "<< a <<" b = "<<b<<" c = "<<c);
1129 
1130  return goodPulse;
1131 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
MistimedStreamMonitorAlgorithm::m_maxEvents
Gaudi::Property< int > m_maxEvents
Definition: MistimedStreamMonitorAlgorithm.h:142
MistimedStreamMonitorAlgorithm.h
L1CaloReadoutConfigJSON::l1aFadcSlice
unsigned int l1aFadcSlice() const
Definition: L1CaloReadoutConfigJSON.h:21
xAOD::jFexTauRoI_v1
Class describing properties of a LVL1 jFEX global Trigger Object (TOB) in the xAOD format.
Definition: jFexTauRoI_v1.h:22
xAOD::jFexSRJetRoI_v1
Class describing properties of a LVL1 jFEX global Trigger Object (TOB) in the xAOD format.
Definition: jFexSRJetRoI_v1.h:22
MistimedStreamMonitorAlgorithm::badpeakTT
@ badpeakTT
Definition: MistimedStreamMonitorAlgorithm.h:156
MistimedStreamMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: MistimedStreamMonitorAlgorithm.cxx:55
MistimedStreamMonitorAlgorithm::MistimedStreamMonitorAlgorithm
MistimedStreamMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MistimedStreamMonitorAlgorithm.cxx:12
xAOD::CPMTower_v2::phi
float phi() const
get phi (note that for L1Calo phi runs from 0 to 2pi)
MistimedStreamMonitorAlgorithm::m_mutex
std::mutex m_mutex
Definition: MistimedStreamMonitorAlgorithm.h:147
MistimedStreamMonitorAlgorithm::m_ttTool
ToolHandle< LVL1::IL1TriggerTowerToolRun3 > m_ttTool
Definition: MistimedStreamMonitorAlgorithm.h:116
xAOD::jFexTauRoI_v1::eta
float eta() const
MistimedStreamMonitorAlgorithm::MonitorJE::element
const xAOD::JetElement * element
Definition: MistimedStreamMonitorAlgorithm.h:77
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MistimedStreamMonitorAlgorithm::m_eFexTauContainerKey
SG::ReadHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauContainerKey
Definition: MistimedStreamMonitorAlgorithm.h:102
SG::Accessor< float >
MistimedStreamMonitorAlgorithm::MonitorJE::etaScaled
std::vector< double > etaScaled
Definition: MistimedStreamMonitorAlgorithm.h:79
L1CaloReadoutConfigContainerJSON::readoutConfigJSON
const L1CaloReadoutConfigJSON * readoutConfigJSON(unsigned int channelId) const
Definition: L1CaloReadoutConfigContainerJSON.cxx:237
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MistimedStreamMonitorAlgorithm::EtaPhiOverlap
@ EtaPhiOverlap
Definition: MistimedStreamMonitorAlgorithm.h:162
xAOD::CPMTower_v2::eta
float eta() const
get eta
xAOD::JetElement_v2
Description of JetElement_v2.
Definition: JetElement_v2.h:26
RunTileMonitoring.groupName
groupName
Definition: RunTileMonitoring.py:158
MistimedStreamMonitorAlgorithm::lateTT
@ lateTT
Definition: MistimedStreamMonitorAlgorithm.h:159
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
M_PI
#define M_PI
Definition: ActiveFraction.h:11
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
xAOD::gFexJetRoIContainer
gFexJetRoIContainer_v1 gFexJetRoIContainer
Definition: gFexJetRoIContainer.h:15
MistimedStreamMonitorAlgorithm::m_runParametersContainer
SG::ReadCondHandleKey< L1CaloRunParametersContainer > m_runParametersContainer
Definition: MistimedStreamMonitorAlgorithm.h:122
MistimedStreamMonitorAlgorithm::TTEMLayer
@ TTEMLayer
Definition: MistimedStreamMonitorAlgorithm.h:161
xAOD::jFexTowerContainer
jFexTowerContainer_v1 jFexTowerContainer
Define the latest version of the TriggerTower container.
Definition: jFexTowerContainer.h:14
xAOD::jFexSRJetRoI_v1::eta
float eta() const
xAOD::jFexSRJetRoI_v1::phi
float phi() const
xAOD::jFexSRJetRoI_v1::tobWord
uint32_t tobWord() const
The "raw" 32-bit word describing the object candidate.
MistimedStreamMonitorAlgorithm::m_eFexEMContainerKey
SG::ReadHandleKey< xAOD::eFexEMRoIContainer > m_eFexEMContainerKey
Definition: MistimedStreamMonitorAlgorithm.h:101
xAOD::JetElement_v2::eta
float eta() const
get eta
MistimedStreamMonitorAlgorithm::m_gFexJetTobKeyList
SG::ReadHandleKeyArray< xAOD::gFexJetRoIContainer > m_gFexJetTobKeyList
Definition: MistimedStreamMonitorAlgorithm.h:114
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
MistimedStreamMonitorAlgorithm::badCentralTT
@ badCentralTT
Definition: MistimedStreamMonitorAlgorithm.h:157
MistimedStreamMonitorAlgorithm::MonitorTT
Struct to contain PPM trigger tower info.
Definition: MistimedStreamMonitorAlgorithm.h:61
MistimedStreamMonitorAlgorithm::MonitorTT::phi1d
double phi1d
phi for 2d maps with integer bins (taking into account granularity in eta)
Definition: MistimedStreamMonitorAlgorithm.h:64
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
MistimedStreamMonitorAlgorithm::MonitorCPM::tower
const xAOD::CPMTower * tower
Definition: MistimedStreamMonitorAlgorithm.h:69
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
L1CaloRunParametersContainer::runParameters
const L1CaloRunParameters * runParameters(unsigned int channelId) const
Definition: L1CaloRunParametersContainer.cxx:93
MistimedStreamMonitorAlgorithm::fillPPMEtaPhi
StatusCode fillPPMEtaPhi(MonitorTT &monTT, const std::string &groupName, const std::string &weightName, double weight) const
Definition: MistimedStreamMonitorAlgorithm.cxx:1062
xAOD::jFexTauRoI_v1::tobEt
uint16_t tobEt() const
MistimedStreamMonitorAlgorithm::All
@ All
Definition: MistimedStreamMonitorAlgorithm.h:152
MistimedStreamMonitorAlgorithm::L1_Trigger
@ L1_Trigger
Definition: MistimedStreamMonitorAlgorithm.h:155
L1CaloReadoutConfigJSON::numFadcSlices
unsigned int numFadcSlices() const
Definition: L1CaloReadoutConfigJSON.h:20
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
xAOD::gFexJetRoI_v1
Class describing properties of a LVL1 gFEX jet Trigger Object (TOB) in the xAOD format.
Definition: gFexJetRoI_v1.h:25
xAOD::jFexSRJetRoI_v1::tobEt
uint16_t tobEt() const
xAOD::TriggerTower_v2
Description of TriggerTower_v2.
Definition: TriggerTower_v2.h:49
xAOD::jFexTauRoI_v1::tobWord
uint32_t tobWord() const
The "raw" 32-bit word describing the object candidate.
MistimedStreamMonitorAlgorithm::m_xAODTriggerTowerContainerName
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_xAODTriggerTowerContainerName
container keys including steering parameter and description
Definition: MistimedStreamMonitorAlgorithm.h:95
MistimedStreamMonitorAlgorithm::makeTowerJE
StatusCode makeTowerJE(const xAOD::JetElement *je, std::vector< MonitorJE > &vecMonJE) const
Definition: MistimedStreamMonitorAlgorithm.cxx:999
xAOD::TriggerTower_v2::eta
virtual double eta() const final
The pseudorapidity ( ) of the particle.
Definition: TriggerTower_v2.cxx:210
MistimedStreamMonitorAlgorithm::MonitorTT::tower
const xAOD::TriggerTower * tower
Definition: MistimedStreamMonitorAlgorithm.h:62
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::jFexSRJetRoI
jFexSRJetRoI_v1 jFexSRJetRoI
Define the latest version of the jFexSRJetRoI class
Definition: jFexSRJetRoI.h:14
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::jFexTauRoI_v1::phi
float phi() const
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
MistimedStreamMonitorAlgorithm::badLateTT
@ badLateTT
Definition: MistimedStreamMonitorAlgorithm.h:158
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
MistimedStreamMonitorAlgorithm::m_trigDec
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
Definition: MistimedStreamMonitorAlgorithm.h:92
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
JetAnalysisAlgorithmsTest_EMTopo_eljob.jetContainer
string jetContainer
Definition: JetAnalysisAlgorithmsTest_EMTopo_eljob.py:36
MistimedStreamMonitorAlgorithm::m_packageName
StringProperty m_packageName
Definition: MistimedStreamMonitorAlgorithm.h:86
MistimedStreamMonitorAlgorithm::m_eventCounter
std::atomic< int > m_eventCounter
Definition: MistimedStreamMonitorAlgorithm.h:145
MistimedStreamMonitorAlgorithm::m_jFexSRJetContainerKey
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_jFexSRJetContainerKey
Definition: MistimedStreamMonitorAlgorithm.h:107
MistimedStreamMonitorAlgorithm::MonitorJE::phiScaled
std::vector< double > phiScaled
Definition: MistimedStreamMonitorAlgorithm.h:78
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MistimedStreamMonitorAlgorithm::m_jetElementLocation
SG::ReadHandleKey< xAOD::JetElementContainer > m_jetElementLocation
Definition: MistimedStreamMonitorAlgorithm.h:99
xAOD::gFexJetRoI
gFexJetRoI_v1 gFexJetRoI
Define the latest version of the gFexJetRoI class.
Definition: gFexJetRoI.h:16
MistimedStreamMonitorAlgorithm::m_EmulTowerKey
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_EmulTowerKey
Definition: MistimedStreamMonitorAlgorithm.h:111
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MistimedStreamMonitorAlgorithm::pulseQuality
bool pulseQuality(const std::vector< uint16_t > &ttPulse, int peakSlice) const
Definition: MistimedStreamMonitorAlgorithm.cxx:1109
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
MistimedStreamMonitorAlgorithm::makeTowerCPM
StatusCode makeTowerCPM(const xAOD::CPMTower *cpm, std::vector< MonitorCPM > &vecMonCPM) const
Definition: MistimedStreamMonitorAlgorithm.cxx:951
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
MistimedStreamMonitorAlgorithm::m_jFexDataTowerKey
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_jFexDataTowerKey
Definition: MistimedStreamMonitorAlgorithm.h:110
MistimedStreamMonitorAlgorithm::InTime
@ InTime
Definition: MistimedStreamMonitorAlgorithm.h:160
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
MistimedStreamMonitorAlgorithm::MonitorCPM::etaScaled
double etaScaled
Definition: MistimedStreamMonitorAlgorithm.h:71
MistimedStreamMonitorAlgorithm::MonitorCPM
Struct to contain CPM tower info.
Definition: MistimedStreamMonitorAlgorithm.h:68
a
TList * a
Definition: liststreamerinfos.cxx:10
MistimedStreamMonitorAlgorithm::m_eFexEMOutContainerKey
SG::ReadHandleKey< xAOD::eFexEMRoIContainer > m_eFexEMOutContainerKey
Definition: MistimedStreamMonitorAlgorithm.h:103
MistimedStreamMonitorAlgorithm::MonitorTT::phiScaled
double phiScaled
Definition: MistimedStreamMonitorAlgorithm.h:63
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
MistimedStreamMonitorAlgorithm::HLT_mistimemonj400
@ HLT_mistimemonj400
Definition: MistimedStreamMonitorAlgorithm.h:154
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MistimedStreamMonitorAlgorithm::MonitorJE
Struct to contain JE info.
Definition: MistimedStreamMonitorAlgorithm.h:76
MistimedStreamMonitorAlgorithm::m_jFexTauContainerKey
SG::ReadHandleKey< xAOD::jFexTauRoIContainer > m_jFexTauContainerKey
Definition: MistimedStreamMonitorAlgorithm.h:108
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:232
xAOD::jFexTauRoI
jFexTauRoI_v1 jFexTauRoI
Define the latest version of the jFexSRJetRoI class
Definition: jFexTauRoI.h:13
xAOD::JetElement_v2::phi
float phi() const
get phi (note that for L1Calo phi runs from 0 to 2pi)
MistimedStreamMonitorAlgorithm::m_jFexLRJetContainerKey
SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer > m_jFexLRJetContainerKey
Definition: MistimedStreamMonitorAlgorithm.h:106
MistimedStreamMonitorAlgorithm::m_cpmTowerLocation
SG::ReadHandleKey< xAOD::CPMTowerContainer > m_cpmTowerLocation
Definition: MistimedStreamMonitorAlgorithm.h:97
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
fillSCTHists.etaMod
etaMod
Definition: fillSCTHists.py:23
MistimedStreamMonitorAlgorithm::MonitorCPM::phiScaled
std::vector< double > phiScaled
Definition: MistimedStreamMonitorAlgorithm.h:70
xAOD::jFexTower_v1
Class describing input data of a LVL1 jFEX.
Definition: jFexTower_v1.h:22
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
MistimedStreamMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: MistimedStreamMonitorAlgorithm.cxx:17
L1CaloReadoutConfigJSON::channelId
unsigned int channelId() const
Definition: L1CaloReadoutConfigJSON.h:18
L1CaloRunParameters::readoutConfigID
unsigned int readoutConfigID() const
Definition: L1CaloRunParameters.h:29
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
MistimedStreamMonitorAlgorithm::m_phiScaleTT
Gaudi::Property< double > m_phiScaleTT
Definition: MistimedStreamMonitorAlgorithm.h:119
python.compressB64.c
def c
Definition: compressB64.py:93
MistimedStreamMonitorAlgorithm::makeTowerPPM
StatusCode makeTowerPPM(const xAOD::TriggerTower *tt, std::vector< MonitorTT > &vecMonTT) const
Helper functions.
Definition: MistimedStreamMonitorAlgorithm.cxx:931
MistimedStreamMonitorAlgorithm::m_readoutConfigContainerJSON
SG::ReadCondHandleKey< L1CaloReadoutConfigContainerJSON > m_readoutConfigContainerJSON
Definition: MistimedStreamMonitorAlgorithm.h:123
xAOD::TriggerTower
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/TriggerTower.h:16
PhysDESDM_Quirks.trigger
trigger
Definition: PhysDESDM_Quirks.py:27
L1CaloReadoutConfigJSON::readout80ModePpm
unsigned int readout80ModePpm() const
Definition: L1CaloReadoutConfigJSON.h:68
MistimedStreamMonitorAlgorithm::UnsuitableReadout
@ UnsuitableReadout
Definition: MistimedStreamMonitorAlgorithm.h:153
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
xAOD::CPMTower_v2
Description of CPMTower_v2.
Definition: CPMTower_v2.h:26