CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual bool checkCorrectCalibrationType ()
 
virtual bool doFits (uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix)
 
void doSetup (const edm::ParameterSet &)
 
 SiPixelGainCalibrationAnalysis (const edm::ParameterSet &iConfig)
 
 ~SiPixelGainCalibrationAnalysis ()
 
- 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

std::vector< float > CalculateAveragePerColumn (uint32_t detid, std::string label)
 
virtual void calibrationEnd ()
 
virtual void calibrationSetup (const edm::EventSetup &iSetup)
 
void fillDatabase ()
 
virtual void newDetID (uint32_t detid)
 
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
 
- 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 Public Attributes inherited from SiPixelOfflineCalibAnalysisBase
static TF1 * fitFunction_ = NULL
 
- 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 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 48 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_.

34  :
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 
57  filldb_(iConfig.getUntrackedParameter<bool>("writeDatabase",false)),
58  writeSummary_(iConfig.getUntrackedParameter<bool>("writeSummary",true)),
60 
61  appendMode_(conf_.getUntrackedParameter<bool>("appendMode",true)),
62  /*theGainCalibrationDbInput_(0),
63  theGainCalibrationDbInputOffline_(0),
64  theGainCalibrationDbInputHLT_(0),
65  theGainCalibrationDbInputService_(iConfig),*/
66  gainlow_(10.),gainhi_(0.),pedlow_(255.),pedhi_(0.),
67  useVcalHigh_(conf_.getParameter<bool>("useVCALHIGH")),
68  scalarVcalHigh_VcalLow_(conf_.getParameter<double>("vcalHighToLowConversionFac"))
69 {
71  min_nentries_=1;
72  else
73  min_nentries_=0;
74  ::putenv((char*)"CORAL_AUTH_USER=me");
75  ::putenv((char*)"CORAL_AUTH_PASSWORD=test");
76  edm::LogInfo("SiPixelGainCalibrationAnalysis") << "now using fit function " << fitfunction_ << ", which has " << nfitparameters_ << " free parameters. " << std::endl;
77  func_= new TF1("func",fitfunction_.c_str(),0,256*scalarVcalHigh_VcalLow_);
78  graph_ = new TGraphErrors();
79  currentDetID_=0;
80  summary_.open("SummaryPerDetID.txt");
81  statusNumbers_ = new int[10];
82  for(int ii=0;ii<10;ii++)
83  statusNumbers_[ii]=0;
84 }
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_
int ii
Definition: cuy.py:588
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
SiPixelGainCalibrationAnalysis::~SiPixelGainCalibrationAnalysis ( )

Definition at line 86 of file SiPixelGainCalibrationAnalysis.cc.

87 {
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_, cond::rpcobgas::detid, diffTwoXMLs::label, and query::result.

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 }
tuple result
Definition: query.py:137
std::map< uint32_t, std::map< std::string, MonitorElement * > > bookkeeper_
void SiPixelGainCalibrationAnalysis::calibrationEnd ( )
privatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 173 of file SiPixelGainCalibrationAnalysis.cc.

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

173  {
174 
176 
177  // this is where we loop over all histograms and save the database objects
178  if(filldb_)
179  fillDatabase();
180 }
void SiPixelGainCalibrationAnalysis::calibrationSetup ( const edm::EventSetup iSetup)
privatevirtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 127 of file SiPixelGainCalibrationAnalysis.cc.

128 {
129 }
bool SiPixelGainCalibrationAnalysis::checkCorrectCalibrationType ( )
virtual

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 111 of file SiPixelGainCalibrationAnalysis.cc.

References SiPixelOfflineCalibAnalysisBase::calibrationMode_, and ignoreMode_.

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

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 190 of file SiPixelGainCalibrationAnalysis.cc.

References funct::abs(), SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D(), bookkeeper_, bookkeeper_pixels_, chi2ProbThreshold_, chi2Threshold_, currentDetID_, cond::rpcobgas::detid, spr::find(), func_, gainhi_, gainlow_, graph_, cuy::ii, edm::detail::isnan(), listofdetids_, maxGainInHist_, min_nentries_, pedhi_, pedlow_, funct::pow(), mix_2012_Summer_50ns_PoissonOOTPU_cfi::prob, reject_badpoints_, reject_badpoints_frac_, reject_first_point_, reject_plateaupoints_, reject_single_entries_, saveALLHistograms_, savePixelHists_, scalarVcalHigh_VcalLow_, SiPixelOfflineCalibAnalysisBase::setDQMDirectory(), slope, mathSSE::sqrt(), ntuplemaker::status, statusNumbers_, AlCaHLTBitMon_QueryRunRegistry::string, summary_, SiPixelOfflineCalibAnalysisBase::translateDetIdToString(), useVcalHigh_, SiPixelOfflineCalibAnalysisBase::vCalValues_, and writeSummary_.

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

Referenced by calibrationEnd().

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

Reimplemented from SiPixelOfflineCalibAnalysisBase.

Definition at line 471 of file SiPixelGainCalibrationAnalysis.cc.

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

472 {
475  bookkeeper_[detid]["gain_1d"] = bookDQMHistogram1D(detid,"Gain1d","gain for "+tempname,100,0.,maxGainInHist_);
476  bookkeeper_[detid]["gain_2d"] = bookDQMHistoPlaquetteSummary2D(detid, "Gain2d","gain for "+tempname);
477  bookkeeper_[detid]["errorgain_2d"] = bookDQMHistoPlaquetteSummary2D(detid, "ErrorGain2d","error on gain for "+tempname);
478  bookkeeper_[detid]["ped_1d"] = bookDQMHistogram1D(detid,"Pedestal1d","pedestal for "+tempname,256,0.,256.0);
479  bookkeeper_[detid]["ped_2d"] = bookDQMHistoPlaquetteSummary2D(detid,"Pedestal2d","pedestal for "+tempname);
480  bookkeeper_[detid]["errorped_2d"] = bookDQMHistoPlaquetteSummary2D(detid,"ErrorPedestal2d","error on pedestal for "+tempname);
481  bookkeeper_[detid]["chi2_1d"] = bookDQMHistogram1D(detid,"GainChi2NDF1d","#chi^{2}/NDOF for "+tempname,100,0.,maxChi2InHist_);
482  bookkeeper_[detid]["chi2_2d"] = bookDQMHistoPlaquetteSummary2D(detid,"GainChi2NDF2d","#chi^{2}/NDOF for "+tempname);
483  bookkeeper_[detid]["prob_1d"] = bookDQMHistogram1D(detid,"GainChi2Prob1d","P(#chi^{2},NDOF) for "+tempname,100,0.,1.0);
484  bookkeeper_[detid]["prob_2d"] = bookDQMHistoPlaquetteSummary2D(detid,"GainChi2Prob2d","P(#chi^{2},NDOF) for "+tempname);
485  bookkeeper_[detid]["status_2d"] = bookDQMHistoPlaquetteSummary2D(detid,"GainFitResult2d","Fit result for "+tempname);
486  bookkeeper_[detid]["endpoint_1d"]= bookDQMHistogram1D(detid,"GainEndPoint1d","point where fit meets ADC=255 for "+tempname,256,0.,256.*scalarVcalHigh_VcalLow_);
487  bookkeeper_[detid]["lowpoint_1d"]= bookDQMHistogram1D(detid,"GainLowPoint1d","lowest fit point for "+tempname,256,0.,256.*scalarVcalHigh_VcalLow_);
488  bookkeeper_[detid]["highpoint_1d"]= bookDQMHistogram1D(detid,"GainHighPoint1d","highest fit point for "+tempname,256,0.,256.*scalarVcalHigh_VcalLow_);
489  bookkeeper_[detid]["nfitpoints_1d"]= bookDQMHistogram1D(detid,"GainNPoints1d","number of fit point for "+tempname,20,0.,20);
490  bookkeeper_[detid]["dynamicrange_2d"]=bookDQMHistoPlaquetteSummary2D(detid,"GainDynamicRange2d","Difference lowest and highest points on gain curve for "+tempname);
491  bookkeeper_[detid]["lowpoint_2d"]=bookDQMHistoPlaquetteSummary2D(detid,"GainLowPoint2d","lowest fit point for "+tempname);
492  bookkeeper_[detid]["highpoint_2d"]=bookDQMHistoPlaquetteSummary2D(detid,"GainHighPoint2d","highest fit point for "+tempname);
493  bookkeeper_[detid]["plateau_2d"]=bookDQMHistoPlaquetteSummary2D(detid,"GainSaturate2d","Highest points on gain curve for "+tempname);
494 
495 }
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 132 of file SiPixelGainCalibrationAnalysis.cc.

References begin, bookkeeper_, bookkeeper_pixels_, CalculateAveragePerColumn(), chi2Threshold_, cond::rpcobgas::detid, i, cuy::ii, python.multivaluedict::map(), statusNumbers_, summary_, and SiPixelOfflineCalibAnalysisBase::translateDetIdToString().

Referenced by calibrationEnd().

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

Member Data Documentation

bool SiPixelGainCalibrationAnalysis::appendMode_
private

Definition at line 103 of file SiPixelGainCalibrationAnalysis.h.

bool SiPixelGainCalibrationAnalysis::bookBIGCalibPayload_
private

Definition at line 89 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 71 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and printSummary().

double SiPixelGainCalibrationAnalysis::chi2ProbThreshold_
private

Definition at line 92 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::chi2Threshold_
private

Definition at line 91 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and printSummary().

edm::ParameterSet SiPixelGainCalibrationAnalysis::conf_
private

Definition at line 68 of file SiPixelGainCalibrationAnalysis.h.

uint32_t SiPixelGainCalibrationAnalysis::currentDetID_
private

Definition at line 120 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

bool SiPixelGainCalibrationAnalysis::filldb_
private

Definition at line 98 of file SiPixelGainCalibrationAnalysis.h.

Referenced by calibrationEnd().

std::string SiPixelGainCalibrationAnalysis::fitfunction_
private

Definition at line 75 of file SiPixelGainCalibrationAnalysis.h.

Referenced by SiPixelGainCalibrationAnalysis().

TF1* SiPixelGainCalibrationAnalysis::func_
private

Definition at line 76 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

float SiPixelGainCalibrationAnalysis::gainhi_
private

Definition at line 111 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

float SiPixelGainCalibrationAnalysis::gainlow_
private

Definition at line 110 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

TGraphErrors* SiPixelGainCalibrationAnalysis::graph_
private

Definition at line 77 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

bool SiPixelGainCalibrationAnalysis::ignoreMode_
private

Definition at line 80 of file SiPixelGainCalibrationAnalysis.h.

Referenced by checkCorrectCalibrationType().

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

Definition at line 79 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::maxChi2InHist_
private

Definition at line 94 of file SiPixelGainCalibrationAnalysis.h.

Referenced by newDetID().

double SiPixelGainCalibrationAnalysis::maxGainInHist_
private

Definition at line 93 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and newDetID().

uint16_t SiPixelGainCalibrationAnalysis::min_nentries_
private

Definition at line 114 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

int SiPixelGainCalibrationAnalysis::nfitparameters_
private

Definition at line 74 of file SiPixelGainCalibrationAnalysis.h.

Referenced by SiPixelGainCalibrationAnalysis().

float SiPixelGainCalibrationAnalysis::pedhi_
private

Definition at line 113 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

float SiPixelGainCalibrationAnalysis::pedlow_
private

Definition at line 112 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::plateau_max_slope_
private

Definition at line 86 of file SiPixelGainCalibrationAnalysis.h.

std::string SiPixelGainCalibrationAnalysis::recordName_
private

Definition at line 102 of file SiPixelGainCalibrationAnalysis.h.

bool SiPixelGainCalibrationAnalysis::reject_badpoints_
private

Definition at line 83 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

double SiPixelGainCalibrationAnalysis::reject_badpoints_frac_
private

Definition at line 88 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::reject_first_point_
private

Definition at line 87 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::reject_plateaupoints_
private

Definition at line 84 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::reject_single_entries_
private

Definition at line 85 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits(), and SiPixelGainCalibrationAnalysis().

bool SiPixelGainCalibrationAnalysis::saveALLHistograms_
private

Definition at line 95 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::savePixelHists_
private

Definition at line 90 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 97 of file SiPixelGainCalibrationAnalysis.h.

bool SiPixelGainCalibrationAnalysis::sum_ped_cols_
private

Definition at line 96 of file SiPixelGainCalibrationAnalysis.h.

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

Definition at line 115 of file SiPixelGainCalibrationAnalysis.h.

Referenced by doFits().

bool SiPixelGainCalibrationAnalysis::writeSummary_
private

Definition at line 99 of file SiPixelGainCalibrationAnalysis.h.

Referenced by calibrationEnd(), and doFits().