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_
 
bool readLegacyVDriftDB
 
TFile * rootFile_
 
const DTRecoConditionsvDriftMap_
 

Detailed Description

Definition at line 24 of file DTVDriftSegment.h.

Constructor & Destructor Documentation

◆ DTVDriftSegment()

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

Definition at line 36 of file DTVDriftSegment.cc.

37  : nSigmas_(pset.getUntrackedParameter<unsigned int>("nSigmasFitRange", 1)),
38  mTimeMap_(nullptr),
39  vDriftMap_(nullptr) {
40  string rootFileName = pset.getParameter<string>("rootFileName");
41  rootFile_ = new TFile(rootFileName.c_str(), "READ");
42 
43  bool debug = pset.getUntrackedParameter<bool>("debug", false);
45  //if(debug) fitter_->setVerbosity(1);
46 
47  readLegacyVDriftDB = pset.getParameter<bool>("readLegacyVDriftDB");
48  }

References debug, fitter_, muonDTDigis_cfi::pset, readLegacyVDriftDB, rootFile_, and CSCSkim_cfi::rootFileName.

◆ ~DTVDriftSegment()

DTVDriftSegment::~DTVDriftSegment ( )
override

Definition at line 50 of file DTVDriftSegment.cc.

50  {
51  rootFile_->Close();
52  delete fitter_;
53  }

References fitter_, and rootFile_.

Member Function Documentation

◆ compute()

DTVDriftData DTVDriftSegment::compute ( const DTSuperLayerId slId)
overridevirtual

Implements dtCalibration::DTVDriftBaseAlgo.

Definition at line 73 of file DTVDriftSegment.cc.

73  {
74  // Get original value from DB; vdrift is cm/ns , resolution is cm
75  // Note that resolution is irrelevant as it is no longer used anywhere in reconstruction.
76 
77  float vDrift = 0., resolution = 0.;
78  if (readLegacyVDriftDB) { // Legacy format
80  if (status != 0)
81  throw cms::Exception("DTCalibration") << "Could not find vDrift entry in DB for" << slId << endl;
82  } else { // New DB format
83  vDrift = vDriftMap_->get(DTWireId(slId.rawId()));
84  }
85 
86  // For RZ superlayers use original value
87  if (slId.superLayer() == 2) {
88  LogTrace("Calibration") << "[DTVDriftSegment]: RZ superlayer\n"
89  << " Will use original vDrift and resolution.";
90  return DTVDriftData(vDrift, resolution);
91  } else {
92  TH1F* vDriftCorrHisto = getHisto(slId);
93  // If empty histogram
94  if (vDriftCorrHisto->GetEntries() == 0) {
95  LogError("Calibration") << "[DTVDriftSegment]: Histogram " << vDriftCorrHisto->GetName() << " is empty.\n"
96  << " Will use original vDrift and resolution.";
97  return DTVDriftData(vDrift, resolution);
98  }
99 
100  LogTrace("Calibration") << "[DTVDriftSegment]: Fitting histogram " << vDriftCorrHisto->GetName();
101  DTResidualFitResult fitResult = fitter_->fitResiduals(*vDriftCorrHisto, nSigmas_);
102  LogTrace("Calibration") << "[DTVDriftSegment]: \n"
103  << " Fit Mean = " << fitResult.fitMean << " +/- " << fitResult.fitMeanError << "\n"
104  << " Fit Sigma = " << fitResult.fitSigma << " +/- " << fitResult.fitSigmaError;
105 
106  float vDriftCorr = fitResult.fitMean;
107  float vDriftNew = vDrift * (1. - vDriftCorr);
108  float resolutionNew = resolution;
109  return DTVDriftData(vDriftNew, resolutionNew);
110  }
111  }

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

◆ getHisto()

TH1F * DTVDriftSegment::getHisto ( const DTSuperLayerId slId)
private

Definition at line 113 of file DTVDriftSegment.cc.

113  {
114  string histoName = getHistoName(slId);
115  TH1F* histo = static_cast<TH1F*>(rootFile_->Get(histoName.c_str()));
116  if (!histo)
117  throw cms::Exception("DTCalibration") << "v-drift correction histogram not found:" << histoName << endl;
118  return histo;
119  }

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

Referenced by compute().

◆ getHistoName()

string DTVDriftSegment::getHistoName ( const DTSuperLayerId slId)
private

Definition at line 121 of file DTVDriftSegment.cc.

121  {
122  DTChamberId chId = slId.chamberId();
123 
124  // Compose the chamber name
125  std::string wheel = std::to_string(chId.wheel());
126  std::string station = std::to_string(chId.station());
127  std::string sector = std::to_string(chId.sector());
128 
129  string chHistoName = "_W" + wheel + "_St" + station + "_Sec" + sector;
130 
131  return (slId.superLayer() != 2) ? ("hRPhiVDriftCorr" + chHistoName) : ("hRZVDriftCorr" + chHistoName);
132  }

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

Referenced by getHisto().

◆ setES()

void DTVDriftSegment::setES ( const edm::EventSetup setup)
overridevirtual

Implements dtCalibration::DTVDriftBaseAlgo.

Definition at line 55 of file DTVDriftSegment.cc.

55  {
56  // Get the map of vdrift from the setup
57  if (readLegacyVDriftDB) {
58  ESHandle<DTMtime> mTime;
59  setup.get<DTMtimeRcd>().get(mTime);
60  mTimeMap_ = &*mTime;
61  } else {
63  setup.get<DTRecoConditionsVdriftRcd>().get(hVdrift);
64  vDriftMap_ = &*hVdrift;
65  // Consistency check: no parametrization is implemented for the time being
66  int version = vDriftMap_->version();
67  if (version != 1) {
68  throw cms::Exception("Configuration") << "only version 1 is presently supported for VDriftDB";
69  }
70  }
71  }

References Exception, get, mTimeMap_, readLegacyVDriftDB, singleTopDQM_cfi::setup, vDriftMap_, DTRecoConditions::version(), and BeamSplash_cfg::version.

Member Data Documentation

◆ fitter_

DTResidualFitter* dtCalibration::DTVDriftSegment::fitter_
private

Definition at line 42 of file DTVDriftSegment.h.

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

◆ mTimeMap_

const DTMtime* dtCalibration::DTVDriftSegment::mTimeMap_
private

Definition at line 38 of file DTVDriftSegment.h.

Referenced by compute(), and setES().

◆ nSigmas_

unsigned int dtCalibration::DTVDriftSegment::nSigmas_
private

Definition at line 36 of file DTVDriftSegment.h.

Referenced by compute().

◆ readLegacyVDriftDB

bool dtCalibration::DTVDriftSegment::readLegacyVDriftDB
private

Definition at line 40 of file DTVDriftSegment.h.

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

◆ rootFile_

TFile* dtCalibration::DTVDriftSegment::rootFile_
private

Definition at line 41 of file DTVDriftSegment.h.

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

◆ vDriftMap_

const DTRecoConditions* dtCalibration::DTVDriftSegment::vDriftMap_
private

Definition at line 39 of file DTVDriftSegment.h.

Referenced by compute(), and setES().

DTRecoConditionsVdriftRcd
Definition: DTRecoConditionsVdriftRcd.h:5
mps_update.status
status
Definition: mps_update.py:69
relativeConstraints.station
station
Definition: relativeConstraints.py:67
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DTResidualFitter::fitResiduals
DTResidualFitResult fitResiduals(TH1F &histo, int nSigmas=1)
Definition: DTResidualFitter.cc:19
DTSuperLayerId::superLayer
int superLayer() const
Return the superlayer number.
Definition: DTSuperLayerId.h:39
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
dtCalibration::DTVDriftSegment::vDriftMap_
const DTRecoConditions * vDriftMap_
Definition: DTVDriftSegment.h:39
DTRecoConditions::get
float get(const DTWireId &wireid, double *x=nullptr) const
Get the value correspoding to the given WireId, / using x[] as parameters of the parametrization when...
Definition: DTRecoConditions.cc:42
dtCalibration::DTVDriftSegment::readLegacyVDriftDB
bool readLegacyVDriftDB
Definition: DTVDriftSegment.h:40
debug
#define debug
Definition: HDRShower.cc:19
DTResidualFitResult::fitSigma
double fitSigma
Definition: DTResidualFitter.h:17
DTRecoConditions::version
int version() const
Version numer specifying the structure of the payload. See .cc file for details.
Definition: DTRecoConditions.h:43
DTWireId
Definition: DTWireId.h:12
dtCalibration::DTVDriftSegment::nSigmas_
unsigned int nSigmas_
Definition: DTVDriftSegment.h:36
edm::ESHandle< DTMtime >
L1TObjectsTimingClient_cff.resolution
resolution
Definition: L1TObjectsTimingClient_cff.py:52
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dtCalibration::DTVDriftSegment::mTimeMap_
const DTMtime * mTimeMap_
Definition: DTVDriftSegment.h:38
dtCalibration::DTVDriftSegment::getHistoName
std::string getHistoName(const DTSuperLayerId &)
Definition: DTVDriftSegment.cc:121
DTVelocityUnits::cm_per_ns
Definition: DTVelocityUnits.h:32
DTSuperLayerId::chamberId
DTChamberId chamberId() const
Return the corresponding ChamberId.
Definition: DTSuperLayerId.h:45
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
dtCalibration::DTVDriftSegment::fitter_
DTResidualFitter * fitter_
Definition: DTVDriftSegment.h:42
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DTResidualFitResult
Definition: DTResidualFitter.h:10
get
#define get
DTResidualFitResult::fitSigmaError
double fitSigmaError
Definition: DTResidualFitter.h:18
DTResidualFitter
Definition: DTResidualFitter.h:21
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Exception
Definition: hltDiff.cc:246
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
DTResidualFitResult::fitMeanError
double fitMeanError
Definition: DTResidualFitter.h:16
dtCalibration::DTVDriftSegment::rootFile_
TFile * rootFile_
Definition: DTVDriftSegment.h:41
CSCSkim_cfi.rootFileName
rootFileName
Definition: CSCSkim_cfi.py:9
DTResidualFitResult::fitMean
double fitMean
Definition: DTResidualFitter.h:15
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
dtCalibration::DTVDriftSegment::getHisto
TH1F * getHisto(const DTSuperLayerId &)
Definition: DTVDriftSegment.cc:113
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
DTMtime::get
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
DTMtimeRcd
Definition: DTMtimeRcd.h:5