Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:37

0001 #ifndef CALIBTRACKER_SIPIXELSCURVECALIBRATION_SIPIXELSCURVE_CALIBRATION_H
0002 #define CALIBTRACKER_SIPIXELSCURVECALIBRATION_SIPIXELSCURVE_CALIBRATION_H
0003 //
0004 // Package:    SiPixelSCurveCalibrationAnalysis
0005 // Class:      SiPixelSCurveCalibrationAnalysis
0006 //
0007 /**\class SiPixelSCurveCalibrationAnalysis SiPixelSCurveCalibrationAnalysis.cc
0008  CalibTracker/SiPixelSCurveCalibration/src/SiPixelSCurveCalibrationAnalysis.cc
0009 
0010  Description: <one line class summary>
0011 
0012  Implementation:
0013      <Notes on implementation>
0014 */
0015 //
0016 // Original Author:  Evan Klose Friis
0017 //         Created:  Tue Nov 13 13:59:09 CET 2007
0018 //
0019 //
0020 
0021 // system include files
0022 #include <memory>
0023 
0024 // user include files
0025 #include "CalibTracker/SiPixelTools/interface/SiPixelOfflineCalibAnalysisBase.h"
0026 #include "TMinuit.h"
0027 #include <iomanip>
0028 //
0029 enum sCurveHistogramType {
0030   kSigmaSummary,      // 1d
0031   kSigmas,            // 2d
0032   kThresholdSummary,  // 1d
0033   kThresholds,        // 2d
0034   kChi2Summary,       // 1d
0035   kChi2s,             // 2d
0036   kFitResults,        // 2d
0037   kFitResultSummary   // 1d
0038 };
0039 
0040 enum sCurveErrorFlag {
0041   errNoDigi,            // default value (will actually never get passed to the analyzer,
0042                         // but included for consistency when viewing histograms)
0043   errOK,                // everything is OK
0044   errFlaggedBadByUser,  // fit converged, but parameters are outside a user
0045                         // specified range (i.e. noise (sigma) > 6 ADC counts)
0046   errBadChi2Prob,       // fit converged, but failed user specified chi2 test
0047   errFitNonPhysical,    // fit converged, but in a nonsensical region (i.e. vCalMax
0048                         // < threshold < 0, sigma > vCalMax, etc)
0049   errNoTurnOn,          // sCurve never turned on above 90%
0050   errAllZeros           // sCurve was all zeros.  This shouldn't ever happen, (all zeros
0051                         // would prevent a CalibDigi from being produced) but is included
0052                         // as a potential tool for potential future debugging
0053 };
0054 
0055 typedef dqm::legacy::MonitorElement MonitorElement;
0056 typedef std::map<sCurveHistogramType, MonitorElement *> sCurveHistogramHolder;
0057 typedef std::map<uint32_t, sCurveHistogramHolder> detIDHistogramMap;
0058 
0059 // class decleration
0060 //
0061 
0062 class SiPixelSCurveCalibrationAnalysis : public SiPixelOfflineCalibAnalysisBase {
0063 public:
0064   explicit SiPixelSCurveCalibrationAnalysis(const edm::ParameterSet &iConfig)
0065       : SiPixelOfflineCalibAnalysisBase(iConfig) {
0066     doSetup(iConfig);
0067   };
0068   ~SiPixelSCurveCalibrationAnalysis() override;
0069   void doSetup(const edm::ParameterSet &);
0070 
0071   bool doFits(uint32_t detid, std::vector<SiPixelCalibDigi>::const_iterator ipix) override;
0072 
0073   static std::vector<float> efficiencies_;
0074   static std::vector<float> effErrors_;
0075   std::vector<float> vCalPointsAsFloats_;  // need to save single histograms
0076 
0077   sCurveErrorFlag estimateSCurveParameters(const std::vector<float> &eff, float &threshold, float &sigma);
0078   sCurveErrorFlag fittedSCurveSanityCheck(float threshold, float sigma, float amplitude);
0079 
0080   void buildACurveHistogram(const uint32_t &detid,
0081                             const uint32_t &row,
0082                             const uint32_t &col,
0083                             sCurveErrorFlag errorFlag,
0084                             const std::vector<float> &efficiencies,
0085                             const std::vector<float> &errors);
0086 
0087 private:
0088   // configuration options
0089   bool useDetectorHierarchyFolders_;
0090   bool saveCurvesThatFlaggedBad_;
0091   unsigned int maxCurvesToSave_;  // define maximum number of curves to save, to
0092                                   // prevent huge memory consumption
0093   unsigned int curvesSavedCounter_;
0094   bool write2dHistograms_;
0095   bool write2dFitResult_;
0096   std::vector<std::string> plaquettesToSave_;
0097   bool printoutthresholds_;
0098   bool writeZeroes_;
0099   std::string thresholdfilename_;
0100   std::map<uint32_t, bool> detIDsToSave_;
0101 
0102   // parameters that define "bad curves"
0103   double minimumChi2prob_;
0104   double minimumThreshold_;
0105   double maximumThreshold_;
0106   double minimumSigma_;
0107   double maximumSigma_;
0108   double minimumEffAsymptote_;
0109   double maximumEffAsymptote_;
0110 
0111   // parameters that define histogram size/binning
0112   double maximumThresholdBin_;
0113   double maximumSigmaBin_;
0114 
0115   // holds histogrms entered
0116   detIDHistogramMap histograms_;
0117 
0118   void calibrationSetup(const edm::EventSetup &iSetup) override;
0119   bool checkCorrectCalibrationType() override;
0120   void newDetID(uint32_t detid) override;
0121   void makeThresholdSummary(void);
0122   void calibrationEnd() override;
0123 
0124   // ----------member data ---------------------------
0125 };
0126 
0127 #endif