ATLAS Offline Software
Loading...
Searching...
No Matches
MdtRDOAnalysis.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 "MdtRDOAnalysis.h"
8
9#include <algorithm>
10#include <math.h>
11#include <functional>
12#include <iostream>
13#include <format>
14
15namespace MuonVal{
16 using namespace Muon::MuonStationIndex;
17
19 const std::string& basePath,
20 const StIdx_t stIndex):
21 stIdx{stIndex} {
22
23 auto createHisto = [stIndex, &histSvc, &basePath](const std::string& hName,
24 const std::string& hTitle,
25 const unsigned nBins,
26 const float xLow,
27 const float xHigh){
28 TH1* h = new TH1F(hName.c_str(), hTitle.c_str(), nBins, xLow, xHigh);
29 histSvc->regHist(std::format("/{}/RDO/Station_{}/{}",
30 basePath,
31 stIndex != StIdx_t::StUnknown ? stName(stIndex) : "Inclusive",
32 hName), h).ignore();
33 return h;
34 };
35
36 h_subID = createHisto("subDetId", "Subdetector ID", 100, 0 , 150);
37 h_mrodID = createHisto("mrodID", "MROD ID", 100, 0, 150);
38 h_csmID = createHisto("csmID", "CSM ID", 100, 0, 10);
39 h_tdcID = createHisto("tdcID", "TDC ID", 100, 0, 50);
40 h_chanID = createHisto("channelID", "Channel ID", 100, 0, 50);
41 h_coarse = createHisto("coarseTime", "Drift time (coarse)", 100, 0, 100);
42 h_fine = createHisto("fineTime", "Drift time (fine)", 100, 0, 50);
43 h_width = createHisto("width", "Width", 100, 0, 500);
44 }
45
47 ATH_MSG_DEBUG( "Initializing MdtRDOAnalysis" );
48
49 // This will check that the properties were initialized
50 // properly by job configuration.
51 ATH_CHECK(m_inputKey.initialize());
52 ATH_CHECK(m_idHelperSvc.retrieve());
53
54 for (int s = static_cast<int>(StIdx_t::StUnknown); s < static_cast<int>(StIdx_t::StIndexMax); ++s) {
55 auto stIdx = static_cast<StIdx_t>(s);
56 m_histos.emplace_back(histSvc(), m_path, stIdx);
57 }
58
59 return StatusCode::SUCCESS;
60 }
61
63 const EventContext& ctx{Gaudi::Hive::currentContext()};
64 const MdtCsmContainer* csmCont{nullptr};
65 ATH_CHECK(SG::get(csmCont, m_inputKey, ctx));
66
67 for (const MdtCsm* csm : *csmCont) {
68 std::vector<unsigned> fillMe{};
69 const StIdx_t stIdx = m_idHelperSvc->stationIndex(csm->identify());
70 for (unsigned h =0 ; h < m_histos.size() ; ++h) {
71 if (m_histos[h].stIdx == StIdx_t::StUnknown ||
72 m_histos[h].stIdx == stIdx) {
73 fillMe.push_back(h);
74 }
75 const uint16_t subID = csm->SubDetId();
76 const uint16_t mrodID = csm->MrodId();
77 const uint16_t csmID = csm->CsmId();
78 for (unsigned h : fillMe) {
79 m_histos[h].h_subID->Fill(subID);
80 m_histos[h].h_mrodID->Fill(mrodID);
81 m_histos[h].h_csmID->Fill(csmID);
82 }
83 for (const MdtAmtHit* hit : *csm) {
84 const uint16_t tdcID = hit->tdcId();
85 const uint16_t chanID = hit->channelId();
86 const uint16_t coarseTime = hit->coarse();
87 const uint16_t fineTime = hit->fine();
88 const uint16_t widthComb = hit->width();
89 for (auto h : fillMe) {
90 m_histos[h].h_tdcID->Fill(tdcID);
91 m_histos[h].h_chanID->Fill(chanID);
92 m_histos[h].h_coarse->Fill(coarseTime);
93 m_histos[h].h_fine->Fill(fineTime);
94 m_histos[h].h_width->Fill(widthComb);
95 }
96 }
97 }
98 }
99 return StatusCode::SUCCESS;
100 }
101}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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...
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition MdtAmtHit.h:20
This container provides acces to the MDT RDOs.
MDT RDOs : Chamber Service Module, container of AmtHits of a single Mdt chamber.
Definition MdtCsm.h:19
std::vector< HistoSet > m_histos
Gaudi::Property< std::string > m_path
virtual StatusCode execute() override final
SG::ReadHandleKey< MdtCsmContainer > m_inputKey
Input read handle key.
virtual StatusCode initialize() override final
Muon::MuonStationIndex::StIndex StIdx_t
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
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()=default
Default constructor.