For a start, you need a 2D histogram holding the
quantity you are interested in and the one you would like to use for
the reweighting (e.g. W boson pT
). Typically, such a
histogram can be produced by
calling TQHistoMakerAnalysisJob::bookHistogram("..."),
or by adding the histogram definition to an appropriate configuration
file (i.e. histograms.txt) file when running the analysis
job. Histograms can be defined by simple strings, as shown in the
following example.
TH2F('PT_W_vs_DPhill_WZDilep', '', 15, 0., 300., 24, 0., 3.14) << (Pt_WZDilep / 1000. : '#it{p}_{T}(W) [GeV]', DPhi_WZDilep : '#it{#Delta#phi}_{ll, WZ OS} [rad]' )
After you have produced your two-dimensional histogram and it resides in some sort of analysis ROOT file (for example, samples.root) you can retrieve it from the folder structure as usual.
TString filename = "/path/to/my/file/samples.root";
TQSampleFolder * samples = TQSampleFolder::loadSampleFolder(filename + ":samples_Nominal");
TQSampleDataReader * rd = new TQSampleDataReader(samples);
TH2 * hist = rd->getHistogram("bkg/?/diboson/NonWW/[ZW+ZZ]", "CutWCandPt/PT_W_vs_DPhill_WZDilep");
Additionally, you need the one dimensional histograms that you would like to use for the reweighting: (e.g. the W boson pT in data and Monte Carlo). Of course, you need to define them beforehand as described earlier.
TH1 * hw_bkg = rd->getHistogram("bkg/?/diboson/NonWW/[ZW+ZZ]", "CutWCandPt/PT_WCand_Coarse");
TH1 * hw_data = rd->getHistogram("data/? - bkg/?/Zjets - bkg/?/top - bkg/?/diboson/WW - bkg/?/diboson/NonWW/Wgamma", "CutWCandPt/PT_WCand_Coarse");
You might want to create a copy of the data histogram that will hold the ratio data/MC afterwards:
TH1 * hw = TQHistogramUtils::copyHistogram(hw_data);
hw->Divide(hw_bkg);
Now you can employ the following, very handy functionality that uses the 2D histogram and the 1D histogram with the weights and yields a 1D histogram that is reweighted.
TH1 * h_DPhill_bkg_rew = TQHistogramUtils::getReweightedHistogramY(h_bkg_WZ_CutWCandPt_PT_W_vs_DPhill_WZDilep , hw);