CMS 3D CMS Logo

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

#include <CalibTracker/SiPixelGainCalibrationAnalysis/interface/SiPixelGainCalibrationAnalysis.h>

Inheritance diagram for SiPixelGainCalibrationAnalysis:
SiPixelOfflineCalibAnalysisBase edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

bool checkCorrectCalibrationType () override
 
bool doFits (uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix) override
 
void doSetup (const edm::ParameterSet &)
 
 SiPixelGainCalibrationAnalysis (const edm::ParameterSet &iConfig)
 
 ~SiPixelGainCalibrationAnalysis () 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::vector< float > CalculateAveragePerColumn (uint32_t detid, std::string label)
 
void calibrationEnd () override
 
void calibrationSetup (const edm::EventSetup &iSetup) override
 
void fillDatabase ()
 
void newDetID (uint32_t detid) override
 
void printSummary ()
 

Private Attributes

bool appendMode_
 
bool bookBIGCalibPayload_
 
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
 
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_pixels_
 
double chi2ProbThreshold_
 
double chi2Threshold_
 
edm::ParameterSet conf_
 
uint32_t currentDetID_
 
bool filldb_
 
std::string fitfunction_
 
TF1 * func_
 
float gainhi_
 
float gainlow_
 
TGraphErrors * graph_
 
bool ignoreMode_
 
std::vector< uint32_t > listofdetids_
 
double maxChi2InHist_
 
double maxGainInHist_
 
uint16_t min_nentries_
 
int nfitparameters_
 
float pedhi_
 
float pedlow_
 
double plateau_max_slope_
 
std::string recordName_
 
bool reject_badpoints_
 
double reject_badpoints_frac_
 
bool reject_first_point_
 
bool reject_plateaupoints_
 
bool reject_single_entries_
 
bool saveALLHistograms_
 
bool savePixelHists_
 
double scalarVcalHigh_VcalLow_
 
int * statusNumbers_
 
bool sum_gain_cols_
 
bool sum_ped_cols_
 
std::ofstream summary_
 
bool useVcalHigh_
 
bool writeSummary_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer 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::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Static Public Attributes inherited from SiPixelOfflineCalibAnalysisBase
static TF1 * fitFunction_ = 0
 
- 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)
 
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<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< SiPixelCalibConfigurationcalib_
 
std::string calibrationMode_
 
edm::ESHandle< TrackerGeometrygeom_
 
short nTriggers_
 
edm::ESHandle< SiPixelFedCablingMaptheCablingMap_
 
- 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 47 of file SiPixelGainCalibrationAnalysis.h.

Constructor & Destructor Documentation

SiPixelGainCalibrationAnalysis::SiPixelGainCalibrationAnalysis ( const edm::ParameterSet iConfig)
explicit

Definition at line 34 of file SiPixelGainCalibrationAnalysis.cc.

References currentDetID_, fitfunction_, func_, graph_, cuy::ii, min_nentries_, nfitparameters_, reject_single_entries_, scalarVcalHigh_VcalLow_, statusNumbers_, and summary_.

36  conf_(iConfig),
37  bookkeeper_(),
39  nfitparameters_(iConfig.getUntrackedParameter<int>("numberOfFitParameters", 2)),
40  fitfunction_(iConfig.getUntrackedParameter<std::string>("fitFunctionRootFormula", "pol1")),
41  listofdetids_(conf_.getUntrackedParameter<std::vector<uint32_t> >("listOfDetIDs")),
42  ignoreMode_(conf_.getUntrackedParameter<bool>("ignoreMode", false)),
43  reject_plateaupoints_(iConfig.getUntrackedParameter<bool>("suppressPlateauInFit", true)),
44  reject_single_entries_(iConfig.getUntrackedParameter<bool>("suppressPointsWithOneEntryOrLess", true)),
45  plateau_max_slope_(iConfig.getUntrackedParameter<double>("plateauSlopeMax", 1.0)),
46  reject_first_point_(iConfig.getUntrackedParameter<bool>("rejectVCalZero", true)),
47  reject_badpoints_frac_(iConfig.getUntrackedParameter<double>("suppressZeroAndPlateausInFitFrac", 0)),
48  bookBIGCalibPayload_(iConfig.getUntrackedParameter<bool>("saveFullPayloads", false)),
49  savePixelHists_(iConfig.getUntrackedParameter<bool>("savePixelLevelHists", false)),
50  chi2Threshold_(iConfig.getUntrackedParameter<double>("minChi2NDFforHistSave", 10)),
51  chi2ProbThreshold_(iConfig.getUntrackedParameter<double>("minChi2ProbforHistSave", 0.05)),
52  maxGainInHist_(iConfig.getUntrackedParameter<double>("maxGainInHist", 10)),
53  maxChi2InHist_(iConfig.getUntrackedParameter<double>("maxChi2InHist", 25)),
54  saveALLHistograms_(iConfig.getUntrackedParameter<bool>("saveAllHistograms", false)),
55 
56  filldb_(iConfig.getUntrackedParameter<bool>("writeDatabase", false)),
57  writeSummary_(iConfig.getUntrackedParameter<bool>("writeSummary", true)),
59 
60  appendMode_(conf_.getUntrackedParameter<bool>("appendMode", true)),
61  /*theGainCalibrationDbInput_(0),
62  theGainCalibrationDbInputOffline_(0),
63  theGainCalibrationDbInputHLT_(0),
64  theGainCalibrationDbInputService_(iConfig),*/
65  gainlow_(10.),
66  gainhi_(0.),
67  pedlow_(255.),
68  pedhi_(0.),
69  useVcalHigh_(conf_.getParameter<bool>("useVCALHIGH")),
70  scalarVcalHigh_VcalLow_(conf_.getParameter<double>("vcalHighToLowConversionFac")) {
72  min_nentries_ = 1;
73  else
74  min_nentries_ = 0;
75  ::putenv((char *)"CORAL_AUTH_USER=me");
76  ::putenv((char *)"CORAL_AUTH_PASSWORD=test");
77  edm::LogInfo("SiPixelGainCalibrationAnalysis") << "now using fit function " << fitfunction_ << ", which has "
78  << nfitparameters_ << " free parameters. " << std::endl;
79  func_ = new TF1("func", fitfunction_.c_str(), 0, 256 * scalarVcalHigh_VcalLow_);
80  graph_ = new TGraphErrors();
81  currentDetID_ = 0;
82  summary_.open("SummaryPerDetID.txt");
83  statusNumbers_ = new int[10];
84  for (int ii = 0; ii < 10; ii++)
85  statusNumbers_[ii] = 0;
86 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_pixels_
ii
Definition: cuy.py:590
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
SiPixelGainCalibrationAnalysis::~SiPixelGainCalibrationAnalysis ( )
override

Definition at line 88 of file SiPixelGainCalibrationAnalysis.cc.

88 {}

Member Function Documentation

std::vector< float > SiPixelGainCalibrationAnalysis::CalculateAveragePerColumn ( uint32_t  detid,
std::string  label 
)
private

Definition at line 93 of file SiPixelGainCalibrationAnalysis.cc.

References bookkeeper_, label, hgcalPlots::ncols, mps_fire::result, and heppy_batch::val.

Referenced by printSummary().

93  {
94  std::vector<float> result;
95  int ncols = bookkeeper_[detid][label]->getNbinsX();
96  int nrows = bookkeeper_[detid][label]->getNbinsY();
97  for (int icol = 1; icol <= ncols; ++icol) {
98  float val = 0;
99  float ntimes = 0;
100  for (int irow = 1; irow <= nrows; ++irow) {
101  val += bookkeeper_[detid][label]->getBinContent(icol, irow);
102  ntimes++;
103  }
104  val /= ntimes;
105  result.push_back(val);
106  }
107  return result;
108 }
char const * label
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
void SiPixelGainCalibrationAnalysis::calibrationEnd ( )
overrideprivatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 167 of file SiPixelGainCalibrationAnalysis.cc.

References fillDatabase(), filldb_, printSummary(), and writeSummary_.

167  {
168  if (writeSummary_)
169  printSummary();
170 
171  // this is where we loop over all histograms and save the database objects
172  if (filldb_)
173  fillDatabase();
174 }
void SiPixelGainCalibrationAnalysis::calibrationSetup ( const edm::EventSetup iSetup)
overrideprivatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 125 of file SiPixelGainCalibrationAnalysis.cc.

125 {}
bool SiPixelGainCalibrationAnalysis::checkCorrectCalibrationType ( )
overridevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 110 of file SiPixelGainCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::calibrationMode_, and ignoreMode_.

110  {
111  if (calibrationMode_ == "GainCalibration")
112  return true;
113  else if (ignoreMode_ == true)
114  return true;
115  else if (calibrationMode_ == "unknown") {
116  edm::LogInfo("SiPixelGainCalibrationAnalysis")
117  << "calibration mode is: " << calibrationMode_ << ", continuing anyway...";
118  return true;
119  } else {
120  // edm::LogError("SiPixelGainCalibrationAnalysis") << "unknown calibration mode for Gain calibration, should be \"Gain\" and is \"" << calibrationMode_ << "\"";
121  }
122  return false;
123 }
bool SiPixelGainCalibrationAnalysis::doFits ( uint32_t  detid,
std::vector< SiPixelCalibDigi >::const_iterator  ipix 
)
overridevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 185 of file SiPixelGainCalibrationAnalysis.cc.

References funct::abs(), Abs(), SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D(), bookkeeper_, bookkeeper_pixels_, vertices_cff::chi2, chi2ProbThreshold_, chi2Threshold_, currentDetID_, spr::find(), objects.autophobj::float, func_, gainhi_, gainlow_, graph_, cuy::ii, edm::detail::isnan(), listofdetids_, maxGainInHist_, min_nentries_, npoints, pedhi_, pedlow_, funct::pow(), TtFullHadEvtBuilder_cfi::prob, reject_badpoints_, reject_badpoints_frac_, reject_first_point_, reject_plateaupoints_, reject_single_entries_, saveALLHistograms_, savePixelHists_, scalarVcalHigh_VcalLow_, SiPixelOfflineCalibAnalysisBase::setDQMDirectory(), slope, mathSSE::sqrt(), mps_update::status, statusNumbers_, AlCaHLTBitMon_QueryRunRegistry::string, summary_, SiPixelOfflineCalibAnalysisBase::translateDetIdToString(), useVcalHigh_, SiPixelOfflineCalibAnalysisBase::vCalValues_, and writeSummary_.

185  {
186  float lowmeanval = 255;
187  float highmeanval = 0;
188  bool makehistopersistent = saveALLHistograms_;
189  std::vector<uint32_t>::const_iterator detidfinder = find(listofdetids_.begin(), listofdetids_.end(), detid);
190  if (detidfinder != listofdetids_.end())
191  makehistopersistent = true;
192  // first, fill the input arrays to the TLinearFitter.
193  double xvals[257];
194  double yvals[256];
195  double yerrvals[256];
196  double xvalsall[257];
197  double yvalsall[256];
198  double yerrvalsall[256];
199  int npoints = 0;
200  int nallpoints = 0;
201  bool use_point = true;
202  int status = 0;
203  statusNumbers_[9]++;
204 
205  bookkeeper_[detid]["status_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, 0);
206  if (writeSummary_ && detid != currentDetID_) {
207  currentDetID_ = detid;
208  summary_ << endl << "DetId_" << currentDetID_ << endl;
209  }
210 
211  for (uint32_t ii = 0; ii < ipix->getnpoints() && ii < 200; ii++) {
212  // std::cout << ipix->getsum(ii) << " " << ipix->getnentries(ii) << " " << ipix->getsumsquares(ii) << std::endl;
213  nallpoints++;
214  use_point = true;
215  if (useVcalHigh_) {
216  xvalsall[ii] = vCalValues_[ii] * scalarVcalHigh_VcalLow_;
217  } else
218  xvalsall[ii] = vCalValues_[ii];
219  yerrvalsall[ii] = yvalsall[ii] = 0;
220 
221  if (ipix->getnentries(ii) > min_nentries_) {
222  yvalsall[ii] = ipix->getsum(ii) / (float)ipix->getnentries(ii);
223  yerrvalsall[ii] = ipix->getsumsquares(ii) / (float)(ipix->getnentries(ii));
224  yerrvalsall[ii] -= pow(yvalsall[ii], 2);
225  yerrvalsall[ii] = sqrt(yerrvalsall[ii]) / sqrt(ipix->getnentries(ii));
226 
227  if (yvalsall[ii] < lowmeanval)
228  lowmeanval = yvalsall[ii];
229  if (yvalsall[ii] > highmeanval)
230  highmeanval = yvalsall[ii];
231  }
232  }
233 
234  // calculate plateau value from last 4 entries
235  double plateauval = 0;
236  bool noPlateau = false;
237  if (nallpoints >= 4) {
238  for (int ii = nallpoints - 1; ii > nallpoints - 5; --ii)
239  plateauval += yvalsall[ii];
240  plateauval /= 4;
241  for (int ii = nallpoints - 1; ii > nallpoints - 5; --ii) {
242  if (fabs(yvalsall[ii] - plateauval) > 5) {
243  plateauval = 255;
244  noPlateau = true;
245  continue;
246  }
247  }
248 
249  int NbofPointsInPlateau = 0;
250  for (int ii = 0; ii < nallpoints; ++ii)
251  if (fabs(yvalsall[ii] - plateauval) < 10 || yvalsall[ii] == 0)
252  NbofPointsInPlateau++;
253  //summary_<<"row_"<<ipix->row()<<" col_"<<ipix->col()<<" "<<plateauval<<" "<<NbofPointsInPlateau<<" "<<nallpoints<<endl;
254  if (NbofPointsInPlateau >= (nallpoints - 2)) {
255  status = -2;
256  bookkeeper_[detid]["status_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, status);
257  if (writeSummary_) {
258  summary_ << "row_" << ipix->row() << " col_" << ipix->col() << " status_" << status << endl;
259  statusNumbers_[abs(status)]++;
260  }
261  return false;
262  }
263  } else
264  plateauval = 255;
265 
266  double maxgoodvalinfit = plateauval * (1. - reject_badpoints_frac_);
267  npoints = 0;
268  for (int ii = 0; ii < nallpoints; ++ii) {
269  // now selecting the appropriate points for the fit.
270  use_point = true;
271  if (reject_first_point_ && xvalsall[ii] < 0.1)
272  use_point = false;
273  if (ipix->getnentries(ii) <= min_nentries_ && reject_single_entries_)
274  use_point = false;
275  if (ipix->getnentries(ii) == 0 && reject_badpoints_)
276  use_point = false;
277  if (yvalsall[ii] > maxgoodvalinfit && !noPlateau)
278  use_point = false;
279  if (ii > 1 && fabs(yvalsall[ii] - yvalsall[ii - 1]) < 5. && yvalsall[ii] > 0.8 * maxgoodvalinfit &&
281  use_point = false;
282  break;
283  }
284 
285  if (use_point) {
286  xvals[npoints] = xvalsall[ii];
287  yvals[npoints] = yvalsall[ii];
288  yerrvals[npoints] = yerrvalsall[ii];
289  npoints++;
290  }
291  }
292 
293  float chi2, slope, intercept, prob, slopeerror, intercepterror;
294  prob = chi2 = -1;
295  slope = intercept = slopeerror = intercepterror = 0;
296 
297  // now check on number of points. If bad just start taking the first 4:
298 
299  if (npoints < 4) {
300  npoints = 0;
301  for (int ii = 0; ii < nallpoints && npoints < 4 && yvalsall[ii] < plateauval * 0.97; ++ii) {
302  if (yvalsall[ii] > 0) {
303  if (ii > 0 && yvalsall[ii] - yvalsall[ii - 1] < 0.1)
304  continue;
305  xvals[npoints] = xvalsall[ii];
306  yvals[npoints] = yvalsall[ii];
307  yerrvals[npoints] = yerrvalsall[ii];
308  npoints++;
309  }
310  }
311  }
312  if (npoints < 2) {
313  status = -7;
314  bookkeeper_[detid]["status_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, status);
315  if (writeSummary_) {
316  summary_ << "row_" << ipix->row() << " col_" << ipix->col() << " status_" << status << endl;
317  statusNumbers_[abs(status)]++;
318  }
319  std::ostringstream pixelinfo;
320  pixelinfo << "GainCurve_row_" << ipix->row() << "_col_" << ipix->col();
321  std::string tempname = translateDetIdToString(detid);
322  tempname += "_";
323  tempname += pixelinfo.str();
324  setDQMDirectory(detid);
325  bookkeeper_pixels_[detid][pixelinfo.str()] = bookDQMHistogram1D(
326  detid, pixelinfo.str(), tempname, 105 * nallpoints, xvalsall[0], xvalsall[nallpoints - 1] * 1.05);
327  for (int ii = 0; ii < nallpoints; ++ii)
328  bookkeeper_pixels_[detid][pixelinfo.str()]->Fill(xvalsall[ii], yvalsall[ii]);
329  return false;
330  }
331 
332  // std::cout << "starting fit!" << std::endl;
333  graph_->Set(npoints);
334 
335  func_->SetParameter(0, 50.);
336  func_->SetParameter(1, 0.25);
337  for (int ipointtemp = 0; ipointtemp < npoints; ++ipointtemp) {
338  graph_->SetPoint(ipointtemp, xvals[ipointtemp], yvals[ipointtemp]);
339  graph_->SetPointError(ipointtemp, 0, yerrvals[ipointtemp]);
340  }
341  Int_t tempresult = graph_->Fit(func_, "FQ0N");
342  slope = func_->GetParameter(1);
343  slopeerror = func_->GetParError(1);
344  intercept = func_->GetParameter(0);
345  intercepterror = func_->GetParError(0);
346  chi2 = func_->GetChisquare() / ((float)npoints - func_->GetNpar());
347  prob = TMath::Prob(func_->GetChisquare(), npoints - func_->GetNpar());
348  size_t ntimes = 0;
349  while ((isnan(slope) || isnan(intercept)) && ntimes < 10) {
350  ntimes++;
351  makehistopersistent = true;
352  // std::cout << slope << " " << intercept << " " << prob << std::endl;
353  edm::LogWarning("SiPixelGainCalibrationAnalysis") << "impossible to fit values, try " << ntimes << ": ";
354  for (int ii = 0; ii < npoints; ++ii) {
355  edm::LogWarning("SiPixelGainCalibrationAnalysis")
356  << "vcal " << xvals[ii] << " response: " << yvals[ii] << "+/-" << yerrvals[ii] << std::endl;
357  }
358  tempresult = graph_->Fit(func_, "FQ0NW");
359  slope = func_->GetParameter(1);
360  slopeerror = func_->GetParError(1);
361  intercept = func_->GetParameter(0);
362  intercepterror = func_->GetParError(0);
363  chi2 = func_->GetChisquare() / ((float)npoints - func_->GetNpar());
364  prob = TMath::Prob(func_->GetChisquare(), npoints - func_->GetNpar());
365  }
366 
367  if (tempresult == 0)
368  status = 1;
369  else
370  status = 0;
371  if (slope != 0)
372  slope = 1. / slope;
373  if (isnan(slope) || isnan(intercept)) {
374  status = -6;
375  bookkeeper_[detid]["status_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, status);
376  if (writeSummary_) {
377  summary_ << "row_" << ipix->row() << " col_" << ipix->col() << " status_" << status << endl;
378  statusNumbers_[abs(status)]++;
379  }
380  //return false;
381  }
382  if (chi2 > chi2Threshold_ && chi2Threshold_ >= 0)
383  status = 5;
384  if (prob < chi2ProbThreshold_)
385  status = 5;
386  if (noPlateau)
387  status = 3;
388  if (nallpoints < 4)
389  status = -7;
390  if (TMath::Abs(slope > maxGainInHist_) || slope < 0)
391  status = -8;
392  if (status != 1)
393  makehistopersistent = true;
394  statusNumbers_[abs(status)]++;
395 
396  if (slope < gainlow_)
397  gainlow_ = slope;
398  if (slope > gainhi_)
399  gainhi_ = slope;
400  if (intercept > pedhi_)
401  pedhi_ = intercept;
402  if (intercept < pedlow_)
403  pedlow_ = intercept;
404  bookkeeper_[detid]["gain_1d"]->Fill(slope);
405  if (slope > maxGainInHist_) {
406  makehistopersistent = true;
407  edm::LogWarning("SiPixelGainCalibration")
408  << "For DETID " << detid << "pixel row,col " << ipix->row() << "," << ipix->col() << " Gain was measured to be "
409  << slope << " which is outside the range of the summary plot (" << maxGainInHist_ << ") !!!! " << std::endl;
410  }
411  bookkeeper_[detid]["dynamicrange_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, highmeanval - lowmeanval);
412  bookkeeper_[detid]["plateau_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, highmeanval);
413  bookkeeper_[detid]["gain_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, slope);
414  bookkeeper_[detid]["errorgain_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, slopeerror);
415  bookkeeper_[detid]["ped_1d"]->Fill(intercept);
416  bookkeeper_[detid]["ped_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, intercept);
417  bookkeeper_[detid]["errorped_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, intercepterror);
418  bookkeeper_[detid]["chi2_1d"]->Fill(chi2);
419  bookkeeper_[detid]["chi2_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, chi2);
420  bookkeeper_[detid]["prob_1d"]->Fill(prob);
421  bookkeeper_[detid]["prob_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, prob);
422  bookkeeper_[detid]["lowpoint_1d"]->Fill(xvals[0]);
423  bookkeeper_[detid]["lowpoint_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, xvals[0]);
424  bookkeeper_[detid]["highpoint_1d"]->Fill(xvals[npoints - 1]);
425  bookkeeper_[detid]["highpoint_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, xvals[npoints - 1]);
426  bookkeeper_[detid]["nfitpoints_1d"]->Fill(npoints);
427  bookkeeper_[detid]["endpoint_1d"]->Fill((255 - intercept) * slope);
428  bookkeeper_[detid]["status_2d"]->setBinContent(ipix->col() + 1, ipix->row() + 1, status);
429 
430  if (!savePixelHists_)
431  return true;
432  if (detidfinder == listofdetids_.end() && !listofdetids_.empty())
433  return true;
434  if (makehistopersistent) {
435  std::ostringstream pixelinfo;
436  pixelinfo << "GainCurve_row_" << ipix->row() << "_col_" << ipix->col();
437  std::string tempname = translateDetIdToString(detid);
438  tempname += "_";
439  tempname += pixelinfo.str();
440 
441  // and book the histo
442  // fill the last value of the vcal array...
443 
444  setDQMDirectory(detid);
445  bookkeeper_pixels_[detid][pixelinfo.str()] = bookDQMHistogram1D(
446  detid, pixelinfo.str(), tempname, 105 * nallpoints, xvalsall[0], xvalsall[nallpoints - 1] * 1.05);
447 
448  edm::LogInfo("SiPixelGainCalibrationAnalysis")
449  << "now saving histogram for pixel " << tempname << ", gain = " << slope << ", pedestal = " << intercept
450  << ", chi2/NDF=" << chi2 << "(prob:" << prob << "), fit status " << status;
451  for (int ii = 0; ii < nallpoints; ++ii) {
452  // std::cout << xvalsall[ii]<<","<<yvalsall[ii]<< " " << tempfloats[ii] << std::endl;
453  bookkeeper_pixels_[detid][pixelinfo.str()]->Fill(xvalsall[ii], yvalsall[ii]);
454  }
455 
456  // addTF1ToDQMMonitoringElement(bookkeeper_pixels_[detid][pixelinfo.str()],func_);
457 
458  if (writeSummary_) {
459  summary_ << "row_" << ipix->row() << " col_" << ipix->col();
460  summary_ << " status_" << status;
461  summary_ << endl;
462 
463  //std::cout<<detid<<" "<<"row " <<ipix->row()<<" col "<<ipix->col()<<" "<<status<<" "<<chi2<<" "<<prob<<" "<<npoints<<" "<<xvals[0]<<" "<<xvals[npoints-1]<<" "<<plateauval<<std::endl;
464  }
465  }
466  return true;
467 }
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_pixels_
static const double slope[3]
std::string translateDetIdToString(uint32_t detid)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool isnan(float x)
Definition: math.h:13
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
T Abs(T a)
Definition: MathUtil.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int npoints
ii
Definition: cuy.py:590
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void SiPixelGainCalibrationAnalysis::doSetup ( const edm::ParameterSet )
void SiPixelGainCalibrationAnalysis::fillDatabase ( )
private

Definition at line 176 of file SiPixelGainCalibrationAnalysis.cc.

Referenced by calibrationEnd().

176  {
177  // only create when necessary.
178  // process the minimum and maximum gain & ped values...
179  edm::LogError("SiPixelGainCalibration::fillDatabase()")
180  << "PLEASE do not fill the database directly from the gain calibration analyzer. This function is currently "
181  "disabled and no DB payloads will be produced!"
182  << std::endl;
183 }
void SiPixelGainCalibrationAnalysis::newDetID ( uint32_t  detid)
overrideprivatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 469 of file SiPixelGainCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D(), SiPixelOfflineCalibAnalysisBase::bookDQMHistoPlaquetteSummary2D(), bookkeeper_, DEFINE_FWK_MODULE, maxChi2InHist_, maxGainInHist_, scalarVcalHigh_VcalLow_, SiPixelOfflineCalibAnalysisBase::setDQMDirectory(), AlCaHLTBitMon_QueryRunRegistry::string, and SiPixelOfflineCalibAnalysisBase::translateDetIdToString().

469  {
470  setDQMDirectory(detid);
471  std::string tempname = translateDetIdToString(detid);
472  bookkeeper_[detid]["gain_1d"] = bookDQMHistogram1D(detid, "Gain1d", "gain for " + tempname, 100, 0., maxGainInHist_);
473  bookkeeper_[detid]["gain_2d"] = bookDQMHistoPlaquetteSummary2D(detid, "Gain2d", "gain for " + tempname);
474  bookkeeper_[detid]["errorgain_2d"] =
475  bookDQMHistoPlaquetteSummary2D(detid, "ErrorGain2d", "error on gain for " + tempname);
476  bookkeeper_[detid]["ped_1d"] = bookDQMHistogram1D(detid, "Pedestal1d", "pedestal for " + tempname, 256, 0., 256.0);
477  bookkeeper_[detid]["ped_2d"] = bookDQMHistoPlaquetteSummary2D(detid, "Pedestal2d", "pedestal for " + tempname);
478  bookkeeper_[detid]["errorped_2d"] =
479  bookDQMHistoPlaquetteSummary2D(detid, "ErrorPedestal2d", "error on pedestal for " + tempname);
480  bookkeeper_[detid]["chi2_1d"] =
481  bookDQMHistogram1D(detid, "GainChi2NDF1d", "#chi^{2}/NDOF for " + tempname, 100, 0., maxChi2InHist_);
482  bookkeeper_[detid]["chi2_2d"] =
483  bookDQMHistoPlaquetteSummary2D(detid, "GainChi2NDF2d", "#chi^{2}/NDOF for " + tempname);
484  bookkeeper_[detid]["prob_1d"] =
485  bookDQMHistogram1D(detid, "GainChi2Prob1d", "P(#chi^{2},NDOF) for " + tempname, 100, 0., 1.0);
486  bookkeeper_[detid]["prob_2d"] =
487  bookDQMHistoPlaquetteSummary2D(detid, "GainChi2Prob2d", "P(#chi^{2},NDOF) for " + tempname);
488  bookkeeper_[detid]["status_2d"] =
489  bookDQMHistoPlaquetteSummary2D(detid, "GainFitResult2d", "Fit result for " + tempname);
490  bookkeeper_[detid]["endpoint_1d"] = bookDQMHistogram1D(
491  detid, "GainEndPoint1d", "point where fit meets ADC=255 for " + tempname, 256, 0., 256. * scalarVcalHigh_VcalLow_);
492  bookkeeper_[detid]["lowpoint_1d"] = bookDQMHistogram1D(
493  detid, "GainLowPoint1d", "lowest fit point for " + tempname, 256, 0., 256. * scalarVcalHigh_VcalLow_);
494  bookkeeper_[detid]["highpoint_1d"] = bookDQMHistogram1D(
495  detid, "GainHighPoint1d", "highest fit point for " + tempname, 256, 0., 256. * scalarVcalHigh_VcalLow_);
496  bookkeeper_[detid]["nfitpoints_1d"] =
497  bookDQMHistogram1D(detid, "GainNPoints1d", "number of fit point for " + tempname, 20, 0., 20);
498  bookkeeper_[detid]["dynamicrange_2d"] = bookDQMHistoPlaquetteSummary2D(
499  detid, "GainDynamicRange2d", "Difference lowest and highest points on gain curve for " + tempname);
500  bookkeeper_[detid]["lowpoint_2d"] =
501  bookDQMHistoPlaquetteSummary2D(detid, "GainLowPoint2d", "lowest fit point for " + tempname);
502  bookkeeper_[detid]["highpoint_2d"] =
503  bookDQMHistoPlaquetteSummary2D(detid, "GainHighPoint2d", "highest fit point for " + tempname);
504  bookkeeper_[detid]["plateau_2d"] =
505  bookDQMHistoPlaquetteSummary2D(detid, "GainSaturate2d", "Highest points on gain curve for " + tempname);
506 }
std::string translateDetIdToString(uint32_t detid)
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
void SiPixelGainCalibrationAnalysis::printSummary ( )
private

Definition at line 127 of file SiPixelGainCalibrationAnalysis.cc.

References begin, bookkeeper_, bookkeeper_pixels_, CalculateAveragePerColumn(), chi2Threshold_, mps_fire::i, cuy::ii, genParticles_cff::map, statusNumbers_, summary_, and SiPixelOfflineCalibAnalysisBase::translateDetIdToString().

Referenced by calibrationEnd().

127  {
128  uint32_t detid = 0;
129  for (std::map<uint32_t, std::map<std::string, MonitorElement *> >::const_iterator idet = bookkeeper_.begin();
130  idet != bookkeeper_.end();
131  ++idet) {
132  if (detid == idet->first)
133  continue; // only do things once per detid
134  detid = idet->first;
135  std::vector<float> gainvec = CalculateAveragePerColumn(detid, "gain_2d");
136  std::vector<float> pedvec = CalculateAveragePerColumn(detid, "ped_2d");
137  std::vector<float> chi2vec = CalculateAveragePerColumn(detid, "chi2_2d");
138  std::ostringstream summarytext;
139 
140  summarytext << "Summary for det ID " << detid << "(" << translateDetIdToString(detid) << ")\n";
141  summarytext << "\t Following: values per column: column #, gain, pedestal, chi2\n";
142  for (uint32_t i = 0; i < gainvec.size(); i++)
143  summarytext << "\t " << i << " \t" << gainvec[i] << " \t" << pedvec[i] << " \t" << chi2vec[i] << "\n";
144  summarytext << "\t list of pixels with high chi2 (chi2> " << chi2Threshold_ << "): \n";
145 
146  for (std::map<std::string, MonitorElement *>::const_iterator ipix = bookkeeper_pixels_[detid].begin();
147  ipix != bookkeeper_pixels_[detid].end();
148  ++ipix)
149  summarytext << "\t " << ipix->first << "\n";
150  edm::LogInfo("SiPixelGainCalibrationAnalysis") << summarytext.str() << std::endl;
151  }
152  if (summary_.is_open()) {
153  summary_.close();
154  summary_.open("Summary.txt");
155  summary_ << "Total Number of Pixel computed :" << statusNumbers_[9] << endl;
156  summary_ << "Number of pixel tagged with status :" << endl;
157  for (int ii = 0; ii < 9; ii++)
158  summary_ << ii << " -> " << statusNumbers_[ii] << " ~ "
159  << double(statusNumbers_[ii]) / double(statusNumbers_[9]) * 100. << " %" << endl;
160 
161  summary_.close();
162  }
163 }
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_pixels_
std::string translateDetIdToString(uint32_t detid)
ii
Definition: cuy.py:590
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
std::vector< float > CalculateAveragePerColumn(uint32_t detid, std::string label)
#define begin
Definition: vmac.h:32

Member Data Documentation

bool SiPixelGainCalibrationAnalysis::appendMode_
private

Definition at line 101 of file SiPixelGainCalibrationAnalysis.h.

bool SiPixelGainCalibrationAnalysis::bookBIGCalibPayload_
private

Definition at line 87 of file SiPixelGainCalibrationAnalysis.h.

std::map<uint32_t, std::map<std::string, MonitorElement *> > SiPixelGainCalibrationAnalysis::bookkeeper_
private
std::map<uint32_t, std::map<std::string, MonitorElement *> > SiPixelGainCalibrationAnalysis::bookkeeper_pixels_
private

Definition at line 69 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and printSummary().

double SiPixelGainCalibrationAnalysis::chi2ProbThreshold_
private

Definition at line 90 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::chi2Threshold_
private

Definition at line 89 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and printSummary().

edm::ParameterSet SiPixelGainCalibrationAnalysis::conf_
private

Definition at line 66 of file SiPixelGainCalibrationAnalysis.h.

uint32_t SiPixelGainCalibrationAnalysis::currentDetID_
private

Definition at line 118 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

bool SiPixelGainCalibrationAnalysis::filldb_
private

Definition at line 96 of file SiPixelGainCalibrationAnalysis.h.

Referenced by calibrationEnd().

std::string SiPixelGainCalibrationAnalysis::fitfunction_
private

Definition at line 73 of file SiPixelGainCalibrationAnalysis.h.

Referenced by SiPixelGainCalibrationAnalysis().

TF1* SiPixelGainCalibrationAnalysis::func_
private

Definition at line 74 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

float SiPixelGainCalibrationAnalysis::gainhi_
private

Definition at line 109 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

float SiPixelGainCalibrationAnalysis::gainlow_
private

Definition at line 108 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

TGraphErrors* SiPixelGainCalibrationAnalysis::graph_
private

Definition at line 75 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

bool SiPixelGainCalibrationAnalysis::ignoreMode_
private

Definition at line 78 of file SiPixelGainCalibrationAnalysis.h.

Referenced by checkCorrectCalibrationType().

std::vector<uint32_t> SiPixelGainCalibrationAnalysis::listofdetids_
private

Definition at line 77 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::maxChi2InHist_
private

Definition at line 92 of file SiPixelGainCalibrationAnalysis.h.

Referenced by newDetID().

double SiPixelGainCalibrationAnalysis::maxGainInHist_
private

Definition at line 91 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and newDetID().

uint16_t SiPixelGainCalibrationAnalysis::min_nentries_
private

Definition at line 112 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

int SiPixelGainCalibrationAnalysis::nfitparameters_
private

Definition at line 72 of file SiPixelGainCalibrationAnalysis.h.

Referenced by SiPixelGainCalibrationAnalysis().

float SiPixelGainCalibrationAnalysis::pedhi_
private

Definition at line 111 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

float SiPixelGainCalibrationAnalysis::pedlow_
private

Definition at line 110 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::plateau_max_slope_
private

Definition at line 84 of file SiPixelGainCalibrationAnalysis.h.

std::string SiPixelGainCalibrationAnalysis::recordName_
private

Definition at line 100 of file SiPixelGainCalibrationAnalysis.h.

bool SiPixelGainCalibrationAnalysis::reject_badpoints_
private

Definition at line 81 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::reject_badpoints_frac_
private

Definition at line 86 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::reject_first_point_
private

Definition at line 85 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::reject_plateaupoints_
private

Definition at line 82 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::reject_single_entries_
private

Definition at line 83 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

bool SiPixelGainCalibrationAnalysis::saveALLHistograms_
private

Definition at line 93 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::savePixelHists_
private

Definition at line 88 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::scalarVcalHigh_VcalLow_
private
int* SiPixelGainCalibrationAnalysis::statusNumbers_
private
bool SiPixelGainCalibrationAnalysis::sum_gain_cols_
private

Definition at line 95 of file SiPixelGainCalibrationAnalysis.h.

bool SiPixelGainCalibrationAnalysis::sum_ped_cols_
private

Definition at line 94 of file SiPixelGainCalibrationAnalysis.h.

std::ofstream SiPixelGainCalibrationAnalysis::summary_
private
bool SiPixelGainCalibrationAnalysis::useVcalHigh_
private

Definition at line 113 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::writeSummary_
private

Definition at line 97 of file SiPixelGainCalibrationAnalysis.h.

Referenced by calibrationEnd(), and doFits().