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
0042
0043
0044
0045
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);
0058 void doFastSubtraction(TH1F& Total, TH1F& Result, SbsRegion& leftRegion, SbsRegion& rightRegion);
0059 void printResults(std::string prefix = "");
0060 void saveResults(std::string outname);
0061
0062
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();
0069 void resetSBSProducts();
0070 };
0071
0072 #endif