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
69 const EventContext& ctx{Gaudi::Hive::currentContext()};
70 const TgcRdoContainer* rdos{nullptr};
71 ATH_CHECK(SG::get(rdos, m_inputKey, ctx));
72 for (const TgcRdo* rdo : *rdos) {
73 const uint16_t tgcSubDetID = rdo->subDetectorId();
74 const uint16_t tgcID = rdo->identify();
75 const uint16_t tgcTrigType = rdo->triggerType();
76 const uint16_t tgcRodID = rdo->rodId();
77 const uint16_t tgcBcID = rdo->bcId();
78 const uint16_t tgcL1ID = rdo->l1Id();
79
80 std::vector<unsigned> fillMe{};
82 for (unsigned h = 0 ; h < m_histos.size(); ++h) {
83 if (m_histos[h].stationName == -1) {
84 fillMe.push_back(h);
85 }
86 }
87
88 for (int h : fillMe) {
89 m_histos[h].h_tgcID->Fill(tgcID);
90 m_histos[h].h_tgcSubDetID->Fill(tgcSubDetID);
91 m_histos[h].h_tgcRodID->Fill(tgcRodID);
92 m_histos[h].h_tgcTrigType->Fill(tgcTrigType);
93 m_histos[h].h_tgcBcID->Fill(tgcBcID);
94 m_histos[h].h_tgcL1ID->Fill(tgcL1ID);
95 }
96
97 for (const TgcRawData* channel: *rdo) {
98 const uint16_t bctag = channel->bcTag();
99 const uint16_t subDetID = channel->subDetectorId();
100 const uint16_t rodID = channel->rodId();
101 const uint16_t sswID = channel->sswId();
102 const uint16_t slbID = channel->slbId();
103 const uint16_t bcID = channel->bcId();
104 const uint16_t l1ID = channel->l1Id();
105 TgcRawData::DataType type_var = channel->type();
106 TgcRawData::SlbType slbType_var = channel->slbType();
107 const uint16_t bitPos = channel->bitpos();
108 const uint16_t track = channel->tracklet();
109 const bool adj = channel->isAdjacent();
110
111 for (int h : fillMe) {
112 m_histos[h].h_bcTag->Fill(bctag);
113 m_histos[h].h_subDetID->Fill(subDetID);
114 m_histos[h].h_rodID->Fill(rodID);
115 m_histos[h].h_sswID->Fill(sswID);
116 m_histos[h].h_slbID->Fill(slbID);
117 m_histos[h].h_bcID->Fill(bcID);
118 m_histos[h].h_l1ID->Fill(l1ID);
119 m_histos[h].h_type->Fill(type_var);
120 m_histos[h].h_slbType->Fill(slbType_var);
121 if (type_var== 0) {
122 m_histos[h].h_bitPos->Fill(bitPos);
123 m_histos[h].h_track->Fill(track);
124 m_histos[h].h_adj->Fill(adj);
125 }
126 }
127 }
128 }
129 return StatusCode::SUCCESS;
130 }
131}
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
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 int &index) const
Gaudi::Property< std::string > m_path
virtual StatusCode initialize() override final
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
virtual StatusCode execute() override final
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.