ATLAS Offline Software
Loading...
Searching...
No Matches
MdtRawDataMonAlg.h
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4*/
5
7// Package : MdtRawDataMonitoring
8// Author: N. Benekos(Illinois) - G. Dedes(MPI) - Orin Harris (University of Washington)
9// Author: M. Biglietti (INFN Roma3)
10//
11// DESCRIPTION:
12// Subject: MDT-->Offline Muon Data Quality
14
15#ifndef MdtRawDataMonAlg_H
16#define MdtRawDataMonAlg_H
17
18// Core Include
22#include "GaudiKernel/ServiceHandle.h"
23#include "GaudiKernel/ToolHandle.h"
24
25// Helper Includes
27#include "MDTChamber.h"
28#include "MDTNoisyTubes.h"
41// standard library includes
42#include <atomic>
43#include <cstdlib>
44#include <fstream>
45#include <iostream>
46
47namespace Muon {
48 class MdtPrepData;
49}
50
51// stl includes
52#include <map>
53#include <set>
54#include <sstream>
55#include <string>
56#include <vector>
57
58// root includes
59class TH2;
63
64namespace monAlg {
66
68 public:
69 TubeTraversedBySegment(const std::string& hn, int tb, bool ih, IdentifierHash idh) :
70 hardware_name(hn),
71 tubeBin(tb),
72 isHit(ih),
73 idHash(idh)
74 {
75 }
76 std::string hardware_name;
78 bool isHit;
80 };
81
82 // Be careful here -- changes to this can break whether insertions to set are unique
83 // JG remove expensive hardware_name comparison w/ idHash comparison
84 // Hope I was careful ;)
87 if (A.idHash != B.idHash) return A.idHash < B.idHash;
88
89 if (A.tubeBin != B.tubeBin) return A.tubeBin < B.tubeBin;
90 return A.isHit < B.isHit;
91 }
92 };
93} // namespace monAlg
94
95// template <class ConcreteAlgorithm> class AlgFactory;
97public:
98 MdtRawDataMonAlg(const std::string& name, ISvcLocator* pSvcLocator);
99
101 virtual StatusCode initialize() override;
102 virtual StatusCode fillHistograms(const EventContext& ctx) const override;
103
104private:
105 static constexpr Identifier::value_type s_detectorElementMask = 0xFFFFC00000000000;
106
107 std::unique_ptr<MDTNoisyTubes> m_masked_tubes{nullptr};
108
109 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
110 ToolHandle<CP::IMuonSelectionTool> m_muonSelectionTool;
111
112 // MuonDetectorManager from the conditions store
113 SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey{this, "DetectorManagerKey", "MuonDetectorManager",
114 "Key of input MuonDetectorManager condition data"};
115
116 virtual void fillMDTOverviewVects(const Muon::MdtPrepData*, bool& isNoiseBurstCandidate, MDTOverviewHistogramStruct& vects) const;
117 virtual void fillMDTOverviewHistograms(const MDTOverviewHistogramStruct& vects) const;
118 virtual StatusCode fillMDTSummaryVects(const Muon::MdtPrepData*, const std::set<std::string>&, bool& isNoiseBurstCandidate,
119 bool trig_barrel, bool trig_endcap, std::array<MDTSummaryHistogramStruct, 4096>*) const;
120 virtual StatusCode fillMDTSummaryHistograms(std::array<MDTSummaryHistogramStruct, 4096>* vects, int lb) const;
121 virtual StatusCode fillMDTHistograms(const Muon::MdtPrepData*) const; // fill chamber by chamber histos
122
123 StatusCode handleEvent_effCalc_fillVects(const Trk::SegmentCollection* segms, MDTSegmentHistogramStruct (&vects)[4][4][16]) const;
124 virtual StatusCode fillMDTSegmentHistograms(const MDTSegmentHistogramStruct (&vects)[4][4][16]) const;
125
126 // MDTRawDataUtils_cxx
127 static bool AinB(int A, std::vector<int>& B);
128 virtual StatusCode binMdtGlobal(TH2*, char ecap);
129 virtual StatusCode binMdtRegional(TH2*, std::string_view xAxis);
130 virtual StatusCode binMdtGlobal_byLayer(TH2*, TH2*, TH2*);
131 virtual StatusCode binMdtOccVsLB(TH2*& h, int region, int layer);
132 virtual StatusCode binMdtOccVsLB_Crate(TH2*& h, int region, int crate);
133 static void ChamberTubeNumberCorrection(int& tubeNum, std::string_view hardware_name, int tubePos, int numLayers);
134 static void CorrectTubeMax(const std::string& hardware_name, int& numTubes);
135 static void CorrectLayerMax(const std::string& hardware_name, int& numLayers);
136 int get_bin_for_LB_hist(int region, int layer, int phi, int eta, bool isBIM) const;
137 int get_bin_for_LB_crate_hist(int region, int layer, int phi, int eta, std::string_view chamber) const;
138 // private function to initialize the selection of a certain region
139 void mdtchamberId();
140 // private function to find mdt mezz cards
141 int mezzmdt(const Identifier& id) const;
142 int GetTubeMax(const Identifier& digcoll_id, std::string_view hardware_name);
143
144 StatusCode GetTimingInfo(); // here
145 void initDeadChannels(const MuonGM::MdtReadoutElement* mydetEl);
146
148 this, "SegmentKey", {"TrkMuonSegments", "UnAssocMuonTrkSegments"}, "muon segments"};
149 SG::ReadHandleKey<xAOD::TrackParticleContainer> m_muon_type{this, "Muon_type", "ExtrapolatedMuonTrackParticles", "extrapolated muons"};
150
151 std::vector<Identifier> m_chambersId;
152 std::vector<IdentifierHash> m_chambersIdHash;
153 // std::map<std::string,float> m_hitsperchamber_map;//DEV to be put back?
154 std::map<std::string, int> m_tubesperchamber_map;
155
156 SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_key_mdt{this, "MdtPrepDataContainer", "MDT_DriftCircles", "MDT PRDs"};
157 SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_key_rpc{this, "RpcPrepDataContainer", "RPC_Measurements", "RPC PRDs"};
158 SG::ReadHandleKey<xAOD::MuonRoIContainer> m_l1RoiKey{this, "L1RoiKey", "LVL1MuonRoIs", "L1 muon ROIs"};
159 SG::ReadHandleKey<xAOD::MuonContainer> m_muonKey{this, "MuonKey", "Muons", "muons"};
160 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfo", "EventInfo", "event info"};
161
162 // Chamber by Chamber Plots
163 std::vector<std::unique_ptr<MDTChamber>> m_hist_hash_list{};
164
165 std::string getChamberName(const Muon::MdtPrepData*) const;
166 std::string getChamberName(const Identifier&) const;
167 StatusCode getChamber(const IdentifierHash& id, MDTChamber*& chamber) const;
168
169 Gaudi::Property<bool> m_doMdtESD{this, "DoMdtEsd", false};
170 Gaudi::Property<bool> m_doChamberHists{this, "DoChamberHist", true};
171 Gaudi::Property<bool> m_maskNoisyTubes{this, "maskNoisyTubes", true};
172 Gaudi::Property<size_t> m_ADCCut{this, "ADCCut", 50};
173 Gaudi::Property<size_t> m_nb_hits{this, "Eff_nHits", 5};
174 Gaudi::Property<bool> m_chi2_cut{this, "Eff_chi2Cut", 10};
175 Gaudi::Property<bool> m_do_mdtChamberHits{this, "do_mdtChamberHits", true};
176 Gaudi::Property<bool> m_do_mdttdccut_sector{this, "do_mdttdccut_sector", true};
177 Gaudi::Property<bool> m_do_mdtchamberstatphislice{this, "do_mdtchamberstatphislice", true};
178 Gaudi::Property<bool> m_do_run3Geometry{this, "do_Run3Geometry", false};
179 Gaudi::Property<size_t> m_HighOccThreshold{this, "nHits_NoiseThreshold", 16000};
180 Gaudi::Property<size_t> m_adcScale{this, "ADCScale", 1};
181
182 bool m_BMGpresent{false};
183 int m_BMGid{-1};
184 std::map<Identifier, std::set<Identifier> > m_DeadChannels{};
185 mutable std::atomic<int> m_firstEvent{-1};
186
187 bool m_atlas_ready{false};
188 bool isATLASReady() const { return m_atlas_ready; }
189 void setIsATLASReady();
190
191 int cachedTubeMax(const Identifier& id) const;
192 int cachedTubeLayerMax(const Identifier& id) const;
194};
195
196#endif
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Header file to be included by clients of the Monitored infrastructure.
Property holding a SG store/key/clid from which a ReadHandle is made.
Header file for AthHistogramAlgorithm.
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
This is a "hash" representation of an Identifier.
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
int get_bin_for_LB_hist(int region, int layer, int phi, int eta, bool isBIM) const
virtual StatusCode fillMDTHistograms(const Muon::MdtPrepData *) const
StatusCode getChamber(const IdentifierHash &id, MDTChamber *&chamber) const
virtual StatusCode binMdtRegional(TH2 *, std::string_view xAxis)
Gaudi::Property< bool > m_do_mdttdccut_sector
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_muon_type
int GetTubeMax(const Identifier &digcoll_id, std::string_view hardware_name)
std::map< Identifier, std::set< Identifier > > m_DeadChannels
virtual StatusCode binMdtGlobal_byLayer(TH2 *, TH2 *, TH2 *)
StatusCode handleEvent_effCalc_fillVects(const Trk::SegmentCollection *segms, MDTSegmentHistogramStruct(&vects)[4][4][16]) const
std::string getChamberName(const Muon::MdtPrepData *) const
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_key_rpc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< size_t > m_ADCCut
std::vector< std::unique_ptr< MDTChamber > > m_hist_hash_list
std::vector< Identifier > m_chambersId
static void CorrectLayerMax(const std::string &hardware_name, int &numLayers)
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_key_mdt
virtual StatusCode binMdtOccVsLB_Crate(TH2 *&h, int region, int crate)
Gaudi::Property< bool > m_do_run3Geometry
Gaudi::Property< bool > m_doMdtESD
virtual StatusCode fillMDTSummaryHistograms(std::array< MDTSummaryHistogramStruct, 4096 > *vects, int lb) const
const MuonGM::MuonDetectorManager * m_detMgr
virtual StatusCode binMdtGlobal(TH2 *, char ecap)
bool isATLASReady() const
int mezzmdt(const Identifier &id) const
virtual StatusCode initialize() override
initialize
virtual ~MdtRawDataMonAlg()
int get_bin_for_LB_crate_hist(int region, int layer, int phi, int eta, std::string_view chamber) const
Gaudi::Property< bool > m_do_mdtchamberstatphislice
StatusCode GetTimingInfo()
int cachedTubeLayerMax(const Identifier &id) const
ToolHandle< CP::IMuonSelectionTool > m_muonSelectionTool
std::vector< IdentifierHash > m_chambersIdHash
Gaudi::Property< size_t > m_adcScale
Gaudi::Property< bool > m_chi2_cut
Gaudi::Property< bool > m_maskNoisyTubes
virtual StatusCode binMdtOccVsLB(TH2 *&h, int region, int layer)
int cachedTubeMax(const Identifier &id) const
Gaudi::Property< size_t > m_HighOccThreshold
std::unique_ptr< MDTNoisyTubes > m_masked_tubes
virtual void fillMDTOverviewHistograms(const MDTOverviewHistogramStruct &vects) const
SG::ReadHandleKeyArray< Trk::SegmentCollection > m_segm_type
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_l1RoiKey
MdtRawDataMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode fillMDTSegmentHistograms(const MDTSegmentHistogramStruct(&vects)[4][4][16]) const
std::map< std::string, int > m_tubesperchamber_map
void initDeadChannels(const MuonGM::MdtReadoutElement *mydetEl)
virtual StatusCode fillMDTSummaryVects(const Muon::MdtPrepData *, const std::set< std::string > &, bool &isNoiseBurstCandidate, bool trig_barrel, bool trig_endcap, std::array< MDTSummaryHistogramStruct, 4096 > *) const
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Gaudi::Property< bool > m_doChamberHists
static void ChamberTubeNumberCorrection(int &tubeNum, std::string_view hardware_name, int tubePos, int numLayers)
Gaudi::Property< size_t > m_nb_hits
std::atomic< int > m_firstEvent
Gaudi::Property< bool > m_do_mdtChamberHits
static bool AinB(int A, std::vector< int > &B)
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
static constexpr Identifier::value_type s_detectorElementMask
static void CorrectTubeMax(const std::string &hardware_name, int &numTubes)
virtual void fillMDTOverviewVects(const Muon::MdtPrepData *, bool &isNoiseBurstCandidate, MDTOverviewHistogramStruct &vects) const
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
Property holding a SG store/key/clid from which a ReadHandle is made.
TubeTraversedBySegment(const std::string &hn, int tb, bool ih, IdentifierHash idh)
int lb
Definition globals.cxx:23
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
HandleKeyArray< ReadHandle< T >, ReadHandleKey< T >, Gaudi::DataHandle::Reader > ReadHandleKeyArray
DataVector< Trk::Segment > SegmentCollection
hold the test vectors and ease the comparison
bool operator()(const TubeTraversedBySegment &A, const TubeTraversedBySegment &B) const