27 for (detIDHistogramMap::iterator thisDetIdHistoGrams =
histograms_.begin(); thisDetIdHistoGrams !=
histograms_.end();
28 ++thisDetIdHistoGrams) {
32 uint32_t detid = (*thisDetIdHistoGrams).first;
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);
52 if (realfedID == -1) {
53 std::cout <<
"error: could not obtain real fed ID" << std::endl;
74 static_cast<unsigned int>(cabling.
link),
75 static_cast<unsigned int>(cabling.
roc)};
78 int newrow = locpixel.
rocRow();
79 int newcol = locpixel.
rocCol();
80 myfile << rocname << theRoc->
idInDetUnit() <<
" " << newcol <<
" " << newrow <<
" "
92 void chi2toMinimize(
int &npar,
double *grad,
double &fcnval,
double *xval,
int iflag) {
95 for (
int i = 0;
i < npar;
i++)
96 theFormula->SetParameter(
i, xval[
i]);
100 for (uint32_t
i = 0;
i < theVCalValues->size();
i++) {
108 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Setting up calibration paramters.";
109 std::vector<uint32_t> anEmptyDefaultVectorOfUInts;
110 std::vector<uint32_t> detIDsToSaveVector_;
113 detIDsToSaveVector_ =
133 for (
unsigned int i = 0;
i < detIDsToSaveVector_.size();
i++)
134 detIDsToSave_.insert(std::make_pair(detIDsToSaveVector_[
i],
true));
146 const std::vector<float> &
errors) {
149 <<
"WARNING: Request to save curve for [detid](col/row): [" << detid <<
"](" <<
col <<
"/" << row
150 <<
") denied. Maximum number of saved curves (defined in .cfi) "
154 std::ostringstream rootName;
155 rootName <<
"SCurve_row_" << row <<
"_col_" <<
col;
156 std::ostringstream humanName;
161 if (
efficiencies.size() != numberOfVCalPoints ||
errors.size() != numberOfVCalPoints) {
163 <<
"Error saving single curve histogram! Number of Vcal values (" << numberOfVCalPoints
164 <<
") does not match number of efficiency points or error points!";
174 vcalValuesToPassToCrappyRoot);
177 for (
unsigned int iBin = 0; iBin < numberOfVCalPoints; ++iBin) {
178 int rootBin = iBin + 1;
192 const std::vector<short> *theVCalValues = this->
getVcalValues();
193 unsigned int numberOfVCalPoints = theVCalValues->size();
195 <<
"WARNING: Option set to save indiviual S-Curves - max number: " <<
maxCurvesToSave_
196 <<
" This can lead to large memory consumption! (Got " << numberOfVCalPoints <<
" VCal Points";
197 for (
unsigned int i = 0;
i < numberOfVCalPoints;
i++) {
199 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Adding calibration Vcal: " << (*theVCalValues)[
i];
206 "0.5*[2]*(1+TMath::Erf( (x-[0]) / ([1]*sqrt(2)) ) )",
230 bool allZeroSoFar =
true;
232 int saturationBin = -1;
233 for (uint32_t iVcalPt = 0; iVcalPt < eff.size(); iVcalPt++) {
234 if (allZeroSoFar && eff[iVcalPt] != 0) {
236 allZeroSoFar =
false;
238 }
else if (eff[iVcalPt] > 0.90) {
239 saturationBin = iVcalPt;
242 short delta = saturationVcal - turnOnVcal;
243 sigma =
delta * 0.682;
270 eff = (
float)nADCResponse / (
float)nTriggers;
271 double effForErrorCalculation = eff;
272 if (eff <= 0 || eff >= 1)
273 effForErrorCalculation = 0.5 / (double)nTriggers;
274 error = TMath::Sqrt(effForErrorCalculation * (1 - effForErrorCalculation) / (
double)nTriggers);
280 <<
"Found a new DetID (" << detid <<
")! Checking to make sure it has not been added.";
283 std::pair<detIDHistogramMap::iterator, bool> insertResult;
284 insertResult =
histograms_.insert(std::make_pair(detid, tempMap));
285 if (insertResult.second)
287 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysisHistogramReport")
288 <<
"Histogram Map.insert() returned true! Booking new histogrames for "
300 insertResult.first->second.insert(std::make_pair(
kSigmas, D2sigma));
301 insertResult.first->second.insert(std::make_pair(
kThresholds, D2thresh));
302 insertResult.first->second.insert(std::make_pair(
kChi2s, D2chi2));
306 insertResult.first->second.insert(std::make_pair(
kFitResults, D2FitResult));
311 detid,
"ScurveThresholdSummary", detIdName +
" Thresholds Summary", 255, 0,
maximumThresholdBin_);
313 bookDQMHistogram1D(detid,
"ScurveChi2ProbSummary", detIdName +
" Chi2Prob Summary", 101, 0, 1.01);
315 bookDQMHistogram1D(detid,
"ScurveFitResultSummary", detIdName +
" Fit Result Summary", 10, -0.5, 9.5);
316 insertResult.first->second.insert(std::make_pair(
kSigmaSummary, D1sigma));
318 insertResult.first->second.insert(std::make_pair(
kChi2Summary, D1chi2));
319 insertResult.first->second.insert(std::make_pair(
kFitResultSummary, D1FitResult));
325 uint32_t nVCalPts = calibDigi->getnpoints();
329 for (uint32_t iVcalPt = 0; iVcalPt < nVCalPts; iVcalPt++) {
334 <<
"Eff: " << eff <<
" Error: " <<
error <<
" nEntries: " << calibDigi->getnentries(iVcalPt)
341 float thresholdGuess = -1.0;
342 float sigmaGuess = -1.0;
347 Double_t sigma = -1.0;
348 Double_t sigmaError = -1.0;
350 Double_t thresholdError = -1.0;
352 Double_t amplitudeError = -1.0;
353 Double_t
chi2 = -1.0;
356 Double_t chi2probability = 0;
358 if (errorFlag ==
errOK)
361 TMinuit *
gMinuit =
new TMinuit(3);
366 gMinuit->DefineParameter(0,
"Threshold", (Double_t)thresholdGuess, 1, -50, 300);
368 gMinuit->DefineParameter(1,
"Sigma", (Double_t)sigmaGuess, 0.1, 0, 255);
370 gMinuit->DefineParameter(2,
"Amplitude", 1, 0.1, -0.001, 200);
375 gMinuit->GetParameter(1, sigma, sigmaError);
385 chi2probability = TMath::Prob(
chi2, nDOF);
394 <<
"Fit finished with errorFlag: " << errorFlag <<
" - threshold: " <<
threshold <<
" sigma: " << sigma
395 <<
" chi2: " <<
chi2 <<
" nDOF: " << nDOF <<
" chi2Prob: " << chi2probability
401 uint32_t row = calibDigi->row();
402 uint32_t
col = calibDigi->col();
405 detIDHistogramMap::iterator thisDetIdHistoGrams;
408 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysisHistogramReport")
409 <<
"Filling histograms for [detid](col/row): [" << detid <<
"](" <<
col <<
"/" << row
410 <<
") ErrorFlag: " << errorFlag;
414 (*thisDetIdHistoGrams)
416 ->setBinContent(
col + 1,
424 (*thisDetIdHistoGrams)
426 ->setBinContent(
col + 1,
429 (*thisDetIdHistoGrams)
431 ->setBinContent(
col + 1,
436 (*thisDetIdHistoGrams).second[
kChi2Summary]->Fill(chi2probability);
438 (*thisDetIdHistoGrams).second[
kChi2s]->Fill(
col, row, chi2probability);
442 bool thisDetIDinList =
false;
444 thisDetIDinList =
true;
446 if (errorFlag !=
errOK || thisDetIDinList) {
447 edm::LogError(
"SiPixelSCurveCalibrationAnalysis") <<
"Saving error histogram for [detid](col/row): [" << detid
448 <<
"](" <<
col <<
"/" << row <<
") ErrorFlag: " << errorFlag;