The former version had istrip + 2 == nstrip as an alternative condition. But q over next is then just zero and hence always smaller than qthis
53 {
56
57
58 unsigned int nstrip = sfits.size();
59 if (nstrip == 0) {
64 }
65 if (sfits.size() != nstrip) {
70 }
71
72 if (sfits.empty() || !sfits[0].strip) {
77 }
79 const Identifier idStrip0 = pstrip->
identify();
80
81
83 const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.
cptr();
84 if (!MuonDetMgr) {
85 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
87 }
89
90 bool measphi =
m_idHelperSvc->cscIdHelper().CscIdHelper::measuresPhi(idStrip0);
93 int strip0 =
m_idHelperSvc->cscIdHelper().strip(idStrip0) - 1;
94
96 int station =
m_idHelperSvc->cscIdHelper().stationName(idStrip0) - 49;
97 int phisec =
m_idHelperSvc->cscIdHelper().stationPhi(idStrip0);
98
99 int sector = zsec * (2 * phisec - station + 1);
101
102
103 int peak_count = 0;
104 bool edge = (strip0 == 0);
105 int stripidx = 0;
106 int countstrip = 0;
107 double qsum = 0;
108 double xsum = 0;
109 double qxsum = 0;
110 double qerravg = 0;
111
112
113
114 unsigned int istrip_peak = 0;
115 double lastqpeak = 0;
116 float qlast = 0.;
117 float q_second_last = 0.;
118
119 for (unsigned int istrip = 0; istrip < nstrip; ++istrip) {
120 const StripFit& sfit = sfits[istrip];
121 const float qthis = sfit.charge;
122 const float qnext = (istrip + 1 < nstrip) ? sfits[istrip + 1].
charge : 0.;
123 const float q_over_next = (istrip + 2 < nstrip) ? sfits[istrip + 2].
charge : 0.;
124 countstrip = istrip + 1;
125
126 stripidx = strip0 + istrip;
127 qsum += qthis;
128 qerravg += qthis;
129 xsum += stripidx;
130 qxsum += qthis * stripidx;
131
132 if (countstrip == 2 && qthis < qlast) ++peak_count;
133 if (countstrip > 2 && qthis < qlast && qlast >= q_second_last) ++peak_count;
134
135 bool ispeak = qthis > qlast && qthis > qnext;
136
137
138
141 if (!ispeak && qthis == qnext) { ispeak = qthis > qlast && q_over_next < qthis; }
142
143
144
145 if (!ispeak && istrip == 1 && qthis == qlast) {
146 ispeak = qthis > qnext;
147 }
148
149
150 if (ispeak && qthis > lastqpeak) {
151 istrip_peak = istrip;
152 lastqpeak = qthis;
153 }
155 q_second_last = qlast;
156 qlast = qthis;
157 }
158 if (stripidx == maxstrip - 1) edge = true;
159
160 if (countstrip == 1) ++peak_count;
161 if (countstrip > 1 && sfits[nstrip - 1].
charge >= sfits[nstrip - 2].
charge) ++peak_count;
162
163
164 if (qsum <= 0) {
165
166
168 double savg = strip0 + istrip_peak;
169 res.position = pitch * (savg + 0.5 - 0.5 * maxstrip);
170 res.strip = istrip_peak;
172 res.dposition = errorScaler * pitch / sqrt(12.0);
173
174
176 res.lstrip = nstrip - 1;
177 res.time = sfits[istrip_peak].time;
178 res.timeStatus = sfits[istrip_peak].timeStatus;
179 res.qpeak = sfits[istrip_peak].charge;
180
182 res.charge_beforeBPCorr = sfits[
res.strip].charge_beforeBPCorr;
183
186
187 if (istrip_peak >= 1) {
188 res.qleft = sfits[istrip_peak - 1].charge;
190 res.charge_beforeBPCorr += sfits[istrip_peak - 1].charge_beforeBPCorr;
191 }
192 if (istrip_peak + 1 < nstrip) {
193 res.qright = sfits[istrip_peak + 1].charge;
195 res.charge_beforeBPCorr += sfits[istrip_peak + 1].charge_beforeBPCorr;
196 }
197 res.time_beforeT0Corr = sfits[
res.strip].time_beforeT0Corr;
198 res.time_beforeBPCorr = sfits[
res.strip].time_beforeBPCorr;
199
202 }
203
204
205 double strip_mean = xsum / nstrip;
206 double strip_qmean = qxsum / qsum;
207 qerravg = qerravg / nstrip;
208
209
212 if (edge)
214 else if (peak_count > 1)
216
217 double savg = -99.;
219 savg = strip_mean;
221 savg = strip0 + istrip_peak;
222 }
else if (
m_option ==
"CENTROID") {
223 savg = strip_qmean;
224 } else {
227 }
228
229
231
232 if (measphi) savg = strip_mean;
233
234
235
236
237 res.strip = istrip_peak;
238
239
240 res.position = pitch * (savg + 0.5 - 0.5 * maxstrip);
241
242
243 Identifier
id = sfits[
res.strip].strip->identify();
246
247
248 double wmeas = pitch * nstrip;
250 double weffmin = 0.5 * wmeas;
251 if (weff < weffmin) weff = weffmin;
253 res.dposition = errorScaler * weff / sqrt(12.0);
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
272 << " nstr=" << nstrip << "[sector:wlay:measphi]= " << sector << ":" << wlay << ":" << measphi << " strip0=" << strip0
273 << " istrip_peak=" << istrip_peak << " peaktime=" << sfits[istrip_peak].time
274 << " peakstatus=" << sfits[istrip_peak].status << " peaktimeStatus=" << sfits[istrip_peak].timeStatus
275 <<
" pos=" <<
res.position <<
" dpos=" <<
res.dposition <<
" chg=" << qsum);
276
277
279 res.lstrip = nstrip - 1;
280 res.time = sfits[istrip_peak].time;
281 res.timeStatus = sfits[istrip_peak].timeStatus;
282 res.qpeak = sfits[istrip_peak].charge;
283
285 res.charge_beforeBPCorr = sfits[
res.strip].charge_beforeBPCorr;
286
289
290 if (istrip_peak >= 1) {
291 res.qleft = sfits[istrip_peak - 1].charge;
293 res.charge_beforeBPCorr += sfits[istrip_peak - 1].charge_beforeBPCorr;
294 }
295 if (istrip_peak + 1 < nstrip) {
296 res.qright = sfits[istrip_peak + 1].charge;
298 res.charge_beforeBPCorr += sfits[istrip_peak + 1].charge_beforeBPCorr;
299 }
300 res.time_beforeT0Corr = sfits[
res.strip].time_beforeT0Corr;
301 res.time_beforeBPCorr = sfits[
res.strip].time_beforeBPCorr;
302
303
304
307}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
std::pair< std::vector< unsigned int >, bool > res
ICscStripFitter::Result StripFit
std::vector< Result > Results
double cathodeReadoutPitch(int chLayer, int measuresPhi) const
int maxNumberOfStrips(int measuresPhi) const
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const_pointer_type cptr()
ToolHandle< ICscAlignmentTool > m_alignmentTool
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
retrieve MuonDetectorManager from the conditions store
Identifier identify() const
return the identifier
@ CscStatusSimple
Cluster with non-precision fit.
@ CscStatusUndefined
Undefined, should not happen, most likely indicates a problem.
@ CscStatusEdge
Cluster reaches the edge of plane.
@ CscStatusMultiPeak
More than one peak in cluster.