28 for (detIDHistogramMap::iterator thisDetIdHistoGrams =
histograms_.begin(); thisDetIdHistoGrams !=
histograms_.end();
29 ++thisDetIdHistoGrams) {
33 uint32_t
detid = (*thisDetIdHistoGrams).first;
38 int total_columns = sigmahist->
getNbinsX();
40 for (
int irow = 0; irow < total_rows; ++irow) {
41 for (
int icol = 0; icol < total_columns; ++icol) {
42 float threshold_error = sigmahist->
getBinContent(icol + 1, irow + 1);
53 if (realfedID == -1) {
54 std::cout <<
"error: could not obtain real fed ID" << std::endl;
75 static_cast<unsigned int>(cabling.
link),
76 static_cast<unsigned int>(cabling.
roc)};
79 int newrow = locpixel.
rocRow();
80 int newcol = locpixel.
rocCol();
81 myfile << rocname << theRoc->
idInDetUnit() <<
" " << newcol <<
" " << newrow <<
" " 96 for (
int i = 0;
i < npar;
i++)
97 theFormula->SetParameter(
i,
xval[
i]);
101 for (uint32_t
i = 0;
i < theVCalValues->size();
i++) {
109 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Setting up calibration paramters.";
110 std::vector<uint32_t> anEmptyDefaultVectorOfUInts;
111 std::vector<uint32_t> detIDsToSaveVector_;
114 detIDsToSaveVector_ =
134 for (
unsigned int i = 0;
i < detIDsToSaveVector_.size();
i++)
135 detIDsToSave_.insert(std::make_pair(detIDsToSaveVector_[
i],
true));
147 const std::vector<float> &
errors) {
150 <<
"WARNING: Request to save curve for [detid](col/row): [" <<
detid <<
"](" <<
col <<
"/" << row
151 <<
") denied. Maximum number of saved curves (defined in .cfi) " 155 std::ostringstream rootName;
156 rootName <<
"SCurve_row_" << row <<
"_col_" <<
col;
157 std::ostringstream humanName;
162 if (
efficiencies.size() != numberOfVCalPoints ||
errors.size() != numberOfVCalPoints) {
164 <<
"Error saving single curve histogram! Number of Vcal values (" << numberOfVCalPoints
165 <<
") does not match number of efficiency points or error points!";
175 vcalValuesToPassToCrappyRoot);
178 for (
unsigned int iBin = 0; iBin < numberOfVCalPoints; ++iBin) {
179 int rootBin = iBin + 1;
193 const std::vector<short> *theVCalValues = this->
getVcalValues();
194 unsigned int numberOfVCalPoints = theVCalValues->size();
196 <<
"WARNING: Option set to save indiviual S-Curves - max number: " <<
maxCurvesToSave_ 197 <<
" This can lead to large memory consumption! (Got " << numberOfVCalPoints <<
" VCal Points";
198 for (
unsigned int i = 0;
i < numberOfVCalPoints;
i++) {
200 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysis") <<
"Adding calibration Vcal: " << (*theVCalValues)[
i];
207 "0.5*[2]*(1+TMath::Erf( (x-[0]) / ([1]*sqrt(2)) ) )",
231 bool allZeroSoFar =
true;
233 int saturationBin = -1;
234 for (uint32_t iVcalPt = 0; iVcalPt < eff.size(); iVcalPt++) {
235 if (allZeroSoFar && eff[iVcalPt] != 0) {
237 allZeroSoFar =
false;
239 }
else if (eff[iVcalPt] > 0.90) {
240 saturationBin = iVcalPt;
243 short delta = saturationVcal - turnOnVcal;
244 sigma =
delta * 0.682;
271 eff = (
float)nADCResponse / (
float)nTriggers;
272 double effForErrorCalculation = eff;
273 if (eff <= 0 || eff >= 1)
274 effForErrorCalculation = 0.5 / (double)nTriggers;
275 error = TMath::Sqrt(effForErrorCalculation * (1 - effForErrorCalculation) / (
double)nTriggers);
281 <<
"Found a new DetID (" <<
detid <<
")! Checking to make sure it has not been added.";
284 std::pair<detIDHistogramMap::iterator, bool> insertResult;
286 if (insertResult.second)
288 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysisHistogramReport")
289 <<
"Histogram Map.insert() returned true! Booking new histogrames for " 301 insertResult.first->second.insert(std::make_pair(
kSigmas, D2sigma));
302 insertResult.first->second.insert(std::make_pair(
kThresholds, D2thresh));
303 insertResult.first->second.insert(std::make_pair(
kChi2s, D2chi2));
307 insertResult.first->second.insert(std::make_pair(
kFitResults, D2FitResult));
317 insertResult.first->second.insert(std::make_pair(
kSigmaSummary, D1sigma));
319 insertResult.first->second.insert(std::make_pair(
kChi2Summary, D1chi2));
320 insertResult.first->second.insert(std::make_pair(
kFitResultSummary, D1FitResult));
326 uint32_t nVCalPts = calibDigi->getnpoints();
330 for (uint32_t iVcalPt = 0; iVcalPt < nVCalPts; iVcalPt++) {
335 <<
"Eff: " << eff <<
" Error: " <<
error <<
" nEntries: " << calibDigi->getnentries(iVcalPt)
342 float thresholdGuess = -1.0;
343 float sigmaGuess = -1.0;
348 Double_t sigma = -1.0;
349 Double_t sigmaError = -1.0;
351 Double_t thresholdError = -1.0;
353 Double_t amplitudeError = -1.0;
354 Double_t
chi2 = -1.0;
357 Double_t chi2probability = 0;
359 if (errorFlag ==
errOK)
362 TMinuit *gMinuit =
new TMinuit(3);
363 gMinuit->SetPrintLevel(-1);
367 gMinuit->DefineParameter(0,
"Threshold", (Double_t)thresholdGuess, 1, -50, 300);
369 gMinuit->DefineParameter(1,
"Sigma", (Double_t)sigmaGuess, 0.1, 0, 255);
371 gMinuit->DefineParameter(2,
"Amplitude", 1, 0.1, -0.001, 200);
375 gMinuit->GetParameter(0,
threshold, thresholdError);
376 gMinuit->GetParameter(1, sigma, sigmaError);
377 gMinuit->GetParameter(2,
amplitude, amplitudeError);
386 chi2probability = TMath::Prob(
chi2, nDOF);
395 <<
"Fit finished with errorFlag: " << errorFlag <<
" - threshold: " <<
threshold <<
" sigma: " << sigma
396 <<
" chi2: " <<
chi2 <<
" nDOF: " << nDOF <<
" chi2Prob: " << chi2probability
402 uint32_t row = calibDigi->row();
403 uint32_t
col = calibDigi->col();
406 detIDHistogramMap::iterator thisDetIdHistoGrams;
409 edm::LogInfo(
"SiPixelSCurveCalibrationAnalysisHistogramReport")
410 <<
"Filling histograms for [detid](col/row): [" <<
detid <<
"](" <<
col <<
"/" << row
411 <<
") ErrorFlag: " << errorFlag;
415 (*thisDetIdHistoGrams)
417 ->setBinContent(
col + 1,
425 (*thisDetIdHistoGrams)
427 ->setBinContent(
col + 1,
430 (*thisDetIdHistoGrams)
432 ->setBinContent(
col + 1,
437 (*thisDetIdHistoGrams).second[
kChi2Summary]->Fill(chi2probability);
439 (*thisDetIdHistoGrams).second[
kChi2s]->Fill(
col, row, chi2probability);
443 bool thisDetIDinList =
false;
445 thisDetIDinList =
true;
447 if (errorFlag !=
errOK || thisDetIDinList) {
448 edm::LogError(
"SiPixelSCurveCalibrationAnalysis") <<
"Saving error histogram for [detid](col/row): [" <<
detid 449 <<
"](" <<
col <<
"/" << row <<
") ErrorFlag: " << errorFlag;
std::string thresholdfilename_
std::map< sCurveHistogramType, MonitorElement * > sCurveHistogramHolder
void calculateEffAndError(int nADCResponse, int nTriggers, float &eff, float &error)
bool useDetectorHierarchyFolders_
void doSetup(const edm::ParameterSet &)
~SiPixelSCurveCalibrationAnalysis() override
std::vector< float > vCalPointsAsFloats_
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
static std::vector< float > efficiencies_
void calibrationSetup(const edm::EventSetup &iSetup) override
std::string translateDetIdToString(uint32_t detid)
unsigned int curvesSavedCounter_
Log< level::Error, false > LogError
static std::vector< float > effErrors_
identify pixel inside single ROC
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookDQMHistogram1D(uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
bool doFits(uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix) override
T const * product() const
static TF1 * fitFunction_
std::map< uint32_t, bool > detIDsToSave_
double maximumEffAsymptote_
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
sCurveErrorFlag estimateSCurveParameters(const std::vector< float > &eff, float &threshold, float &sigma)
static std::vector< short > vCalValues_
void makeThresholdSummary(void)
detIDHistogramMap histograms_
virtual int getNbinsY() const
get # of bins in Y-axis
bool checkCorrectCalibrationType() override
double collumn and pixel ID in double collumn representation
virtual std::string getTitle() const
get MonitorElement title
MonitorElement * bookDQMHistoPlaquetteSummary2D(uint32_t detid, std::string name, std::string title)
Log< level::Info, false > LogInfo
double minimumEffAsymptote_
double maximumThresholdBin_
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
sCurveErrorFlag fittedSCurveSanityCheck(float threshold, float sigma, float amplitude)
void calibrationEnd() override
void chi2toMinimize(int &npar, double *grad, double &fcnval, double *xval, int iflag)
void newDetID(uint32_t detid) override
static const std::vector< short > * getVcalValues()
bool saveCurvesThatFlaggedBad_
virtual int getNbinsX() const
get # of bins in X-axis
std::string calibrationMode_
bool setDQMDirectory(std::string dirName)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
unsigned int maxCurvesToSave_
Log< level::Warning, false > LogWarning
edm::ESHandle< SiPixelFedCablingMap > theCablingMap_
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
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 double getBinContent(int binx) const
get content of bin (1-D)