CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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: 2010/11/18 20:58:24 $
00006  *  $Revision: 1.2 $
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 DTVDriftMeanTimer::DTVDriftMeanTimer(const ParameterSet& pset) {
00033   string rootFileName = pset.getParameter<string>("rootFileName");
00034   rootFile_ = new TFile(rootFileName.c_str(), "READ");
00035   fitter_ = new DTMeanTimerFitter(rootFile_);
00036   bool debug = pset.getUntrackedParameter<bool>("debug", false);
00037   if(debug) fitter_->setVerbosity(1);
00038 }
00039 
00040 DTVDriftMeanTimer::~DTVDriftMeanTimer() {
00041   rootFile_->Close();
00042   delete fitter_;
00043 }
00044 
00045 void DTVDriftMeanTimer::setES(const edm::EventSetup& setup) {}
00046 
00047 DTVDriftData DTVDriftMeanTimer::compute(DTSuperLayerId const& slId) {
00048 
00049   // Evaluate v_drift and sigma from the TMax histograms
00050   DTWireId wireId(slId, 0, 0);
00051   TString N = ( ( ( ( (TString)"TMax" + (long)wireId.wheel() )
00052                                       + (long)wireId.station() )
00053                                       + (long)wireId.sector() ) + (long)wireId.superLayer() );
00054   vector<float> vDriftAndReso = fitter_->evaluateVDriftAndReso(N);
00055 
00056   // Don't write the constants for the SL if the vdrift was not computed
00057   if(vDriftAndReso.front() == -1)
00058      throw cms::Exception("DTCalibration") << "Could not compute valid vDrift value for SL " << slId << endl;
00059 
00060   return DTVDriftData(vDriftAndReso[0],vDriftAndReso[1]);
00061 }