CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/CalibTracker/SiPixelSCurveCalibration/interface/SiPixelSCurveCalibrationAnalysis.h

Go to the documentation of this file.
00001 #ifndef CALIBTRACKER_SIPIXELSCURVECALIBRATION_SIPIXELSCURVE_CALIBRATION_H
00002 #define CALIBTRACKER_SIPIXELSCURVECALIBRATION_SIPIXELSCURVE_CALIBRATION_H
00003 //
00004 // Package:    SiPixelSCurveCalibrationAnalysis
00005 // Class:      SiPixelSCurveCalibrationAnalysis
00006 // 
00014 //
00015 // Original Author:  Evan Klose Friis
00016 //         Created:  Tue Nov 13 13:59:09 CET 2007
00017 // $Id: SiPixelSCurveCalibrationAnalysis.h,v 1.18 2008/08/29 14:57:27 fblekman Exp $
00018 //
00019 //
00020 
00021 
00022 // system include files
00023 #include <memory>
00024 
00025 // user include files
00026 #include "CalibTracker/SiPixelTools/interface/SiPixelOfflineCalibAnalysisBase.h"
00027 #include "TMinuit.h"
00028 #include <iomanip>
00029 //
00030 enum sCurveHistogramType {
00031    kSigmaSummary,       //1d
00032    kSigmas,             //2d
00033    kThresholdSummary,   //1d
00034    kThresholds,         //2d
00035    kChi2Summary,        //1d
00036    kChi2s,              //2d
00037    kFitResults,         //2d
00038    kFitResultSummary   //1d
00039 };
00040 
00041 enum sCurveErrorFlag {
00042    errNoDigi,                   //default value (will actually never get passed to the analyzer, but included for consistency when viewing histograms) 
00043    errOK,                       //everything is OK
00044    errFlaggedBadByUser,         //fit converged, but parameters are outside a user specified range (i.e. noise (sigma) > 6 ADC counts)
00045    errBadChi2Prob,              //fit converged, but failed user specified chi2 test
00046    errFitNonPhysical,           //fit converged, but in a nonsensical region (i.e. vCalMax < threshold < 0, sigma > vCalMax, etc)
00047    errNoTurnOn,                 //sCurve never turned on above 90%
00048    errAllZeros                  //sCurve was all zeros.  This shouldn't ever happen, (all zeros would prevent a CalibDigi from being produced) but is included as a potential tool for potential future debugging        
00049 };
00050 
00051 
00052 typedef std::map<sCurveHistogramType, MonitorElement*> sCurveHistogramHolder;
00053 typedef std::map<uint32_t, sCurveHistogramHolder> detIDHistogramMap;
00054 
00055 // class decleration
00056 //
00057 
00058 class SiPixelSCurveCalibrationAnalysis : public SiPixelOfflineCalibAnalysisBase {
00059    public:
00060       explicit SiPixelSCurveCalibrationAnalysis(const edm::ParameterSet& iConfig):SiPixelOfflineCalibAnalysisBase(iConfig){doSetup(iConfig);};
00061       ~SiPixelSCurveCalibrationAnalysis();
00062       void doSetup(const edm::ParameterSet&);
00063 
00064       virtual bool doFits(uint32_t detid, std::vector<SiPixelCalibDigi>::const_iterator ipix);
00065 
00066       static std::vector<float> efficiencies_;
00067       static std::vector<float> effErrors_;
00068       std::vector<float> vCalPointsAsFloats_;  //need to save single histograms
00069 
00070       sCurveErrorFlag estimateSCurveParameters(const std::vector<float>& eff, float& threshold, float& sigma);
00071       sCurveErrorFlag fittedSCurveSanityCheck(float threshold, float sigma, float amplitude);
00072 
00073       void            buildACurveHistogram(const uint32_t& detid, const uint32_t& row, 
00074                                            const uint32_t& col, sCurveErrorFlag errorFlag, 
00075                                            const std::vector<float>& efficiencies, const std::vector<float>& errors);
00076 
00077    private:
00078       //configuration options
00079       bool                      useDetectorHierarchyFolders_;
00080       bool                      saveCurvesThatFlaggedBad_;
00081       unsigned int              maxCurvesToSave_;               //define maximum number of curves to save, to prevent huge memory consumption
00082       unsigned int              curvesSavedCounter_;
00083       bool                      write2dHistograms_;
00084       bool                      write2dFitResult_; 
00085       std::vector<std::string>  plaquettesToSave_;
00086       bool                      printoutthresholds_;
00087       bool                      writeZeroes_;
00088       std::string               thresholdfilename_;
00089       std::map<uint32_t, bool>  detIDsToSave_;      
00090 
00091 
00092       //parameters that define "bad curves"
00093       double                     minimumChi2prob_;
00094       double                     minimumThreshold_;
00095       double                     maximumThreshold_;
00096       double                     minimumSigma_;
00097       double                     maximumSigma_;
00098       double                     minimumEffAsymptote_;
00099       double                     maximumEffAsymptote_;
00100 
00101       //parameters that define histogram size/binning
00102       double                     maximumThresholdBin_;
00103       double                     maximumSigmaBin_;
00104 
00105       
00106       //holds histogrms entered
00107       detIDHistogramMap histograms_;
00108 
00109       virtual void calibrationSetup(const edm::EventSetup& iSetup);
00110       virtual bool checkCorrectCalibrationType();
00111       virtual void newDetID(uint32_t detid);
00112       void makeThresholdSummary(void);
00113       virtual void calibrationEnd() ;
00114       
00115       // ----------member data ---------------------------
00116 };
00117 
00118 #endif