CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibMuon/DTCalibration/plugins/DTTTrigMatchRPhi.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2010/02/16 10:03:23 $
00005  *  $Revision: 1.2 $
00006  *  \author A. Vilela Pereira
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   // Get tTrig record from DB
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   // RZ superlayers return the current value
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){ // Gets average of both SuperLayer's
00048       if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns)){
00049         tTrigMeanNew = (tTrigMean + tTrigMeanNew)/2.;
00050 //         tTrigSigmaNew = sqrt(tTrigSigmaNew*tTrigSigmaNew + tTrigSigma*tTrigSigma)/2.;
00051         tTrigSigmaNew = (tTrigSigmaNew + tTrigSigma)/2.;
00052 
00053         kFactorNew = kFactor;
00054         return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00055       } else return DTTTrigData(tTrigMean,tTrigSigma,kFactor); 
00056     } else{ // If there is no entry tries to find partner SL and retrieves its value
00057       if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns))
00058         return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00059       else { // Both RPhi SL's not present in DB
00060         throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
00061                                                    << slId << "\n" << partnerSLId << endl;
00062       }
00063     }
00064   }
00065 }