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!)
405 cout <<
"[DTT0CalibrationNewPerLayer]Writing histos to file!" << endl;
409 for(map<DTWireId, TH1I*>::const_iterator wHisto =
theHistoWireMap.begin();
412 (*wHisto).second->Write();
414 for(map<DTLayerId, TH1I*>::const_iterator lHisto =
theHistoLayerMap.begin();
417 (*lHisto).second->Write();
421 cout <<
"[DTT0CalibrationNew] Compute and store t0 and sigma per wire" << endl;
431 double t0 = (*wiret0).second/
nDigiPerWire[(*wiret0).first];
432 DTChamberId chamberId = ((*wiret0).first).chamberId();
442 cout<<
"[DTT0CalibrationNew] ERROR: no digis in wire "<<(*wiret0).first<<endl;
449 const vector<const DTSuperLayer*>& superLayers =
dtGeom->superLayers();
451 for(
auto sl = superLayers.begin();
452 sl != superLayers.end(); sl++) {
456 double oddLayersMean=0;
457 double evenLayersMean=0;
458 double oddLayersDen=0;
459 double evenLayersDen=0;
463 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
465 cout<<
"[DTT0CalibrationNew] Superlayer "<<(*sl)->id()
466 <<
"layer " <<(*wiret0).first.layerId().layer()<<
" with "<<(*wiret0).second<<endl;
467 if(((*wiret0).first.layerId().layer()) % 2){
468 oddLayersMean = oddLayersMean + (*wiret0).second;
472 evenLayersMean = evenLayersMean + (*wiret0).second;
477 oddLayersMean = oddLayersMean/oddLayersDen;
478 evenLayersMean = evenLayersMean/evenLayersDen;
479 if(
debug && oddLayersMean)
480 cout<<
"[DTT0CalibrationNew] Relative T0 mean for odd layers "<<oddLayersMean<<
" even layers"<<evenLayersMean<<endl;
483 double oddLayersSigma=0;
484 double evenLayersSigma=0;
488 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
489 if(((*wiret0).first.layerId().layer()) % 2){
490 oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean);
493 evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean);
497 oddLayersSigma = oddLayersSigma/oddLayersDen;
498 evenLayersSigma = evenLayersSigma/evenLayersDen;
499 oddLayersSigma =
sqrt(oddLayersSigma);
500 evenLayersSigma =
sqrt(evenLayersSigma);
502 if(
debug && oddLayersMean)
503 cout<<
"[DTT0CalibrationNew] Relative T0 sigma for odd layers "<<oddLayersSigma<<
" even layers"<<evenLayersSigma<<endl;
506 double oddLayersFinalMean=0;
507 double evenLayersFinalMean=0;
511 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
512 if(((*wiret0).first.layerId().layer()) % 2){
513 if(
abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma))
514 oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second;
517 if(
abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma))
518 evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second;
522 oddLayersFinalMean = oddLayersFinalMean/oddLayersDen;
523 evenLayersFinalMean = evenLayersFinalMean/evenLayersDen;
524 if(
debug && oddLayersMean)
525 cout<<
"[DTT0CalibrationNew] Final relative T0 mean for odd layers "<<oddLayersFinalMean<<
" even layers"<<evenLayersFinalMean<<endl;
530 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
532 if(((*wiret0).first.layerId().layer()) % 2)
533 t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean);
535 t0 = (*wiret0).second;
537 cout<<
"[DTT0CalibrationNew] Wire "<<(*wiret0).first<<
" has t0 "<<(*wiret0).second<<
" (relative, after even-odd layer corrections) "
547 cout <<
"[DTT0CalibrationNew]Computing relative t0 wrt to chamber average" << endl;
549 map<DTChamberId,double> sumT0ByChamber;
550 map<DTChamberId,int> countT0ByChamber;
558 int channelId =
tzero->channelId;
559 if ( channelId == 0 )
continue;
567 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f;
569 countT0ByChamber[chamberId]++;
587 int channelId =
tzero->channelId;
588 if ( channelId == 0 )
continue;
597 double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
598 double t0rms = t0rms_f;
600 t0sWRTChamber->
set(wireId,
607 cout<<
"Changing t0 of wire "<<wireId<<
" from "<<
tzero->t0mean<<
" to "<<t0mean<<endl;
613 cout <<
"[DTT0CalibrationNew]Writing values in DB!" << endl;
615 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)
std::map< DTChamberId, double > theRefT0ByChamber
std::map< DTWireId, TH1I * > theHistoWireMap
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< DTChamberId, double > theSumT0ByChamber
std::map< DTWireId, double > theSigmaT0PerWire
std::map< DTChamberId, int > theCountT0ByChamber
Abs< T >::type abs(const T &t)
std::map< DTWireId, int > nDigiPerWire
std::map< DTWireId, double > theRelativeT0PerWire
const_iterator end() const
std::map< DTLayerId, TH1I * > theHistoLayerMap
std::map< DTWireId, double > theAbsoluteT0PerWire
static const double tzero[3]
std::map< DTWireId, double > qK
edm::ESHandle< DTGeometry > dtGeom
static void writeToDB(std::string record, T *payload)