CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoLocalCalo/HcalRecAlgos/interface/HBHEPulseShapeFlag.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 #ifndef HBHE_PULSESHAPE_FLAG_H_IKAJHGEWRHIGKHAWFIKGHAWIKGH
00003 #define HBHE_PULSESHAPE_FLAG_H_IKAJHGEWRHIGKHAWFIKGHAWIKGH
00004 //---------------------------------------------------------------------------
00005 // Fitting-based algorithms for HBHE noise flagging
00006 // 
00007 // Included:
00008 //    1. Linear discriminator (chi2 from linear fit / chi2 from nominal fit)
00009 //    2. RMS8/Max ((RMS8/Max)^2 / chi2 from nominal fit)
00010 //    3. Triangle fit
00011 //
00012 // Original Author: Yi Chen (Caltech), 6351 (Nov. 8, 2010)
00013 //---------------------------------------------------------------------------
00014 #include <string>
00015 #include <vector>
00016 #include <map>
00017 //---------------------------------------------------------------------------
00018 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
00019 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00020 #include "DataFormats/HcalRecHit/interface/HBHERecHit.h"
00021 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalCaloFlagLabels.h"
00022 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00023 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00024 //---------------------------------------------------------------------------
00025 class HBHEPulseShapeFlagSetter;
00026 struct TriangleFitResult;
00027 //---------------------------------------------------------------------------
00028 class HBHEPulseShapeFlagSetter
00029 {
00030 public:
00031    HBHEPulseShapeFlagSetter();
00032    HBHEPulseShapeFlagSetter(double MinimumChargeThreshold, 
00033                             unsigned int TrianglePeakTS,
00034                             std::vector<double> LinearThreshold, 
00035                             std::vector<double> LinearCut,
00036                             std::vector<double> RMS8MaxThreshold,
00037                             std::vector<double> RMS8MaxCut,
00038                             std::vector<double> LeftSlopeThreshold, 
00039                             std::vector<double> LeftSlopeCut,
00040                             std::vector<double> RightSlopeThreshold, 
00041                             std::vector<double> RightSlopeCut,
00042                             std::vector<double> RightSlopeSmallThreshold, 
00043                             std::vector<double> RightSlopeSmallCut,
00044                             bool UseDualFit, 
00045                             bool TriangleIgnoreSlow);
00046    ~HBHEPulseShapeFlagSetter();
00047    void Clear();
00048    void SetPulseShapeFlags(HBHERecHit& hbhe, const HBHEDataFrame &digi,
00049       const HcalCoder &coder, const HcalCalibrations &calib);
00050    void Initialize();
00051 private:
00052    double mMinimumChargeThreshold;
00053    int mTrianglePeakTS;
00054    std::vector<double>  mCharge;  // stores charge for each TS in each digi
00055    // the pair is defined as (threshold, cut position)
00056    std::vector<std::pair<double, double> > mLambdaLinearCut;
00057    std::vector<std::pair<double, double> > mLambdaRMS8MaxCut;
00058    std::vector<std::pair<double, double> > mLeftSlopeCut;
00059    std::vector<std::pair<double, double> > mRightSlopeCut;
00060    std::vector<std::pair<double, double> > mRightSlopeSmallCut;
00061    bool mUseDualFit;
00062    bool mTriangleIgnoreSlow;
00063    std::vector<double> CumulativeIdealPulse;
00064 private:
00065    TriangleFitResult PerformTriangleFit(const std::vector<double> &Charge);
00066    double PerformNominalFit(const std::vector<double> &Charge);
00067    double PerformDualNominalFit(const std::vector<double> &Charge);
00068    double DualNominalFitSingleTry(const std::vector<double> &Charge, int Offset, int Distance);
00069    double CalculateRMS8Max(const std::vector<double> &Charge);
00070    double PerformLinearFit(const std::vector<double> &Charge);
00071 private:
00072    bool CheckPassFilter(double Charge, double Discriminant, std::vector<std::pair<double, double> > &Cuts,
00073       int Side);
00074 };
00075 //---------------------------------------------------------------------------
00076 struct TriangleFitResult
00077 {
00078    double Chi2;
00079    double LeftSlope;
00080    double RightSlope;
00081 };
00082 //---------------------------------------------------------------------------
00083 #endif
00084