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 DTTTrigMatchRPhi::DTTTrigMatchRPhi(const ParameterSet& pset) {
00023 dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
00024 }
00025
00026 DTTTrigMatchRPhi::~DTTTrigMatchRPhi() {}
00027
00028 void DTTTrigMatchRPhi::setES(const EventSetup& setup) {
00029
00030 ESHandle<DTTtrig> tTrig;
00031 setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
00032 tTrigMap_ = &*tTrig;
00033 }
00034
00035 DTTTrigData DTTTrigMatchRPhi::correction(const DTSuperLayerId& slId) {
00036
00037 float tTrigMean,tTrigSigma,kFactor;
00038 int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
00039
00040 if(slId.superLayer() == 2){
00041 if(status != 0) throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
00042 << slId << endl;
00043 return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
00044 } else{
00045 DTSuperLayerId partnerSLId(slId.chamberId(),(slId.superLayer() == 1)?3:1);
00046 float tTrigMeanNew,tTrigSigmaNew,kFactorNew;
00047 if(!status){
00048 if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns)){
00049 tTrigMeanNew = (tTrigMean + tTrigMeanNew)/2.;
00050
00051 tTrigSigmaNew = (tTrigSigmaNew + tTrigSigma)/2.;
00052
00053 kFactorNew = kFactor;
00054 return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00055 } else return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
00056 } else{
00057 if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns))
00058 return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00059 else {
00060 throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
00061 << slId << "\n" << partnerSLId << endl;
00062 }
00063 }
00064 }
00065 }