ATLAS Offline Software
Loading...
Searching...
No Matches
TgcRDOAnalysis.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "TgcRDOAnalysis.h"
8
9#include <format>
10
11namespace MuonVal{
14 const std::string& basePath,
15 const int stName):
17 auto createHisto = [&](const std::string& hName,
18 const std::string& hTitle,
19 const unsigned nBins,
20 const float xLow,
21 const float xHigh) {
22 TH1* h = new TH1F(hName.c_str(), hTitle.c_str(), nBins, xLow, xHigh);
23 h->Sumw2();
24 histSvc->regHist(std::format("/{}/RDO/Station_{}/{}",
25 basePath,
26 stName > 0 ? idHelper.stationNameString(stName) : "Inclusive",
27 hName), h).ignore();
28 return h;
29 };
30 h_tgcID = createHisto("tgcID", "TGC ID", 100, 0, 25);
31 h_tgcSubDetID = createHisto("tgcSubDetID", "TGC sub-detector ID", 100, 0, 110);
32 h_tgcRodID = createHisto("tgcRodID", "TGC ROD ID", 100, 0, 15);
33 h_tgcTrigType = createHisto("tgcTrigType", "TGC trigger type", 100, 0, 2);
34 h_tgcBcID = createHisto("tgcBcID", "TGC BCID", 100, 0, 2);
35 h_tgcL1ID = createHisto("tgcL1ID", "TGC L1ID", 100, 0, 2);
36 h_bcTag = createHisto("bcTag", "BC Tag", 100, 0, 5);
37 h_subDetID = createHisto("subDetID", "Sub-detector ID", 100, 0, 110);
38 h_rodID = createHisto("rodID", "ROD ID", 100, 0, 15);
39 h_sswID = createHisto("sswID", "SSW ID", 100, 0, 10);
40 h_slbID = createHisto("slbID", "SLB ID", 100, 0, 30);
41 h_bcID = createHisto("bcID", "BCID", 100, 0, 10);
42 h_l1ID = createHisto("l1ID", "L1ID", 100, 0, 10);
43 h_type = createHisto("type", "type (hit or coinc)", 100, 0, 10);
44 h_slbType = createHisto("slbType", "SLB type", 100, 0, 10);
45 h_bitPos = createHisto("bitPos", "Bitmap position", 100, 0, 220);
46 h_track = createHisto("track", "tracklet", 100, 0, 10);
47 h_adj = createHisto("adj", "Adjacent", 100, 0, 2);
48 }
49
50
52 ATH_CHECK(m_inputKey.initialize());
53 ATH_CHECK(m_idHelperSvc.retrieve());
54
55 std::set<int> stationNames{-1};
56 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
57 std::for_each(idHelper.module_begin(), idHelper.module_end(),
58 [&stationNames, &idHelper](const Identifier& id) {
59 stationNames.insert(idHelper.stationName(id));
60 });
61 for (const int st : stationNames) {
62 m_histos.emplace_back(idHelper, histSvc(), m_path, st);
63 }
64
65 return StatusCode::SUCCESS;
66 }
67
68 StatusCode TgcRDOAnalysis::execute(const EventContext& ctx) {
69 const TgcRdoContainer* rdos{nullptr};
70 ATH_CHECK(SG::get(rdos, m_inputKey, ctx));
71 for (const TgcRdo* rdo : *rdos) {
72 const uint16_t tgcSubDetID = rdo->subDetectorId();
73 const uint16_t tgcID = rdo->identify();
74 const uint16_t tgcTrigType = rdo->triggerType();
75 const uint16_t tgcRodID = rdo->rodId();
76 const uint16_t tgcBcID = rdo->bcId();
77 const uint16_t tgcL1ID = rdo->l1Id();
78
79 std::vector<unsigned> fillMe{};
81 for (unsigned h = 0 ; h < m_histos.size(); ++h) {
82 if (m_histos[h].stationName == -1) {
83 fillMe.push_back(h);
84 }
85 }
86
87 for (int h : fillMe) {
88 m_histos[h].h_tgcID->Fill(tgcID);
89 m_histos[h].h_tgcSubDetID->Fill(tgcSubDetID);
90 m_histos[h].h_tgcRodID->Fill(tgcRodID);
91 m_histos[h].h_tgcTrigType->Fill(tgcTrigType);
92 m_histos[h].h_tgcBcID->Fill(tgcBcID);
93 m_histos[h].h_tgcL1ID->Fill(tgcL1ID);
94 }
95
96 for (const TgcRawData* channel: *rdo) {
97 const uint16_t bctag = channel->bcTag();
98 const uint16_t subDetID = channel->subDetectorId();
99 const uint16_t rodID = channel->rodId();
100 const uint16_t sswID = channel->sswId();
101 const uint16_t slbID = channel->slbId();
102 const uint16_t bcID = channel->bcId();
103 const uint16_t l1ID = channel->l1Id();
104 TgcRawData::DataType type_var = channel->type();
105 TgcRawData::SlbType slbType_var = channel->slbType();
106 const uint16_t bitPos = channel->bitpos();
107 const uint16_t track = channel->tracklet();
108 const bool adj = channel->isAdjacent();
109
110 for (int h : fillMe) {
111 m_histos[h].h_bcTag->Fill(bctag);
112 m_histos[h].h_subDetID->Fill(subDetID);
113 m_histos[h].h_rodID->Fill(rodID);
114 m_histos[h].h_sswID->Fill(sswID);
115 m_histos[h].h_slbID->Fill(slbID);
116 m_histos[h].h_bcID->Fill(bcID);
117 m_histos[h].h_l1ID->Fill(l1ID);
118 m_histos[h].h_type->Fill(type_var);
119 m_histos[h].h_slbType->Fill(slbType_var);
120 if (type_var== 0) {
121 m_histos[h].h_bitPos->Fill(bitPos);
122 m_histos[h].h_track->Fill(track);
123 m_histos[h].h_adj->Fill(adj);
124 }
125 }
126 }
127 }
128 return StatusCode::SUCCESS;
129 }
130}
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
virtual StatusCode execute()
Execute method without EventContext (deprecated).
Header file for AthHistogramAlgorithm.
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
const_id_iterator module_end() const
const_id_iterator module_begin() const
Iterators over full set of ids.
const std::string & stationNameString(const Identifier &id) const
Gaudi::Property< std::string > m_path
virtual StatusCode initialize() override final
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
SG::ReadHandleKey< TgcRdoContainer > m_inputKey
std::vector< HistoSet > m_histos
An unit object of TGC ROD output.
Definition TgcRawData.h:23
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19
const std::string & stName(StIndex index)
convert StIndex into a string
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
HistoSet(const TgcIdHelper &idHelper, const ServiceHandle< ITHistSvc > &histSvc, const std::string &basePath, const int stName)
Constructor instantiating the monitoring histograms.