CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTTrigT0SegCorrection.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2010/02/16 10:03:23 $
5  * $Revision: 1.2 $
6  * \author A. Vilela Pereira
7  */
8 
16 
17 #include "TFile.h"
18 #include "TH1F.h"
19 
20 #include <string>
21 #include <sstream>
22 
23 using namespace std;
24 using namespace edm;
25 
27  string t0SegRootFile = pset.getParameter<string>("t0SegRootFile");
28  rootFile_ = new TFile(t0SegRootFile.c_str(),"READ");
29  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
30 }
31 
33  delete rootFile_;
34 }
35 
37  // Get tTrig record from DB
38  ESHandle<DTTtrig> tTrig;
39  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
40  tTrigMap_ = &*tTrig;
41 }
42 
44  float tTrigMean,tTrigSigma,kFactor;
45  int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
46  if(status != 0) throw cms::Exception("[DTTTrigT0SegCorrection]") << "Could not find tTrig entry in DB for"
47  << slId << endl;
48 
49  const TH1F* t0SegHisto = getHisto(slId);
50  double corrMean = tTrigMean;
51  double corrSigma = tTrigSigma;
52  //FIXME: can we fit the t0seg histo? How do we remove the peak at 0?;
53  double corrKFact = (kFactor*tTrigSigma + t0SegHisto->GetMean())/tTrigSigma;
54  return DTTTrigData(corrMean,corrSigma,corrKFact);
55 }
56 
58  string histoName = getHistoName(slId);
59  TH1F* histo = static_cast<TH1F*>(rootFile_->Get(histoName.c_str()));
60  if(!histo) throw cms::Exception("[DTTTrigT0SegCorrection]") << "t0-seg histogram not found:"
61  << histoName << endl;
62  return histo;
63 }
64 
66  DTChamberId chId = slId.chamberId();
67 
68  // Compose the chamber name
69  stringstream wheel; wheel << chId.wheel();
70  stringstream station; station << chId.station();
71  stringstream sector; sector << chId.sector();
72 
73  string chHistoName =
74  "_W" + wheel.str() +
75  "_St" + station.str() +
76  "_Sec" + sector.str();
77 
78  return (slId.superLayer() != 2)?("hRPhiSegT0"+chHistoName):("hRZSegT0"+chHistoName);
79 }
80 
81 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DTChamberId chamberId() const
Return the corresponding ChamberId.
std::string getHistoName(const DTSuperLayerId &slID)
const TH1F * getHisto(const DTSuperLayerId &)
virtual DTTTrigData correction(const DTSuperLayerId &)
virtual void setES(const edm::EventSetup &setup)
int superLayer() const
Return the superlayer number.
const T & get() const
Definition: EventSetup.h:55
int sector() const
Definition: DTChamberId.h:63
DTTTrigT0SegCorrection(const edm::ParameterSet &)
tuple status
Definition: ntuplemaker.py:245
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
TH1F * getHisto(std::string name, std::string process, DQMStore *dbe_, bool verb=false, bool clone=false)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")