ATLAS Offline Software
CpmSimMonitorAlgorithm.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef TRIGT1CALOMONITORING_CPMSIMMONITORALGORITHM_H
5 #define TRIGT1CALOMONITORING_CPMSIMMONITORALGORITHM_H
6 
18 //
22 //
24 //
30 
31 #include "TrigConfData/L1Menu.h"
32 
33 #include <mutex>
34 
35 class IL1CPCMXTools;
36 class IL1CPMTools;
37 class ITrigT1CaloMonErrorTool;
38 
40  public:CpmSimMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator );
41  virtual ~CpmSimMonitorAlgorithm()=default;
42  virtual StatusCode initialize() override;
43  virtual StatusCode fillHistograms( const EventContext& ctx ) const override;
44 
45  private:
46 
47  // to deal with L1 menu
48  ServiceHandle<TrigConf::ITrigConfigSvc> m_configSvc{this, "TrigConfigSvc", "TrigConf::xAODConfigSvc/xAODConfigSvc"};
49  const TrigConf::L1Menu* getL1Menu(const EventContext& ctx) const;
50 
51  StringProperty m_packageName{this,"PackageName","CpmSimMonitor","group name for histograming"};
52 
53  // Error vector StoreGate key
54  SG::WriteHandleKey<std::vector<int>> m_errorLocation{this,"ErrorLocation","L1CaloCPMMismatchVector","ErrorVector"};
55 
56  Gaudi::Property<int> m_crates{this,"s_crates", 4, "Number of CPM crates"};
57  Gaudi::Property<int> m_modules{this,"s_modules", 14, "Number of modules per crate (modules numbered 1-14)"};
58  Gaudi::Property<int> m_maxSlices{this,"s_maxSlices", 5, "Maximum number of slices"};
59  Gaudi::Property<int> m_cmxs{this,"s_cmxs", 2, "Number of CMXs"};
60 
61  Gaudi::Property<bool> m_legacyCpHadInputsDisabled{this,"s_legacyCpHadInputsDisabled", false, "Status of the L1Calo Legacy CP hadronic inputs"};
62 
63  // CPM overlap tower container present
65 
66  // Mismatch summary bins
71 
72  typedef std::vector<int> ErrorVector;
73 
74  // container keys including steering parameter and description
77  SG::ReadHandleKey<xAOD::CPMTowerContainer> m_cpmTowerLocationOverlap{this, "CPMTowerLocationOverlap",LVL1::TrigT1CaloDefs::CPMTowerLocation + "Overlap", "CPM Overlap container"};
82 
83  SG::ReadHandleKey<TrigConf::L1Menu> m_L1MenuKey { this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu" };
84 
85 
86  // CP-CMX simulation tool
87  ToolHandle<LVL1::IL1CPCMXTools> m_cpCmxTool;
88  // CP simulation tool
89  ToolHandle<LVL1::IL1CPMTools> m_cpmTool;
90  // Event veto error tool
91  ToolHandle<LVL1::ITrigT1CaloMonErrorTool> m_errorTool;
92 
93  //typedef maps
94  typedef std::map<int, const xAOD::TriggerTower*> TriggerTowerMapEm;
95  typedef std::map<int, const xAOD::TriggerTower*> TriggerTowerMapHad;
97  typedef std::map<int, const xAOD::CMXCPTob*> CmxCpTobMap;
98  typedef std::map<int, const xAOD::CMXCPHits*> CmxCpHitsMap;
100 
101  // Set up TriggerTower map
103  TriggerTowerMapEm& emmap, TriggerTowerMapHad& hadmap) const;
104 
105  // Set up CpmTower map
106  StatusCode setupMap(const xAOD::CPMTowerContainer* coll, CpmTowerMap& map) const;
107 
108  // Set up CpmTobRoi map - one for read handles and one without?
109  StatusCode setupMap(const xAOD::CPMTobRoIContainer* coll, CpmTobRoiMap& map) const;
110 
111  // Set up CmxCpTob map
113  std::vector<int>* parityMap = 0) const;
114  // Set up CmxCpHits map
115  StatusCode setupMap(const xAOD::CMXCPHitsContainer* coll, CmxCpHitsMap& map) const;
116 
117  // Compare Trigger Towers and CPM Towers
118  bool compareEm(const TriggerTowerMapEm& ttMap, const CpmTowerMap& cpMap,
119  ErrorVector& errors, bool overlap) const;
120  bool compareHad(const TriggerTowerMapHad& ttMap, const CpmTowerMap& cpMap,
121  ErrorVector& errors, bool overlap) const;
122 
123  // Compare Simulated RoIs with data
124  void compare(const CpmTobRoiMap& roiSimMap, const CpmTobRoiMap& roiMap,
126  const xAOD::RODHeaderContainer* rodTES) const;
127 
128  // Compare simulated CMX TOBs with data
129  void compare(const CmxCpTobMap& simMap, const CmxCpTobMap& datMap,
130  const std::vector<int> & parityMap,
131  ErrorVector& errorsCPM, ErrorVector& errorsCMX,
132  const xAOD::RODHeaderContainer* rodTES) const;
133 
134  // Compare Simulated CMX Hit Sums and Data CMX Hit Sums
135  void compare(const CmxCpHitsMap& cmxSimMap, const CmxCpHitsMap& cmxMap,
136  ErrorVector& errors, int selection) const;
137 
138 
139  // simulation
140  // Simulate CPM RoIs from CPM Towers
141  void simulate(const CpmTowerMap *towers, const CpmTowerMap *towersOv,
142  xAOD::CPMTobRoIContainer* rois, const EventContext& ctx) const;
143  // Simulate CPM RoIs from CPM Towers quick version
144  void simulate(const CpmTowerMap* towers, xAOD::CPMTobRoIContainer* rois, const EventContext& ctx) const;
145 
146 
147  // Simulate CMX-CP TOBs from CPM RoIs
149 
150  // Simulate CMX Hit sums from CMX TOBs
151  void simulate(const xAOD::CMXCPTobContainer* tobs,
153  const EventContext& ctx) const;
154 
155  // Simulate CMX Total Hit sums from Remote/Local
156  void simulate(const xAOD::CMXCPHitsContainer* hitsIn,
157  xAOD::CMXCPHitsContainer* hitsOut) const;
158 
159  // Return EM FPGA for given crate/phi
160  int fpga(int crate, double phi) const;
161 
162  // Return a tower with zero energy if parity bit is set
163  CpmTowerMap::mapped_type ttCheck( CpmTowerMap::mapped_type tt, xAOD::CPMTowerContainer* coll) const;
164 
165  // Check if LimitedRoISet bit is set
166  bool limitedRoiSet(int crate, SG::ReadHandle<xAOD::RODHeaderContainer> &rodTES) const;
167  bool limitedRoiSet(int crate, const xAOD::RODHeaderContainer* rodTES) const;
168 
169  // Flag which threshold hit values are non-zero and the same
170  int thresholdsSame(int val1, int val2, int nThresh, int nBits) const;
171 
172  // Flag which threshold hit values are different
173  int thresholdsDiff(int val1, int val2, int nThresh, int nBits) const;
174 
176  Monitored::Scalar<int> &witem,
177  int x, int val, int nThresh,
178  int nBits, int offset = 0) const;
179 
180  // count number of error events per lumiblock across threads for each type of error
181  mutable std::mutex m_mutex{};
182  mutable std::map<uint32_t, int> m_errorLB_tt_counter ATLAS_THREAD_SAFE;
183  mutable std::map<uint32_t, int> m_errorLB_roi_counter ATLAS_THREAD_SAFE;
184  mutable std::map<uint32_t, int> m_errorLB_tob_counter ATLAS_THREAD_SAFE;
185  mutable std::map<uint32_t, int> m_errorLB_thresh_counter ATLAS_THREAD_SAFE;
186 
187 };
188 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
CpmSimMonitorAlgorithm::EMTowerMismatch
@ EMTowerMismatch
Definition: CpmSimMonitorAlgorithm.h:67
CpmSimMonitorAlgorithm::HadTowerMismatch
@ HadTowerMismatch
Definition: CpmSimMonitorAlgorithm.h:67
CpmSimMonitorAlgorithm::CpmSimMonitorAlgorithm
CpmSimMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CpmSimMonitorAlgorithm.cxx:9
xAOD::CPMTobRoIMap_t
std::map< int, const CPMTobRoI * > CPMTobRoIMap_t
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTobRoI.h:19
CpmSimMonitorAlgorithm::simulate
void simulate(const CpmTowerMap *towers, const CpmTowerMap *towersOv, xAOD::CPMTobRoIContainer *rois, const EventContext &ctx) const
Definition: CpmSimMonitorAlgorithm.cxx:1884
CpmSimMonitorAlgorithm::m_cpmTool
ToolHandle< LVL1::IL1CPMTools > m_cpmTool
Definition: CpmSimMonitorAlgorithm.h:89
CpmSimMonitorAlgorithm::m_errorTool
ToolHandle< LVL1::ITrigT1CaloMonErrorTool > m_errorTool
Definition: CpmSimMonitorAlgorithm.h:91
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
CpmSimMonitorAlgorithm::NumberOfSummaryBins
@ NumberOfSummaryBins
Definition: CpmSimMonitorAlgorithm.h:70
LVL1::TrigT1CaloDefs::RODHeaderLocation
static const std::string RODHeaderLocation
Definition: TrigT1CaloDefs.h:68
CpmSimMonitorAlgorithm::TriggerTowerMapHad
std::map< int, const xAOD::TriggerTower * > TriggerTowerMapHad
Definition: CpmSimMonitorAlgorithm.h:95
CpmSimMonitorAlgorithm::thresholdsSame
int thresholdsSame(int val1, int val2, int nThresh, int nBits) const
Definition: CpmSimMonitorAlgorithm.cxx:1735
CpmSimMonitorAlgorithm::ATLAS_THREAD_SAFE
std::map< uint32_t, int > m_errorLB_thresh_counter ATLAS_THREAD_SAFE
Definition: CpmSimMonitorAlgorithm.h:185
CpmSimMonitorAlgorithm::m_packageName
StringProperty m_packageName
Definition: CpmSimMonitorAlgorithm.h:51
CpmSimMonitorAlgorithm::fillXVsThresholds
void fillXVsThresholds(Monitored::Scalar< int > &xitem, Monitored::Scalar< int > &yitem, Monitored::Scalar< int > &witem, int x, int val, int nThresh, int nBits, int offset=0) const
Definition: CpmSimMonitorAlgorithm.cxx:1714
CpmSimMonitorAlgorithm::fpga
int fpga(int crate, double phi) const
Definition: CpmSimMonitorAlgorithm.cxx:1980
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CpmSimMonitorAlgorithm::~CpmSimMonitorAlgorithm
virtual ~CpmSimMonitorAlgorithm()=default
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
CpmSimMonitorAlgorithm::m_mutex
std::mutex m_mutex
Definition: CpmSimMonitorAlgorithm.h:181
CpmSimMonitorAlgorithm::m_rodHeaderLocation
SG::ReadHandleKey< xAOD::RODHeaderContainer > m_rodHeaderLocation
Definition: CpmSimMonitorAlgorithm.h:81
IL1CPCMXTools.h
CpmSimMonitorAlgorithm::ATLAS_THREAD_SAFE
std::map< uint32_t, int > m_errorLB_tt_counter ATLAS_THREAD_SAFE
Definition: CpmSimMonitorAlgorithm.h:182
CPRoIDecoder.h
TriggerTowerKey.h
CpmSimMonitorAlgorithm::ATLAS_THREAD_SAFE
std::map< uint32_t, int > m_errorLB_roi_counter ATLAS_THREAD_SAFE
Definition: CpmSimMonitorAlgorithm.h:183
CpmSimMonitorAlgorithm::TotalSumMismatch
@ TotalSumMismatch
Definition: CpmSimMonitorAlgorithm.h:69
CPMTowerContainer.h
LVL1::TrigT1CaloDefs::CMXCPTobLocation
static const std::string CMXCPTobLocation
Definition: TrigT1CaloDefs.h:58
CPMTobRoIAuxContainer.h
CpmSimMonitorAlgorithm::thresholdsDiff
int thresholdsDiff(int val1, int val2, int nThresh, int nBits) const
Definition: CpmSimMonitorAlgorithm.cxx:1750
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
RODHeaderContainer.h
ITrigT1CaloMonErrorTool.h
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
CpmSimMonitorAlgorithm::m_cpCmxTool
ToolHandle< LVL1::IL1CPCMXTools > m_cpCmxTool
Definition: CpmSimMonitorAlgorithm.h:87
CpmSimMonitorAlgorithm::m_cmxCpTobLocation
SG::ReadHandleKey< xAOD::CMXCPTobContainer > m_cmxCpTobLocation
Definition: CpmSimMonitorAlgorithm.h:79
CpmSimMonitorAlgorithm::limitedRoiSet
bool limitedRoiSet(int crate, SG::ReadHandle< xAOD::RODHeaderContainer > &rodTES) const
Definition: CpmSimMonitorAlgorithm.cxx:2033
x
#define x
CMXCPTobContainer.h
CpmSimMonitorAlgorithm::CpmTowerMap
xAOD::CPMTowerMap_t CpmTowerMap
Definition: CpmSimMonitorAlgorithm.h:96
CpmSimMonitorAlgorithm::compareHad
bool compareHad(const TriggerTowerMapHad &ttMap, const CpmTowerMap &cpMap, ErrorVector &errors, bool overlap) const
Definition: CpmSimMonitorAlgorithm.cxx:605
CMXCPTobAuxContainer.h
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
CpmSimMonitorAlgorithm::m_overlapPresent
bool m_overlapPresent
Definition: CpmSimMonitorAlgorithm.h:64
CMXCPHitsContainer.h
CpmSimMonitorAlgorithm::m_cpmTowerLocation
SG::ReadHandleKey< xAOD::CPMTowerContainer > m_cpmTowerLocation
Definition: CpmSimMonitorAlgorithm.h:76
CpmSimMonitorAlgorithm::m_cpmTowerLocationOverlap
SG::ReadHandleKey< xAOD::CPMTowerContainer > m_cpmTowerLocationOverlap
Definition: CpmSimMonitorAlgorithm.h:77
CpmSimMonitorAlgorithm::compare
void compare(const CpmTobRoiMap &roiSimMap, const CpmTobRoiMap &roiMap, ErrorVector &errors, const xAOD::RODHeaderContainer *rodTES) const
Definition: CpmSimMonitorAlgorithm.cxx:834
CpmSimMonitorAlgorithm::m_errorLocation
SG::WriteHandleKey< std::vector< int > > m_errorLocation
Definition: CpmSimMonitorAlgorithm.h:54
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
CpmSimMonitorAlgorithm::ErrorVector
std::vector< int > ErrorVector
Definition: CpmSimMonitorAlgorithm.h:72
CpmSimMonitorAlgorithm::CmxCpTobMap
std::map< int, const xAOD::CMXCPTob * > CmxCpTobMap
Definition: CpmSimMonitorAlgorithm.h:97
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthMonitorAlgorithm.h
CpmSimMonitorAlgorithm::m_cpmTobRoiLocation
SG::ReadHandleKey< xAOD::CPMTobRoIContainer > m_cpmTobRoiLocation
Definition: CpmSimMonitorAlgorithm.h:78
CpmSimMonitorAlgorithm::ttCheck
CpmTowerMap::mapped_type ttCheck(CpmTowerMap::mapped_type tt, xAOD::CPMTowerContainer *coll) const
Definition: CpmSimMonitorAlgorithm.cxx:1991
CpmSimMonitorAlgorithm::TauRoIMismatch
@ TauRoIMismatch
Definition: CpmSimMonitorAlgorithm.h:68
CpmSimMonitorAlgorithm::TriggerTowerMapEm
std::map< int, const xAOD::TriggerTower * > TriggerTowerMapEm
Definition: CpmSimMonitorAlgorithm.h:94
xAOD::CPMTowerMap_t
std::map< int, const CPMTower * > CPMTowerMap_t
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTower.h:18
CpmSimMonitorAlgorithm::m_legacyCpHadInputsDisabled
Gaudi::Property< bool > m_legacyCpHadInputsDisabled
Definition: CpmSimMonitorAlgorithm.h:61
CpmSimMonitorAlgorithm::LocalSumMismatch
@ LocalSumMismatch
Definition: CpmSimMonitorAlgorithm.h:69
CpmSimMonitorAlgorithm::setupMap
StatusCode setupMap(const xAOD::TriggerTowerContainer *coll, TriggerTowerMapEm &emmap, TriggerTowerMapHad &hadmap) const
Definition: CpmSimMonitorAlgorithm.cxx:1767
CpmSimMonitorAlgorithm::m_cmxs
Gaudi::Property< int > m_cmxs
Definition: CpmSimMonitorAlgorithm.h:59
CpmSimMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: CpmSimMonitorAlgorithm.cxx:18
LVL1::TrigT1CaloDefs::CPMTowerLocation
static const std::string CPMTowerLocation
Definition: TrigT1CaloDefs.h:38
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CpmSimMonitorAlgorithm::m_triggerTowerLocation
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerLocation
Definition: CpmSimMonitorAlgorithm.h:75
CpmSimMonitorAlgorithm::m_crates
Gaudi::Property< int > m_crates
Definition: CpmSimMonitorAlgorithm.h:56
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
CMXCPHitsAuxContainer.h
DataError.h
CpmSimMonitorAlgorithm::m_cmxCpHitsLocation
SG::ReadHandleKey< xAOD::CMXCPHitsContainer > m_cmxCpHitsLocation
Definition: CpmSimMonitorAlgorithm.h:80
CpmSimMonitorAlgorithm::m_configSvc
ServiceHandle< TrigConf::ITrigConfigSvc > m_configSvc
Definition: CpmSimMonitorAlgorithm.h:48
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
CpmSimMonitorAlgorithm::EMRoIMismatch
@ EMRoIMismatch
Definition: CpmSimMonitorAlgorithm.h:67
CpmSimMonitorAlgorithm::LeftCMXTobMismatch
@ LeftCMXTobMismatch
Definition: CpmSimMonitorAlgorithm.h:68
selection
const std::string selection
Definition: fbtTestBasics.cxx:74
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CpmSimMonitorAlgorithm::m_modules
Gaudi::Property< int > m_modules
Definition: CpmSimMonitorAlgorithm.h:57
CpmSimMonitorAlgorithm::TopoMismatch
@ TopoMismatch
Definition: CpmSimMonitorAlgorithm.h:70
LVL1::TrigT1CaloDefs::xAODTriggerTowerLocation
static const std::string xAODTriggerTowerLocation
Definition: TrigT1CaloDefs.h:36
TrigT1CaloDefs.h
CpmSimMonitorAlgorithm::RightCMXTobMismatch
@ RightCMXTobMismatch
Definition: CpmSimMonitorAlgorithm.h:68
CpmSimMonitorAlgorithm::simulate
void simulate(const xAOD::CMXCPHitsContainer *hitsIn, xAOD::CMXCPHitsContainer *hitsOut) const
CpmSimMonitorAlgorithm::m_maxSlices
Gaudi::Property< int > m_maxSlices
Definition: CpmSimMonitorAlgorithm.h:58
CoordinateRange.h
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
TriggerTower.h
CpmSimMonitorAlgorithm::ATLAS_THREAD_SAFE
std::map< uint32_t, int > m_errorLB_tob_counter ATLAS_THREAD_SAFE
Definition: CpmSimMonitorAlgorithm.h:184
CpmSimMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: CpmSimMonitorAlgorithm.cxx:59
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
IL1CPMTools.h
CPMTowerAuxContainer.h
TriggerTest.rois
rois
Definition: TriggerTest.py:23
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
CpmSimMonitorAlgorithm::getL1Menu
const TrigConf::L1Menu * getL1Menu(const EventContext &ctx) const
Definition: CpmSimMonitorAlgorithm.cxx:2051
CpmSimMonitorAlgorithm::SummaryErrors
SummaryErrors
Definition: CpmSimMonitorAlgorithm.h:67
LVL1::TrigT1CaloDefs::CPMTobRoILocation
static const std::string CPMTobRoILocation
Definition: TrigT1CaloDefs.h:62
CpmSimMonitorAlgorithm
Definition: CpmSimMonitorAlgorithm.py:1
CpmSimMonitorAlgorithm::compareEm
bool compareEm(const TriggerTowerMapEm &ttMap, const CpmTowerMap &cpMap, ErrorVector &errors, bool overlap) const
Definition: CpmSimMonitorAlgorithm.cxx:387
CpmSimMonitorAlgorithm::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: CpmSimMonitorAlgorithm.h:83
CpmSimMonitorAlgorithm::CmxCpHitsMap
std::map< int, const xAOD::CMXCPHits * > CmxCpHitsMap
Definition: CpmSimMonitorAlgorithm.h:98
CpmSimMonitorAlgorithm::CpmTobRoiMap
xAOD::CPMTobRoIMap_t CpmTobRoiMap
Definition: CpmSimMonitorAlgorithm.h:99
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
L1Menu.h
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
LVL1::TrigT1CaloDefs::CMXCPHitsLocation
static const std::string CMXCPHitsLocation
Definition: TrigT1CaloDefs.h:59
CpmSimMonitorAlgorithm::RemoteSumMismatch
@ RemoteSumMismatch
Definition: CpmSimMonitorAlgorithm.h:69
ServiceHandle< TrigConf::ITrigConfigSvc >