From c276ca485ccb46c32a64873ddfc8c44555710cd6 Mon Sep 17 00:00:00 2001
From: Florencia Luciana Castillo <florencia.luciana.castillo@cern.ch>
Date: Tue, 27 Sep 2022 21:24:21 +0200
Subject: [PATCH] Mistimed, extra histo: Not saved events

Mistimed, extra histo: Not saved events
---
 .../python/MistimedStreamMonitorAlgorithm.py  |  9 ++++---
 .../src/MistimedStreamMonitorAlgorithm.cxx    | 25 ++++++++++---------
 .../src/MistimedStreamMonitorAlgorithm.h      |  1 -
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/python/MistimedStreamMonitorAlgorithm.py b/Trigger/TrigT1/TrigT1CaloMonitoring/python/MistimedStreamMonitorAlgorithm.py
index 1ea9798d2a4e..7fb9efc89fb5 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/python/MistimedStreamMonitorAlgorithm.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/python/MistimedStreamMonitorAlgorithm.py
@@ -85,9 +85,12 @@ def MistimedStreamMonitorConfig(flags):
                             xbins=NumberOfGlobalErrors,xmin=0.,xmax=NumberOfGlobalErrors,xlabels=globalStatus_xlabels,
                             opt='kAlwaysCreate')
     
-    groupMapsEM         = helper.addGroup(MistimedMonAlg, 'Event_', mainDir)
-    groupMapsEM.defineHistogram('eventMonitor,lbMonitor;1d_selectedEvents_mistimedStreamAna', title='Events of interest - Lumi Block;Events of interest;Lumi Block',type='TH2I', xbins=NumberofEvents, ybins=NumberofEvents, path=trigPath)
-
+    groupMapsEvents         = helper.addGroup(MistimedMonAlg, 'Event_', mainDir)
+    groupMapsEvents.defineHistogram('eventMonitor,lbMonitor;1d_selectedEvents_mistimedStreamAna', title='Events of interest - Lumi Block;Events of interest;Lumi Block',type='TH2I', xbins=NumberofEvents, ybins=NumberofEvents, path=trigPath)
+    
+    groupMapsEvents_all         = helper.addGroup(MistimedMonAlg, 'Event_all_', mainDir)
+    groupMapsEvents_all.defineHistogram('eventMonitor_all,lbMonitor_all;1d_selectedEvents_mistimedStreamAna_notSaved', title='Events of interest - Lumi Block (not saved);Events of interest;Lumi Block',type='TH2I', path=trigPath)
+    
 
     # add monitoring algorithm to group, with group name and main directory
     histPath = trigPath+'/EventofInterest'
diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.cxx b/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.cxx
index e28d71e18c1c..1605f34e3c06 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.cxx
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.cxx
@@ -100,7 +100,7 @@ StatusCode MistimedStreamMonitorAlgorithm::fillHistograms( const EventContext& c
   unsigned int currentEventNo =  ctx.eventID().event_number();
 
 
-
+  
   ATH_MSG_DEBUG("Lumi Block :: " << lumiNo);
   ATH_MSG_DEBUG("Run Number :: " << currentRunNo);
   ATH_MSG_DEBUG("Event Number :: " << currentEventNo);
@@ -193,7 +193,6 @@ StatusCode MistimedStreamMonitorAlgorithm::fillHistograms( const EventContext& c
   for (const xAOD::TriggerTower* tt : *triggerTowerTES) {
   
     float ttPulseCategory = 0;
-    //std::vector<uint16_t> ttADC =  (tt)->adc();
     const std::vector<uint16_t>& ttADC =  (tt)->adc();
     std::vector<uint16_t> readoutCorrectedADC; //this is the standard readout ADC vector: 5 40MHz samples with l1A in the middle
     if(!readout80ModePpm){//40 MHz
@@ -305,22 +304,20 @@ StatusCode MistimedStreamMonitorAlgorithm::fillHistograms( const EventContext& c
   cutFlowX=  TTEMLayer;
   fill(m_packageName,cutFlowX);
   
-  
-  
-  
-  
+    
   
   // scope for mutable error event per lumi block tt counter
   // it allows only one event per lumiblock
   std::lock_guard<std::mutex> lock(m_mutex);	
   m_event_counter[lumiNo]+=1;
   const int eventCounter = m_eventCounter++;
-
+ 
   
-  if( m_event_counter[lumiNo] <=1){ 
-    ATH_MSG_DEBUG( "EventID :: " <<  m_event_counter[lumiNo]);
-    if (eventCounter < m_maxEvents) { // save less than MaxEvents
 
+
+
+  if( (m_event_counter[lumiNo] <=1) && (eventCounter < m_maxEvents) ){ 
+    ATH_MSG_DEBUG( "EventID :: " <<  m_event_counter[lumiNo]);
     
       // Saving the lumiblock and event number of the events with mistimed 
       auto  eventMonitor= Monitored::Scalar<std::string>("eventMonitor", "Event"+std::to_string(eventCounter)+"="+std::to_string(currentEventNo));
@@ -373,7 +370,6 @@ StatusCode MistimedStreamMonitorAlgorithm::fillHistograms( const EventContext& c
       //Loop over CPM tower container
       //Create the CPM objects and calculate scaled phi
       std::vector<MonitorCPM> vecMonCPM;     // All towers
-      //Create the CPM objects and calculate scaled phi
       for (const xAOD::CPMTower* cpm : *cpmTowerTES) {
 	ATH_CHECK( makeTowerCPM(cpm, vecMonCPM) );     
 	
@@ -483,7 +479,12 @@ StatusCode MistimedStreamMonitorAlgorithm::fillHistograms( const EventContext& c
 	    if(jepHADenergy.at(2) > 0)  fill(groupName+"lut_HAD2",etalut,philut, hadLUT2);
 	  }}
 	}}}
-    }
+  }
+
+  else if ( eventCounter >= m_maxEvents ) { 
+    auto  eventMonitor_all= Monitored::Scalar<std::string>("eventMonitor_all", std::to_string(currentEventNo));
+    auto  lbMonitor_all= Monitored::Scalar<std::string>("lbMonitor_all", std::to_string(lumiNo));
+    fill("Event_all_", eventMonitor_all, lbMonitor_all );
   }
   
 
diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.h b/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.h
index ec9350dc7d32..01c703308f5c 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.h
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/src/MistimedStreamMonitorAlgorithm.h
@@ -47,7 +47,6 @@ public: MistimedStreamMonitorAlgorithm( const std::string& name, ISvcLocator* pS
     const xAOD::JetElement* element;
     std::vector<double>  phiScaled;
     std::vector<double> etaScaled;
-    //std::vector<double>  etaScaled; /// phi for 2d maps with integer bins (taking into account granularity in eta)
     double phi1d;     /// phi for 1d phi distributions (taking into account granularity in eta) 
   };
 
-- 
GitLab