Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DTT0FillDefaultFromDB.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Framework/interface/EventSetup.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014
00015 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00016 #include "CondFormats/DTObjects/interface/DTT0.h"
00017 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
00018
00019 #include <string>
00020
00021 using namespace std;
00022 using namespace edm;
00023
00024 namespace dtCalibration {
00025
00026 DTT0FillDefaultFromDB::DTT0FillDefaultFromDB(const ParameterSet& pset):
00027 dbLabelRef_( pset.getParameter<string>("dbLabelRef") ) {
00028 }
00029
00030 DTT0FillDefaultFromDB::~DTT0FillDefaultFromDB() {
00031 }
00032
00033 void DTT0FillDefaultFromDB::setES(const EventSetup& setup) {
00034
00035 ESHandle<DTT0> t0H;
00036 setup.get<DTT0Rcd>().get(t0H);
00037 t0Map_ = &*t0H;
00038 LogVerbatim("Calibration") << "[DTT0FillDefaultFromDB] T0 version: " << t0H->version();
00039
00040
00041 ESHandle<DTT0> t0RefH;
00042 setup.get<DTT0Rcd>().get(dbLabelRef_,t0RefH);
00043 t0MapRef_ = &*t0RefH;
00044 LogVerbatim("Calibration") << "[DTT0FillDefaultFromDB] Reference T0 version: " << t0RefH->version();
00045
00046 }
00047
00048 DTT0Data DTT0FillDefaultFromDB::correction(const DTWireId& wireId) {
00049
00050
00051
00052
00053 float t0Mean,t0RMS;
00054 int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
00055 if(!status){
00056 return DTT0Data(t0Mean,t0RMS);
00057 } else{
00058
00059 float t0MeanRef,t0RMSRef;
00060 int statusRef = t0MapRef_->get(wireId,t0MeanRef,t0RMSRef,DTTimeUnits::counts);
00061 if(!statusRef){
00062 return DTT0Data(t0MeanRef,t0RMSRef);
00063 } else{
00064
00065 throw cms::Exception("[DTT0FillDefaultFromDB]") << "Could not find t0 entry in reference DB for"
00066 << wireId << endl;
00067 }
00068 }
00069 }
00070
00071 }