From de3430f5e1a163240a6cc12dc807529372f8012b Mon Sep 17 00:00:00 2001
From: Sergi Rodriguez <Sergi.Rodriguez@cern.ch>
Date: Thu, 1 Dec 2022 18:08:41 +0100
Subject: [PATCH 1/4] updating jFEX monitoring

---
 .../python/JfexInputMonitorAlgorithm.py       |  47 ++--
 .../python/JfexMonitorAlgorithm.py            |  38 +++-
 .../src/JfexInputMonitorAlgorithm.cxx         | 211 +++++++++---------
 .../src/JfexInputMonitorAlgorithm.h           |   2 +
 4 files changed, 170 insertions(+), 128 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
index c958bcf93dfb..5021c2651da5 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
@@ -4,7 +4,6 @@
 def JfexInputMonitoringConfig(inputFlags):
     '''Function to configure LVL1 JfexInput algorithm in the monitoring system.'''
 
-    import math 
     # get the component factory - used for getting the algorithms
     from AthenaConfiguration.ComponentFactory import CompFactory
     from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
@@ -28,12 +27,23 @@ def JfexInputMonitoringConfig(inputFlags):
     mainDir = 'L1Calo'
     trigPath = 'JfexInput/'
     Calosource_names = ["Barrel","Tile","EMEC","HEC","FCAL1","FCAL2","FCAL3"]
-    # See if the file contains xTOBs else use TOBs
-    #hasXtobs = True if "L1_eFexTower" in inputFlags.Input.Collections else False
-    #if not hasXtobs:
-    #    EfexInputMonAlg.eFexTowerContainer = "L1_eEMRoI"
-
-    #tobStr = "TOB"
+    
+    from ROOT import TMath
+    
+    x_phi = []
+    for i in range(67):
+        phi = (-TMath.Pi()- TMath.Pi()/32) + TMath.Pi()/32*i 
+        x_phi.append(phi)
+    x_phi = sorted(x_phi)
+    
+    phi_bins = {
+        'xbins': x_phi
+    }
+    
+    eta_phi_bins = {
+        'xbins': 100, 'xmin': -5, 'xmax': 5,
+        'ybins': x_phi
+    }
 
     # add monitoring algorithm to group, with group name and main directory 
     myGroup = helper.addGroup(JfexInputMonAlg, groupName , mainDir)
@@ -46,10 +56,13 @@ def JfexInputMonitoringConfig(inputFlags):
                             type='TH1F', path=trigPath, xbins=100,xmin=-5.0,xmax=5.0)
 
     myGroup.defineHistogram('TowerPhi;h_TowerPhi', title='jFex Tower Phi',
-                            type='TH1F', path=trigPath, xbins=66,xmin=-math.pi,xmax=math.pi)
+                            type='TH1F', path=trigPath, **phi_bins)
 
     myGroup.defineHistogram('TowerEta,TowerPhi;h_TowerEtaPhiMap', title='jFex Tower Eta vs Phi',
-                            type='TH2F',path=trigPath, xbins=100,xmin=-5.0,xmax=5.0,ybins=66,ymin=-math.pi,ymax=math.pi)
+                            type='TH2F',path=trigPath, **eta_phi_bins)
+
+    myGroup.defineHistogram('TowerEtaInvalid,TowerPhiInvalid;h_TowerEtaPhiInvalids', title='jFex Tower Invalid Et codes; Eta vs Phi Map',
+                            type='TH2F',path=trigPath, **eta_phi_bins)
 
     myGroup.defineHistogram('TowerGlobalEta;h_TowerGlobalEta', title='jFex Tower Global Eta',
                             type='TH1F', path=trigPath, xbins=100,xmin=-50,xmax=50)
@@ -79,25 +92,25 @@ def JfexInputMonitoringConfig(inputFlags):
                             type='TH1F', path=trigPath, xbins=7,xmin=0,xmax=7.0,xlabels=Calosource_names)
 
     myGroup.defineHistogram('TowerEtcount_barrel;h_TowerEtcount_barrel', title='jFex Tower Et Barrel',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_tile;h_TowerEtcount_tile', title='jFex Tower Et Tile',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_emec;h_TowerEtcount_emec', title='jFex Tower Et EMEC',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_hec;h_TowerEtcount_hec', title='jFex Tower Et HEC',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal1;h_TowerEtcount_fcal1', title='jFex Tower Et FCAL1',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal2;h_TowerEtcount_fcal2', title='jFex Tower Et FCAL2',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal3;h_TowerEtcount_fcal3', title='jFex Tower Et FCAL3',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-10,xmax=500.0)
+                            type='THI', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerSaturationflag;h_TowerSaturationflag', title='jFex Tower Saturation FLag',
                             type='TH1F', path=trigPath, xbins=2,xmin=0,xmax=2.0)
@@ -113,7 +126,7 @@ if __name__=='__main__':
     from AthenaConfiguration.AllConfigFlags import ConfigFlags
     import glob
 
-    inputs = glob.glob('/eos/atlas/atlastier0/rucio/data18_13TeV/physics_Main/00354311/data18_13TeV.00354311.physics_Main.recon.ESD.f1129/data18_13TeV.00354311.physics_Main.recon.ESD.f1129._lb0013._SFO-8._0001.1')
+    inputs = glob.glob('data22_13p6TeV.00440613.physics_Main.daq.RAW._lb0180-0189.data')
 
     ConfigFlags.Input.Files = inputs
     ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1_MC.root'
diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexMonitorAlgorithm.py b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexMonitorAlgorithm.py
index 8155d4cd192d..dc6dee07b48b 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexMonitorAlgorithm.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexMonitorAlgorithm.py
@@ -32,6 +32,24 @@ def JfexMonitoringConfig(inputFlags):
     FPGA_names = ["U1","U2","U4","U3"]
     Modules_names = ["jFEX 0","jFEX 1","jFEX 2","jFEX 3","jFEX 4","jFEX 5"]
     
+    from ROOT import TMath
+    
+    x_phi = []
+    for i in range(67):
+        phi = (-TMath.Pi()- TMath.Pi()/32) + TMath.Pi()/32*i 
+        x_phi.append(phi)
+    x_phi = sorted(x_phi)
+    
+    phi_bins = {
+        'xbins': x_phi
+    }
+    
+    eta_phi_bins = {
+        'xbins': 100, 'xmin': -5, 'xmax': 5,
+        'ybins': x_phi
+    }
+
+    
     ######  jJ  ######  
     myGroup.defineHistogram('jJ_jFexNumber;h_jJ_jFexNumber', title='jFex SRJet Module;Module number;Counts',
                             type='TH1I', path=trigPath+'jJ/', xbins=6,xmin=0,xmax=6)
@@ -49,10 +67,10 @@ def JfexMonitoringConfig(inputFlags):
                             type='TH1F', path=trigPath+'jJ/',xbins=100,xmin=-5.0,xmax=5.0)
 
     myGroup.defineHistogram('jJ_Phi;h_jJ_Phi', title='jFex SRJet #phi;#phi;Counts',
-                            type='TH1F', path=trigPath+'jJ/',xbins=67,xmin=-math.pi,xmax=math.pi)
+                            type='TH1F', path=trigPath+'jJ/',**phi_bins)
                             
     myGroup.defineHistogram('jJ_Eta,jJ_Phi;h_jJ_EtaPhiMap', title="jFex SRJet #eta vs #phi;#eta;#phi",
-                            type='TH2F',path=trigPath+'jJ/', xbins=100,xmin=-5.0,xmax=5.0,ybins=66,ymin=-math.pi,ymax=math.pi)                            
+                            type='TH2F',path=trigPath+'jJ/', **eta_phi_bins)                            
 
     myGroup.defineHistogram('jJ_GlobalEta;h_jJ_GlobalEta', title='jFex SRJet Global #eta;#eta;Counts',
                             type='TH1F', path=trigPath+'jJ/',xbins=100,xmin=-50,xmax=50)
@@ -80,10 +98,10 @@ def JfexMonitoringConfig(inputFlags):
                             type='TH1F', path=trigPath+'jLJ/',xbins=100,xmin=-5.0,xmax=5.0)
 
     myGroup.defineHistogram('jLJ_Phi;h_jLJ_Phi', title='jFex LRJet #phi;#phi;Counts',
-                            type='TH1F', path=trigPath+'jLJ/',xbins=67,xmin=-math.pi,xmax=math.pi)
+                            type='TH1F', path=trigPath+'jLJ/',**phi_bins)
                             
     myGroup.defineHistogram('jLJ_Eta,jLJ_Phi;h_jLJ_EtaPhiMap', title="jFEX LRJet #eta vs #phi;#eta;#phi",
-                            type='TH2F',path=trigPath+'jLJ/', xbins=100,xmin=-5.0,xmax=5.0,ybins=67,ymin=-math.pi,ymax=math.pi)                             
+                            type='TH2F',path=trigPath+'jLJ/', **eta_phi_bins)                             
 
     myGroup.defineHistogram('jLJ_GlobalEta;h_jLJ_GlobalEta', title='jFex LRJet Global #eta;#eta;Counts',
                             type='TH1F', path=trigPath+'jLJ/',xbins=100,xmin=-50,xmax=50)
@@ -113,10 +131,10 @@ def JfexMonitoringConfig(inputFlags):
                             type='TH1F', path=trigPath+'jTau/',xbins=100,xmin=-5.0,xmax=5.0)
 
     myGroup.defineHistogram('jTau_Phi;h_jTau_Phi', title='jFex Tau #phi;#phi;Counts',
-                            type='TH1F', path=trigPath+'jTau/',xbins=67,xmin=-math.pi,xmax=math.pi)
+                            type='TH1F', path=trigPath+'jTau/',**phi_bins)
                             
     myGroup.defineHistogram('jTau_Eta,jTau_Phi;h_jTau_EtaPhiMap', title="jFex Tau #eta vs #phi;#eta;#phi",
-                            type='TH2F',path=trigPath+'jTau/', xbins=100,xmin=-5.0,xmax=5.0,ybins=67,ymin=-math.pi,ymax=math.pi)          
+                            type='TH2F',path=trigPath+'jTau/', **eta_phi_bins)          
 
     myGroup.defineHistogram('jTau_GlobalEta;h_jTau_GlobalEta', title='jFex Tau Global #eta;#eta;Counts',
                             type='TH1F', path=trigPath+'jTau/',xbins=100,xmin=-50,xmax=50)
@@ -143,7 +161,7 @@ def JfexMonitoringConfig(inputFlags):
                             type='TH1F', path=trigPath+'jEM/',xbins=100,xmin=-5.0,xmax=5.0)
 
     myGroup.defineHistogram('jEM_Phi;h_jEM_Phi', title='jFex EM #phi;#phi;Counts',
-                            type='TH1F', path=trigPath+'jEM/',xbins=67,xmin=-math.pi,xmax=math.pi)
+                            type='TH1F', path=trigPath+'jEM/',**phi_bins)
 
     em_labels = ['None','loose','medium','tight']
     myGroup.defineHistogram('jEM_Iso;h_jEM_Iso', title='jFex EM Isolation;tobIso;Counts',
@@ -156,7 +174,7 @@ def JfexMonitoringConfig(inputFlags):
                             type='TH1I', path=trigPath+'jEM/',xbins=4,xmin=0,xmax=4,xlabels=em_labels)
                             
     myGroup.defineHistogram('jEM_Eta,jEM_Phi;h_jEM_EtaPhiMap', title="jFex EM #eta vs #phi;#eta;#phi",
-                            type='TH2F',path=trigPath+'jEM/', xbins=100,xmin=-5.0,xmax=5.0,ybins=67,ymin=-math.pi,ymax=math.pi) 
+                            type='TH2F',path=trigPath+'jEM/',  **eta_phi_bins) 
 
     myGroup.defineHistogram('jEM_GlobalEta;h_jEM_GlobalEta', title='jFex EM Global #eta;#eta;Counts',
                             type='TH1F', path=trigPath+'jEM/',xbins=100,xmin=-50,xmax=50)
@@ -200,8 +218,8 @@ if __name__=='__main__':
     # set input file and config options
     from AthenaConfiguration.AllConfigFlags import ConfigFlags
     import glob
-    inputs = glob.glob('/eos/user/t/thompson/ATLAS/LVL1_mon/MC_ESD/valid1.601189.PhPy8EG_AZNLO_Zee.recon.ESD.e8392_e7400_s3775_r13717_r13737/ESD.29453686._000286.pool.root.1')
-
+    inputs = glob.glob('../../Monitoring/run/valid1.601229.PhPy8EG_A14_ttbar_hdamp258p75_SingleLep.recon.AOD.e8453_e8455_s3873_s3874_r14022/*.root*')
+    
     ConfigFlags.Input.Files = inputs
     ConfigFlags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1.root'
 
diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx b/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx
index e8107f26f78d..58ecfc8a9b5b 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx
@@ -23,109 +23,118 @@ StatusCode JfexInputMonitorAlgorithm::initialize() {
 
 StatusCode JfexInputMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
 
-  ATH_MSG_DEBUG("JfexInputMonitorAlgorithm::fillHistograms");
+    ATH_MSG_DEBUG("JfexInputMonitorAlgorithm::fillHistograms");
+
+    // Access gFex gTower container
+    SG::ReadHandle<xAOD::jFexTowerContainer> jFexTowerContainer{m_jFexTowerContainerKey, ctx};
+    if(!jFexTowerContainer.isValid()) {
+        ATH_MSG_ERROR("No jFex Tower container found in storegate  "<< m_jFexTowerContainerKey);
+        return StatusCode::SUCCESS;
+    }
+
+    // monitored variables for histograms
+    auto nJfexTowers = Monitored::Scalar<int>("NJfexTowers",0.0);
+    auto Towereta = Monitored::Scalar<float>("TowerEta",0.0);
+    auto Towerphi = Monitored::Scalar<float>("TowerPhi",0.0);
+    auto ToweretaInvalid = Monitored::Scalar<float>("TowerEtaInvalid",-99.0);
+    auto TowerPhiInvalid = Monitored::Scalar<float>("TowerPhiInvalid",-99.0);
+    auto Towerglobaleta = Monitored::Scalar<int>("TowerGlobalEta",0.0);
+    auto Towerglobalphi = Monitored::Scalar<uint32_t>("TowerGlobalPhi",0.0);
+    auto Towermodule = Monitored::Scalar<uint8_t>("TowerModule",0.0);
+    auto Towerfpga = Monitored::Scalar<uint8_t>("TowerFpga",0.0);
+    auto Towerchannel = Monitored::Scalar<uint8_t>("TowerChannel",0.0);
+    auto TowerdataID = Monitored::Scalar<uint8_t>("TowerDataID",0.0);
+    auto TowersimulationID = Monitored::Scalar<uint32_t>("TowerSimulationID",0.0);
+    auto Towercalosource = Monitored::Scalar<uint8_t>("TowerCalosource",0.0);
+
+    auto Toweretcount_barrel = Monitored::Scalar<uint16_t>("TowerEtcount_barrel",0);
+    auto Toweretcount_tile = Monitored::Scalar<uint16_t>("TowerEtcount_tile",0);
+    auto Toweretcount_emec = Monitored::Scalar<uint16_t>("TowerEtcount_emec",0);
+    auto Toweretcount_hec = Monitored::Scalar<uint16_t>("TowerEtcount_hec",0);
+    auto Toweretcount_fcal1 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal1",0);
+    auto Toweretcount_fcal2 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal2",0);
+    auto Toweretcount_fcal3 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal3",0);
+
+    auto Towersaturationflag = Monitored::Scalar<char>("TowerSaturationflag",0.0);
+
+    ATH_MSG_DEBUG("number of jfex towers = "<< jFexTowerContainer->size());
+
+    unsigned int njfexTowers=jFexTowerContainer->size();
+    nJfexTowers=njfexTowers;
+    fill(m_packageName,nJfexTowers);
+
+    for(const xAOD::jFexTower* jfexTowerRoI : *jFexTowerContainer) {
+
+        Towereta=jfexTowerRoI->eta();
+        Towerphi=jfexTowerRoI->phi();
+        fill(m_packageName,Towereta,Towerphi);
+
+        Towerglobaleta=jfexTowerRoI->globalEta();
+        Towerglobalphi=jfexTowerRoI->globalPhi();
+        fill(m_packageName,Towerglobaleta,Towerglobalphi);
+
+        Towermodule=jfexTowerRoI->module();
+        fill(m_packageName,Towermodule);
+
+        Towerfpga=jfexTowerRoI->fpga();
+        fill(m_packageName,Towerfpga);
+
+        Towerchannel=jfexTowerRoI->channel();
+        fill(m_packageName,Towerchannel);
+
+        TowerdataID=jfexTowerRoI->jFEXdataID();
+        fill(m_packageName,TowerdataID);
+
+        TowersimulationID=jfexTowerRoI->jFEXtowerID();
+        fill(m_packageName,TowersimulationID);
+
+        Towercalosource=jfexTowerRoI->Calosource();
+        fill(m_packageName,Towercalosource);
+
+        std::vector<uint16_t> Toweret_count=jfexTowerRoI->et_count();
+        Toweretcount_barrel=Toweret_count.at(0);
+        Toweretcount_tile=Toweret_count.at(0);
+        Toweretcount_emec=Toweret_count.at(0);
+        Toweretcount_hec=Toweret_count.at(0);
+        Toweretcount_fcal1=Toweret_count.at(0);
+        Toweretcount_fcal2=Toweret_count.at(0);
+        Toweretcount_fcal3=Toweret_count.at(0);
+        
+        if(Toweret_count.at(0) == m_InvalidCode){
+            ToweretaInvalid=jfexTowerRoI->eta();
+            TowerPhiInvalid=jfexTowerRoI->phi();
+            fill(m_packageName,ToweretaInvalid,TowerPhiInvalid);
+        }
+
+        if(Towercalosource==0) {
+            fill(m_packageName,Toweretcount_barrel);
+        }
+        if(Towercalosource==1) {
+            fill(m_packageName,Toweretcount_tile);
+        }
+        if(Towercalosource==2) {
+            fill(m_packageName,Toweretcount_emec);
+        }
+        if(Towercalosource==3) {
+            fill(m_packageName,Toweretcount_hec);
+        }
+        if(Towercalosource==4) {
+            fill(m_packageName,Toweretcount_fcal1);
+        }
+        if(Towercalosource==5) {
+            fill(m_packageName,Toweretcount_fcal2);
+        }
+        if(Towercalosource==6) {
+            fill(m_packageName,Toweretcount_fcal3);
+        }
+
+        std::vector<char> Tower_saturationflag=jfexTowerRoI->isjTowerSat();
+        Towersaturationflag=Tower_saturationflag.at(0);
+        fill(m_packageName,Towersaturationflag);
+
+    }
 
-  // Access gFex gTower container
-  SG::ReadHandle<xAOD::jFexTowerContainer> jFexTowerContainer{m_jFexTowerContainerKey, ctx};
-  if(!jFexTowerContainer.isValid()){
-    ATH_MSG_ERROR("No jFex Tower container found in storegate  "<< m_jFexTowerContainerKey);
     return StatusCode::SUCCESS;
-  }  
-
-  // monitored variables for histograms
-  auto nJfexTowers = Monitored::Scalar<int>("NJfexTowers",0.0);
-  auto Towereta = Monitored::Scalar<float>("TowerEta",0.0);
-  auto Towerphi = Monitored::Scalar<float>("TowerPhi",0.0);
-  auto Towerglobaleta = Monitored::Scalar<int>("TowerGlobalEta",0.0);
-  auto Towerglobalphi = Monitored::Scalar<uint32_t>("TowerGlobalPhi",0.0);
-  auto Towermodule = Monitored::Scalar<uint8_t>("TowerModule",0.0);
-  auto Towerfpga = Monitored::Scalar<uint8_t>("TowerFpga",0.0);
-  auto Towerchannel = Monitored::Scalar<uint8_t>("TowerChannel",0.0);
-  auto TowerdataID = Monitored::Scalar<uint8_t>("TowerDataID",0.0);
-  auto TowersimulationID = Monitored::Scalar<uint32_t>("TowerSimulationID",0.0);
-  auto Towercalosource = Monitored::Scalar<uint8_t>("TowerCalosource",0.0);
-
-  auto Toweretcount_barrel = Monitored::Scalar<uint16_t>("TowerEtcount_barrel",0.0);
-  auto Toweretcount_tile = Monitored::Scalar<uint16_t>("TowerEtcount_tile",0.0);
-  auto Toweretcount_emec = Monitored::Scalar<uint16_t>("TowerEtcount_emec",0.0);
-  auto Toweretcount_hec = Monitored::Scalar<uint16_t>("TowerEtcount_hec",0.0);
-  auto Toweretcount_fcal1 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal1",0.0);
-  auto Toweretcount_fcal2 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal2",0.0);
-  auto Toweretcount_fcal3 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal3",0.0);
-
-  auto Towersaturationflag = Monitored::Scalar<char>("TowerSaturationflag",0.0);
-
-  ATH_MSG_DEBUG("number of jfex towers = "<< jFexTowerContainer->size());
-
-  unsigned int njfexTowers=jFexTowerContainer->size();
-  nJfexTowers=njfexTowers;
-  fill(m_packageName,nJfexTowers);
-
-  for(const xAOD::jFexTower* jfexTowerRoI : *jFexTowerContainer){
-
-  Towereta=jfexTowerRoI->eta();
-  Towerphi=jfexTowerRoI->phi();
-  fill(m_packageName,Towereta,Towerphi);
-
-  Towerglobaleta=jfexTowerRoI->globalEta();
-  Towerglobalphi=jfexTowerRoI->globalPhi();
-  fill(m_packageName,Towerglobaleta,Towerglobalphi);
-
-  Towermodule=jfexTowerRoI->module();
-  fill(m_packageName,Towermodule);
-
-  Towerfpga=jfexTowerRoI->fpga();
-  fill(m_packageName,Towerfpga);
-
-  Towerchannel=jfexTowerRoI->channel();
-  fill(m_packageName,Towerchannel);
-
-  TowerdataID=jfexTowerRoI->jFEXdataID();
-  fill(m_packageName,TowerdataID);
-
-  TowersimulationID=jfexTowerRoI->jFEXtowerID();
-  fill(m_packageName,TowersimulationID);
-
-  Towercalosource=jfexTowerRoI->Calosource();
-  fill(m_packageName,Towercalosource);
-
-  std::vector<uint16_t> Toweret_count=jfexTowerRoI->et_count();
-  Toweretcount_barrel=Toweret_count.at(0);
-  Toweretcount_tile=Toweret_count.at(0);
-  Toweretcount_emec=Toweret_count.at(0);
-  Toweretcount_hec=Toweret_count.at(0);
-  Toweretcount_fcal1=Toweret_count.at(0);
-  Toweretcount_fcal2=Toweret_count.at(0);
-  Toweretcount_fcal3=Toweret_count.at(0);
-
-  if(Towercalosource==0){
-  fill(m_packageName,Toweretcount_barrel);
-  }
-  if(Towercalosource==1){
-  fill(m_packageName,Toweretcount_tile);
-  }
-  if(Towercalosource==2){
-  fill(m_packageName,Toweretcount_emec);
-  }
-  if(Towercalosource==3){
-  fill(m_packageName,Toweretcount_hec);
-  }
-  if(Towercalosource==4){
-  fill(m_packageName,Toweretcount_fcal1);
-  }
-  if(Towercalosource==5){
-  fill(m_packageName,Toweretcount_fcal2);
-  }
-  if(Towercalosource==6){
-  fill(m_packageName,Toweretcount_fcal3);
-  }
-
-  std::vector<char> Tower_saturationflag=jfexTowerRoI->isjTowerSat();
-  Towersaturationflag=Tower_saturationflag.at(0);
-  fill(m_packageName,Towersaturationflag);
-
-  }
-  return StatusCode::SUCCESS;
 
 }
 
diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.h b/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.h
index e83230c7cdd8..c65a76bd0be9 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.h
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.h
@@ -24,6 +24,8 @@ private:
 
   // container keys including steering parameter and description
   SG::ReadHandleKey<xAOD::jFexTowerContainer> m_jFexTowerContainerKey{this, "jFexTowerContainer","L1_jFexDataTowers","SG key of the input jFex Tower container"};  
+  
+  unsigned int m_InvalidCode = 4095;
 
 };
 #endif
-- 
GitLab


From dde4fcc6e900d1f936ebd198576a6402cf4b2b76 Mon Sep 17 00:00:00 2001
From: Sergi Rodriguez <Sergi.Rodriguez@cern.ch>
Date: Fri, 2 Dec 2022 17:05:13 +0100
Subject: [PATCH 2/4] Changing THI to TH1I

---
 .../python/JfexInputMonitorAlgorithm.py       | 19 ++++++++++---------
 .../src/JfexInputMonitorAlgorithm.cxx         | 16 ++++++++--------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
index 5021c2651da5..4a21ebc2a52e 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
@@ -27,6 +27,7 @@ def JfexInputMonitoringConfig(inputFlags):
     mainDir = 'L1Calo'
     trigPath = 'JfexInput/'
     Calosource_names = ["Barrel","Tile","EMEC","HEC","FCAL1","FCAL2","FCAL3"]
+    FPGA_names = ["U1","U2","U4","U3"]
     
     from ROOT import TMath
     
@@ -65,31 +66,31 @@ def JfexInputMonitoringConfig(inputFlags):
                             type='TH2F',path=trigPath, **eta_phi_bins)
 
     myGroup.defineHistogram('TowerGlobalEta;h_TowerGlobalEta', title='jFex Tower Global Eta',
-                            type='TH1F', path=trigPath, xbins=100,xmin=-50,xmax=50)
+                            type='TH1I', path=trigPath, xbins=100,xmin=-50,xmax=50)
 
     myGroup.defineHistogram('TowerGlobalPhi;h_TowerGlobalPhi', title='jFex Tower Global Phi',
                             type='TH1F', path=trigPath, xbins=67,xmin=-1,xmax=65)
 
     myGroup.defineHistogram('TowerGlobalEta,TowerGlobalPhi;h_TowerGlobalEtaPhiMap', title='jFex Tower Global Eta vs Phi',
-                            type='TH2F',path=trigPath, xbins=100,xmin=-50,xmax=50,ybins=67,ymin=-1,ymax=65)
+                            type='TH2I',path=trigPath, xbins=100,xmin=-50,xmax=50,ybins=67,ymin=-1,ymax=65)
 
     myGroup.defineHistogram('TowerModule;h_TowerModule', title='jFex Tower Module Number',
-                            type='TH1F', path=trigPath, xbins=6,xmin=0,xmax=6.0)
+                            type='TH1I', path=trigPath, xbins=6,xmin=0,xmax=6)
   
     myGroup.defineHistogram('TowerFpga;h_TowerFpga', title='jFex Tower FPGA Number',
-                            type='TH1F', path=trigPath, xbins=4,xmin=0,xmax=4.0)
+                            type='TH1I', path=trigPath, xbins=4,xmin=0,xmax=4,xlabels=FPGA_names)
 
     myGroup.defineHistogram('TowerChannel;h_TowerChannel', title='jFex Tower Channel Number',
-                            type='TH1F', path=trigPath, xbins=62,xmin=0,xmax=62.0)
+                            type='TH1I', path=trigPath, xbins=60,xmin=0,xmax=60)
 
     myGroup.defineHistogram('TowerDataID;h_TowerDataID', title='jFex Tower Data ID',
-                            type='TH1F', path=trigPath, xbins=16,xmin=0,xmax=16.0)
+                            type='TH1I', path=trigPath, xbins=16,xmin=0,xmax=16)
 
     myGroup.defineHistogram('TowerSimulationID;h_TowerSimulationID', title='jFex Tower Simulation ID',
                             type='TH1F', path=trigPath, xbins=1000,xmin=0,xmax=1500000.0)
 
     myGroup.defineHistogram('TowerCalosource;h_TowerCalosource', title='jFex Tower Calo Source',
-                            type='TH1F', path=trigPath, xbins=7,xmin=0,xmax=7.0,xlabels=Calosource_names)
+                            type='TH1I', path=trigPath, xbins=7,xmin=0,xmax=7,xlabels=Calosource_names)
 
     myGroup.defineHistogram('TowerEtcount_barrel;h_TowerEtcount_barrel', title='jFex Tower Et Barrel',
                             type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
@@ -110,10 +111,10 @@ def JfexInputMonitoringConfig(inputFlags):
                             type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal3;h_TowerEtcount_fcal3', title='jFex Tower Et FCAL3',
-                            type='THI', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerSaturationflag;h_TowerSaturationflag', title='jFex Tower Saturation FLag',
-                            type='TH1F', path=trigPath, xbins=2,xmin=0,xmax=2.0)
+                            type='TH1I', path=trigPath, xbins=2,xmin=0,xmax=2)
 
   
     acc = helper.result()
diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx b/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx
index 58ecfc8a9b5b..61c41177bc67 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/src/JfexInputMonitorAlgorithm.cxx
@@ -38,14 +38,14 @@ StatusCode JfexInputMonitorAlgorithm::fillHistograms( const EventContext& ctx )
     auto Towerphi = Monitored::Scalar<float>("TowerPhi",0.0);
     auto ToweretaInvalid = Monitored::Scalar<float>("TowerEtaInvalid",-99.0);
     auto TowerPhiInvalid = Monitored::Scalar<float>("TowerPhiInvalid",-99.0);
-    auto Towerglobaleta = Monitored::Scalar<int>("TowerGlobalEta",0.0);
-    auto Towerglobalphi = Monitored::Scalar<uint32_t>("TowerGlobalPhi",0.0);
-    auto Towermodule = Monitored::Scalar<uint8_t>("TowerModule",0.0);
-    auto Towerfpga = Monitored::Scalar<uint8_t>("TowerFpga",0.0);
-    auto Towerchannel = Monitored::Scalar<uint8_t>("TowerChannel",0.0);
-    auto TowerdataID = Monitored::Scalar<uint8_t>("TowerDataID",0.0);
+    auto Towerglobaleta = Monitored::Scalar<int>("TowerGlobalEta",0);
+    auto Towerglobalphi = Monitored::Scalar<uint32_t>("TowerGlobalPhi",0);
+    auto Towermodule = Monitored::Scalar<uint8_t>("TowerModule",0);
+    auto Towerfpga = Monitored::Scalar<uint8_t>("TowerFpga",0);
+    auto Towerchannel = Monitored::Scalar<uint8_t>("TowerChannel",0);
+    auto TowerdataID = Monitored::Scalar<uint8_t>("TowerDataID",0);
     auto TowersimulationID = Monitored::Scalar<uint32_t>("TowerSimulationID",0.0);
-    auto Towercalosource = Monitored::Scalar<uint8_t>("TowerCalosource",0.0);
+    auto Towercalosource = Monitored::Scalar<uint8_t>("TowerCalosource",0);
 
     auto Toweretcount_barrel = Monitored::Scalar<uint16_t>("TowerEtcount_barrel",0);
     auto Toweretcount_tile = Monitored::Scalar<uint16_t>("TowerEtcount_tile",0);
@@ -55,7 +55,7 @@ StatusCode JfexInputMonitorAlgorithm::fillHistograms( const EventContext& ctx )
     auto Toweretcount_fcal2 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal2",0);
     auto Toweretcount_fcal3 = Monitored::Scalar<uint16_t>("TowerEtcount_fcal3",0);
 
-    auto Towersaturationflag = Monitored::Scalar<char>("TowerSaturationflag",0.0);
+    auto Towersaturationflag = Monitored::Scalar<char>("TowerSaturationflag",0);
 
     ATH_MSG_DEBUG("number of jfex towers = "<< jFexTowerContainer->size());
 
-- 
GitLab


From 53b571d5ab50dbe98f9d6e62d94849c6414270d2 Mon Sep 17 00:00:00 2001
From: Sergi Rodriguez <Sergi.Rodriguez@cern.ch>
Date: Fri, 2 Dec 2022 17:06:36 +0100
Subject: [PATCH 3/4] Changing THI to TH1I

---
 .../python/JfexInputMonitorAlgorithm.py            | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
index 4a21ebc2a52e..62bab5e486a9 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
@@ -93,25 +93,25 @@ def JfexInputMonitoringConfig(inputFlags):
                             type='TH1I', path=trigPath, xbins=7,xmin=0,xmax=7,xlabels=Calosource_names)
 
     myGroup.defineHistogram('TowerEtcount_barrel;h_TowerEtcount_barrel', title='jFex Tower Et Barrel',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_tile;h_TowerEtcount_tile', title='jFex Tower Et Tile',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_emec;h_TowerEtcount_emec', title='jFex Tower Et EMEC',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_hec;h_TowerEtcount_hec', title='jFex Tower Et HEC',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal1;h_TowerEtcount_fcal1', title='jFex Tower Et FCAL1',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal2;h_TowerEtcount_fcal2', title='jFex Tower Et FCAL2',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerEtcount_fcal3;h_TowerEtcount_fcal3', title='jFex Tower Et FCAL3',
-                            type='TH1I', path=trigPath, xbins=4097,xmin=0,xmax=4096)
+                            type='TH1I', path=trigPath, xbins=4096,xmin=0,xmax=4096)
 
     myGroup.defineHistogram('TowerSaturationflag;h_TowerSaturationflag', title='jFex Tower Saturation FLag',
                             type='TH1I', path=trigPath, xbins=2,xmin=0,xmax=2)
-- 
GitLab


From cf7a8edbbce6e63a763480a8777ad69c7e5d0ffe Mon Sep 17 00:00:00 2001
From: Sergi Rodriguez <Sergi.Rodriguez@cern.ch>
Date: Tue, 6 Dec 2022 20:38:18 +0100
Subject: [PATCH 4/4] =?UTF-8?q?=C3=82from=20TMath=20to=20math=20lib?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
index 62bab5e486a9..70250a95a5c0 100644
--- a/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
+++ b/Trigger/TrigT1/TrigT1CaloMonitoring/python/JfexInputMonitorAlgorithm.py
@@ -29,11 +29,11 @@ def JfexInputMonitoringConfig(inputFlags):
     Calosource_names = ["Barrel","Tile","EMEC","HEC","FCAL1","FCAL2","FCAL3"]
     FPGA_names = ["U1","U2","U4","U3"]
     
-    from ROOT import TMath
+    from math import pi
     
     x_phi = []
     for i in range(67):
-        phi = (-TMath.Pi()- TMath.Pi()/32) + TMath.Pi()/32*i 
+        phi = (-pi- pi/32) + pi/32*i 
         x_phi.append(phi)
     x_phi = sorted(x_phi)
     
-- 
GitLab