Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:21

0001 #ifndef PhysicsTools_SideBandSubtraction_h
0002 #define PhysicsTools_SideBandSubtraction_h
0003 #include <string>
0004 #include "TROOT.h"
0005 #include "RooRealVar.h"
0006 
0007 class TH1F;
0008 class TF1;
0009 class RooAbsPdf;
0010 class RooDataSet;
0011 class RooFitResult;
0012 
0013 typedef struct {
0014   Double_t min;
0015   Double_t max;
0016   std::string RegionName;
0017 } SbsRegion;
0018 
0019 class SideBandSubtract {
0020 private:
0021   void print_plot(RooRealVar* printVar, std::string outname);
0022   Double_t getYield(const std::vector<SbsRegion>& Regions, RooAbsPdf* PDF);
0023   RooAbsPdf* BackgroundPDF;
0024   RooAbsPdf* ModelPDF;
0025   RooDataSet* Data;
0026   RooRealVar* SeparationVariable;
0027   bool verbose;
0028   std::vector<SbsRegion> SignalRegions;
0029   std::vector<SbsRegion> SideBandRegions;
0030   std::vector<TH1F> SideBandHistos;
0031   std::vector<TH1F> RawHistos;
0032   std::vector<TH1F> SBSHistos;
0033   std::vector<TH1F*> BaseHistos;
0034   TH1F* base_histo;
0035   RooFitResult* fit_result;
0036   Double_t SignalSidebandRatio;
0037 
0038 public:
0039   SideBandSubtract();
0040   /*
0041   SideBandSubtract(RooAbsPdf *model_shape, 
0042            RooAbsPdf *bkg_shape, 
0043            RooDataSet* data,
0044            RooRealVar* sep_var,
0045            bool verb);
0046   */
0047   SideBandSubtract(RooAbsPdf* model_shape,
0048                    RooAbsPdf* bkg_shape,
0049                    RooDataSet* data,
0050                    RooRealVar* sep_var,
0051                    const std::vector<TH1F*>& base,
0052                    bool verb);
0053   ~SideBandSubtract();
0054   void addSignalRegion(Double_t min, Double_t max);
0055   void addSideBandRegion(Double_t min, Double_t max);
0056   int doGlobalFit();
0057   int doSubtraction(RooRealVar* variable, Double_t stsratio, Int_t index);  //stsratio -> signal to sideband ratio
0058   void doFastSubtraction(TH1F& Total, TH1F& Result, SbsRegion& leftRegion, SbsRegion& rightRegion);
0059   void printResults(std::string prefix = "");
0060   void saveResults(std::string outname);
0061   //the user may want to change the dataset pointer so they can do
0062   //various subtractions on subsets of the original dataset...
0063   void setDataSet(RooDataSet* newData);
0064   RooFitResult* getFitResult();
0065   std::vector<TH1F> getRawHistos();
0066   std::vector<TH1F> getSBSHistos();
0067   std::vector<TH1F*> getBaseHistos();
0068   Double_t getSTSRatio();   //returns signal-to-sideband ratio
0069   void resetSBSProducts();  //empties histograms
0070 };
0071 
0072 #endif