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;
425 (*tzero).first.stationId,
426 (*tzero).first.sectorId);
427 sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + (*tzero).second.t0mean;
428 countT0ByChamber[chamberId]++;
435 (*tzero).first.stationId,
436 (*tzero).first.sectorId);
437 double t0mean = ((*tzero).second.t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]);
438 double t0rms = (*tzero).second.t0rms;
439 DTWireId wireId((*tzero).first.wheelId,
440 (*tzero).first.stationId,
441 (*tzero).first.sectorId,
443 (*tzero).first.layerId,
444 (*tzero).first.cellId);
445 t0sWRTChamber->
set(wireId,
451 cout<<
"Changing t0 of wire "<<wireId<<
" from "<<(*tzero).second.t0mean<<
" to "<<t0mean<<endl;
457 cout <<
"[DTT0Calibration]Writing values in DB!" << endl;
459 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
std::map< DTWireId, double > theRelativeT0PerWire
std::map< DTWireId, double > qK
const_iterator end() const
std::vector< std::pair< DTT0Id, DTT0Data > >::const_iterator const_iterator
Access methods to data.
static const double tzero[3]
static void writeToDB(std::string record, T *payload)