CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/CalibMuon/DTCalibration/plugins/DTTTrigConstantShift.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2012/03/21 13:48:06 $
00005  *  $Revision: 1.1 $
00006  *  \author A. Vilela Pereira
00007  */
00008 
00009 #include "DTTTrigConstantShift.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/DTSuperLayerId.h"
00016 #include "CondFormats/DTObjects/interface/DTTtrig.h"
00017 #include "CondFormats/DataRecord/interface/DTTtrigRcd.h"
00018 
00019 #include <math.h>
00020 
00021 using namespace std;
00022 using namespace edm;
00023 
00024 namespace dtCalibration {
00025 
00026 DTTTrigConstantShift::DTTTrigConstantShift(const ParameterSet& pset):
00027   dbLabel_( pset.getUntrackedParameter<string>("dbLabel", "") ),
00028   calibChamber_( pset.getParameter<string>("calibChamber") ),
00029   value_( pset.getParameter<double>("value") ) {
00030 
00031   LogVerbatim("Calibration") << "[DTTTrigConstantShift] Applying constant correction value: " << value_ << endl;
00032 
00033   if( calibChamber_ != "" && calibChamber_ != "None" && calibChamber_ != "All" ){
00034     stringstream linestr;
00035     int selWheel, selStation, selSector;
00036     linestr << calibChamber_;
00037     linestr >> selWheel >> selStation >> selSector;
00038     chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
00039     LogVerbatim("Calibration") << "[DTTTrigConstantShift] Chosen chamber: " << chosenChamberId_ << endl;
00040   }
00041   //FIXME: Check if chosen chamber is valid.
00042 }
00043 
00044 DTTTrigConstantShift::~DTTTrigConstantShift() {}
00045 
00046 void DTTTrigConstantShift::setES(const EventSetup& setup) {
00047   // Get tTrig record from DB
00048   ESHandle<DTTtrig> tTrig;
00049   setup.get<DTTtrigRcd>().get(dbLabel_,tTrig);
00050   tTrigMap_ = &*tTrig;
00051 }
00052 
00053 DTTTrigData DTTTrigConstantShift::correction(const DTSuperLayerId& slId) {
00054   
00055   float tTrigMean,tTrigSigma,kFactor;
00056   int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
00057   if(status != 0) throw cms::Exception("[DTTTrigConstantShift]") << "Could not find tTrig entry in DB for"
00058                                                                  << slId << endl;
00059 
00060   float tTrigMeanNew = tTrigMean;
00061   if( calibChamber_ != "" && calibChamber_ != "None"){
00062      if( ( calibChamber_ == "All" ) ||
00063          ( calibChamber_ != "All" && slId.chamberId() == chosenChamberId_ ) ) {
00064         tTrigMeanNew = tTrigMean + value_; 
00065      }
00066   }
00067 
00068   return DTTTrigData(tTrigMeanNew,tTrigSigma,kFactor);
00069 }
00070 
00071 } // namespace