CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
SiPixelSCurveCalibrationAnalysis Class Reference

#include <SiPixelSCurveCalibrationAnalysis.h>

Inheritance diagram for SiPixelSCurveCalibrationAnalysis:
SiPixelOfflineCalibAnalysisBase edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void buildACurveHistogram (const uint32_t &detid, const uint32_t &row, const uint32_t &col, sCurveErrorFlag errorFlag, const std::vector< float > &efficiencies, const std::vector< float > &errors)
 
bool doFits (uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix) override
 
void doSetup (const edm::ParameterSet &)
 
sCurveErrorFlag estimateSCurveParameters (const std::vector< float > &eff, float &threshold, float &sigma)
 
sCurveErrorFlag fittedSCurveSanityCheck (float threshold, float sigma, float amplitude)
 
 SiPixelSCurveCalibrationAnalysis (const edm::ParameterSet &iConfig)
 
 ~SiPixelSCurveCalibrationAnalysis () override
 
- Public Member Functions inherited from SiPixelOfflineCalibAnalysisBase
void addTF1ToDQMMonitoringElement (MonitorElement *ele, TF1 *func)
 
MonitorElementbookDQMHistogram1D (uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
 
MonitorElementbookDQMHistogram1D (uint32_t detid, std::string name, std::string title, int nchX, float *xbinsize)
 
MonitorElementbookDQMHistogram2D (uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
 
MonitorElementbookDQMHistoPlaquetteSummary2D (uint32_t detid, std::string name, std::string title)
 
std::vector< uint32_t > & getRunNumbers ()
 
bool setDQMDirectory (std::string dirName)
 
bool setDQMDirectory (uint32_t detID)
 
 SiPixelOfflineCalibAnalysisBase (const edm::ParameterSet &)
 
 SiPixelOfflineCalibAnalysisBase ()
 
std::string translateDetIdToString (uint32_t detid)
 
 ~SiPixelOfflineCalibAnalysisBase () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Public Attributes

std::vector< float > vCalPointsAsFloats_
 

Static Public Attributes

static std::vector< float > effErrors_
 
static std::vector< float > efficiencies_
 
- Static Public Attributes inherited from SiPixelOfflineCalibAnalysisBase
static TF1 * fitFunction_ = nullptr
 

Private Member Functions

void calibrationEnd () override
 
void calibrationSetup (const edm::EventSetup &iSetup) override
 
bool checkCorrectCalibrationType () override
 
void makeThresholdSummary (void)
 
void newDetID (uint32_t detid) override
 

Private Attributes

unsigned int curvesSavedCounter_
 
std::map< uint32_t, bool > detIDsToSave_
 
detIDHistogramMap histograms_
 
unsigned int maxCurvesToSave_
 
double maximumEffAsymptote_
 
double maximumSigma_
 
double maximumSigmaBin_
 
double maximumThreshold_
 
double maximumThresholdBin_
 
double minimumChi2prob_
 
double minimumEffAsymptote_
 
double minimumSigma_
 
double minimumThreshold_
 
std::vector< std::string > plaquettesToSave_
 
bool printoutthresholds_
 
bool saveCurvesThatFlaggedBad_
 
std::string thresholdfilename_
 
bool useDetectorHierarchyFolders_
 
bool write2dFitResult_
 
bool write2dHistograms_
 
bool writeZeroes_
 

Additional Inherited Members

- Public Types inherited from SiPixelOfflineCalibAnalysisBase
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from SiPixelOfflineCalibAnalysisBase
static const std::vector< short > * getVcalValues ()
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from SiPixelOfflineCalibAnalysisBase
uint32_t & EventNumber ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 
- Protected Attributes inherited from SiPixelOfflineCalibAnalysisBase
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcdcablingMapToken_
 
edm::ESHandle< SiPixelCalibConfigurationcalib_
 
std::string calibrationMode_
 
edm::ESGetToken< SiPixelCalibConfiguration, SiPixelCalibConfigurationRcdcalibToken_
 
edm::ESGetToken< SiPixelCalibConfiguration, SiPixelCalibConfigurationRcdcalibTokenBeginRun_
 
edm::ESHandle< TrackerGeometrygeom_
 
short nTriggers_
 
edm::ESHandle< SiPixelFedCablingMaptheCablingMap_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeomToken_
 
- Static Protected Attributes inherited from SiPixelOfflineCalibAnalysisBase
static std::vector< short > vCalValues_
 

Detailed Description

CalibTracker/SiPixelSCurveCalibration/src/SiPixelSCurveCalibrationAnalysis.cc

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 62 of file SiPixelSCurveCalibrationAnalysis.h.

Constructor & Destructor Documentation

◆ SiPixelSCurveCalibrationAnalysis()

SiPixelSCurveCalibrationAnalysis::SiPixelSCurveCalibrationAnalysis ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 64 of file SiPixelSCurveCalibrationAnalysis.h.

References doSetup().

◆ ~SiPixelSCurveCalibrationAnalysis()

SiPixelSCurveCalibrationAnalysis::~SiPixelSCurveCalibrationAnalysis ( )
override

Definition at line 138 of file SiPixelSCurveCalibrationAnalysis.cc.

138  {
139  // do nothing
140 }

Member Function Documentation

◆ buildACurveHistogram()

void SiPixelSCurveCalibrationAnalysis::buildACurveHistogram ( const uint32_t &  detid,
const uint32_t &  row,
const uint32_t &  col,
sCurveErrorFlag  errorFlag,
const std::vector< float > &  efficiencies,
const std::vector< float > &  errors 
)

Definition at line 142 of file SiPixelSCurveCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D(), cuy::col, curvesSavedCounter_, electronProducer_cfi::efficiencies, createfilelist::int, maxCurvesToSave_, dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), SiPixelOfflineCalibAnalysisBase::setDQMDirectory(), SiPixelOfflineCalibAnalysisBase::translateDetIdToString(), and vCalPointsAsFloats_.

Referenced by doFits().

147  {
149  edm::LogWarning("SiPixelSCurveCalibrationAnalysis")
150  << "WARNING: Request to save curve for [detid](col/row): [" << detid << "](" << col << "/" << row
151  << ") denied. Maximum number of saved curves (defined in .cfi) "
152  "exceeded.";
153  return;
154  }
155  std::ostringstream rootName;
156  rootName << "SCurve_row_" << row << "_col_" << col;
157  std::ostringstream humanName;
158  humanName << translateDetIdToString(detid) << "_" << rootName.str() << "_ErrorFlag_" << (int)errorFlag;
159 
160  unsigned int numberOfVCalPoints = vCalPointsAsFloats_.size() - 1; // minus one is necessary since the lower
161  // edge of the last bin must be added
162  if (efficiencies.size() != numberOfVCalPoints || errors.size() != numberOfVCalPoints) {
163  edm::LogError("SiPixelSCurveCalibrationAnalysis")
164  << "Error saving single curve histogram! Number of Vcal values (" << numberOfVCalPoints
165  << ") does not match number of efficiency points or error points!";
166  return;
167  }
168  setDQMDirectory(detid);
169  float *vcalValuesToPassToCrappyRoot = &vCalPointsAsFloats_[0];
170  MonitorElement *aBadHisto =
171  bookDQMHistogram1D(detid,
172  rootName.str(),
173  humanName.str(),
174  numberOfVCalPoints,
175  vcalValuesToPassToCrappyRoot); // ROOT only takes an input as array. :(
176  // HOORAY FOR CINT!
178  for (unsigned int iBin = 0; iBin < numberOfVCalPoints; ++iBin) {
179  int rootBin = iBin + 1; // root bins start at 1
180  aBadHisto->setBinContent(rootBin, efficiencies[iBin]);
181  aBadHisto->setBinError(rootBin, errors[iBin]);
182  }
183 }
std::string translateDetIdToString(uint32_t detid)
Log< level::Error, false > LogError
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
col
Definition: cuy.py:1009
Definition: errors.py:1
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
Log< level::Warning, false > LogWarning

◆ calibrationEnd()

void SiPixelSCurveCalibrationAnalysis::calibrationEnd ( )
overrideprivatevirtual

◆ calibrationSetup()

void SiPixelSCurveCalibrationAnalysis::calibrationSetup ( const edm::EventSetup iSetup)
overrideprivatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 185 of file SiPixelSCurveCalibrationAnalysis.cc.

References curvesSavedCounter_, SiPixelOfflineCalibAnalysisBase::fitFunction_, SiPixelOfflineCalibAnalysisBase::getVcalValues(), mps_fire::i, maxCurvesToSave_, SiPixelOfflineCalibAnalysisBase::nTriggers_, saveCurvesThatFlaggedBad_, vCalPointsAsFloats_, and SiPixelOfflineCalibAnalysisBase::vCalValues_.

185  {
186  edm::LogInfo("SiPixelSCurveCalibrationAnalysis")
187  << "Calibration Settings: VCalLow: " << vCalValues_[0] << " VCalHigh: " << vCalValues_[vCalValues_.size() - 1]
188  << " nVCal: " << vCalValues_.size() << " nTriggers: " << nTriggers_;
191  // build the vCal values as a vector of floats if we want to save single
192  // curves
193  const std::vector<short> *theVCalValues = this->getVcalValues();
194  unsigned int numberOfVCalPoints = theVCalValues->size();
195  edm::LogWarning("SiPixelSCurveCalibrationAnalysis")
196  << "WARNING: Option set to save indiviual S-Curves - max number: " << maxCurvesToSave_
197  << " This can lead to large memory consumption! (Got " << numberOfVCalPoints << " VCal Points";
198  for (unsigned int i = 0; i < numberOfVCalPoints; i++) {
199  vCalPointsAsFloats_.push_back(static_cast<float>((*theVCalValues)[i]));
200  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Adding calibration Vcal: " << (*theVCalValues)[i];
201  }
202  // must add lower edge of last bin to the vector
203  vCalPointsAsFloats_.push_back(vCalPointsAsFloats_[numberOfVCalPoints - 1] + 1);
204  }
205 
206  fitFunction_ = new TF1("sCurve",
207  "0.5*[2]*(1+TMath::Erf( (x-[0]) / ([1]*sqrt(2)) ) )",
208  vCalValues_[0],
209  vCalValues_[vCalValues_.size() - 1]);
210 }
Log< level::Info, false > LogInfo
static const std::vector< short > * getVcalValues()
Log< level::Warning, false > LogWarning

◆ checkCorrectCalibrationType()

bool SiPixelSCurveCalibrationAnalysis::checkCorrectCalibrationType ( )
overrideprivatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 212 of file SiPixelSCurveCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::calibrationMode_.

212  {
213  if (calibrationMode_ == "SCurve")
214  return true;
215  else if (calibrationMode_ == "unknown") {
216  edm::LogInfo("SiPixelSCurveCalibrationAnalysis")
217  << "calibration mode is: " << calibrationMode_ << ", continuing anyway...";
218  return true;
219  } else {
220  // edm::LogDebug("SiPixelSCurveCalibrationAnalysis") << "unknown
221  // calibration mode for SCurves, should be \"SCurve\" and is \"" <<
222  // calibrationMode_ << "\"";
223  }
224  return false;
225 }
Log< level::Info, false > LogInfo

◆ doFits()

bool SiPixelSCurveCalibrationAnalysis::doFits ( uint32_t  detid,
std::vector< SiPixelCalibDigi >::const_iterator  ipix 
)
overridevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 324 of file SiPixelSCurveCalibrationAnalysis.cc.

References CustomPhysics_cfi::amplitude, buildACurveHistogram(), calculateEffAndError(), hltPixelTracks_cff::chi2, chi2toMinimize(), cuy::col, detIDsToSave_, effErrors_, efficiencies_, errBadChi2Prob, errOK, relativeConstraints::error, estimateSCurveParameters(), fittedSCurveSanityCheck(), histograms_, kChi2s, kChi2Summary, kFitResults, kFitResultSummary, kSigmas, kSigmaSummary, kThresholds, kThresholdSummary, minimumChi2prob_, SiPixelOfflineCalibAnalysisBase::nTriggers_, submitPVValidationJobs::params, saveCurvesThatFlaggedBad_, remoteMonitoring_LASER_era2018_cfg::threshold, SiPixelOfflineCalibAnalysisBase::vCalValues_, write2dFitResult_, and write2dHistograms_.

324  {
325  sCurveErrorFlag errorFlag = errOK;
326  uint32_t nVCalPts = calibDigi->getnpoints();
327  // reset and fill static datamembers with vector of points and errors
328  efficiencies_.resize(0);
329  effErrors_.resize(0);
330  for (uint32_t iVcalPt = 0; iVcalPt < nVCalPts; iVcalPt++) {
331  float eff;
332  float error;
333  calculateEffAndError(calibDigi->getnentries(iVcalPt), nTriggers_, eff, error);
334  edm::LogInfo("SiPixelSCurveCalibrationAnalysis")
335  << "Eff: " << eff << " Error: " << error << " nEntries: " << calibDigi->getnentries(iVcalPt)
336  << " nTriggers: " << nTriggers_ << " VCalPt " << vCalValues_[iVcalPt];
337  efficiencies_.push_back(eff);
338  effErrors_.push_back(error);
339  }
340 
341  // estimate the S-Curve parameters
342  float thresholdGuess = -1.0;
343  float sigmaGuess = -1.0;
344  errorFlag = estimateSCurveParameters(efficiencies_, thresholdGuess, sigmaGuess);
345 
346  // these -1.0 default values will only be filled if the curve is all zeroes,
347  // or doesn't turn on, WHICH INDICATES A SERIOUS PROBLEM
348  Double_t sigma = -1.0;
349  Double_t sigmaError = -1.0;
350  Double_t threshold = -1.0;
351  Double_t thresholdError = -1.0;
352  Double_t amplitude = -1.0;
353  Double_t amplitudeError = -1.0;
354  Double_t chi2 = -1.0;
355  // calculate NDF
356  Int_t nDOF = vCalValues_.size() - 3;
357  Double_t chi2probability = 0;
358 
359  if (errorFlag == errOK) // only do fit if curve is fittable
360  {
361  // set up minuit fit
362  TMinuit *gMinuit = new TMinuit(3);
363  gMinuit->SetPrintLevel(-1); // save ourselves from gigabytes of stdout
364  gMinuit->SetFCN(chi2toMinimize);
365 
366  // define threshold parameters - choose step size 1, max 300, min -50
367  gMinuit->DefineParameter(0, "Threshold", (Double_t)thresholdGuess, 1, -50, 300);
368  // sigma
369  gMinuit->DefineParameter(1, "Sigma", (Double_t)sigmaGuess, 0.1, 0, 255);
370  // amplitude
371  gMinuit->DefineParameter(2, "Amplitude", 1, 0.1, -0.001, 200);
372 
373  // Do Chi2 minimazation
374  gMinuit->Migrad();
375  gMinuit->GetParameter(0, threshold, thresholdError);
376  gMinuit->GetParameter(1, sigma, sigmaError);
377  gMinuit->GetParameter(2, amplitude, amplitudeError);
378 
379  // get Chi2
380  Double_t params[3] = {threshold, sigma, amplitude};
381  gMinuit->Eval(3, nullptr, chi2, params, 0);
382  // calculate Chi2 proability
383  if (nDOF <= 0)
384  chi2probability = 0;
385  else
386  chi2probability = TMath::Prob(chi2, nDOF);
387 
388  // check to make sure output makes sense (i.e. threshold > 0)
389  if (chi2probability > minimumChi2prob_)
390  errorFlag = fittedSCurveSanityCheck(threshold, sigma, amplitude);
391  else
392  errorFlag = errBadChi2Prob;
393 
394  edm::LogInfo("SiPixelSCurveCalibrationAnalysis")
395  << "Fit finished with errorFlag: " << errorFlag << " - threshold: " << threshold << " sigma: " << sigma
396  << " chi2: " << chi2 << " nDOF: " << nDOF << " chi2Prob: " << chi2probability
397  << " chi2MinUser: " << minimumChi2prob_;
398 
399  delete gMinuit;
400  }
401  // get row and column for this pixel
402  uint32_t row = calibDigi->row();
403  uint32_t col = calibDigi->col();
404 
405  // get iterator to histogram holder for this detid
406  detIDHistogramMap::iterator thisDetIdHistoGrams;
407  thisDetIdHistoGrams = histograms_.find(detid);
408  if (thisDetIdHistoGrams != histograms_.end()) {
409  edm::LogInfo("SiPixelSCurveCalibrationAnalysisHistogramReport")
410  << "Filling histograms for [detid](col/row): [" << detid << "](" << col << "/" << row
411  << ") ErrorFlag: " << errorFlag;
412  // always fill fit result
413  (*thisDetIdHistoGrams).second[kFitResultSummary]->Fill(errorFlag);
414  if (write2dFitResult_)
415  (*thisDetIdHistoGrams)
416  .second[kFitResults]
417  ->setBinContent(col + 1,
418  row + 1,
419  errorFlag); // +1 because root bins start at 1
420 
421  // fill sigma/threshold result
422  (*thisDetIdHistoGrams).second[kSigmaSummary]->Fill(sigma);
423  (*thisDetIdHistoGrams).second[kThresholdSummary]->Fill(threshold);
424  if (write2dHistograms_) {
425  (*thisDetIdHistoGrams)
426  .second[kSigmas]
427  ->setBinContent(col + 1,
428  row + 1,
429  sigma); // +1 because root bins start at 1
430  (*thisDetIdHistoGrams)
431  .second[kThresholds]
432  ->setBinContent(col + 1,
433  row + 1,
434  threshold); // +1 because root bins start at 1
435  }
436  // fill chi2
437  (*thisDetIdHistoGrams).second[kChi2Summary]->Fill(chi2probability);
438  if (write2dHistograms_)
439  (*thisDetIdHistoGrams).second[kChi2s]->Fill(col, row, chi2probability);
440  }
441  // save individual curves, if requested
443  bool thisDetIDinList = false;
444  if (detIDsToSave_.find(detid) != detIDsToSave_.end()) // see if we want to save this histogram
445  thisDetIDinList = true;
446 
447  if (errorFlag != errOK || thisDetIDinList) {
448  edm::LogError("SiPixelSCurveCalibrationAnalysis") << "Saving error histogram for [detid](col/row): [" << detid
449  << "](" << col << "/" << row << ") ErrorFlag: " << errorFlag;
450  buildACurveHistogram(detid, row, col, errorFlag, efficiencies_, effErrors_);
451  }
452  }
453 
454  return true;
455 }
void calculateEffAndError(int nADCResponse, int nTriggers, float &eff, float &error)
Log< level::Error, false > LogError
sCurveErrorFlag estimateSCurveParameters(const std::vector< float > &eff, float &threshold, float &sigma)
Log< level::Info, false > LogInfo
sCurveErrorFlag fittedSCurveSanityCheck(float threshold, float sigma, float amplitude)
void chi2toMinimize(int &npar, double *grad, double &fcnval, double *xval, int iflag)
col
Definition: cuy.py:1009
void buildACurveHistogram(const uint32_t &detid, const uint32_t &row, const uint32_t &col, sCurveErrorFlag errorFlag, const std::vector< float > &efficiencies, const std::vector< float > &errors)

◆ doSetup()

void SiPixelSCurveCalibrationAnalysis::doSetup ( const edm::ParameterSet iConfig)

Definition at line 108 of file SiPixelSCurveCalibrationAnalysis.cc.

References detIDsToSave_, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, maxCurvesToSave_, maximumEffAsymptote_, maximumSigma_, maximumSigmaBin_, maximumThreshold_, maximumThresholdBin_, minimumChi2prob_, minimumEffAsymptote_, minimumSigma_, minimumThreshold_, printoutthresholds_, saveCurvesThatFlaggedBad_, AlCaHLTBitMon_QueryRunRegistry::string, thresholdfilename_, useDetectorHierarchyFolders_, write2dFitResult_, write2dHistograms_, and writeZeroes_.

Referenced by SiPixelSCurveCalibrationAnalysis().

108  {
109  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Setting up calibration paramters.";
110  std::vector<uint32_t> anEmptyDefaultVectorOfUInts;
111  std::vector<uint32_t> detIDsToSaveVector_;
112  useDetectorHierarchyFolders_ = iConfig.getUntrackedParameter<bool>("useDetectorHierarchyFolders", true);
113  saveCurvesThatFlaggedBad_ = iConfig.getUntrackedParameter<bool>("saveCurvesThatFlaggedBad", false);
114  detIDsToSaveVector_ =
115  iConfig.getUntrackedParameter<std::vector<uint32_t>>("detIDsToSave", anEmptyDefaultVectorOfUInts);
116  maxCurvesToSave_ = iConfig.getUntrackedParameter<uint32_t>("maxCurvesToSave", 1000);
117  write2dHistograms_ = iConfig.getUntrackedParameter<bool>("write2dHistograms", true);
118  write2dFitResult_ = iConfig.getUntrackedParameter<bool>("write2dFitResult", true);
119  printoutthresholds_ = iConfig.getUntrackedParameter<bool>("writeOutThresholdSummary", true);
120  thresholdfilename_ = iConfig.getUntrackedParameter<std::string>("thresholdOutputFileName", "thresholds.txt");
121  minimumChi2prob_ = iConfig.getUntrackedParameter<double>("minimumChi2prob", 0);
122  minimumThreshold_ = iConfig.getUntrackedParameter<double>("minimumThreshold", -10);
123  maximumThreshold_ = iConfig.getUntrackedParameter<double>("maximumThreshold", 300);
124  minimumSigma_ = iConfig.getUntrackedParameter<double>("minimumSigma", 0);
125  maximumSigma_ = iConfig.getUntrackedParameter<double>("maximumSigma", 100);
126  minimumEffAsymptote_ = iConfig.getUntrackedParameter<double>("minimumEffAsymptote", 0);
127  maximumEffAsymptote_ = iConfig.getUntrackedParameter<double>("maximumEffAsymptote", 1000);
128  maximumSigmaBin_ = iConfig.getUntrackedParameter<double>("maximumSigmaBin", 10);
129  maximumThresholdBin_ = iConfig.getUntrackedParameter<double>("maximumThresholdBin", 255);
130 
131  writeZeroes_ = iConfig.getUntrackedParameter<bool>("alsoWriteZeroThresholds", false);
132 
133  // convert the vector into a map for quicker lookups.
134  for (unsigned int i = 0; i < detIDsToSaveVector_.size(); i++)
135  detIDsToSave_.insert(std::make_pair(detIDsToSaveVector_[i], true));
136 }
T getUntrackedParameter(std::string const &, T const &) const
Log< level::Info, false > LogInfo

◆ estimateSCurveParameters()

sCurveErrorFlag SiPixelSCurveCalibrationAnalysis::estimateSCurveParameters ( const std::vector< float > &  eff,
float &  threshold,
float &  sigma 
)

Definition at line 227 of file SiPixelSCurveCalibrationAnalysis.cc.

References dumpMFGeometry_cfg::delta, errAllZeros, errNoTurnOn, errOK, convertSQLitetoXML_cfg::output, remoteMonitoring_LASER_era2018_cfg::threshold, and SiPixelOfflineCalibAnalysisBase::vCalValues_.

Referenced by doFits().

229  {
231  bool allZeroSoFar = true;
232  int turnOnBin = -1;
233  int saturationBin = -1;
234  for (uint32_t iVcalPt = 0; iVcalPt < eff.size(); iVcalPt++) {
235  if (allZeroSoFar && eff[iVcalPt] != 0) {
236  turnOnBin = iVcalPt;
237  allZeroSoFar = false;
239  } else if (eff[iVcalPt] > 0.90) {
240  saturationBin = iVcalPt;
241  short turnOnVcal = vCalValues_[turnOnBin];
242  short saturationVcal = vCalValues_[saturationBin];
243  short delta = saturationVcal - turnOnVcal;
244  sigma = delta * 0.682;
245  if (sigma < 1) // check to make sure sigma guess is larger than our X resolution.
246  // Hopefully prevents Minuit from getting stuck at boundary
247  sigma = 1;
248  threshold = turnOnVcal + (0.5 * delta);
249  return errOK;
250  }
251  }
252  return output;
253 }

◆ fittedSCurveSanityCheck()

sCurveErrorFlag SiPixelSCurveCalibrationAnalysis::fittedSCurveSanityCheck ( float  threshold,
float  sigma,
float  amplitude 
)

Definition at line 255 of file SiPixelSCurveCalibrationAnalysis.cc.

References errFitNonPhysical, errFlaggedBadByUser, errOK, maximumEffAsymptote_, maximumSigma_, maximumThreshold_, minimumSigma_, remoteMonitoring_LASER_era2018_cfg::threshold, and SiPixelOfflineCalibAnalysisBase::vCalValues_.

Referenced by doFits().

257  {
258  // check if nonsensical
259  if (threshold > vCalValues_[vCalValues_.size() - 1] || threshold < vCalValues_[0] ||
260  sigma > vCalValues_[vCalValues_.size() - 1] - vCalValues_[0])
261  return errFitNonPhysical;
262 
263  if (threshold < minimumThreshold_ || threshold > maximumThreshold_ || sigma < minimumSigma_ ||
264  sigma > maximumSigma_ || amplitude < minimumEffAsymptote_ || amplitude > maximumEffAsymptote_)
265  return errFlaggedBadByUser;
266 
267  return errOK;
268 }

◆ makeThresholdSummary()

void SiPixelSCurveCalibrationAnalysis::makeThresholdSummary ( void  )
private

Definition at line 25 of file SiPixelSCurveCalibrationAnalysis.cc.

References gather_cfg::cout, sipixelobjects::ElectronicIndex::dcol, sipixelobjects::LocalPixel::DcolPxid::dcol, hgcalTestNeighbor_cfi::detector, PixelSLinkDataInputSource_cfi::fedid, SiPixelFedCablingMap::findItem(), postprocess-scan-build::formatter, dqm::impl::MonitorElement::getBinContent(), dqm::impl::MonitorElement::getNbinsX(), dqm::impl::MonitorElement::getNbinsY(), dqm::impl::MonitorElement::getTitle(), histograms_, sipixelobjects::PixelROC::idInDetUnit(), kSigmas, kThresholds, sipixelobjects::ElectronicIndex::link, Skims_PA_cff::name, castor_dqm_sourceclient_file_cfg::path, edm::ESHandle< T >::product(), sipixelobjects::ElectronicIndex::pxid, sipixelobjects::LocalPixel::DcolPxid::pxid, sipixelobjects::ElectronicIndex::roc, sipixelobjects::LocalPixel::rocCol(), sipixelobjects::LocalPixel::rocRow(), AlCaHLTBitMon_QueryRunRegistry::string, SiPixelOfflineCalibAnalysisBase::theCablingMap_, thresholdfilename_, and writeZeroes_.

Referenced by calibrationEnd().

25  {
26  std::ofstream myfile;
27  myfile.open(thresholdfilename_.c_str());
28  for (detIDHistogramMap::iterator thisDetIdHistoGrams = histograms_.begin(); thisDetIdHistoGrams != histograms_.end();
29  ++thisDetIdHistoGrams) {
30  // loop over det id (det id = number (unsigned int) of pixel module
31  const MonitorElement *sigmahist = (*thisDetIdHistoGrams).second[kSigmas];
32  const MonitorElement *thresholdhist = (*thisDetIdHistoGrams).second[kThresholds];
33  uint32_t detid = (*thisDetIdHistoGrams).first;
34  std::string name = sigmahist->getTitle();
35  std::string rocname = name.substr(0, name.size() - 7);
36  rocname += "_ROC";
37  int total_rows = sigmahist->getNbinsY();
38  int total_columns = sigmahist->getNbinsX();
39  // loop over all rows on columns on all ROCs
40  for (int irow = 0; irow < total_rows; ++irow) {
41  for (int icol = 0; icol < total_columns; ++icol) {
42  float threshold_error = sigmahist->getBinContent(icol + 1, irow + 1); // +1 because root bins start at 1
43  if (writeZeroes_ || (!writeZeroes_ && threshold_error > 0)) {
44  // changing from offline to online numbers
45  int realfedID = -1;
46  for (int fedid = 0; fedid <= 40; ++fedid) {
48  if (converter.hasDetUnit(detid)) {
49  realfedID = fedid;
50  break;
51  }
52  }
53  if (realfedID == -1) {
54  std::cout << "error: could not obtain real fed ID" << std::endl;
55  }
56  sipixelobjects::DetectorIndex detector = {detid, irow, icol};
59  formatter.toCabling(cabling, detector);
60  // cabling should now contain cabling.roc and cabling.dcol and
61  // cabling.pxid however, the coordinates now need to be converted from
62  // dcl,pxid to the row,col coordinates used in the calibration info
64  loc.dcol = cabling.dcol;
65  loc.pxid = cabling.pxid;
66  // FIX to adhere to new cabling map. To be replaced with
67  // CalibTracker/SiPixelTools detid - > hardware id classes ASAP.
68  // const sipixelobjects::PixelFEDCabling *theFed=
69  // theCablingMap.product()->fed(realfedID); const
70  // sipixelobjects::PixelFEDLink * link =
71  // theFed->link(cabling.link); const sipixelobjects::PixelROC
72  // *theRoc = link->roc(cabling.roc);
73  sipixelobjects::LocalPixel locpixel(loc);
74  sipixelobjects::CablingPathToDetUnit path = {static_cast<unsigned int>(realfedID),
75  static_cast<unsigned int>(cabling.link),
76  static_cast<unsigned int>(cabling.roc)};
78  // END of FIX
79  int newrow = locpixel.rocRow();
80  int newcol = locpixel.rocCol();
81  myfile << rocname << theRoc->idInDetUnit() << " " << newcol << " " << newrow << " "
82  << thresholdhist->getBinContent(icol + 1, irow + 1) << " "
83  << threshold_error; // +1 because root bins start at 1
84  myfile << "\n";
85  }
86  }
87  }
88  }
89  myfile.close();
90 }
identify pixel inside single ROC
Definition: LocalPixel.h:7
T const * product() const
Definition: ESHandle.h:86
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
virtual int getNbinsY() const
get # of bins in Y-axis
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:19
virtual std::string getTitle() const
get MonitorElement title
virtual int getNbinsX() const
get # of bins in X-axis
edm::ESHandle< SiPixelFedCablingMap > theCablingMap_
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:37
virtual double getBinContent(int binx) const
get content of bin (1-D)

◆ newDetID()

void SiPixelSCurveCalibrationAnalysis::newDetID ( uint32_t  detid)
overrideprivatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 279 of file SiPixelSCurveCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D(), SiPixelOfflineCalibAnalysisBase::bookDQMHistoPlaquetteSummary2D(), histograms_, kChi2s, kChi2Summary, kFitResults, kFitResultSummary, kSigmas, kSigmaSummary, kThresholds, kThresholdSummary, maximumSigmaBin_, maximumThresholdBin_, SiPixelOfflineCalibAnalysisBase::setDQMDirectory(), AlCaHLTBitMon_QueryRunRegistry::string, SiPixelOfflineCalibAnalysisBase::translateDetIdToString(), useDetectorHierarchyFolders_, write2dFitResult_, and write2dHistograms_.

279  {
280  edm::LogInfo("SiPixelSCurveCalibrationAnalysis")
281  << "Found a new DetID (" << detid << ")! Checking to make sure it has not been added.";
282  // ensure that this DetID has not been added yet
283  sCurveHistogramHolder tempMap;
284  std::pair<detIDHistogramMap::iterator, bool> insertResult;
285  insertResult = histograms_.insert(std::make_pair(detid, tempMap));
286  if (insertResult.second) // indicates successful insertion
287  {
288  edm::LogInfo("SiPixelSCurveCalibrationAnalysisHistogramReport")
289  << "Histogram Map.insert() returned true! Booking new histogrames for "
290  "detID: "
291  << detid;
292  // use detector hierarchy folders if desired
294  setDQMDirectory(detid);
295 
296  std::string detIdName = translateDetIdToString(detid);
297  if (write2dHistograms_) {
298  MonitorElement *D2sigma = bookDQMHistoPlaquetteSummary2D(detid, "ScurveSigmas", detIdName + " Sigmas");
299  MonitorElement *D2thresh = bookDQMHistoPlaquetteSummary2D(detid, "ScurveThresholds", detIdName + " Thresholds");
300  MonitorElement *D2chi2 = bookDQMHistoPlaquetteSummary2D(detid, "ScurveChi2Prob", detIdName + " Chi2Prob");
301  insertResult.first->second.insert(std::make_pair(kSigmas, D2sigma));
302  insertResult.first->second.insert(std::make_pair(kThresholds, D2thresh));
303  insertResult.first->second.insert(std::make_pair(kChi2s, D2chi2));
304  }
305  if (write2dFitResult_) {
306  MonitorElement *D2FitResult = bookDQMHistoPlaquetteSummary2D(detid, "ScurveFitResult", detIdName + " Fit Result");
307  insertResult.first->second.insert(std::make_pair(kFitResults, D2FitResult));
308  }
309  MonitorElement *D1sigma =
310  bookDQMHistogram1D(detid, "ScurveSigmasSummary", detIdName + " Sigmas Summary", 100, 0, maximumSigmaBin_);
312  detid, "ScurveThresholdSummary", detIdName + " Thresholds Summary", 255, 0, maximumThresholdBin_);
313  MonitorElement *D1chi2 =
314  bookDQMHistogram1D(detid, "ScurveChi2ProbSummary", detIdName + " Chi2Prob Summary", 101, 0, 1.01);
315  MonitorElement *D1FitResult =
316  bookDQMHistogram1D(detid, "ScurveFitResultSummary", detIdName + " Fit Result Summary", 10, -0.5, 9.5);
317  insertResult.first->second.insert(std::make_pair(kSigmaSummary, D1sigma));
318  insertResult.first->second.insert(std::make_pair(kThresholdSummary, D1thresh));
319  insertResult.first->second.insert(std::make_pair(kChi2Summary, D1chi2));
320  insertResult.first->second.insert(std::make_pair(kFitResultSummary, D1FitResult));
321  }
322 }
std::map< sCurveHistogramType, MonitorElement * > sCurveHistogramHolder
std::string translateDetIdToString(uint32_t detid)
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
Log< level::Info, false > LogInfo

Member Data Documentation

◆ curvesSavedCounter_

unsigned int SiPixelSCurveCalibrationAnalysis::curvesSavedCounter_
private

Definition at line 93 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by buildACurveHistogram(), and calibrationSetup().

◆ detIDsToSave_

std::map<uint32_t, bool> SiPixelSCurveCalibrationAnalysis::detIDsToSave_
private

Definition at line 100 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), and doSetup().

◆ effErrors_

std::vector< float > SiPixelSCurveCalibrationAnalysis::effErrors_
static

Definition at line 74 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by chi2toMinimize(), and doFits().

◆ efficiencies_

std::vector< float > SiPixelSCurveCalibrationAnalysis::efficiencies_
static

Definition at line 73 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by chi2toMinimize(), and doFits().

◆ histograms_

detIDHistogramMap SiPixelSCurveCalibrationAnalysis::histograms_
private

Definition at line 116 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), makeThresholdSummary(), and newDetID().

◆ maxCurvesToSave_

unsigned int SiPixelSCurveCalibrationAnalysis::maxCurvesToSave_
private

◆ maximumEffAsymptote_

double SiPixelSCurveCalibrationAnalysis::maximumEffAsymptote_
private

Definition at line 109 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

◆ maximumSigma_

double SiPixelSCurveCalibrationAnalysis::maximumSigma_
private

Definition at line 107 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

◆ maximumSigmaBin_

double SiPixelSCurveCalibrationAnalysis::maximumSigmaBin_
private

Definition at line 113 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and newDetID().

◆ maximumThreshold_

double SiPixelSCurveCalibrationAnalysis::maximumThreshold_
private

Definition at line 105 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

◆ maximumThresholdBin_

double SiPixelSCurveCalibrationAnalysis::maximumThresholdBin_
private

Definition at line 112 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and newDetID().

◆ minimumChi2prob_

double SiPixelSCurveCalibrationAnalysis::minimumChi2prob_
private

Definition at line 103 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), and doSetup().

◆ minimumEffAsymptote_

double SiPixelSCurveCalibrationAnalysis::minimumEffAsymptote_
private

Definition at line 108 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup().

◆ minimumSigma_

double SiPixelSCurveCalibrationAnalysis::minimumSigma_
private

Definition at line 106 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

◆ minimumThreshold_

double SiPixelSCurveCalibrationAnalysis::minimumThreshold_
private

Definition at line 104 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup().

◆ plaquettesToSave_

std::vector<std::string> SiPixelSCurveCalibrationAnalysis::plaquettesToSave_
private

Definition at line 96 of file SiPixelSCurveCalibrationAnalysis.h.

◆ printoutthresholds_

bool SiPixelSCurveCalibrationAnalysis::printoutthresholds_
private

Definition at line 97 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by calibrationEnd(), and doSetup().

◆ saveCurvesThatFlaggedBad_

bool SiPixelSCurveCalibrationAnalysis::saveCurvesThatFlaggedBad_
private

Definition at line 90 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by calibrationSetup(), doFits(), and doSetup().

◆ thresholdfilename_

std::string SiPixelSCurveCalibrationAnalysis::thresholdfilename_
private

Definition at line 99 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and makeThresholdSummary().

◆ useDetectorHierarchyFolders_

bool SiPixelSCurveCalibrationAnalysis::useDetectorHierarchyFolders_
private

Definition at line 89 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and newDetID().

◆ vCalPointsAsFloats_

std::vector<float> SiPixelSCurveCalibrationAnalysis::vCalPointsAsFloats_

Definition at line 75 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by buildACurveHistogram(), and calibrationSetup().

◆ write2dFitResult_

bool SiPixelSCurveCalibrationAnalysis::write2dFitResult_
private

Definition at line 95 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), doSetup(), and newDetID().

◆ write2dHistograms_

bool SiPixelSCurveCalibrationAnalysis::write2dHistograms_
private

Definition at line 94 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), doSetup(), and newDetID().

◆ writeZeroes_

bool SiPixelSCurveCalibrationAnalysis::writeZeroes_
private

Definition at line 98 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and makeThresholdSummary().