ATLAS Offline Software
Loading...
Searching...
No Matches
MdtRelativeTubeT0.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7// MuonCalibIdentifier
9
10// MuonCalibEventBase
12
13namespace MuonCalib {
14
15 inline unsigned int get_group_id(const MuonFixedId &id, const MdtRelativeTubeT0::TubeGroup &grp);
16
18 const MuonFixedId &id = hit.identify();
19 if (m_tube_t0.find(id) == m_tube_t0.end()) {
20 if (m_relative_offset.size()) m_relative_offset.clear();
21 m_tube_t0[id] = hit.tubeT0();
22 }
23 }
24
25 double MdtRelativeTubeT0 ::GetRelativeOffset(const MuonFixedId &id, TubeGroup grp) {
26 if (grp == UNKNOWN) return 0;
27 std::map<TubeGroup, std::map<MuonFixedId, double> >::const_iterator it = m_relative_offset.find(grp);
28 if (it == m_relative_offset.end()) {
30 return GetRelativeOffset(id, grp);
31 }
32 std::map<MuonFixedId, double>::const_iterator it2 = it->second.find(id);
33 if (it2 == it->second.end()) { return 0; }
34 return it2->second;
35 }
36
37 inline void MdtRelativeTubeT0 ::calculate_relative_t0s(const TubeGroup &grp) {
38 // calculate mean t0 per group
39 std::map<unsigned int, std::pair<double, int> > mean_t0;
40 for (std::map<MuonFixedId, double>::const_iterator it = m_tube_t0.begin(); it != m_tube_t0.end(); ++it) {
41 unsigned int grp_id(get_group_id(it->first, grp));
42 std::map<unsigned int, std::pair<double, int> >::iterator it2 = mean_t0.find(grp_id);
43 if (it2 == mean_t0.end()) {
44 mean_t0[grp_id] = std::pair<double, int>(it->second, 1.);
45 } else {
46 it2->second.first += it->second;
47 it2->second.second++;
48 }
49 }
50 for (auto & it : mean_t0) {
51 it.second.first /= it.second.second;
52 }
53
54 // calculate tube offsets
55 std::map<MuonFixedId, double> &offsets(m_relative_offset[grp]);
56 offsets.clear();
57 for (std::map<MuonFixedId, double>::const_iterator it = m_tube_t0.begin(); it != m_tube_t0.end(); ++it) {
58 unsigned int grp_id(get_group_id(it->first, grp));
59 offsets[it->first] = it->second - mean_t0[grp_id].first;
60 }
61 }
62
63 inline unsigned int get_group_id(const MuonFixedId &id, const MdtRelativeTubeT0::TubeGroup &grp) {
64 switch (grp) {
65 case MdtRelativeTubeT0::CHAMBER: return id.mdtChamberId().getIdInt(); break;
66 case MdtRelativeTubeT0::MULTILAYER: return id.mdtMultilayerId().getIdInt(); break;
67 case MdtRelativeTubeT0::LAYER: return 4 * (id.mdtMultilayer() - 1) + (id.mdtTubeLayer() - 1); break;
68 case MdtRelativeTubeT0::MEZZ_CARD: return id.mdtMezzanine(); break;
69 case MdtRelativeTubeT0::UNKNOWN: return 0;
70 }
71 return 0;
72 }
73
74} // namespace MuonCalib
Athena-independent part of the MdtCalibHit.
const MuonFixedId & identify() const
retrieve the MuonFixedId of the hit
float tubeT0() const
retrieve the tube T0
double GetRelativeOffset(const MuonFixedId &id, TubeGroup grp)
void calculate_relative_t0s(const TubeGroup &grp)
void AddHit(const MdtCalibHitBase &hit)
std::map< TubeGroup, std::map< MuonFixedId, double > > m_relative_offset
std::map< MuonFixedId, double > m_tube_t0
Implements fixed identifiers not dependent upon Athena Identifier for internal use in the calibration...
Definition MuonFixedId.h:50
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
unsigned int get_group_id(const MuonFixedId &id, const MdtRelativeTubeT0::TubeGroup &grp)