CMS 3D CMS Logo

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

#include <DTTTrigResidualCorrection.h>

Inheritance diagram for dtCalibration::DTTTrigResidualCorrection:
dtCalibration::DTTTrigBaseCorrection

Public Member Functions

DTTTrigData correction (const DTSuperLayerId &) override
 
 DTTTrigResidualCorrection (const edm::ParameterSet &)
 
void setES (const edm::EventSetup &setup) override
 
 ~DTTTrigResidualCorrection () override
 
- Public Member Functions inherited from dtCalibration::DTTTrigBaseCorrection
 DTTTrigBaseCorrection ()
 
virtual ~DTTTrigBaseCorrection ()
 

Private Member Functions

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

Private Attributes

std::string dbLabel_
 
DTResidualFitterfitter_
 
const DTMtimemTimeMap_
 
std::string rootBaseDir_
 
TFile * rootFile_
 
const DTTtrigtTrigMap_
 
bool useFit_
 
bool useSlopesCalib_
 
double vDriftEff_ [5][14][4][3]
 

Detailed Description

Definition at line 28 of file DTTTrigResidualCorrection.h.

Constructor & Destructor Documentation

DTTTrigResidualCorrection::DTTTrigResidualCorrection ( const edm::ParameterSet pset)

Definition at line 43 of file DTTTrigResidualCorrection.cc.

References debug, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

43  {
44  string residualsRootFile = pset.getParameter<string>("residualsRootFile");
45  rootFile_ = new TFile(residualsRootFile.c_str(),"READ");
46  rootBaseDir_ = pset.getUntrackedParameter<string>("rootBaseDir","/DQMData/DT/DTCalibValidation");
47  useFit_ = pset.getParameter<bool>("useFitToResiduals");
48  //useConstantvDrift_ = pset.getParameter<bool>("useConstantDriftVelocity");
49  dbLabel_ = pset.getUntrackedParameter<string>("dbLabel", "");
50  useSlopesCalib_ = pset.getUntrackedParameter<bool>("useSlopesCalib",false);
51 
52  // Load external slopes
53  if(useSlopesCalib_){
54  ifstream fileSlopes;
55  fileSlopes.open( pset.getParameter<FileInPath>("slopesFileName").fullPath().c_str() );
56 
57  int tmp_wheel = 0, tmp_sector = 0, tmp_station = 0, tmp_SL = 0;
58  double tmp_ttrig = 0., tmp_t0 = 0., tmp_kfact = 0.;
59  int tmp_a = 0, tmp_b = 0, tmp_c = 0, tmp_d = 0;
60  double tmp_v_eff = 0.;
61  while(!fileSlopes.eof()){
62  fileSlopes >> tmp_wheel >> tmp_sector >> tmp_station >> tmp_SL >> tmp_a >> tmp_b >>
63  tmp_ttrig >> tmp_t0 >> tmp_kfact >> tmp_c >> tmp_d >> tmp_v_eff;
64  vDriftEff_[tmp_wheel+2][tmp_sector-1][tmp_station-1][tmp_SL-1] = -tmp_v_eff;
65  }
66  fileSlopes.close();
67  }
68 
69  bool debug = pset.getUntrackedParameter<bool>("debug",false);
70  fitter_ = new DTResidualFitter(debug);
71 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define debug
Definition: HDRShower.cc:19
std::string fullPath() const
Definition: FileInPath.cc:163
DTTTrigResidualCorrection::~DTTTrigResidualCorrection ( )
override

Definition at line 73 of file DTTTrigResidualCorrection.cc.

Member Function Documentation

DTTTrigData DTTTrigResidualCorrection::correction ( const DTSuperLayerId slId)
overridevirtual

Implements dtCalibration::DTTTrigBaseCorrection.

Definition at line 91 of file DTTTrigResidualCorrection.cc.

References DTVelocityUnits::cm_per_ns, Exception, DTResidualFitResult::fitMean, DTResidualFitResult::fitSigma, DTLinearDriftAlgo_cfi::hitResolution, DTAnalyzerDetailed_cfi::kFactor, LogTrace, DTTimeUnits::ns, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, mps_update::status, DTSuperLayerId::superLayer(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

91  {
92 
93  float tTrigMean,tTrigSigma,kFactor;
94  int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
95  if(status != 0) throw cms::Exception("[DTTTrigResidualCorrection]") << "Could not find tTrig entry in DB for"
96  << slId << endl;
97 
98  float vDrift,hitResolution;
99  status = mTimeMap_->get(slId,vDrift,hitResolution,DTVelocityUnits::cm_per_ns);
100  if(status != 0) throw cms::Exception("[DTTTrigResidualCorrection]") << "Could not find vDrift entry in DB for"
101  << slId << endl;
102  TH1F residualHisto = *(getHisto(slId));
103  LogTrace("Calibration") << "[DTTTrigResidualCorrection]: \n"
104  << " Mean, RMS = " << residualHisto.GetMean() << ", " << residualHisto.GetRMS();
105 
106  double fitMean = -1.;
107  double fitSigma = -1.;
108  if(useFit_){
109  LogTrace("Calibration") << "[DTTTrigResidualCorrection]: Fitting histogram " << residualHisto.GetName();
110  int nSigmas = 2;
111 
112  DTResidualFitResult fitResult = fitter_->fitResiduals(residualHisto,nSigmas);
113  fitMean = fitResult.fitMean;
114  fitSigma = fitResult.fitSigma;
115 
116  LogTrace("Calibration") << "[DTTTrigResidualCorrection]: \n"
117  << " Fit Mean = " << fitMean << "\n"
118  << " Fit Sigma = " << fitSigma;
119  }
120  double resMean = (useFit_) ? fitMean : residualHisto.GetMean();
121 
122  int wheel = slId.wheel();
123  int sector = slId.sector();
124  int station = slId.station();
125  int superLayer = slId.superLayer();
126  double resTime = 0.;
127  if(useSlopesCalib_){
128  double vdrift_eff = vDriftEff_[wheel+2][sector-1][station-1][superLayer-1];
129  if(vdrift_eff == 0) vdrift_eff = vDrift;
130 
131  if(vdrift_eff) resTime = resMean/vdrift_eff;
132 
133  LogTrace("Calibration") << "[DTTTrigResidualCorrection]: Effective vDrift, correction to tTrig = "
134  << vdrift_eff << ", " << resTime;
135  } else{
136  if(vDrift) resTime = resMean/vDrift;
137 
138  LogTrace("Calibration") << "[DTTTrigResidualCorrection]: vDrift from DB, correction to tTrig = "
139  << vDrift << ", " << resTime;
140  }
141 
142  double corrMean = tTrigMean;
143  double corrSigma = (tTrigSigma != 0.) ? tTrigSigma : 1.;
144  double corrKFact = (tTrigSigma != 0.) ? (kFactor + resTime/tTrigSigma) : resTime;
145 
146  return DTTTrigData(corrMean,corrSigma,corrKFact);
147 }
const TH1F * getHisto(const DTSuperLayerId &)
int superLayer() const
Return the superlayer number.
#define LogTrace(id)
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:85
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:82
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
const TH1F * DTTTrigResidualCorrection::getHisto ( const DTSuperLayerId slId)
private

Definition at line 149 of file DTTTrigResidualCorrection.cc.

References Exception, mergeVDriftHistosByStation::getHistoName(), trackerHits::histo, and LogTrace.

149  {
150  string histoName = getHistoName(slId);
151  LogTrace("Calibration") << "[DTTTrigResidualCorrection]: Accessing histogram " << histoName.c_str();
152  TH1F* histo = static_cast<TH1F*>(rootFile_->Get(histoName.c_str()));
153  if(!histo) throw cms::Exception("[DTTTrigResidualCorrection]") << "residual histogram not found:"
154  << histoName << endl;
155  return histo;
156 }
#define LogTrace(id)
std::string getHistoName(const DTSuperLayerId &slID)
string DTTTrigResidualCorrection::getHistoName ( const DTSuperLayerId slID)
private

Definition at line 158 of file DTTTrigResidualCorrection.cc.

References DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, cmsPerfCommons::Step, AlCaHLTBitMon_QueryRunRegistry::string, DTSuperLayerId::superlayer(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

158  {
159 
160  int step = 3;
161 
162  std::string wheel = std::to_string(slId.wheel());
163  std::string station = std::to_string(slId.station());
164  std::string sector = std::to_string(slId.sector());
165  std::string superLayer = std::to_string(slId.superlayer());
166  std::string Step = std::to_string(step);
167 
168  string histoName =
169  rootBaseDir_ + "/Wheel" + wheel + "/Station" + station + "/Sector" + sector +
170  "/hResDist_STEP" + Step + "_W" + wheel + "_St" + station + "_Sec" + sector + "_SL" + superLayer;
171 
172  return histoName;
173 }
step
Definition: StallMonitor.cc:94
void DTTTrigResidualCorrection::setES ( const edm::EventSetup setup)
overridevirtual

Implements dtCalibration::DTTTrigBaseCorrection.

Definition at line 78 of file DTTTrigResidualCorrection.cc.

References edm::EventSetup::get().

78  {
79  // Get tTrig record from DB
80  ESHandle<DTTtrig> tTrig;
81  //setup.get<DTTtrigRcd>().get(tTrig);
82  setup.get<DTTtrigRcd>().get(dbLabel_,tTrig);
83  tTrigMap_ = &*tTrig;
84 
85  // Get vDrift record
86  ESHandle<DTMtime> mTimeHandle;
87  setup.get<DTMtimeRcd>().get(mTimeHandle);
88  mTimeMap_ = &*mTimeHandle;
89 }
T get() const
Definition: EventSetup.h:71

Member Data Documentation

std::string dtCalibration::DTTTrigResidualCorrection::dbLabel_
private

Definition at line 47 of file DTTTrigResidualCorrection.h.

DTResidualFitter* dtCalibration::DTTTrigResidualCorrection::fitter_
private

Definition at line 54 of file DTTTrigResidualCorrection.h.

const DTMtime* dtCalibration::DTTTrigResidualCorrection::mTimeMap_
private

Definition at line 53 of file DTTTrigResidualCorrection.h.

std::string dtCalibration::DTTTrigResidualCorrection::rootBaseDir_
private

Definition at line 45 of file DTTTrigResidualCorrection.h.

TFile* dtCalibration::DTTTrigResidualCorrection::rootFile_
private

Definition at line 43 of file DTTTrigResidualCorrection.h.

const DTTtrig* dtCalibration::DTTTrigResidualCorrection::tTrigMap_
private

Definition at line 52 of file DTTTrigResidualCorrection.h.

bool dtCalibration::DTTTrigResidualCorrection::useFit_
private

Definition at line 46 of file DTTTrigResidualCorrection.h.

bool dtCalibration::DTTTrigResidualCorrection::useSlopesCalib_
private

Definition at line 48 of file DTTTrigResidualCorrection.h.

double dtCalibration::DTTTrigResidualCorrection::vDriftEff_[5][14][4][3]
private

Definition at line 50 of file DTTTrigResidualCorrection.h.