CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/PhysicsTools/Utilities/interface/SideBandSubtraction.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_SideBandSubtraction_h
00002 #define PhysicsTools_SideBandSubtraction_h
00003 #include <string>
00004 #include "TROOT.h"
00005 #include "RooRealVar.h"
00006 
00007 class TH1F;
00008 class TF1;
00009 class RooAbsPdf;
00010 class RooDataSet;
00011 class RooFitResult;
00012 
00013 typedef struct 
00014 {
00015   Double_t min;
00016   Double_t max;
00017   std::string RegionName;
00018 } SbsRegion;
00019 
00020 class SideBandSubtract 
00021 {
00022  private:
00023   void print_plot(RooRealVar* printVar, std::string outname);
00024   Double_t getYield(std::vector<SbsRegion> Regions, RooAbsPdf *PDF);
00025   RooAbsPdf *BackgroundPDF;
00026   RooAbsPdf *ModelPDF;
00027   RooDataSet* Data;
00028   RooRealVar* SeparationVariable;
00029   bool verbose;
00030   std::vector<SbsRegion> SignalRegions;
00031   std::vector<SbsRegion> SideBandRegions;
00032   std::vector<TH1F> SideBandHistos;
00033   std::vector<TH1F> RawHistos;
00034   std::vector<TH1F> SBSHistos;
00035   std::vector<TH1F*> BaseHistos;
00036   TH1F* base_histo;
00037   RooFitResult *fit_result;
00038   Double_t SignalSidebandRatio;
00039  public:
00040   SideBandSubtract();
00041   /*
00042   SideBandSubtract(RooAbsPdf *model_shape, 
00043                    RooAbsPdf *bkg_shape, 
00044                    RooDataSet* data,
00045                    RooRealVar* sep_var,
00046                    bool verb);
00047   */
00048   SideBandSubtract(RooAbsPdf *model_shape, 
00049                    RooAbsPdf *bkg_shape, 
00050                    RooDataSet* data, 
00051                    RooRealVar* sep_var, 
00052                    std::vector<TH1F*> base, 
00053                    bool verb);
00054   ~SideBandSubtract();
00055   void addSignalRegion(Double_t min, Double_t max);
00056   void addSideBandRegion(Double_t min, Double_t max);
00057   int doGlobalFit();
00058   int doSubtraction(RooRealVar* variable,Double_t stsratio,Int_t index); //stsratio -> signal to sideband ratio
00059   void doFastSubtraction(TH1F &Total, TH1F &Result, SbsRegion& leftRegion, SbsRegion& rightRegion);
00060   void printResults(std::string prefix="");
00061   void saveResults(std::string outname);
00062   //the user may want to change the dataset pointer so they can do
00063   //various subtractions on subsets of the original dataset...
00064   void setDataSet(RooDataSet* newData);
00065   RooFitResult* getFitResult();
00066   std::vector<TH1F> getRawHistos();
00067   std::vector<TH1F> getSBSHistos();
00068   std::vector<TH1F*> getBaseHistos();
00069   Double_t getSTSRatio(); //returns signal-to-sideband ratio
00070   void resetSBSProducts(); //empties histograms 
00071 };
00072 
00073 #endif