ATLAS Offline Software
GfexInputMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 #include "TProfile2D.h"
7 #include "TMath.h"
8 GfexInputMonitorAlgorithm::GfexInputMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
9  : AthMonitorAlgorithm(name,pSvcLocator)
10 {
11 }
12 
14 
15  ATH_MSG_DEBUG("GfexInputMonitorAlgorith::initialize");
16  ATH_MSG_DEBUG("Package Name "<< m_packageName);
17  ATH_MSG_DEBUG("m_gFexTowerContainer"<< m_gFexTowerContainerKey);
18 
19  // we initialise all the containers that we need
20  ATH_CHECK( m_gFexTowerContainerKey.initialize() );
21 
23 }
24 
25 StatusCode GfexInputMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
26 
27  ATH_MSG_DEBUG("GfexInputMonitorAlgorithm::fillHistograms");
28 
29  // Access gFex gTower container
31  if(!gFexTowerContainer.isValid()){
32  ATH_MSG_ERROR("No gFex Tower container found in storegate "<< m_gFexTowerContainerKey);
33  return StatusCode::SUCCESS;
34  }
35 
36  // monitored variables for histograms
37  auto nGfexTowers = Monitored::Scalar<int>("NGfexTowers",0.0);
38  auto Towereta = Monitored::Scalar<float>("TowerEta",0.0);
39  auto Towerphi = Monitored::Scalar<float>("TowerPhi",0.0);
40  auto Towersaturationflag = Monitored::Scalar<char>("TowerSaturationflag",0.0);
41  auto Toweret = Monitored::Scalar<int>("TowerEt",0);
42  auto evtNumber = Monitored::Scalar<ULong64_t>("EventNumber",GetEventInfo(ctx)->eventNumber());
43  auto lbnString = Monitored::Scalar<std::string>("LBNString",std::to_string(GetEventInfo(ctx)->lumiBlock()));
44  auto lbn = Monitored::Scalar<int>("LBN",GetEventInfo(ctx)->lumiBlock());
45  auto binNumber = Monitored::Scalar<int>("binNumber",0);
46 
47 
48 
49  unsigned int nTowers = 0;
50  for(const xAOD::gFexTower* gfexTowerRoI : *gFexTowerContainer){
51 
52  Toweret=gfexTowerRoI->towerEt();
53  Towersaturationflag=gfexTowerRoI->isSaturated();
54  fill("gTowers",Toweret,Towersaturationflag);
55 
56  float eta = gfexTowerRoI->eta();
57  float phi = gfexTowerRoI->phi();
58 
59  if (eta < -3.17 && eta > -3.25){ eta = -3.225;}
60  if (eta < 3.3 && eta > 3.17){ eta = 3.275;}
61 
62  Towereta = eta;
63 
64  if(gfexTowerRoI->towerEt() >= 200 ){
65  nTowers++;
66  }
67 
68  //GREATER THAN 2GEV
69  if (gfexTowerRoI->towerEt() >= 10){
70  if (std::abs(eta) >= 3.2 ){
71  Towerphi = phi- 0.1;
72  binNumber = getBinNumberTower(eta,phi-0.1,0,0);
73  fill("highEtgTowers",Towereta,Towerphi);
74  fill("highEtgTowers",lbn,binNumber);
75  Towerphi = phi + 0.1;
76  binNumber = getBinNumberTower(eta, phi+0.1,0,0);
77  fill("highEtgTowers",Towereta,Towerphi);
78  fill("highEtgTowers",lbn,binNumber);
79  } else {
80  Towerphi = phi;
81  binNumber = getBinNumberTower(eta,phi,0,0);
82  fill("highEtgTowers",Towereta,Towerphi);
83  fill("highEtgTowers",lbn,binNumber);
84  }
85 
86  }
87  //only for h_gTower_coldtowers_etaphimap
88  else if (gfexTowerRoI->towerEt() <= -10){
89  if (std::abs(eta) >= 3.2){
90  Towerphi = phi- 0.1;
91  binNumber = getBinNumberTower(eta,phi-0.1,0,0);
92  fill("lowEtgTowers",Towereta,Towerphi);
93  fill("lowEtgTowers",lbn,binNumber);
94  Towerphi = phi + 0.1;
95  binNumber = getBinNumberTower(eta, phi+0.1,0,0);
96  fill("lowEtgTowers",Towereta,Towerphi);
97  fill("lowEtgTowers",lbn,binNumber);
98  } else {
99  Towerphi = phi;
100  binNumber = getBinNumberTower(eta,phi,0,0);
101  fill("lowEtgTowers",Towereta,Towerphi);
102  fill("lowEtgTowers",lbn,binNumber);
103  }
104  }
105  }
106 
107  nGfexTowers = nTowers;
108  fill ("highEtgTowers",lbn,nGfexTowers);
109 
110 
111  return StatusCode::SUCCESS;
112 }
113 
114 int GfexInputMonitorAlgorithm::getBinNumberTower (const float& inputEta, const float& inputPhi, int xbin, int ybin) const{
115  const std::vector<float> eta = {-4.9, -4.1,-3.5,-3.25,-3.2,-3.1,-2.9,-2.7,-2.5,-2.2,-2.0,-1.8,-1.6,-1.4,-1.2,-1.0,-0.8,-0,6,-0.4,-0.2,0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.5,2.7,2.9,3.1,3.3,3.25,3.5,4.1,4.9};
116 
117  for (int i = 0; i <= 40; i++){
118  if (inputEta >= eta[i] && inputEta < eta[i+1]){
119  xbin = i+1;
120  continue;
121  }
122  }
123  int j=1;
124  for (float phi = -3.2; phi <= 3.2;phi = phi+ 0.2){
125  if (inputPhi >= phi && inputPhi < phi+0.2){
126  ybin = j;
127  break;
128  }
129  j++;
130  }
131  int binN = 40*(ybin-1)+xbin;
132  return binN;
133 }
134 
135 
GfexInputMonitorAlgorithm::m_packageName
StringProperty m_packageName
Definition: GfexInputMonitorAlgorithm.h:23
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
GfexInputMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: GfexInputMonitorAlgorithm.cxx:13
GfexInputMonitorAlgorithm::GfexInputMonitorAlgorithm
GfexInputMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GfexInputMonitorAlgorithm.cxx:8
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
GfexInputMonitorAlgorithm.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::gFexTower_v1
Class describing input data of a LVL1 eFEX.
Definition: gFexTower_v1.h:22
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
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.
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
GfexInputMonitorAlgorithm::m_gFexTowerContainerKey
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gFexTowerContainerKey
Definition: GfexInputMonitorAlgorithm.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
xAOD::gFexTowerContainer
gFexTowerContainer_v1 gFexTowerContainer
Define the latest version of the TriggerTower container.
Definition: gFexTowerContainer.h:14
GfexInputMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: GfexInputMonitorAlgorithm.cxx:25
GfexInputMonitorAlgorithm::getBinNumberTower
int getBinNumberTower(const float &inputEta, const float &inputPhi, int xbin, int ybin) const
Definition: GfexInputMonitorAlgorithm.cxx:114
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327