CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
dtCalibration::DTVDriftSegment Class Reference

#include <DTVDriftSegment.h>

Inheritance diagram for dtCalibration::DTVDriftSegment:
dtCalibration::DTVDriftBaseAlgo

Public Member Functions

DTVDriftData compute (const DTSuperLayerId &) override
 
 DTVDriftSegment (edm::ParameterSet const &)
 
void setES (const edm::EventSetup &setup) override
 
 ~DTVDriftSegment () override
 
- Public Member Functions inherited from dtCalibration::DTVDriftBaseAlgo
 DTVDriftBaseAlgo ()
 
virtual ~DTVDriftBaseAlgo ()
 

Private Member Functions

TH1F * getHisto (const DTSuperLayerId &)
 
std::string getHistoName (const DTSuperLayerId &)
 

Private Attributes

DTResidualFitterfitter_
 
const DTMtimemTimeMap_
 
unsigned int nSigmas_
 
TFile * rootFile_
 

Detailed Description

Definition at line 23 of file DTVDriftSegment.h.

Constructor & Destructor Documentation

DTVDriftSegment::DTVDriftSegment ( edm::ParameterSet const &  )

Definition at line 34 of file DTVDriftSegment.cc.

References debug, fitter_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), rootFile_, and CSCSkim_cfi::rootFileName.

35  : nSigmas_(pset.getUntrackedParameter<unsigned int>("nSigmasFitRange", 1)) {
36  string rootFileName = pset.getParameter<string>("rootFileName");
37  rootFile_ = new TFile(rootFileName.c_str(), "READ");
38 
39  bool debug = pset.getUntrackedParameter<bool>("debug", false);
40  fitter_ = new DTResidualFitter(debug);
41  //bool debug = pset.getUntrackedParameter<bool>("debug", false);
42  //if(debug) fitter_->setVerbosity(1);
43  }
#define debug
Definition: HDRShower.cc:19
DTVDriftSegment::~DTVDriftSegment ( )
override

Definition at line 45 of file DTVDriftSegment.cc.

References fitter_, and rootFile_.

45  {
46  rootFile_->Close();
47  delete fitter_;
48  }

Member Function Documentation

DTVDriftData DTVDriftSegment::compute ( const DTSuperLayerId )
overridevirtual

Implements dtCalibration::DTVDriftBaseAlgo.

Definition at line 57 of file DTVDriftSegment.cc.

References DTVelocityUnits::cm_per_ns, Exception, DTResidualFitResult::fitMean, DTResidualFitResult::fitMeanError, DTResidualFitter::fitResiduals(), DTResidualFitResult::fitSigma, DTResidualFitResult::fitSigmaError, fitter_, DTMtime::get(), getHisto(), LogTrace, mTimeMap_, nSigmas_, L1TObjectsTimingClient_cff::resolution, mps_update::status, and DTSuperLayerId::superLayer().

57  {
58  // Get original value from DB; vdrift is cm/ns , resolution is cm
59  float vDrift = 0., resolution = 0.;
61 
62  if (status != 0)
63  throw cms::Exception("DTCalibration") << "Could not find vDrift entry in DB for" << slId << endl;
64 
65  // For RZ superlayers use original value
66  if (slId.superLayer() == 2) {
67  LogTrace("Calibration") << "[DTVDriftSegment]: RZ superlayer\n"
68  << " Will use original vDrift and resolution.";
69  return DTVDriftData(vDrift, resolution);
70  } else {
71  TH1F* vDriftCorrHisto = getHisto(slId);
72  // If empty histogram
73  if (vDriftCorrHisto->GetEntries() == 0) {
74  LogError("Calibration") << "[DTVDriftSegment]: Histogram " << vDriftCorrHisto->GetName() << " is empty.\n"
75  << " Will use original vDrift and resolution.";
76  return DTVDriftData(vDrift, resolution);
77  }
78 
79  LogTrace("Calibration") << "[DTVDriftSegment]: Fitting histogram " << vDriftCorrHisto->GetName();
80  DTResidualFitResult fitResult = fitter_->fitResiduals(*vDriftCorrHisto, nSigmas_);
81  LogTrace("Calibration") << "[DTVDriftSegment]: \n"
82  << " Fit Mean = " << fitResult.fitMean << " +/- " << fitResult.fitMeanError << "\n"
83  << " Fit Sigma = " << fitResult.fitSigma << " +/- " << fitResult.fitSigmaError;
84 
85  float vDriftCorr = fitResult.fitMean;
86  float vDriftNew = vDrift * (1. - vDriftCorr);
87  float resolutionNew = resolution;
88  return DTVDriftData(vDriftNew, resolutionNew);
89  }
90  }
#define LogTrace(id)
DTResidualFitResult fitResiduals(TH1F &histo, int nSigmas=1)
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
TH1F * getHisto(const DTSuperLayerId &)
TH1F * DTVDriftSegment::getHisto ( const DTSuperLayerId slId)
private

Definition at line 92 of file DTVDriftSegment.cc.

References Exception, getHistoName(), timingPdfMaker::histo, HltBtagPostValidation_cff::histoName, and rootFile_.

Referenced by compute().

92  {
93  string histoName = getHistoName(slId);
94  TH1F* histo = static_cast<TH1F*>(rootFile_->Get(histoName.c_str()));
95  if (!histo)
96  throw cms::Exception("DTCalibration") << "v-drift correction histogram not found:" << histoName << endl;
97  return histo;
98  }
std::string getHistoName(const DTSuperLayerId &)
string DTVDriftSegment::getHistoName ( const DTSuperLayerId slId)
private

Definition at line 100 of file DTVDriftSegment.cc.

References DTSuperLayerId::chamberId(), DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, DTSuperLayerId::superLayer(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

Referenced by getHisto().

100  {
101  DTChamberId chId = slId.chamberId();
102 
103  // Compose the chamber name
104  std::string wheel = std::to_string(chId.wheel());
105  std::string station = std::to_string(chId.station());
106  std::string sector = std::to_string(chId.sector());
107 
108  string chHistoName = "_W" + wheel + "_St" + station + "_Sec" + sector;
109 
110  return (slId.superLayer() != 2) ? ("hRPhiVDriftCorr" + chHistoName) : ("hRZVDriftCorr" + chHistoName);
111  }
DTChamberId chamberId() const
Return the corresponding ChamberId.
int superLayer() const
Return the superlayer number.
int sector() const
Definition: DTChamberId.h:49
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
void DTVDriftSegment::setES ( const edm::EventSetup setup)
overridevirtual

Implements dtCalibration::DTVDriftBaseAlgo.

Definition at line 50 of file DTVDriftSegment.cc.

References edm::EventSetup::get(), and mTimeMap_.

50  {
51  // Get the map of vdrift from the setup
52  ESHandle<DTMtime> mTime;
53  setup.get<DTMtimeRcd>().get(mTime);
54  mTimeMap_ = &*mTime;
55  }
T get() const
Definition: EventSetup.h:73

Member Data Documentation

DTResidualFitter* dtCalibration::DTVDriftSegment::fitter_
private

Definition at line 39 of file DTVDriftSegment.h.

Referenced by compute(), DTVDriftSegment(), and ~DTVDriftSegment().

const DTMtime* dtCalibration::DTVDriftSegment::mTimeMap_
private

Definition at line 37 of file DTVDriftSegment.h.

Referenced by compute(), and setES().

unsigned int dtCalibration::DTVDriftSegment::nSigmas_
private

Definition at line 35 of file DTVDriftSegment.h.

Referenced by compute().

TFile* dtCalibration::DTVDriftSegment::rootFile_
private

Definition at line 38 of file DTVDriftSegment.h.

Referenced by DTVDriftSegment(), getHisto(), and ~DTVDriftSegment().