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 <<
"[DTT0CalibrationRMSPerLayer]Writing histos to file!" << endl;
283 for(map<DTWireId, TH1I*>::const_iterator wHisto =
theHistoWireMap.begin();
286 (*wHisto).second->Write();
291 (*wHisto).second->Write();
293 for(map<DTLayerId, TH1I*>::const_iterator lHisto =
theHistoLayerMap.begin();
296 (*lHisto).second->Write();
300 cout <<
"[DTT0CalibrationRMS] Compute and store t0 and sigma per wire" << endl;
313 cout <<
"Wire " << (*wiret0).first <<
" has t0 " << t0 <<
"(absolute) " 320 cout<<
"[DTT0CalibrationRMS] ERROR: no digis in wire "<<(*wiret0).first<<endl;
330 for(vector<const DTSuperLayer*>::const_iterator sl = superLayers.begin();
331 sl != superLayers.end(); sl++) {
335 double oddLayersMean=0;
336 double evenLayersMean=0;
337 double oddLayersDen=0;
338 double evenLayersDen=0;
342 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
344 cout<<
"[DTT0CalibrationRMS] Superlayer "<<(*sl)->id()
345 <<
"layer " <<(*wiret0).first.layerId().layer()<<
" with "<<(*wiret0).second<<endl;
346 if(((*wiret0).first.layerId().layer()) % 2){
347 oddLayersMean = oddLayersMean + (*wiret0).second;
351 evenLayersMean = evenLayersMean + (*wiret0).second;
356 oddLayersMean = oddLayersMean/oddLayersDen;
357 evenLayersMean = evenLayersMean/evenLayersDen;
359 cout<<
"[DTT0CalibrationRMS] Relative T0 mean for odd layers "<<oddLayersMean<<
" even layers"<<evenLayersMean<<endl;
362 double oddLayersSigma=0;
363 double evenLayersSigma=0;
367 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
368 if(((*wiret0).first.layerId().layer()) % 2){
369 oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean);
372 evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean);
376 oddLayersSigma = oddLayersSigma/oddLayersDen;
377 evenLayersSigma = evenLayersSigma/evenLayersDen;
378 oddLayersSigma =
sqrt(oddLayersSigma);
379 evenLayersSigma =
sqrt(evenLayersSigma);
382 cout<<
"[DTT0CalibrationRMS] Relative T0 sigma for odd layers "<<oddLayersSigma<<
" even layers"<<evenLayersSigma<<endl;
385 double oddLayersFinalMean=0;
386 double evenLayersFinalMean=0;
390 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
391 if(((*wiret0).first.layerId().layer()) % 2){
392 if(
abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma))
393 oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second;
396 if(
abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma))
397 evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second;
401 oddLayersFinalMean = oddLayersFinalMean/oddLayersDen;
402 evenLayersFinalMean = evenLayersFinalMean/evenLayersDen;
404 cout<<
"[DTT0CalibrationRMS] Final relative T0 mean for odd layers "<<oddLayersFinalMean<<
" even layers"<<evenLayersFinalMean<<endl;
409 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
411 if(((*wiret0).first.layerId().layer()) % 2)
412 t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean);
414 t0 = (*wiret0).second;
416 cout <<
"[DTT0CalibrationRMS] Wire " << (*wiret0).first <<
" has t0 " << (*wiret0).second
417 <<
" (relative, after even-odd layer corrections) " 428 cout <<
"[DTT0CalibrationRMS]Computing relative t0 wrt to chamber average" << endl;
430 map<DTChamberId,double> sumT0ByChamber;
431 map<DTChamberId,int> countT0ByChamber;
434 int channelId =
tzero->channelId;
435 if ( channelId == 0 )
continue;
443 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f;
445 countT0ByChamber[chamberId]++;
451 int channelId =
tzero->channelId;
452 if ( channelId == 0 )
continue;
461 double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
462 double t0rms = t0rms_f;
464 t0sWRTChamber->
set(wireId,
470 cout <<
"Changing t0 of wire " << wireId <<
" from " << t0mean_f
471 <<
" to " << t0mean << endl;
477 cout <<
"[DTT0CalibrationRMS]Writing values in DB!" << endl;
479 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< DTWireId, TH1I * > theHistoWireMap
std::map< DTWireId, double > theSigmaT0PerWire
std::map< DTWireId, TH1I * > theHistoWireMap_ref
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
std::map< DTLayerId, TH1I * > theHistoLayerMap
Abs< T >::type abs(const T &t)
std::map< DTWireId, double > theAbsoluteT0PerWire
const_iterator end() const
bool correctByChamberMean_
std::map< DTWireId, int > nDigiPerWire
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.
std::map< DTWireId, double > qK