ATLAS Offline Software
Loading...
Searching...
No Matches
MuonMeanMDTdADCFillerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// MuonMeanMDTdADCFillerTool.cxx, Implementation file for class MuonMeanMDTdADCFillerTool
7
8// MuonCombinedEvaluationTools includes
10
11#include <vector>
12
17#include "TrkTrack/Track.h"
19
20using CLHEP::GeV;
21
22namespace Rec {
23
24 // Athena Algorithm's Hooks
27 ATH_MSG_INFO("Initializing MuonMeanMDTdADCFillerTool");
28
29 ATH_CHECK(m_edmHelperSvc.retrieve());
30 ATH_CHECK(m_idHelperSvc.retrieve());
31 ATH_CHECK(m_eventInfo.initialize());
32
33 return StatusCode::SUCCESS;
34 }
35
37 // exclude statistical combination
38 if (muon.author() == xAOD::Muon::Author::STACO) {
39 return -9999.;
40 }
41 // Trk::Track* for trackParticle
42 using enum xAOD::Muon::TrackParticleType;
43 const Trk::Track* theTrack = muon.trackParticle(CombinedTrackParticle)
44 ? muon.trackParticle(CombinedTrackParticle)->track()
45 : nullptr;
46
47 if (theTrack) { return meanMDTdADCFiller(*theTrack); }
48
49 const Trk::Track* theTrack1 = muon.trackParticle(InnerDetectorTrackParticle)
50 ? muon.trackParticle(InnerDetectorTrackParticle)->track()
51 : nullptr;
52
53 if (theTrack1) { return meanMDTdADCFiller(*theTrack1); }
54
55 const Trk::Track* theTrack2 = muon.trackParticle(MuonSpectrometerTrackParticle)
56 ? muon.trackParticle(MuonSpectrometerTrackParticle)->track()
57 : nullptr;
58
59 if (theTrack2) { return meanMDTdADCFiller(*theTrack2); }
60
61 const Trk::Track* theTrack3 = muon.trackParticle(Primary)->track();
62
63 if (theTrack3) { return meanMDTdADCFiller(*theTrack3); }
64
65 ATH_MSG_DEBUG("No primary author original track for refitted muon, stop calculation...");
66 return -9999.;
67 }
68
70 bool doMdtGasGainCorrectionForMc = false; // default value for DATA
71
72 // Event information
74
75 // check if data or MC
76 if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
77 doMdtGasGainCorrectionForMc = true; // set "true" for MC
78 }
79
80 // return mean Number of ADC counts for MDT tubes on the track
81
82 const Trk::TrackStates* states = track.trackStateOnSurfaces();
83 if (!states) {
84 ATH_MSG_INFO("Cannot get track states on surface for TrackParticle");
85 return -9999.;
86 }
87
88 int nhitsadc = 0;
89 double absR = 0;
90 double datfit = 0;
91 double mcfit = 0;
92 double correction = 0;
93 double testEta = 0;
94 double maxhit = -999.;
95 float PhiFit = 0;
96
97 double meandADC = 0.;
98 std::vector<double> dADCvec;
99 dADCvec.clear();
100 double meanMDTdADC = 0.;
101
102 testEta = asinh(1. / tan(track.perigeeParameters()->parameters()[Trk::theta]));
103 double track_phi = track.perigeeParameters()->parameters()[Trk::phi];
104
105 for (const Trk::TrackStateOnSurface* ts : *states) {
106 // outliers can have type measurement, in Muid
108
109 const Trk::MeasurementBase* measurement = ts->measurementOnTrack();
110 if (!measurement) { continue; }
111 Identifier id = m_edmHelperSvc->getIdentifier(*measurement);
112 if (!(m_idHelperSvc->isMuon(id))) {
113 continue; // MS summary variables - don't need other technologies
114 }
115 if (!id.is_valid()) { continue; }
116 // mdt station counts
117 if (m_idHelperSvc->isMdt(id)) {
118 const Muon::MdtDriftCircleOnTrack* mdtcirc = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(measurement);
119 if (!mdtcirc) {
120 ATH_MSG_WARNING("cannot cast Trk::MeasurementBase to Muon::MdtDriftCircleOnTrack");
121 continue;
122 }
123 const Muon::MdtPrepData* rawdata = mdtcirc->prepRawData();
124 if (rawdata) {
125 // Calculate deltaADC as difference of number of ADC counts for given hit and datfit(Rdrift),
126 // where datfit(Rdrift) is the result of the fit of <ADC> in the given bin of Rdrift dependence on Rdrift
127 absR = fabs(mdtcirc->driftRadius());
128
129 bool isInBme = fabs(testEta) >= 0.644 && fabs(testEta) <= 0.772 && track_phi >= -1.72 && track_phi <= -1.42;
130
131 if ((!isInBme && (absR <= 0.4 || absR >= 14.)) || (isInBme && (absR <= 0.4 || absR >= 6.5))) continue;
132 nhitsadc++;
133
134 if (fabs(testEta) < 1.) {
135 datfit = 105.088 + 27.0638 * pow(absR, 1) - 4.72089 * pow(absR, 2) + 0.110274 * pow(absR, 3) +
136 0.041508 * pow(absR, 4) - 0.00403678 * pow(absR, 5) + 0.000111072 * pow(absR, 6);
137 mcfit = 73.8974 + 12.0642 * pow(absR, 1) + 0.975372 * pow(absR, 2) - 0.922337 * pow(absR, 3) +
138 0.140759 * pow(absR, 4) - 0.00881345 * pow(absR, 5) + 0.000202078 * pow(absR, 6);
139 } else {
140 datfit = 106.329 + 26.5296 * pow(absR, 1) - 4.07423 * pow(absR, 2) - 0.0594686 * pow(absR, 3) +
141 0.0608916 * pow(absR, 4) - 0.00506114 * pow(absR, 5) + 0.000131493 * pow(absR, 6);
142 mcfit = 73.3596 + 12.9939 * pow(absR, 1) + 0.494472 * pow(absR, 2) - 0.812082 * pow(absR, 3) +
143 0.128345 * pow(absR, 4) - 0.00814268 * pow(absR, 5) + 0.000188203 * pow(absR, 6);
144 }
145
146 if (doMdtGasGainCorrectionForMc) {
147 correction = datfit / mcfit; // gas gain correction factor for MC
148 meandADC += (correction * rawdata->adc() - datfit);
149 dADCvec.push_back(correction * rawdata->adc() - datfit);
150
151 maxhit = ((correction * rawdata->adc() - datfit) >= maxhit) ? (correction * rawdata->adc() - datfit) : maxhit;
152 } else {
153 meandADC += (rawdata->adc() - datfit);
154 dADCvec.push_back(rawdata->adc() - datfit);
155
156 maxhit = ((rawdata->adc() - datfit) >= maxhit) ? (rawdata->adc() - datfit) : maxhit;
157 }
158 }
159 }
160 } // end loop over hits
161
162 if (nhitsadc == 0) { meandADC = -9999; }
163
164 if (nhitsadc == 1) { meandADC = meandADC / double(nhitsadc); }
165 if (nhitsadc >= 2) { meandADC = double(meandADC - maxhit) / double(nhitsadc - 1); }
166
167 if (doMdtGasGainCorrectionForMc) {
168 if (track_phi > -3.2 && track_phi <= -2.87) PhiFit = -13.5471 * pow(track_phi, 2) - 39.0001 * track_phi + 4.23613;
169 if (track_phi > -2.87 && track_phi <= -2.13) PhiFit = 53.209 * pow(track_phi, 2) + 272.502 * track_phi + 342.867;
170 if (track_phi > -2.13 && track_phi <= -1.37) PhiFit = 72.4707 * pow(track_phi, 2) + 254.911 * track_phi + 216.811;
171 if (track_phi > -1.37 && track_phi <= -0.57) PhiFit = 77.218 * pow(track_phi, 2) + 149.676 * track_phi + 65.371;
172 if (track_phi > -0.57 && track_phi < 0.21) PhiFit = 86.977 * pow(track_phi, 2) + 29.0558 * track_phi - 6.09313;
173 if (track_phi >= 0.21 && track_phi <= 1.00) PhiFit = 79.203 * pow(track_phi, 2) - 92.9512 * track_phi + 21.6361;
174 if (track_phi > 1.00 && track_phi <= 1.79) PhiFit = 85.5711 * pow(track_phi, 2) - 239.068 * track_phi + 161.918;
175 if (track_phi > 1.79 && track_phi <= 2.60) PhiFit = 82.8996 * pow(track_phi, 2) - 362.665 * track_phi + 391.419;
176 if (track_phi > 2.60 && track_phi < 3.20) PhiFit = 73.8744 * pow(track_phi, 2) - 443.274 * track_phi + 656.926;
177
178 meandADC += PhiFit - 5.01 + 9.46;
179 }
180
181 dADCvec.clear();
182
183 meanMDTdADC = meandADC;
184
185 return meanMDTdADC;
186 }
187} // end namespace Rec
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
double driftRadius() const
Returns the value of the drift radius.
virtual const MdtPrepData * prepRawData() const override final
Returns the PrepRawData used to create this corrected measurement.
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
int adc() const
Returns the ADC (typically range is 0 to 250).
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
ServiceHandle< Muon::IMuonEDMHelperSvc > m_edmHelperSvc
double meanMDTdADCFiller(const xAOD::Muon &muon) const override
return mean Number of ADC counts for MDT tubes on the track of muon (method will simply step down to ...
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
This class is the pure abstract base class for all fittable tracking measurements.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ IS_SIMULATION
true: simulation, false: data
int ts
Definition globals.cxx:24
Gaudi Tools.
DataVector< const Trk::TrackStateOnSurface > TrackStates
@ theta
Definition ParamDefs.h:66
@ phi
Definition ParamDefs.h:75
Muon_v1 Muon
Reference the current persistent version: