CpmMonitorAlgorithm.h 4.67 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
*/
#ifndef TRIGT1CALOMONITORING_CPMMONITORALGORITHM_H
#define TRIGT1CALOMONITORING_CPMMONITORALGORITHM_H

#include "AthenaMonitoring/AthMonitorAlgorithm.h"
#include "AthenaMonitoringKernel/Monitored.h"
#include "StoreGate/ReadHandleKey.h"
#include "xAODTrigL1Calo/CPMTowerContainer.h" 
#include "xAODTrigL1Calo/CPMTobRoIContainer.h"
#include "xAODTrigL1Calo/CMXCPTobContainer.h"
#include "xAODTrigL1Calo/CMXCPHitsContainer.h"
#include "TrigT1Interfaces/TrigT1CaloDefs.h"


class CpmMonitorAlgorithm : public AthMonitorAlgorithm {
 public:CpmMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator );
  virtual ~CpmMonitorAlgorithm()=default;
  virtual StatusCode initialize() override;
  virtual StatusCode fillHistograms( const EventContext& ctx ) const override;

  // monitoring trigger tower structs for various towers
  struct MonitorTT{
Shaun Roe's avatar
Shaun Roe committed
25
26
    const xAOD::TriggerTower_v2* ttower{};
    double phi_scaled{}; // rescaled for 2D plots
27
  };
28

29
  struct MonitorCpmTT{
Shaun Roe's avatar
Shaun Roe committed
30
    const xAOD::CPMTower_v2* ttower{};
31
    // some modified/derived information 
Shaun Roe's avatar
Shaun Roe committed
32
33
    double phi_scaled{}; // rescaled for 2D plots
    int slice{}; // crate * m_maxSlices + emEnergyVec()).size() - 1;
34
    // errors
Shaun Roe's avatar
Shaun Roe committed
35
36
37
38
39
    bool emParityError{};
    bool emLinkDownError{};
    bool emGLinkParityError[8]{}; 
    bool hadParityError{};
    bool hadLinkDownError{};   
40
41
42
43
44
  };

  struct MonitorTobRoI{
    const xAOD::CPMTobRoI_v1* tobroi;
    // some modified/derived information 
Shaun Roe's avatar
Shaun Roe committed
45
46
    double etaMod{}; 
    double phiMod{}; 
47
48
49
50
51
  };

  struct MonitorCmxCpTob{
    const xAOD::CMXCPTob_v1* tob;
    // some modified/derived information 
Shaun Roe's avatar
Shaun Roe committed
52
53
54
    uint8_t x{}; // crate * m_modules + cpm - 1
    uint8_t y{}; // chip * 4 + location
    int ybase{}; // cmx * 5
55
    // errors required to be used as masks
Shaun Roe's avatar
Shaun Roe committed
56
57
    bool parityError{};
    int ybaseError{}; 
58
59
  };

60
  struct MonitorCmxCpHits{
Shaun Roe's avatar
Shaun Roe committed
61
    const xAOD::CMXCPHits_v1* hit{};
62
    // some modified/derived information 
Shaun Roe's avatar
Shaun Roe committed
63
64
    uint8_t crateSlices{}; // crate * m_maxSlices + slices - 1
    uint8_t crateCmx{}; // crate * 2 + cmx
65
    // source flag
Shaun Roe's avatar
Shaun Roe committed
66
    bool srcTopoCheckSum{};
67
  };
68
69
70
71
72


private:

  // Phi scale for trigger tower eta/phi plots
Shaun Roe's avatar
Shaun Roe committed
73
  double m_phiScaleTT{};
74
75
76
77
78
79
80

  StringProperty m_packageName{this,"PackageName","CpmMonitor","group name for histograming"};

  Gaudi::Property<int> m_crates{this,"s_crates", 4,  "Number of CPM crates"};
  Gaudi::Property<int> m_modules{this,"s_modules", 14, "Number of modules per crate (modules numbered 1-14)"};
  Gaudi::Property<int> m_maxSlices{this,"s_maxSlices", 5,  "Maximum number of slices"};
  Gaudi::Property<int> m_tobsPerCPM{this,"s_tobsPerCPM", 5,  "Maximum number of TOBs per CPM sent to CMX"};
81
  Gaudi::Property<int> m_isolBits{this,"s_isolBits", 5,  "Number of bits for encoded isolation"};
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  Gaudi::Property<int> m_threshBits{this,"s_threshBits", 3,  "Number of bits per threshold for hit sums"};
  Gaudi::Property<int> m_thresholds{this,"s_thresholds", 16, "Number of EM/Tau threshold bits"};
  Gaudi::Property<int> m_maxTobsPerCmx{this,"MaxTOBsPerCMX", 70,  "Maximum number of TOBs per CMX plotted"};

  /// Error summary plot bins
  enum SummaryErrors { EMParity, EMLink, HadParity, HadLink, CPMStatus,
                       TOBParity, SumParity, CMXStatus, NumberOfSummaryBins };


  // container keys including steering parameter and description
  SG::ReadHandleKey<xAOD::TriggerTowerContainer> m_xAODTriggerTowerContainerName{this, "BS_xAODTriggerTowerContainer",LVL1::TrigT1CaloDefs::xAODTriggerTowerLocation,"Trigger Tower Container"};
  SG::ReadHandleKey<xAOD::CPMTowerContainer> m_cpmTowerLocation{this, "CPMTowerLocation", LVL1::TrigT1CaloDefs::CPMTowerLocation, "CPM container"};
  SG::ReadHandleKey<xAOD::CPMTowerContainer> m_cpmTowerLocationOverlap{this, "CPMTowerLocationOverlap",LVL1::TrigT1CaloDefs::CPMTowerLocation + "Overlap", "CPM Overlap container"};
  SG::ReadHandleKey<xAOD::CPMTobRoIContainer> m_cpmTobRoiLocation{this, "CPMTobRoILocation", LVL1::TrigT1CaloDefs::CPMTobRoILocation, "CPMTobRoI container"};
  SG::ReadHandleKey<xAOD::CMXCPTobContainer> m_cmxCpTobLocation{this, "CMXCPTobLocation", LVL1::TrigT1CaloDefs::CMXCPTobLocation, "CMXCPTob container"};
  SG::ReadHandleKey<xAOD::CMXCPHitsContainer> m_cmxCpHitsLocation{this, "CMXCPHitsLocation", LVL1::TrigT1CaloDefs::CMXCPHitsLocation, "CMXCPHits container"};

99
  std::vector<bool> getIsolationBits(int val, int nThresh, int nBits) const;
100
101
102
103
104


  StatusCode fillCpmTowerVectors(SG::ReadHandle<xAOD::CPMTowerContainer> &cpmTower,
				 std::vector<MonitorCpmTT> &monCpmTTs_em, std::vector<MonitorCpmTT> &monCpmTTs_had,
				 std::vector<int> &errorsCPM, 
105
106
107
				 bool core,
				 Monitored::Scalar<int> &cpmLoc,
				 Monitored::Scalar<int> &GLinkParityError
108
109
110
111
112
				 ) const;


};
#endif