Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DTTTrigMatchRPhi.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Framework/interface/EventSetup.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
00014 #include "CondFormats/DTObjects/interface/DTTtrig.h"
00015 #include "CondFormats/DataRecord/interface/DTTtrigRcd.h"
00016
00017 #include <math.h>
00018
00019 using namespace std;
00020 using namespace edm;
00021
00022 namespace dtCalibration {
00023
00024 DTTTrigMatchRPhi::DTTTrigMatchRPhi(const ParameterSet& pset) {
00025 dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
00026 }
00027
00028 DTTTrigMatchRPhi::~DTTTrigMatchRPhi() {}
00029
00030 void DTTTrigMatchRPhi::setES(const EventSetup& setup) {
00031
00032 ESHandle<DTTtrig> tTrig;
00033 setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
00034 tTrigMap_ = &*tTrig;
00035 }
00036
00037 DTTTrigData DTTTrigMatchRPhi::correction(const DTSuperLayerId& slId) {
00038
00039 float tTrigMean,tTrigSigma,kFactor;
00040 int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
00041
00042 if(slId.superLayer() == 2){
00043 if(status != 0) throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
00044 << slId << endl;
00045 return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
00046 } else{
00047 DTSuperLayerId partnerSLId(slId.chamberId(),(slId.superLayer() == 1)?3:1);
00048 float tTrigMeanNew,tTrigSigmaNew,kFactorNew;
00049 if(!status){
00050 if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns)){
00051 tTrigMeanNew = (tTrigMean + tTrigMeanNew)/2.;
00052
00053 tTrigSigmaNew = (tTrigSigmaNew + tTrigSigma)/2.;
00054
00055 kFactorNew = kFactor;
00056 return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00057 } else return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
00058 } else{
00059 if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns))
00060 return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00061 else {
00062 throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
00063 << slId << "\n" << partnerSLId << endl;
00064 }
00065 }
00066 }
00067 }
00068
00069 }