Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity.
Loop on superlayer to correct between even-odd layers (2 different test pulse lines!)
278 cout <<
"[DTT0CalibrationPerLayer]Writing histos to file!" << endl;
282 for(map<DTWireId, TH1I*>::const_iterator wHisto =
theHistoWireMap.begin();
285 (*wHisto).second->Write();
290 (*wHisto).second->Write();
292 for(map<DTLayerId, TH1I*>::const_iterator lHisto =
theHistoLayerMap.begin();
295 (*lHisto).second->Write();
299 cout <<
"[DTT0Calibration] Compute and store t0 and sigma per wire" << endl;
312 cout <<
"Wire " << (*wiret0).first <<
" has t0 " << t0 <<
"(absolute) " 319 cout<<
"[DTT0Calibration] ERROR: no digis in wire "<<(*wiret0).first<<endl;
329 for(
auto sl = superLayers.begin();
330 sl != superLayers.end(); sl++) {
334 double oddLayersMean=0;
335 double evenLayersMean=0;
336 double oddLayersDen=0;
337 double evenLayersDen=0;
341 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
343 cout<<
"[DTT0Calibration] Superlayer "<<(*sl)->id()
344 <<
"layer " <<(*wiret0).first.layerId().layer()<<
" with "<<(*wiret0).second<<endl;
345 if(((*wiret0).first.layerId().layer()) % 2){
346 oddLayersMean = oddLayersMean + (*wiret0).second;
350 evenLayersMean = evenLayersMean + (*wiret0).second;
355 oddLayersMean = oddLayersMean/oddLayersDen;
356 evenLayersMean = evenLayersMean/evenLayersDen;
358 cout<<
"[DTT0Calibration] Relative T0 mean for odd layers "<<oddLayersMean<<
" even layers"<<evenLayersMean<<endl;
361 double oddLayersSigma=0;
362 double evenLayersSigma=0;
366 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
367 if(((*wiret0).first.layerId().layer()) % 2){
368 oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean);
371 evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean);
375 oddLayersSigma = oddLayersSigma/oddLayersDen;
376 evenLayersSigma = evenLayersSigma/evenLayersDen;
377 oddLayersSigma =
sqrt(oddLayersSigma);
378 evenLayersSigma =
sqrt(evenLayersSigma);
381 cout<<
"[DTT0Calibration] Relative T0 sigma for odd layers "<<oddLayersSigma<<
" even layers"<<evenLayersSigma<<endl;
384 double oddLayersFinalMean=0;
385 double evenLayersFinalMean=0;
389 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
390 if(((*wiret0).first.layerId().layer()) % 2){
391 if(
abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma))
392 oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second;
395 if(
abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma))
396 evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second;
400 oddLayersFinalMean = oddLayersFinalMean/oddLayersDen;
401 evenLayersFinalMean = evenLayersFinalMean/evenLayersDen;
403 cout<<
"[DTT0Calibration] Final relative T0 mean for odd layers "<<oddLayersFinalMean<<
" even layers"<<evenLayersFinalMean<<endl;
408 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
410 if(((*wiret0).first.layerId().layer()) % 2)
411 t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean);
413 t0 = (*wiret0).second;
415 cout <<
"[DTT0Calibration] Wire " << (*wiret0).first <<
" has t0 " << (*wiret0).second
416 <<
" (relative, after even-odd layer corrections) " 427 cout <<
"[DTT0Calibration]Computing relative t0 wrt to chamber average" << endl;
429 map<DTChamberId,double> sumT0ByChamber;
430 map<DTChamberId,int> countT0ByChamber;
433 int channelId =
tzero->channelId;
434 if ( channelId == 0 )
continue;
442 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f;
444 countT0ByChamber[chamberId]++;
450 int channelId =
tzero->channelId;
451 if ( channelId == 0 )
continue;
460 double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
461 double t0rms = t0rms_f;
463 t0sWRTChamber->
set(wireId,
469 cout <<
"Changing t0 of wire " << wireId <<
" from " << t0mean_f
470 <<
" to " << t0mean << endl;
476 cout <<
"[DTT0Calibration]Writing values in DB!" << endl;
478 string t0Record =
"DTT0Rcd";
const_iterator begin() const
int set(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float t0mean, float t0rms, DTTimeUnits::type unit)
bool correctByChamberMean_
std::map< DTLayerId, TH1I * > theHistoLayerMap
std::map< DTWireId, double > theAbsoluteT0PerWire
std::map< DTWireId, TH1I * > theHistoWireMap
std::map< DTWireId, int > nDigiPerWire
std::map< DTWireId, TH1I * > theHistoWireMap_ref
std::map< DTWireId, double > theSigmaT0PerWire
edm::ESHandle< DTGeometry > dtGeom
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
std::vector< DTT0Data >::const_iterator const_iterator
Access methods to data.
std::map< DTWireId, double > theRelativeT0PerWire
Abs< T >::type abs(const T &t)
std::map< DTWireId, double > qK
const_iterator end() const
static const double tzero[3]
static void writeToDB(std::string record, T *payload)
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.