33 declareInterface<ICscClusterFitter>(
this);
61 return StatusCode::SUCCESS;
68 unsigned int nstrip = sfits.size();
72 bool measphi =
m_idHelperSvc->cscIdHelper().CscIdHelper::measuresPhi(idStrip0);
75 ATH_MSG_DEBUG(
"CscStrip fittter input has " << nstrip <<
" strips");
77 for (
unsigned int istrip = 0; istrip < nstrip; ++istrip) {
78 Identifier id = sfits[istrip].strip->identify();
83 std::vector<float> istrip_peaks;
84 std::vector<float> istrip_vals;
87 for (
unsigned int istrip = 1; istrip < nstrip - 1; ++istrip) {
90 float qlast = sfits[istrip - 1].charge;
91 float qnext = sfits[istrip + 1].charge;
93 if (istrip == 1 && qlast > qthis) istrip_peaks.push_back(0);
95 if (istrip + 2 == nstrip && qthis < qnext) istrip_peaks.push_back(nstrip - 1);
97 bool ispeak = qthis > qlast && qthis > qnext;
98 bool isval = qthis < qlast && qthis < qnext;
101 if (ispeak) istrip_peaks.push_back(istrip);
102 if (isval) istrip_vals.push_back(istrip);
103 if (ispeak || isval)
continue;
106 if (istrip == 1 && qlast == qthis) {
107 float nstripsameCharge = 2.;
108 unsigned int theStrip = 0;
109 for (
unsigned int mstrip = istrip + 1; mstrip < nstrip - 1; ++mstrip) {
111 if (qthis == sfits[mstrip].
charge)
112 nstripsameCharge += 1.;
116 ispeak = (qthis > sfits[theStrip].charge);
117 isval = (qthis < sfits[theStrip].charge);
118 float offset = 0.5 * (nstripsameCharge - 1);
119 if (ispeak) istrip_peaks.push_back(
offset);
122 istrip +=
int(nstripsameCharge) - 2;
129 if (qthis == qnext) {
130 float nstripsameCharge = 2.;
131 unsigned int theStrip = 0;
133 for (
unsigned int mstrip = istrip + 2; mstrip < nstrip - 1; ++mstrip) {
135 if (qthis == sfits[mstrip].
charge)
136 nstripsameCharge += 1.;
143 ispeak = (qthis > qlast);
144 isval = (qthis < qlast);
146 ispeak = (qthis > qlast) && (qthis > sfits[theStrip].
charge);
147 isval = (qthis < qlast) && (qthis < sfits[theStrip].
charge);
149 float offset = 0.5 * (nstripsameCharge - 1);
150 if (ispeak) istrip_peaks.push_back(istrip +
offset);
151 if (isval) istrip_vals.push_back(istrip +
offset);
152 istrip +=
int(nstripsameCharge) - 1;
164 std::vector<unsigned int> splitOnValley;
165 for (
unsigned int ival = 0;
ival < istrip_vals.size() &&
ival + 1 < istrip_peaks.size(); ++
ival) {
167 float istrip_peak0 = istrip_peaks[
ival];
168 float istrip_peak1 = istrip_peaks[
ival + 1];
169 float istrip_val = istrip_vals[
ival];
171 float dist_ptov = istrip_val - istrip_peak0;
172 float dist_vtop = istrip_peak1 - istrip_val;
174 ATH_MSG_DEBUG(
" [ " << istrip_peak0 <<
", " << istrip_val <<
", " << istrip_peak1 <<
"] "
175 <<
"dist p2v:v2p " << dist_ptov <<
" : " << dist_vtop);
177 if (dist_ptov < 0 || dist_vtop < 0) {
178 ATH_MSG_WARNING(
" Peak-to-Val dist is " << dist_ptov <<
" Val-to-Peak dist is " << dist_vtop
179 <<
" Shouldnot be negative value :" << istrip_peak0 <<
" " << istrip_val <<
" "
183 float qlpeak = sfits[
int(istrip_peak0)].charge;
184 float qval = sfits[
int(istrip_val)].charge;
185 float qrpeak = sfits[
int(istrip_peak1)].charge;
187 ATH_MSG_DEBUG(
"qlpk:qval:qrpk " << qlpeak <<
" " << qval <<
" " << qrpeak <<
" " << qval / qlpeak <<
" " << qval / qrpeak
191 splitOnValley.push_back(0);
193 splitOnValley.push_back(1);
196 unsigned int cnt = 0;
197 for (
unsigned int ii = 0; ii < splitOnValley.size(); ii++)
198 if (splitOnValley[ii] == 1)
cnt++;
211 unsigned int nvals = splitOnValley.size();
212 if (istrip_vals[nvals - 1] != nstrip - 1) {
213 istrip_vals.push_back(nstrip - 1);
214 splitOnValley.push_back(1);
215 nvals = splitOnValley.size();
223 unsigned int firstStripID = 0;
224 unsigned int thisfirstStripID = 0;
225 for (
unsigned int isplit = 0; isplit < nvals; ++isplit) {
226 if (splitOnValley[isplit]) {
229 for (
unsigned int ist = firstStripID; ist <= istrip_vals[isplit]; ++ist) {
230 ATH_MSG_DEBUG(ist <<
" " << firstStripID <<
" " << istrip_vals <<
" lsplit " << splitOnValley);
232 sfits_split.push_back(sfits[ist]);
238 thisfirstStripID = firstStripID;
239 firstStripID =
int(istrip_vals[isplit]);
242 std::vector<ICscClusterFitter::Result> local_results;
249 res = local_results[0];
264 res = local_results[0];
275 if (prec_fitresult) {
276 res.fitStatus = 20 + prec_fitresult;
304 res.strip =
res.strip + thisfirstStripID;
305 res.fstrip =
res.fstrip + thisfirstStripID;
306 res.lstrip =
res.lstrip + thisfirstStripID;