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!)
280 cout <<
"[DTT0CalibrationPerLayer]Writing histos to file!" << endl;
284 for(map<DTWireId, TH1I*>::const_iterator wHisto =
theHistoWireMap.begin();
287 (*wHisto).second->Write();
292 (*wHisto).second->Write();
294 for(map<DTLayerId, TH1I*>::const_iterator lHisto =
theHistoLayerMap.begin();
297 (*lHisto).second->Write();
301 cout <<
"[DTT0Calibration] Compute and store t0 and sigma per wire" << endl;
307 double t0 = (*wiret0).second/
nDigiPerWire[(*wiret0).first];
314 cout <<
"Wire " << (*wiret0).first <<
" has t0 " << t0 <<
"(absolute) "
321 cout<<
"[DTT0Calibration] ERROR: no digis in wire "<<(*wiret0).first<<endl;
329 const vector<DTSuperLayer*> superLayers =
dtGeom->superLayers();
331 for(vector<DTSuperLayer*>::const_iterator sl = superLayers.begin();
332 sl != superLayers.end(); sl++) {
336 double oddLayersMean=0;
337 double evenLayersMean=0;
338 double oddLayersDen=0;
339 double evenLayersDen=0;
343 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
345 cout<<
"[DTT0Calibration] Superlayer "<<(*sl)->id()
346 <<
"layer " <<(*wiret0).first.layerId().layer()<<
" with "<<(*wiret0).second<<endl;
347 if(((*wiret0).first.layerId().layer()) % 2){
348 oddLayersMean = oddLayersMean + (*wiret0).second;
352 evenLayersMean = evenLayersMean + (*wiret0).second;
357 oddLayersMean = oddLayersMean/oddLayersDen;
358 evenLayersMean = evenLayersMean/evenLayersDen;
360 cout<<
"[DTT0Calibration] Relative T0 mean for odd layers "<<oddLayersMean<<
" even layers"<<evenLayersMean<<endl;
363 double oddLayersSigma=0;
364 double evenLayersSigma=0;
368 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
369 if(((*wiret0).first.layerId().layer()) % 2){
370 oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean);
373 evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean);
377 oddLayersSigma = oddLayersSigma/oddLayersDen;
378 evenLayersSigma = evenLayersSigma/evenLayersDen;
379 oddLayersSigma =
sqrt(oddLayersSigma);
380 evenLayersSigma =
sqrt(evenLayersSigma);
383 cout<<
"[DTT0Calibration] Relative T0 sigma for odd layers "<<oddLayersSigma<<
" even layers"<<evenLayersSigma<<endl;
386 double oddLayersFinalMean=0;
387 double evenLayersFinalMean=0;
391 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
392 if(((*wiret0).first.layerId().layer()) % 2){
393 if(
abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma))
394 oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second;
397 if(
abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma))
398 evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second;
402 oddLayersFinalMean = oddLayersFinalMean/oddLayersDen;
403 evenLayersFinalMean = evenLayersFinalMean/evenLayersDen;
405 cout<<
"[DTT0Calibration] Final relative T0 mean for odd layers "<<oddLayersFinalMean<<
" even layers"<<evenLayersFinalMean<<endl;
410 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
412 if(((*wiret0).first.layerId().layer()) % 2)
413 t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean);
415 t0 = (*wiret0).second;
417 cout <<
"[DTT0Calibration] Wire " << (*wiret0).first <<
" has t0 " << (*wiret0).second
418 <<
" (relative, after even-odd layer corrections) "
429 cout <<
"[DTT0Calibration]Computing relative t0 wrt to chamber average" << endl;
431 map<DTChamberId,double> sumT0ByChamber;
432 map<DTChamberId,int> countT0ByChamber;
435 int channelId =
tzero->channelId;
436 if ( channelId == 0 )
continue;
444 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f;
446 countT0ByChamber[chamberId]++;
452 int channelId =
tzero->channelId;
453 if ( channelId == 0 )
continue;
462 double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
463 double t0rms = t0rms_f;
465 t0sWRTChamber->
set(wireId,
471 cout <<
"Changing t0 of wire " << wireId <<
" from " << t0mean_f
472 <<
" to " << t0mean << endl;
478 cout <<
"[DTT0Calibration]Writing values in DB!" << endl;
480 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
std::map< DTWireId, double > qK
const_iterator end() const
static const double tzero[3]
static void writeToDB(std::string record, T *payload)