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 &, edm::ConsumesCollector)
 
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_
 
edm::ESGetToken< DTMtime, DTMtimeRcdmTimeMapToken_
 
unsigned int nSigmas_
 
bool readLegacyVDriftDB
 
TFile * rootFile_
 
const DTRecoConditionsvDriftMap_
 
edm::ESGetToken< DTRecoConditions, DTRecoConditionsVdriftRcdvDriftMapToken_
 

Detailed Description

Definition at line 30 of file DTVDriftSegment.h.

Constructor & Destructor Documentation

◆ DTVDriftSegment()

DTVDriftSegment::DTVDriftSegment ( edm::ParameterSet const &  pset,
edm::ConsumesCollector  cc 
)

Definition at line 36 of file DTVDriftSegment.cc.

References edm::BeginRun, gpuPixelDoublets::cc, debug, fitter_, mTimeMapToken_, muonDTDigis_cfi::pset, readLegacyVDriftDB, rootFile_, CSCSkim_cfi::rootFileName, and vDriftMapToken_.

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  if (readLegacyVDriftDB) {
50  } else {
52  }
53  }
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< DTMtime, DTMtimeRcd > mTimeMapToken_
edm::ESGetToken< DTRecoConditions, DTRecoConditionsVdriftRcd > vDriftMapToken_
const DTRecoConditions * vDriftMap_
#define debug
Definition: HDRShower.cc:19

◆ ~DTVDriftSegment()

DTVDriftSegment::~DTVDriftSegment ( )
override

Definition at line 55 of file DTVDriftSegment.cc.

References fitter_, and rootFile_.

55  {
56  rootFile_->Close();
57  delete fitter_;
58  }

Member Function Documentation

◆ compute()

DTVDriftData DTVDriftSegment::compute ( const DTSuperLayerId slId)
overridevirtual

Implements dtCalibration::DTVDriftBaseAlgo.

Definition at line 74 of file DTVDriftSegment.cc.

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_.

74  {
75  // Get original value from DB; vdrift is cm/ns , resolution is cm
76  // Note that resolution is irrelevant as it is no longer used anywhere in reconstruction.
77 
78  float vDrift = 0., resolution = 0.;
79  if (readLegacyVDriftDB) { // Legacy format
81  if (status != 0)
82  throw cms::Exception("DTCalibration") << "Could not find vDrift entry in DB for" << slId << endl;
83  } else { // New DB format
84  vDrift = vDriftMap_->get(DTWireId(slId.rawId()));
85  }
86 
87  // For RZ superlayers use original value
88  if (slId.superLayer() == 2) {
89  LogTrace("Calibration") << "[DTVDriftSegment]: RZ superlayer\n"
90  << " Will use original vDrift and resolution.";
91  return DTVDriftData(vDrift, resolution);
92  } else {
93  TH1F* vDriftCorrHisto = getHisto(slId);
94  // If empty histogram
95  if (vDriftCorrHisto->GetEntries() == 0) {
96  LogError("Calibration") << "[DTVDriftSegment]: Histogram " << vDriftCorrHisto->GetName() << " is empty.\n"
97  << " Will use original vDrift and resolution.";
98  return DTVDriftData(vDrift, resolution);
99  }
100 
101  LogTrace("Calibration") << "[DTVDriftSegment]: Fitting histogram " << vDriftCorrHisto->GetName();
102  DTResidualFitResult fitResult = fitter_->fitResiduals(*vDriftCorrHisto, nSigmas_);
103  LogTrace("Calibration") << "[DTVDriftSegment]: \n"
104  << " Fit Mean = " << fitResult.fitMean << " +/- " << fitResult.fitMeanError << "\n"
105  << " Fit Sigma = " << fitResult.fitSigma << " +/- " << fitResult.fitSigmaError;
106 
107  float vDriftCorr = fitResult.fitMean;
108  float vDriftNew = vDrift * (1. - vDriftCorr);
109  float resolutionNew = resolution;
110  return DTVDriftData(vDriftNew, resolutionNew);
111  }
112  }
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...
int superLayer() const
Return the superlayer number.
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
Log< level::Error, false > LogError
#define LogTrace(id)
const DTRecoConditions * vDriftMap_
DTResidualFitResult fitResiduals(TH1F &histo, int nSigmas=1)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TH1F * getHisto(const DTSuperLayerId &)

◆ getHisto()

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

Definition at line 114 of file DTVDriftSegment.cc.

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

Referenced by compute().

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

◆ getHistoName()

string DTVDriftSegment::getHistoName ( const DTSuperLayerId slId)
private

Definition at line 122 of file DTVDriftSegment.cc.

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

Referenced by getHisto().

122  {
123  DTChamberId chId = slId.chamberId();
124 
125  // Compose the chamber name
129 
130  string chHistoName = "_W" + wheel + "_St" + station + "_Sec" + sector;
131 
132  return (slId.superLayer() != 2) ? ("hRPhiVDriftCorr" + chHistoName) : ("hRZVDriftCorr" + chHistoName);
133  }
int station() const
Return the station number.
Definition: DTChamberId.h:42
int superLayer() const
Return the superlayer number.
static std::string to_string(const XMLCh *ch)
DTChamberId chamberId() const
Return the corresponding ChamberId.
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49

◆ setES()

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

Implements dtCalibration::DTVDriftBaseAlgo.

Definition at line 60 of file DTVDriftSegment.cc.

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

60  {
61  // Get the map of vdrift from the setup
62  if (readLegacyVDriftDB) {
63  mTimeMap_ = &setup.getData(mTimeMapToken_);
64  } else {
65  vDriftMap_ = &setup.getData(vDriftMapToken_);
66  // Consistency check: no parametrization is implemented for the time being
67  int version = vDriftMap_->version();
68  if (version != 1) {
69  throw cms::Exception("Configuration") << "only version 1 is presently supported for VDriftDB";
70  }
71  }
72  }
int version() const
Version numer specifying the structure of the payload. See .cc file for details.
edm::ESGetToken< DTMtime, DTMtimeRcd > mTimeMapToken_
edm::ESGetToken< DTRecoConditions, DTRecoConditionsVdriftRcd > vDriftMapToken_
const DTRecoConditions * vDriftMap_

Member Data Documentation

◆ fitter_

DTResidualFitter* dtCalibration::DTVDriftSegment::fitter_
private

Definition at line 48 of file DTVDriftSegment.h.

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

◆ mTimeMap_

const DTMtime* dtCalibration::DTVDriftSegment::mTimeMap_
private

Definition at line 44 of file DTVDriftSegment.h.

Referenced by compute(), and setES().

◆ mTimeMapToken_

edm::ESGetToken<DTMtime, DTMtimeRcd> dtCalibration::DTVDriftSegment::mTimeMapToken_
private

Definition at line 50 of file DTVDriftSegment.h.

Referenced by DTVDriftSegment(), and setES().

◆ nSigmas_

unsigned int dtCalibration::DTVDriftSegment::nSigmas_
private

Definition at line 42 of file DTVDriftSegment.h.

Referenced by compute().

◆ readLegacyVDriftDB

bool dtCalibration::DTVDriftSegment::readLegacyVDriftDB
private

Definition at line 46 of file DTVDriftSegment.h.

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

◆ rootFile_

TFile* dtCalibration::DTVDriftSegment::rootFile_
private

Definition at line 47 of file DTVDriftSegment.h.

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

◆ vDriftMap_

const DTRecoConditions* dtCalibration::DTVDriftSegment::vDriftMap_
private

Definition at line 45 of file DTVDriftSegment.h.

Referenced by compute(), and setES().

◆ vDriftMapToken_

edm::ESGetToken<DTRecoConditions, DTRecoConditionsVdriftRcd> dtCalibration::DTVDriftSegment::vDriftMapToken_
private

Definition at line 51 of file DTVDriftSegment.h.

Referenced by DTVDriftSegment(), and setES().