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!)
277 cout <<
"[DTT0CalibrationPerLayer]Writing histos to file!" << endl;
281 for(map<DTWireId, TH1I*>::const_iterator wHisto =
theHistoWireMap.begin();
284 (*wHisto).second->Write();
289 (*wHisto).second->Write();
291 for(map<DTLayerId, TH1I*>::const_iterator lHisto =
theHistoLayerMap.begin();
294 (*lHisto).second->Write();
298 cout <<
"[DTT0Calibration] Compute and store t0 and sigma per wire" << endl;
304 double t0 = (*wiret0).second/
nDigiPerWire[(*wiret0).first];
313 cout<<
"[DTT0Calibration] ERROR: no digis in wire "<<(*wiret0).first<<endl;
320 const vector<DTSuperLayer*> superLayers =
dtGeom->superLayers();
322 for(vector<DTSuperLayer*>::const_iterator sl = superLayers.begin();
323 sl != superLayers.end(); sl++) {
327 double oddLayersMean=0;
328 double evenLayersMean=0;
329 double oddLayersDen=0;
330 double evenLayersDen=0;
334 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
336 cout<<
"[DTT0Calibration] Superlayer "<<(*sl)->id()
337 <<
"layer " <<(*wiret0).first.layerId().layer()<<
" with "<<(*wiret0).second<<endl;
338 if(((*wiret0).first.layerId().layer()) % 2){
339 oddLayersMean = oddLayersMean + (*wiret0).second;
343 evenLayersMean = evenLayersMean + (*wiret0).second;
348 oddLayersMean = oddLayersMean/oddLayersDen;
349 evenLayersMean = evenLayersMean/evenLayersDen;
350 if(
debug && oddLayersMean)
351 cout<<
"[DTT0Calibration] Relative T0 mean for odd layers "<<oddLayersMean<<
" even layers"<<evenLayersMean<<endl;
354 double oddLayersSigma=0;
355 double evenLayersSigma=0;
359 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
360 if(((*wiret0).first.layerId().layer()) % 2){
361 oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean);
364 evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean);
368 oddLayersSigma = oddLayersSigma/oddLayersDen;
369 evenLayersSigma = evenLayersSigma/evenLayersDen;
370 oddLayersSigma =
sqrt(oddLayersSigma);
371 evenLayersSigma =
sqrt(evenLayersSigma);
373 if(
debug && oddLayersMean)
374 cout<<
"[DTT0Calibration] Relative T0 sigma for odd layers "<<oddLayersSigma<<
" even layers"<<evenLayersSigma<<endl;
377 double oddLayersFinalMean=0;
378 double evenLayersFinalMean=0;
382 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
383 if(((*wiret0).first.layerId().layer()) % 2){
384 if(
abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma))
385 oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second;
388 if(
abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma))
389 evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second;
393 oddLayersFinalMean = oddLayersFinalMean/oddLayersDen;
394 evenLayersFinalMean = evenLayersFinalMean/evenLayersDen;
395 if(
debug && oddLayersMean)
396 cout<<
"[DTT0Calibration] Final relative T0 mean for odd layers "<<oddLayersFinalMean<<
" even layers"<<evenLayersFinalMean<<endl;
401 if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){
403 if(((*wiret0).first.layerId().layer()) % 2)
404 t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean);
406 t0 = (*wiret0).second;
408 cout<<
"[DTT0Calibration] Wire "<<(*wiret0).first<<
" has t0 "<<(*wiret0).second<<
" (relative, after even-odd layer corrections) "
418 cout <<
"[DTT0Calibration]Computing relative t0 wrt to chamber average" << endl;
420 map<DTChamberId,double> sumT0ByChamber;
421 map<DTChamberId,int> countT0ByChamber;
429 int channelId =
tzero->channelId;
430 if ( channelId == 0 )
continue;
433 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] +
tzero->t0mean;
438 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f;
440 countT0ByChamber[chamberId]++;
458 int channelId =
tzero->channelId;
459 if ( channelId == 0 )
continue;
462 double t0mean = (
tzero->t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
463 double t0rms =
tzero->t0rms;
468 t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
471 t0sWRTChamber->
set(wireId,
478 cout<<
"Changing t0 of wire "<<wireId<<
" from "<<
tzero->t0mean<<
" to "<<t0mean<<endl;
484 cout <<
"[DTT0Calibration]Writing values in DB!" << endl;
486 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< 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)