ATLAS Offline Software
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"
7 #include "StoreGate/ReadHandle.h"
8 
9 #include <format>
10 
11 namespace 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 
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 }
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition: AthHistogramAlgorithm.h:113
TgcRawData::DataType
DataType
Definition: TgcRawData.h:42
MuonVal::TgcRDOAnalysis::m_histos
std::vector< HistoSet > m_histos
Definition: TgcRDOAnalysis.h:68
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
vtune_athena.format
format
Definition: vtune_athena.py:14
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
TgcIdHelper
Definition: TgcIdHelper.h:50
MuonVal::TgcRDOAnalysis::m_inputKey
SG::ReadHandleKey< TgcRdoContainer > m_inputKey
Definition: TgcRDOAnalysis.h:28
Muon::MuonStationIndex::stName
const std::string & stName(StIndex index)
convert StIndex into a string
Definition: MuonStationIndex.cxx:104
MuonVal::TgcRDOAnalysis::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
Definition: TgcRDOAnalysis.h:31
MuonVal::TgcRDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: TgcRDOAnalysis.cxx:51
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
TgcRdoContainer
Definition: TgcRdoContainer.h:25
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
extractSporadic.h
list h
Definition: extractSporadic.py:96
python.getProblemFolderFromLogs.st
st
Definition: getProblemFolderFromLogs.py:68
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
h_type
std::vector< QString > h_type
Definition: VP1TriggerHandleEF.cxx:35
MuonVal
Class to store array like branches into the n-tuples.
Definition: HitValAlg.cxx:19
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
MuonVal::TgcRDOAnalysis::HistoSet::HistoSet
HistoSet(const TgcIdHelper &idHelper, const ServiceHandle< ITHistSvc > &histSvc, const std::string &basePath, const int stName)
Constructor instantiating the monitoring histograms.
Definition: TgcRDOAnalysis.cxx:12
MuonVal::TgcRDOAnalysis::execute
virtual StatusCode execute() override final
Definition: TgcRDOAnalysis.cxx:68
h
TgcRDOAnalysis.h
TgcRawData
An unit object of TGC ROD output.
Definition: TgcRawData.h:23
TgcRdo
Definition: TgcRdo.h:22
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
ReadHandle.h
Handle class for reading from StoreGate.
MuonVal::TgcRDOAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition: TgcRDOAnalysis.h:34
ServiceHandle< ITHistSvc >
TgcRawData::SlbType
SlbType
Definition: TgcRawData.h:31
Identifier
Definition: IdentifierFieldParser.cxx:14