ATLAS Offline Software
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"
7 #include "StoreGate/ReadHandle.h"
8 
9 #include <algorithm>
10 #include <math.h>
11 #include <functional>
12 #include <iostream>
13 #include <format>
14 
15 namespace 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.
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 }
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
MdtAmtHit
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition: MdtAmtHit.h:20
vtune_athena.format
format
Definition: vtune_athena.py:14
MuonVal::MdtRDOAnalysis::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
Definition: MdtRDOAnalysis.h:29
Muon::MuonStationIndex
Definition: MuonStationIndex.h:13
Muon::MuonStationIndex::stName
const std::string & stName(StIndex index)
convert StIndex into a string
Definition: MuonStationIndex.cxx:104
MdtCsmContainer
This container provides acces to the MDT RDOs.
Definition: MdtCsmContainer.h:22
MdtCsm
MDT RDOs : Chamber Service Module, container of AmtHits of a single Mdt chamber.
Definition: MdtCsm.h:19
MdtRDOAnalysis.h
MuonVal::MdtRDOAnalysis::execute
virtual StatusCode execute() override final
Definition: MdtRDOAnalysis.cxx:62
MuonVal::MdtRDOAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition: MdtRDOAnalysis.h:31
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
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
h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
extractSporadic.h
list h
Definition: extractSporadic.py:96
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
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
MuonVal
Class to store array like branches into the n-tuples.
Definition: HitValAlg.cxx:19
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
MuonVal::MdtRDOAnalysis::m_inputKey
SG::ReadHandleKey< MdtCsmContainer > m_inputKey
Input read handle key.
Definition: MdtRDOAnalysis.h:27
MuonVal::MdtRDOAnalysis::HistoSet::HistoSet
HistoSet()=default
Default constructor.
MuonVal::MdtRDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: MdtRDOAnalysis.cxx:46
MuonVal::MdtRDOAnalysis::m_histos
std::vector< HistoSet > m_histos
Definition: MdtRDOAnalysis.h:57
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
ReadHandle.h
Handle class for reading from StoreGate.
ServiceHandle< ITHistSvc >