28 for(detIDHistogramMap::iterator thisDetIdHistoGrams=
histograms_.begin(); thisDetIdHistoGrams !=
histograms_.end(); ++thisDetIdHistoGrams){
32 uint32_t
detid = (*thisDetIdHistoGrams).first;
34 std::string rocname = name.substr(0,name.size()-7);
37 int total_columns = sigmahist->
getNbinsX();
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);
45 for(
int fedid=0; fedid<=40; ++fedid){
47 if(converter.hasDetUnit(detid)){
53 std::cout<<
"error: could not obtain real fed ID"<<std::endl;
72 int newrow= locpixel.
rocRow();
73 int newcol = locpixel.
rocCol();
74 myfile<<rocname<<theRoc->
idInDetUnit()<<
" "<<newcol<<
" "<<newrow<<
" "<<thresholdhist->
getBinContent(icol+1, irow+1)<<
" "<<threshold_error;
84 void chi2toMinimize(
int &npar,
double* grad,
double &fcnval,
double* xval,
int iflag)
88 for (
int i = 0;
i < npar;
i++)
89 theFormula->SetParameter(
i, xval[
i]);
93 for (uint32_t i = 0; i < theVCalValues->size(); i++)
104 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Setting up calibration paramters.";
105 std::vector<uint32_t> anEmptyDefaultVectorOfUInts;
106 std::vector<uint32_t> detIDsToSaveVector_;
109 detIDsToSaveVector_ = iConfig.
getUntrackedParameter<std::vector<uint32_t> >(
"detIDsToSave", anEmptyDefaultVectorOfUInts);
128 for(
unsigned int i = 0;
i < detIDsToSaveVector_.size();
i++)
129 detIDsToSave_.insert( std::make_pair(detIDsToSaveVector_[
i],
true) );
141 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 std::ostringstream rootName;
145 rootName <<
"SCurve_row_" << row <<
"_col_" << col;
146 std::ostringstream humanName;
150 if (efficiencies.size() != numberOfVCalPoints || errors.size() != numberOfVCalPoints)
152 edm::LogError(
"SiPixelSCurveCalibrationAnalysis") <<
"Error saving single curve histogram! Number of Vcal values (" << numberOfVCalPoints <<
") does not match number of efficiency points or error points!";
159 for(
unsigned int iBin = 0; iBin < numberOfVCalPoints; ++iBin)
161 int rootBin = iBin + 1;
174 const std::vector<short>* theVCalValues = this->
getVcalValues();
175 unsigned int numberOfVCalPoints = theVCalValues->size();
176 edm::LogWarning(
"SiPixelSCurveCalibrationAnalysis") <<
"WARNING: Option set to save indiviual S-Curves - max number: "
177 <<
maxCurvesToSave_ <<
" This can lead to large memory consumption! (Got " << numberOfVCalPoints <<
" VCal Points";
178 for(
unsigned int i = 0;
i < numberOfVCalPoints;
i++)
181 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Adding calibration Vcal: " << (*theVCalValues)[
i];
208 bool allZeroSoFar =
true;
210 int saturationBin = -1;
211 for (uint32_t iVcalPt = 0; iVcalPt < eff.size(); iVcalPt++)
213 if (allZeroSoFar && eff[iVcalPt] != 0 ) {
215 allZeroSoFar =
false;
217 }
else if (eff[iVcalPt] > 0.90)
219 saturationBin = iVcalPt;
222 short delta = saturationVcal - turnOnVcal;
223 sigma = delta * 0.682;
226 threshold = turnOnVcal + (0.5 *
delta);
250 eff = (float)nADCResponse / (
float)nTriggers;
251 double effForErrorCalculation = eff;
252 if (eff <= 0 || eff >= 1)
253 effForErrorCalculation = 0.5 / (double)nTriggers;
254 error = TMath::Sqrt(effForErrorCalculation*(1-effForErrorCalculation) / (
double)nTriggers);
260 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Found a new DetID (" << detid <<
")! Checking to make sure it has not been added.";
263 std::pair<detIDHistogramMap::iterator, bool> insertResult;
264 insertResult =
histograms_.insert(std::make_pair(detid, tempMap));
265 if (insertResult.second)
267 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysisHistogramReport") <<
"Histogram Map.insert() returned true! Booking new histogrames for detID: " <<
detid;
277 insertResult.first->second.insert(std::make_pair(
kSigmas, D2sigma));
278 insertResult.first->second.insert(std::make_pair(
kThresholds, D2thresh));
279 insertResult.first->second.insert(std::make_pair(
kChi2s, D2chi2));
283 insertResult.first->second.insert(std::make_pair(
kFitResults, D2FitResult));
289 insertResult.first->second.insert(std::make_pair(
kSigmaSummary, D1sigma));
291 insertResult.first->second.insert(std::make_pair(
kChi2Summary, D1chi2));
292 insertResult.first->second.insert(std::make_pair(
kFitResultSummary, D1FitResult));
299 uint32_t nVCalPts = calibDigi->getnpoints();
303 for (uint32_t iVcalPt = 0; iVcalPt < nVCalPts; iVcalPt++)
308 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Eff: " << eff <<
" Error: " << error <<
" nEntries: " << calibDigi->getnentries(iVcalPt) <<
" nTriggers: " <<
nTriggers_ <<
" VCalPt " <<
vCalValues_[iVcalPt];
314 float thresholdGuess;
319 Double_t
sigma = -1.0;
320 Double_t sigmaError = -1.0;
322 Double_t thresholdError = -1.0;
323 Double_t amplitude = -1.0;
324 Double_t amplitudeError = -1.0;
325 Double_t
chi2 = -1.0;
328 Double_t chi2probability = 0;
330 if (errorFlag ==
errOK)
333 TMinuit *
gMinuit =
new TMinuit(3);
334 gMinuit->SetPrintLevel(-1);
338 gMinuit->DefineParameter(0,
"Threshold", (Double_t)thresholdGuess, 1, -50, 300);
340 gMinuit->DefineParameter(1,
"Sigma", (Double_t)sigmaGuess, 0.1, 0, 255);
342 gMinuit->DefineParameter(2,
"Amplitude", 1, 0.1, -0.001, 200);
346 gMinuit->GetParameter(0, threshold, thresholdError);
347 gMinuit->GetParameter(1, sigma, sigmaError);
348 gMinuit->GetParameter(2, amplitude, amplitudeError);
352 gMinuit->Eval(3,
NULL, chi2, params, 0);
357 chi2probability = TMath::Prob(chi2, nDOF);
365 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Fit finished with errorFlag: " << errorFlag <<
" - threshold: " << threshold <<
" sigma: " << sigma <<
" chi2: " << chi2 <<
" nDOF: " << nDOF <<
" chi2Prob: " << chi2probability <<
" chi2MinUser: " <<
minimumChi2prob_;
370 uint32_t row = calibDigi->row();
371 uint32_t col = calibDigi->col();
374 detIDHistogramMap::iterator thisDetIdHistoGrams;
378 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysisHistogramReport") <<
"Filling histograms for [detid](col/row): [" << detid <<
"](" << col <<
"/" << row <<
") ErrorFlag: " << errorFlag;
382 (*thisDetIdHistoGrams).second[
kFitResults]->setBinContent(col+1, row+1, errorFlag);
389 (*thisDetIdHistoGrams).second[
kSigmas]->setBinContent(col+1, row+1, sigma);
390 (*thisDetIdHistoGrams).second[
kThresholds]->setBinContent(col+1, row+1, threshold);
393 (*thisDetIdHistoGrams).second[
kChi2Summary]->Fill(chi2probability);
395 (*thisDetIdHistoGrams).second[
kChi2s]->Fill(col, row, chi2probability);
400 bool thisDetIDinList =
false;
402 thisDetIDinList =
true;
404 if (errorFlag !=
errOK || thisDetIDinList)
406 edm::LogError(
"SiPixelSCurveCalibrationAnalysis") <<
"Saving error histogram for [detid](col/row): [" << detid <<
"](" << col <<
"/" << row <<
") ErrorFlag: " << errorFlag;
std::string thresholdfilename_
virtual bool checkCorrectCalibrationType()
T getUntrackedParameter(std::string const &, T const &) const
virtual bool doFits(uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix)
void setBinContent(int binx, double content)
set content of bin (1-D)
void calculateEffAndError(int nADCResponse, int nTriggers, float &eff, float &error)
bool useDetectorHierarchyFolders_
void doSetup(const edm::ParameterSet &)
~SiPixelSCurveCalibrationAnalysis()
std::vector< float > vCalPointsAsFloats_
static std::vector< float > efficiencies_
std::string translateDetIdToString(uint32_t detid)
unsigned int curvesSavedCounter_
static std::vector< float > effErrors_
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
identify pixel inside single ROC
int getNbinsY(void) const
get # of bins in Y-axis
std::map< sCurveHistogramType, MonitorElement * > sCurveHistogramHolder
static TF1 * fitFunction_
std::map< uint32_t, bool > detIDsToSave_
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
double maximumEffAsymptote_
std::string getTitle(void) const
get MonitorElement title
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
sCurveErrorFlag estimateSCurveParameters(const std::vector< float > &eff, float &threshold, float &sigma)
static std::vector< short > vCalValues_
void makeThresholdSummary(void)
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
detIDHistogramMap histograms_
double collumn and pixel ID in double collumn representation
double minimumEffAsymptote_
virtual void newDetID(uint32_t detid)
double maximumThresholdBin_
sCurveErrorFlag fittedSCurveSanityCheck(float threshold, float sigma, float amplitude)
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
T const * product() const
virtual void calibrationEnd()
void chi2toMinimize(int &npar, double *grad, double &fcnval, double *xval, int iflag)
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
static const std::vector< short > * getVcalValues()
bool saveCurvesThatFlaggedBad_
std::string calibrationMode_
bool setDQMDirectory(std::string dirName)
unsigned int maxCurvesToSave_
edm::ESHandle< SiPixelFedCablingMap > theCablingMap_
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 void calibrationSetup(const edm::EventSetup &iSetup)