CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CalibMuon/DTCalibration/plugins/DTVDriftMeanTimer.cc

Go to the documentation of this file.
00001 
00002 /*
00003  *  See header file for a description of this class.
00004  *
00005  *  $Date: 2012/03/02 19:47:33 $
00006  *  $Revision: 1.3 $
00007  *  \author A. Vilela Pereira
00008  */
00009 
00010 #include "DTVDriftMeanTimer.h"
00011 
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 
00017 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00018 #include "CondFormats/DTObjects/interface/DTMtime.h"
00019 
00020 #include "CalibMuon/DTCalibration/interface/DTMeanTimerFitter.h"
00021 #include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h"
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 #include "TFile.h"
00027 #include "TString.h"
00028 
00029 using namespace std;
00030 using namespace edm;
00031 
00032 namespace dtCalibration {
00033 
00034 DTVDriftMeanTimer::DTVDriftMeanTimer(const ParameterSet& pset) {
00035   string rootFileName = pset.getParameter<string>("rootFileName");
00036   rootFile_ = new TFile(rootFileName.c_str(), "READ");
00037   fitter_ = new DTMeanTimerFitter(rootFile_);
00038   bool debug = pset.getUntrackedParameter<bool>("debug", false);
00039   if(debug) fitter_->setVerbosity(1);
00040 }
00041 
00042 DTVDriftMeanTimer::~DTVDriftMeanTimer() {
00043   rootFile_->Close();
00044   delete fitter_;
00045 }
00046 
00047 void DTVDriftMeanTimer::setES(const edm::EventSetup& setup) {}
00048 
00049 DTVDriftData DTVDriftMeanTimer::compute(DTSuperLayerId const& slId) {
00050 
00051   // Evaluate v_drift and sigma from the TMax histograms
00052   DTWireId wireId(slId, 0, 0);
00053   TString N = ( ( ( ( (TString)"TMax" + (long)wireId.wheel() )
00054                                       + (long)wireId.station() )
00055                                       + (long)wireId.sector() ) + (long)wireId.superLayer() );
00056   vector<float> vDriftAndReso = fitter_->evaluateVDriftAndReso(N);
00057 
00058   // Don't write the constants for the SL if the vdrift was not computed
00059   if(vDriftAndReso.front() == -1)
00060      throw cms::Exception("DTCalibration") << "Could not compute valid vDrift value for SL " << slId << endl;
00061 
00062   return DTVDriftData(vDriftAndReso[0],vDriftAndReso[1]);
00063 }
00064 
00065 } // namespace