Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DTTTrigT0SegCorrection.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 "TFile.h"
00018 #include "TH1F.h"
00019
00020 #include <string>
00021 #include <sstream>
00022
00023 using namespace std;
00024 using namespace edm;
00025
00026 DTTTrigT0SegCorrection::DTTTrigT0SegCorrection(const ParameterSet& pset) {
00027 string t0SegRootFile = pset.getParameter<string>("t0SegRootFile");
00028 rootFile_ = new TFile(t0SegRootFile.c_str(),"READ");
00029 dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
00030 }
00031
00032 DTTTrigT0SegCorrection::~DTTTrigT0SegCorrection() {
00033 delete rootFile_;
00034 }
00035
00036 void DTTTrigT0SegCorrection::setES(const EventSetup& setup) {
00037
00038 ESHandle<DTTtrig> tTrig;
00039 setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
00040 tTrigMap_ = &*tTrig;
00041 }
00042
00043 DTTTrigData DTTTrigT0SegCorrection::correction(const DTSuperLayerId& slId) {
00044 float tTrigMean,tTrigSigma,kFactor;
00045 int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
00046 if(status != 0) throw cms::Exception("[DTTTrigT0SegCorrection]") << "Could not find tTrig entry in DB for"
00047 << slId << endl;
00048
00049 const TH1F* t0SegHisto = getHisto(slId);
00050 double corrMean = tTrigMean;
00051 double corrSigma = tTrigSigma;
00052
00053 double corrKFact = (kFactor*tTrigSigma + t0SegHisto->GetMean())/tTrigSigma;
00054 return DTTTrigData(corrMean,corrSigma,corrKFact);
00055 }
00056
00057 const TH1F* DTTTrigT0SegCorrection::getHisto(const DTSuperLayerId& slId) {
00058 string histoName = getHistoName(slId);
00059 TH1F* histo = static_cast<TH1F*>(rootFile_->Get(histoName.c_str()));
00060 if(!histo) throw cms::Exception("[DTTTrigT0SegCorrection]") << "t0-seg histogram not found:"
00061 << histoName << endl;
00062 return histo;
00063 }
00064
00065 string DTTTrigT0SegCorrection::getHistoName(const DTSuperLayerId& slId) {
00066 DTChamberId chId = slId.chamberId();
00067
00068
00069 stringstream wheel; wheel << chId.wheel();
00070 stringstream station; station << chId.station();
00071 stringstream sector; sector << chId.sector();
00072
00073 string chHistoName =
00074 "_W" + wheel.str() +
00075 "_St" + station.str() +
00076 "_Sec" + sector.str();
00077
00078 return (slId.superLayer() != 2)?("hRPhiSegT0"+chHistoName):("hRZSegT0"+chHistoName);
00079 }
00080
00081