58 double averageSigma = 0.;
59 double average2Sigma = 0.;
62 double averagekfactor = 0;
65 for (
auto sl = dtSupLylist.begin(); sl != dtSupLylist.end(); sl++) {
69 if (ttrigMean < ttrigMax && ttrigMean >
ttrigMin) {
71 averageSigma += ttrigSigma;
78 averageSigma = averageSigma /
counter;
79 averagekfactor = kfactor;
83 for (
auto sl = dtSupLylist.begin(); sl != dtSupLylist.end(); sl++) {
88 if (ttrigMean < ttrigMax && ttrigMean >
ttrigMin) {
90 average2Sigma += (ttrigSigma - averageSigma) * (ttrigSigma - averageSigma);
95 rmsSigma = average2Sigma / (
counter - 1);
97 rmsSigma =
sqrt(rmsSigma);
98 cout <<
"average averageSigma counter rms " <<
average <<
" " << averageSigma <<
" " <<
counter <<
" " <<
rms << endl;
100 for (
auto sl = dtSupLylist.begin(); sl != dtSupLylist.end(); sl++) {
102 double newTTrigMean = 0;
103 double newTTrigSigma = 0;
104 double newkfactor = 0;
105 float tempttrigMean = 0;
106 float tempttrigSigma = 0;
107 float tempkfactor = 0;
109 float ttrigSigma = 0;
112 int chamber = (*sl)->id().chamberId().station();
116 newTTrigMean = ttrigMean;
117 newTTrigSigma = ttrigSigma;
118 newkfactor = kfactor;
123 if (((*sl)->id().superlayer()) == 1) {
128 newTTrigMean = tempttrigMean;
129 newTTrigSigma = tempttrigSigma;
130 newkfactor = tempkfactor;
131 cout <<
"Chamber " <<
chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig " << ttrigMean
132 <<
" -> takes value of sl 3 " << newTTrigMean << endl;
134 cout <<
"No correction possible within same chamber (sl1) " << endl;
136 newTTrigSigma = averageSigma;
137 newkfactor = averagekfactor;
138 cout <<
"####### Bad SL: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
143 newTTrigMean = tempttrigMean;
144 newTTrigSigma = tempttrigSigma;
145 newkfactor = tempkfactor;
146 cout <<
"Chamber " <<
chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig " << ttrigMean
147 <<
" -> takes value of sl 2 " << newTTrigMean << endl;
149 cout <<
"No correction possible within same chamber (sl1) " << endl;
151 newTTrigSigma = averageSigma;
152 newkfactor = averagekfactor;
153 cout <<
"####### Bad SL: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
156 }
else if (((*sl)->id().superlayer()) == 2) {
161 newTTrigMean = tempttrigMean;
162 newTTrigSigma = tempttrigSigma;
163 newkfactor = tempkfactor;
164 cout <<
"Chamber " <<
chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig " << ttrigMean
165 <<
" -> takes value of sl 1 " << newTTrigMean << endl;
170 newTTrigMean = tempttrigMean;
171 newTTrigSigma = tempttrigSigma;
172 newkfactor = tempkfactor;
173 cout <<
"Chamber " <<
chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig " << ttrigMean
174 <<
"-> takes value of sl 3 " << newTTrigMean << endl;
176 cout <<
"No correction possible within same chamber (sl2) " << endl;
178 newTTrigSigma = averageSigma;
179 newkfactor = averagekfactor;
180 cout <<
"####### Bad SL: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
184 }
else if (((*sl)->id().superlayer()) == 3) {
189 newTTrigMean = tempttrigMean;
190 newTTrigSigma = tempttrigSigma;
191 newkfactor = tempkfactor;
192 cout <<
"Chamber " <<
chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig " << ttrigMean
193 <<
" -> takes value of sl 1 " << newTTrigMean << endl;
195 cout <<
"No correction possible within same chamber (sl3)" << endl;
197 newTTrigSigma = averageSigma;
198 newkfactor = averagekfactor;
199 cout <<
"####### Bad SL: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
204 newTTrigMean = tempttrigMean;
205 newTTrigSigma = tempttrigSigma;
206 newkfactor = tempkfactor;
207 cout <<
"Chamber " <<
chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig " << ttrigMean
208 <<
" -> takes value of sl 2 " << newTTrigMean << endl;
210 cout <<
"No correction possible within same chamber (sl3) " << endl;
212 newTTrigSigma = averageSigma;
213 newkfactor = averagekfactor;
214 cout <<
"####### Bad SL: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
221 newTTrigSigma = averageSigma;
222 newkfactor = averagekfactor;
223 cout <<
"####### NotPresent SL: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
228 tTrigNewMap->
set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor,
DTTimeUnits::ns);
230 cout <<
"New tTrig: " << (*sl)->id() <<
" from " << ttrigMean <<
" to " << newTTrigMean << endl;
231 cout <<
"New tTrigSigma: " << (*sl)->id() <<
" from " << ttrigSigma <<
" to " << newTTrigSigma << endl;
236 cout <<
"[DTTTrigCorrection]: Writing ttrig object to DB!" << endl;
237 string record =
"DTTtrigRcd";
238 DTCalibDBUtils::writeToDB<DTTtrig>(
record, tTrigNewMap);