CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
SiPixelSCurveCalibrationAnalysis Class Reference

#include <CalibTracker/SiPixelSCurveCalibration/src/SiPixelSCurveCalibrationAnalysis.cc>

Inheritance diagram for SiPixelSCurveCalibrationAnalysis:
SiPixelOfflineCalibAnalysisBase edm::EDAnalyzer 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)
 
virtual bool doFits (uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix)
 
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 ()
 
- 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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_ = NULL
 

Private Member Functions

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

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 edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from SiPixelOfflineCalibAnalysisBase
static const std::vector< short > * getVcalValues ()
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from SiPixelOfflineCalibAnalysisBase
uint32_t & EventNumber ()
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 
- Protected Attributes inherited from SiPixelOfflineCalibAnalysisBase
edm::ESHandle
< SiPixelCalibConfiguration
calib_
 
std::string calibrationMode_
 
edm::ESHandle< TrackerGeometrygeom_
 
short nTriggers_
 
edm::ESHandle
< SiPixelFedCablingMap
theCablingMap_
 
- Static Protected Attributes inherited from SiPixelOfflineCalibAnalysisBase
static std::vector< short > vCalValues_
 

Detailed Description

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

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

Definition at line 58 of file SiPixelSCurveCalibrationAnalysis.h.

Constructor & Destructor Documentation

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

Definition at line 134 of file SiPixelSCurveCalibrationAnalysis.cc.

135 {
136  //do nothing
137 }

Member Function Documentation

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 139 of file SiPixelSCurveCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D(), cuy::col, curvesSavedCounter_, maxCurvesToSave_, MonitorElement::setBinContent(), MonitorElement::setBinError(), SiPixelOfflineCalibAnalysisBase::setDQMDirectory(), SiPixelOfflineCalibAnalysisBase::translateDetIdToString(), and vCalPointsAsFloats_.

Referenced by doFits().

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

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 169 of file SiPixelSCurveCalibrationAnalysis.cc.

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

170 {
171  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Calibration Settings: VCalLow: " << vCalValues_[0] << " VCalHigh: " << vCalValues_[vCalValues_.size()-1] << " nVCal: " << vCalValues_.size() << " nTriggers: " << nTriggers_;
174  {
175  //build the vCal values as a vector of floats if we want to save single curves
176  const std::vector<short>* theVCalValues = this->getVcalValues();
177  unsigned int numberOfVCalPoints = theVCalValues->size();
178  edm::LogWarning("SiPixelSCurveCalibrationAnalysis") << "WARNING: Option set to save indiviual S-Curves - max number: "
179  << maxCurvesToSave_ << " This can lead to large memory consumption! (Got " << numberOfVCalPoints << " VCal Points";
180  for(unsigned int i = 0; i < numberOfVCalPoints; i++)
181  {
182  vCalPointsAsFloats_.push_back( static_cast<float>((*theVCalValues)[i]) );
183  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Adding calibration Vcal: " << (*theVCalValues)[i];
184  }
185  // must add lower edge of last bin to the vector
186  vCalPointsAsFloats_.push_back( vCalPointsAsFloats_[numberOfVCalPoints-1] + 1 );
187  }
188 
189  fitFunction_ = new TF1("sCurve", "0.5*[2]*(1+TMath::Erf( (x-[0]) / ([1]*sqrt(2)) ) )", vCalValues_[0], vCalValues_[vCalValues_.size()-1]);
190 }
int i
Definition: DBlmapReader.cc:9
static const std::vector< short > * getVcalValues()
bool SiPixelSCurveCalibrationAnalysis::checkCorrectCalibrationType ( )
privatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 193 of file SiPixelSCurveCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::calibrationMode_.

194 {
195  if(calibrationMode_=="SCurve")
196  return true;
197  else if(calibrationMode_=="unknown"){
198  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "calibration mode is: " << calibrationMode_ << ", continuing anyway..." ;
199  return true;
200  }
201  else{
202  // edm::LogDebug("SiPixelSCurveCalibrationAnalysis") << "unknown calibration mode for SCurves, should be \"SCurve\" and is \"" << calibrationMode_ << "\"";
203  }
204  return false;
205 }
bool SiPixelSCurveCalibrationAnalysis::doFits ( uint32_t  detid,
std::vector< SiPixelCalibDigi >::const_iterator  ipix 
)
virtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 298 of file SiPixelSCurveCalibrationAnalysis.cc.

References buildACurveHistogram(), calculateEffAndError(), chi2toMinimize(), cuy::col, detIDsToSave_, effErrors_, efficiencies_, errBadChi2Prob, errOK, error, estimateSCurveParameters(), fittedSCurveSanityCheck(), fitWZ::gMinuit, histograms_, kChi2s, kChi2Summary, kFitResults, kFitResultSummary, kSigmas, kSigmaSummary, kThresholds, kThresholdSummary, minimumChi2prob_, SiPixelOfflineCalibAnalysisBase::nTriggers_, NULL, saveCurvesThatFlaggedBad_, dtDQMClient_cfg::threshold, SiPixelOfflineCalibAnalysisBase::vCalValues_, write2dFitResult_, and write2dHistograms_.

299 {
300  sCurveErrorFlag errorFlag = errOK;
301  uint32_t nVCalPts = calibDigi->getnpoints();
302  //reset and fill static datamembers with vector of points and errors
303  efficiencies_.resize(0);
304  effErrors_.resize(0);
305  for (uint32_t iVcalPt = 0; iVcalPt < nVCalPts; iVcalPt++)
306  {
307  float eff;
308  float error;
309  calculateEffAndError(calibDigi->getnentries(iVcalPt), nTriggers_, eff, error);
310  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Eff: " << eff << " Error: " << error << " nEntries: " << calibDigi->getnentries(iVcalPt) << " nTriggers: " << nTriggers_ << " VCalPt " << vCalValues_[iVcalPt];
311  efficiencies_.push_back(eff);
312  effErrors_.push_back(error);
313  }
314 
315  //estimate the S-Curve parameters
316  float thresholdGuess = -1.0;
317  float sigmaGuess = -1.0;
318  errorFlag = estimateSCurveParameters(efficiencies_, thresholdGuess, sigmaGuess);
319 
320  // these -1.0 default values will only be filled if the curve is all zeroes, or doesn't turn on, WHICH INDICATES A SERIOUS PROBLEM
321  Double_t sigma = -1.0;
322  Double_t sigmaError = -1.0;
323  Double_t threshold = -1.0;
324  Double_t thresholdError = -1.0;
325  Double_t amplitude = -1.0;
326  Double_t amplitudeError = -1.0;
327  Double_t chi2 = -1.0;
328  //calculate NDF
329  Int_t nDOF = vCalValues_.size() - 3;
330  Double_t chi2probability = 0;
331 
332  if (errorFlag == errOK) //only do fit if curve is fittable
333  {
334  //set up minuit fit
335  TMinuit *gMinuit = new TMinuit(3);
336  gMinuit->SetPrintLevel(-1); //save ourselves from gigabytes of stdout
337  gMinuit->SetFCN(chi2toMinimize);
338 
339  //define threshold parameters - choose step size 1, max 300, min -50
340  gMinuit->DefineParameter(0, "Threshold", (Double_t)thresholdGuess, 1, -50, 300);
341  //sigma
342  gMinuit->DefineParameter(1, "Sigma", (Double_t)sigmaGuess, 0.1, 0, 255);
343  //amplitude
344  gMinuit->DefineParameter(2, "Amplitude", 1, 0.1, -0.001, 200);
345 
346  //Do Chi2 minimazation
347  gMinuit->Migrad();
348  gMinuit->GetParameter(0, threshold, thresholdError);
349  gMinuit->GetParameter(1, sigma, sigmaError);
350  gMinuit->GetParameter(2, amplitude, amplitudeError);
351 
352  //get Chi2
353  Double_t params[3] = {threshold, sigma, amplitude};
354  gMinuit->Eval(3, NULL, chi2, params, 0);
355  //calculate Chi2 proability
356  if (nDOF <= 0)
357  chi2probability = 0;
358  else
359  chi2probability = TMath::Prob(chi2, nDOF);
360 
361  //check to make sure output makes sense (i.e. threshold > 0)
362  if (chi2probability > minimumChi2prob_)
363  errorFlag = fittedSCurveSanityCheck(threshold, sigma, amplitude);
364  else
365  errorFlag = errBadChi2Prob;
366 
367  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Fit finished with errorFlag: " << errorFlag << " - threshold: " << threshold << " sigma: " << sigma << " chi2: " << chi2 << " nDOF: " << nDOF << " chi2Prob: " << chi2probability << " chi2MinUser: " << minimumChi2prob_;
368 
369  delete gMinuit;
370  }
371  //get row and column for this pixel
372  uint32_t row = calibDigi->row();
373  uint32_t col = calibDigi->col();
374 
375  //get iterator to histogram holder for this detid
376  detIDHistogramMap::iterator thisDetIdHistoGrams;
377  thisDetIdHistoGrams = histograms_.find(detid);
378  if (thisDetIdHistoGrams != histograms_.end())
379  {
380  edm::LogInfo("SiPixelSCurveCalibrationAnalysisHistogramReport") << "Filling histograms for [detid](col/row): [" << detid << "](" << col << "/" << row << ") ErrorFlag: " << errorFlag;
381  //always fill fit result
382  (*thisDetIdHistoGrams).second[kFitResultSummary]->Fill(errorFlag);
383  if (write2dFitResult_)
384  (*thisDetIdHistoGrams).second[kFitResults]->setBinContent(col+1, row+1, errorFlag); // +1 because root bins start at 1
385 
386  // fill sigma/threshold result
387  (*thisDetIdHistoGrams).second[kSigmaSummary]->Fill(sigma);
388  (*thisDetIdHistoGrams).second[kThresholdSummary]->Fill(threshold);
389  if (write2dHistograms_)
390  {
391  (*thisDetIdHistoGrams).second[kSigmas]->setBinContent(col+1, row+1, sigma); // +1 because root bins start at 1
392  (*thisDetIdHistoGrams).second[kThresholds]->setBinContent(col+1, row+1, threshold); // +1 because root bins start at 1
393  }
394  // fill chi2
395  (*thisDetIdHistoGrams).second[kChi2Summary]->Fill(chi2probability);
396  if (write2dHistograms_)
397  (*thisDetIdHistoGrams).second[kChi2s]->Fill(col, row, chi2probability);
398  }
399  // save individual curves, if requested
401  {
402  bool thisDetIDinList = false;
403  if (detIDsToSave_.find(detid) != detIDsToSave_.end()) //see if we want to save this histogram
404  thisDetIDinList = true;
405 
406  if (errorFlag != errOK || thisDetIDinList)
407  {
408  edm::LogError("SiPixelSCurveCalibrationAnalysis") << "Saving error histogram for [detid](col/row): [" << detid << "](" << col << "/" << row << ") ErrorFlag: " << errorFlag;
409  buildACurveHistogram(detid, row, col, errorFlag, efficiencies_, effErrors_);
410  }
411  }
412 
413  return true;
414 
415 }
void calculateEffAndError(int nADCResponse, int nTriggers, float &eff, float &error)
#define NULL
Definition: scimark2.h:8
sCurveErrorFlag estimateSCurveParameters(const std::vector< float > &eff, float &threshold, float &sigma)
sCurveErrorFlag fittedSCurveSanityCheck(float threshold, float sigma, float amplitude)
void chi2toMinimize(int &npar, double *grad, double &fcnval, double *xval, int iflag)
tuple gMinuit
Definition: fitWZ.py:35
int col
Definition: cuy.py:1008
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)
void SiPixelSCurveCalibrationAnalysis::doSetup ( const edm::ParameterSet iConfig)

Definition at line 104 of file SiPixelSCurveCalibrationAnalysis.cc.

References detIDsToSave_, edm::ParameterSet::getUntrackedParameter(), 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().

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

Definition at line 207 of file SiPixelSCurveCalibrationAnalysis.cc.

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

Referenced by doFits().

208 {
210  bool allZeroSoFar = true;
211  int turnOnBin = -1;
212  int saturationBin = -1;
213  for (uint32_t iVcalPt = 0; iVcalPt < eff.size(); iVcalPt++)
214  {
215  if (allZeroSoFar && eff[iVcalPt] != 0 ) {
216  turnOnBin = iVcalPt;
217  allZeroSoFar = false;
218  output = errNoTurnOn;
219  } else if (eff[iVcalPt] > 0.90)
220  {
221  saturationBin = iVcalPt;
222  short turnOnVcal = vCalValues_[turnOnBin];
223  short saturationVcal = vCalValues_[saturationBin];
224  short delta = saturationVcal - turnOnVcal;
225  sigma = delta * 0.682;
226  if (sigma < 1) //check to make sure sigma guess is larger than our X resolution. Hopefully prevents Minuit from getting stuck at boundary
227  sigma = 1;
228  threshold = turnOnVcal + (0.5 * delta);
229  return errOK;
230  }
231  }
232  return output;
233 }
dbl * delta
Definition: mlp_gen.cc:36
sCurveErrorFlag SiPixelSCurveCalibrationAnalysis::fittedSCurveSanityCheck ( float  threshold,
float  sigma,
float  amplitude 
)

Definition at line 235 of file SiPixelSCurveCalibrationAnalysis.cc.

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

Referenced by doFits().

236 {
237  //check if nonsensical
238  if (threshold > vCalValues_[vCalValues_.size()-1] || threshold < vCalValues_[0] ||
239  sigma > vCalValues_[vCalValues_.size()-1] - vCalValues_[0] )
240  return errFitNonPhysical;
241 
242  if (threshold < minimumThreshold_ || threshold > maximumThreshold_ ||
243  sigma < minimumSigma_ || sigma > maximumSigma_ ||
244  amplitude < minimumEffAsymptote_ || amplitude > maximumEffAsymptote_)
245  return errFlaggedBadByUser;
246 
247  return errOK;
248 }
void SiPixelSCurveCalibrationAnalysis::makeThresholdSummary ( void  )
private

Definition at line 25 of file SiPixelSCurveCalibrationAnalysis.cc.

References gather_cfg::cout, sipixelobjects::ElectronicIndex::dcol, sipixelobjects::LocalPixel::DcolPxid::dcol, cond::rpcobgas::detid, MonitorElement::getBinContent(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), MonitorElement::getTitle(), histograms_, sipixelobjects::PixelROC::idInDetUnit(), kSigmas, kThresholds, sipixelobjects::ElectronicIndex::link, mergeVDriftHistosByStation::name, getHLTPrescaleColumns::path, edm::ESHandle< class >::product(), sipixelobjects::ElectronicIndex::pxid, sipixelobjects::LocalPixel::DcolPxid::pxid, sipixelobjects::ElectronicIndex::roc, sipixelobjects::LocalPixel::rocCol(), sipixelobjects::LocalPixel::rocRow(), AlCaHLTBitMon_QueryRunRegistry::string, SiPixelOfflineCalibAnalysisBase::theCablingMap_, thresholdfilename_, SiPixelFrameConverter::toCabling(), and writeZeroes_.

Referenced by calibrationEnd().

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

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 260 of file SiPixelSCurveCalibrationAnalysis.cc.

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

261 {
262  edm::LogInfo("SiPixelSCurveCalibrationAnalysis") << "Found a new DetID (" << detid << ")! Checking to make sure it has not been added.";
263  //ensure that this DetID has not been added yet
264  sCurveHistogramHolder tempMap;
265  std::pair<detIDHistogramMap::iterator, bool> insertResult;
266  insertResult = histograms_.insert(std::make_pair(detid, tempMap));
267  if (insertResult.second) //indicates successful insertion
268  {
269  edm::LogInfo("SiPixelSCurveCalibrationAnalysisHistogramReport") << "Histogram Map.insert() returned true! Booking new histogrames for detID: " << detid;
270  // use detector hierarchy folders if desired
273 
275  if (write2dHistograms_){
276  MonitorElement * D2sigma = bookDQMHistoPlaquetteSummary2D(detid,"ScurveSigmas", detIdName + " Sigmas");
277  MonitorElement * D2thresh = bookDQMHistoPlaquetteSummary2D(detid,"ScurveThresholds", detIdName + " Thresholds");
278  MonitorElement * D2chi2 = bookDQMHistoPlaquetteSummary2D(detid,"ScurveChi2Prob",detIdName + " Chi2Prob");
279  insertResult.first->second.insert(std::make_pair(kSigmas, D2sigma));
280  insertResult.first->second.insert(std::make_pair(kThresholds, D2thresh));
281  insertResult.first->second.insert(std::make_pair(kChi2s, D2chi2));
282  }
283  if (write2dFitResult_){
284  MonitorElement * D2FitResult = bookDQMHistoPlaquetteSummary2D(detid,"ScurveFitResult", detIdName + " Fit Result");
285  insertResult.first->second.insert(std::make_pair(kFitResults, D2FitResult));
286  }
287  MonitorElement * D1sigma = bookDQMHistogram1D(detid,"ScurveSigmasSummary", detIdName + " Sigmas Summary", 100, 0, maximumSigmaBin_);
288  MonitorElement * D1thresh = bookDQMHistogram1D(detid,"ScurveThresholdSummary", detIdName + " Thresholds Summary", 255, 0, maximumThresholdBin_);
289  MonitorElement * D1chi2 = bookDQMHistogram1D(detid,"ScurveChi2ProbSummary", detIdName + " Chi2Prob Summary", 101, 0, 1.01);
290  MonitorElement * D1FitResult = bookDQMHistogram1D(detid,"ScurveFitResultSummary", detIdName + " Fit Result Summary", 10, -0.5, 9.5);
291  insertResult.first->second.insert(std::make_pair(kSigmaSummary, D1sigma));
292  insertResult.first->second.insert(std::make_pair(kThresholdSummary, D1thresh));
293  insertResult.first->second.insert(std::make_pair(kChi2Summary, D1chi2));
294  insertResult.first->second.insert(std::make_pair(kFitResultSummary, D1FitResult));
295  }
296 }
std::string translateDetIdToString(uint32_t detid)
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
std::map< sCurveHistogramType, MonitorElement * > sCurveHistogramHolder
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)

Member Data Documentation

unsigned int SiPixelSCurveCalibrationAnalysis::curvesSavedCounter_
private

Definition at line 82 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by buildACurveHistogram(), and calibrationSetup().

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

Definition at line 89 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), and doSetup().

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

Definition at line 67 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by chi2toMinimize(), and doFits().

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

Definition at line 66 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by chi2toMinimize(), and doFits().

detIDHistogramMap SiPixelSCurveCalibrationAnalysis::histograms_
private

Definition at line 107 of file SiPixelSCurveCalibrationAnalysis.h.

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

unsigned int SiPixelSCurveCalibrationAnalysis::maxCurvesToSave_
private
double SiPixelSCurveCalibrationAnalysis::maximumEffAsymptote_
private

Definition at line 99 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

double SiPixelSCurveCalibrationAnalysis::maximumSigma_
private

Definition at line 97 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

double SiPixelSCurveCalibrationAnalysis::maximumSigmaBin_
private

Definition at line 103 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and newDetID().

double SiPixelSCurveCalibrationAnalysis::maximumThreshold_
private

Definition at line 95 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and fittedSCurveSanityCheck().

double SiPixelSCurveCalibrationAnalysis::maximumThresholdBin_
private

Definition at line 102 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and newDetID().

double SiPixelSCurveCalibrationAnalysis::minimumChi2prob_
private

Definition at line 93 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doFits(), and doSetup().

double SiPixelSCurveCalibrationAnalysis::minimumEffAsymptote_
private

Definition at line 98 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup().

double SiPixelSCurveCalibrationAnalysis::minimumSigma_
private

Definition at line 96 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup().

double SiPixelSCurveCalibrationAnalysis::minimumThreshold_
private

Definition at line 94 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup().

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

Definition at line 85 of file SiPixelSCurveCalibrationAnalysis.h.

bool SiPixelSCurveCalibrationAnalysis::printoutthresholds_
private

Definition at line 86 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by calibrationEnd(), and doSetup().

bool SiPixelSCurveCalibrationAnalysis::saveCurvesThatFlaggedBad_
private

Definition at line 80 of file SiPixelSCurveCalibrationAnalysis.h.

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

std::string SiPixelSCurveCalibrationAnalysis::thresholdfilename_
private

Definition at line 88 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and makeThresholdSummary().

bool SiPixelSCurveCalibrationAnalysis::useDetectorHierarchyFolders_
private

Definition at line 79 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and newDetID().

std::vector<float> SiPixelSCurveCalibrationAnalysis::vCalPointsAsFloats_

Definition at line 68 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by buildACurveHistogram(), and calibrationSetup().

bool SiPixelSCurveCalibrationAnalysis::write2dFitResult_
private

Definition at line 84 of file SiPixelSCurveCalibrationAnalysis.h.

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

bool SiPixelSCurveCalibrationAnalysis::write2dHistograms_
private

Definition at line 83 of file SiPixelSCurveCalibrationAnalysis.h.

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

bool SiPixelSCurveCalibrationAnalysis::writeZeroes_
private

Definition at line 87 of file SiPixelSCurveCalibrationAnalysis.h.

Referenced by doSetup(), and makeThresholdSummary().