CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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: 2012/03/02 19:47:32 $
00005  *  $Revision: 1.3 $
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 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   // Get tTrig record from DB
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   // RZ superlayers return the current value
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){ // Gets average of both SuperLayer's
00050       if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns)){
00051         tTrigMeanNew = (tTrigMean + tTrigMeanNew)/2.;
00052 //         tTrigSigmaNew = sqrt(tTrigSigmaNew*tTrigSigmaNew + tTrigSigma*tTrigSigma)/2.;
00053         tTrigSigmaNew = (tTrigSigmaNew + tTrigSigma)/2.;
00054 
00055         kFactorNew = kFactor;
00056         return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00057       } else return DTTTrigData(tTrigMean,tTrigSigma,kFactor); 
00058     } else{ // If there is no entry tries to find partner SL and retrieves its value
00059       if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns))
00060         return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
00061       else { // Both RPhi SL's not present in DB
00062         throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
00063                                                    << slId << "\n" << partnerSLId << endl;
00064       }
00065     }
00066   }
00067 }
00068 
00069 } // namespace