59 double averageSigma = 0.;
60 double average2Sigma = 0.;
63 double averagekfactor = 0;
66 for (
auto sl = dtSupLylist.begin();
67 sl != dtSupLylist.end(); sl++) {
75 if( ttrigMean < ttrigMax && ttrigMean >
ttrigMin ) {
77 averageSigma += ttrigSigma;
84 averageSigma = averageSigma/
counter;
85 averagekfactor = kfactor;
89 for (
auto sl = dtSupLylist.begin();
90 sl != dtSupLylist.end(); sl++) {
99 if( ttrigMean < ttrigMax && ttrigMean > ttrigMin ) {
100 average2 += (ttrigMean-average)*(ttrigMean-average);
101 average2Sigma += (ttrigSigma-averageSigma)*(ttrigSigma-averageSigma);
105 rms = average2 /(counter-1);
106 rmsSigma = average2Sigma /(counter-1);
108 rmsSigma =
sqrt(rmsSigma);
109 cout <<
"average averageSigma counter rms "<< average <<
" " << averageSigma <<
" " << counter <<
" " << rms <<endl;
112 for (
auto sl = dtSupLylist.begin();
113 sl != dtSupLylist.end(); sl++) {
115 double newTTrigMean = 0;
116 double newTTrigSigma = 0;
117 double newkfactor =0;
118 float tempttrigMean = 0;
119 float tempttrigSigma = 0;
120 float tempkfactor = 0;
122 float ttrigSigma = 0;
129 int chamber = (*sl)->id().chamberId().station();
133 newTTrigMean = ttrigMean;
134 newTTrigSigma = ttrigSigma;
135 newkfactor = kfactor;
140 if(((*sl)->id().superlayer()) == 1){
149 newTTrigMean = tempttrigMean;
150 newTTrigSigma = tempttrigSigma;
151 newkfactor = tempkfactor;
152 cout <<
"Chamber "<< chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig "<< ttrigMean
153 <<
" -> takes value of sl 3 " << newTTrigMean <<endl;
154 }
else if(chamber == 4){
155 cout <<
"No correction possible within same chamber (sl1) " <<endl;
156 newTTrigMean = average;
157 newTTrigSigma = averageSigma;
158 newkfactor = averagekfactor;
159 cout<<
"####### Bad SL: " << (*sl)->id() <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
160 }
else if(chamber != 4){
168 newTTrigMean = tempttrigMean;
169 newTTrigSigma = tempttrigSigma;
170 newkfactor = tempkfactor;
171 cout <<
"Chamber "<< chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig "<< ttrigMean
172 <<
" -> takes value of sl 2 " << newTTrigMean <<endl;
174 cout <<
"No correction possible within same chamber (sl1) " <<endl;
175 newTTrigMean = average;
176 newTTrigSigma = averageSigma;
177 newkfactor = averagekfactor;
178 cout<<
"####### Bad SL: " << (*sl)->id() <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
181 }
else if (((*sl)->id().superlayer()) == 2) {
190 newTTrigMean = tempttrigMean;
191 newTTrigSigma = tempttrigSigma;
192 newkfactor = tempkfactor;
193 cout <<
"Chamber "<< chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig "<< ttrigMean
194 <<
" -> takes value of sl 1 " << newTTrigMean <<endl;
203 newTTrigMean = tempttrigMean;
204 newTTrigSigma = tempttrigSigma;
205 newkfactor = tempkfactor;
206 cout <<
"Chamber "<< chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig "<< ttrigMean
207 <<
"-> takes value of sl 3 " << newTTrigMean <<endl;
209 cout <<
"No correction possible within same chamber (sl2) " <<endl;
210 newTTrigMean = average;
211 newTTrigSigma = averageSigma;
212 newkfactor = averagekfactor;
213 cout<<
"####### Bad SL: " << (*sl)->id() <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
218 }
else if (((*sl)->id().superlayer()) == 3) {
227 newTTrigMean = tempttrigMean;
228 newTTrigSigma = tempttrigSigma;
229 newkfactor = tempkfactor;
230 cout <<
"Chamber "<< chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig "<< ttrigMean
231 <<
" -> takes value of sl 1 " << newTTrigMean <<endl;
232 }
else if(chamber == 4) {
233 cout <<
"No correction possible within same chamber (sl3)" <<endl;
234 newTTrigMean = average;
235 newTTrigSigma = averageSigma;
236 newkfactor = averagekfactor;
237 cout<<
"####### Bad SL: " << (*sl)->id() <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
238 }
else if(chamber != 4){
246 newTTrigMean = tempttrigMean;
247 newTTrigSigma = tempttrigSigma;
248 newkfactor = tempkfactor;
249 cout <<
"Chamber "<< chamber <<
" sl " << ((*sl)->id().superlayer()) <<
"has ttrig "<< ttrigMean
250 <<
" -> takes value of sl 2 " << newTTrigMean <<endl;
252 cout <<
"No correction possible within same chamber (sl3) " <<endl;
253 newTTrigMean = average;
254 newTTrigSigma = averageSigma;
255 newkfactor = averagekfactor;
256 cout<<
"####### Bad SL: " << (*sl)->id() <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
263 newTTrigMean = average;
264 newTTrigSigma = averageSigma;
265 newkfactor = averagekfactor;
266 cout<<
"####### NotPresent SL: " << (*sl)->id() <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
271 tTrigNewMap->
set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor,
DTTimeUnits::ns);
273 cout<<
"New tTrig: " << (*sl)->id()
274 <<
" from "<< ttrigMean <<
" to "<< newTTrigMean <<endl;
275 cout<<
"New tTrigSigma: " << (*sl)->id()
276 <<
" from "<<ttrigSigma <<
" to "<< newTTrigSigma <<endl;
283 cout <<
"[DTTTrigCorrection]: Writing ttrig object to DB!" << endl;
284 string record =
"DTTtrigRcd";
285 DTCalibDBUtils::writeToDB<DTTtrig>(
record, tTrigNewMap);
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Abs< T >::type abs(const T &t)
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
static std::atomic< unsigned int > counter
edm::ESHandle< DTGeometry > muonGeom
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.