Using RooUnfold with V+jets: Jet multiplicity and pt

Getting RooUnfold package

Start by downloading the RooUnfold package and putting in convenient location
Follow instructions on this website:
Also has some basic information on how RooUnfold works and how to use it.

Using RooUnfold

I load the library when starting root by putting the following line in rootlogon.C:
By doing this you can avoid including the header files in your code, if desired.
If you want to use the SVD unfolding option you need to edit the source code to avoid a seg fault, see SVD changes

The response matrix can be initialized and then filled. The parameters are TH1, detector level and gen level, to get the correct binning for each

  RooUnfoldResponse response (h_njets_det_placeholder,h_njets_gen_placeholder);
  response.Fill(detJetNum,genjetsNum, W); //This is the "training"
The response matrix can also be initialized with a TH2 of detector vs generator level information, and no need to fill event-by-event. Two TH1s corresponding to the gen and reco distributions (same as what goes into the TH2) are used for normalization.
  RooUnfoldResponse response (h_njets_det_placeholder, h_njets_gen_placeholder, h2D_DetNjetsGenNjets);  //"Training" included in the initialization
To do the unfolding, give the response matrix defined above, the distribution to be unfolded, and options. For Svd a "kterm" must be given, between 2 and the number of bins. For Bayes, the third parameter is the number of iterations, default is 4. For Invert and BinbyBin there is no third parameter.
  RooUnfold* unfoldNjetsDet  = new RooUnfoldSvd      (&response,  h_njetsDet,    kterm);
  RooUnfold* unfoldNjetsDet  = new RooUnfoldBayes    (&response,  h_njetsDet,    iterations);
  RooUnfold* unfoldNjetsDet  = new RooUnfoldInvert   (&response,  h_njetsDet);
  RooUnfold* unfoldNjetsDet  = new RooUnfoldBinByBin (&response,  h_njetsDet);
To save the resulting unfolded distribution, do the following:
  TH1F* h_njets_unfold_det = (TH1F*) unfoldNjetsDet->Hreco();
The unfolded distribution can then be compared to the original distributions and the generated distributions (if MC). Giving a histogram to be unfolded that is based on the same MC that is used to fill the response matrix is a useful closure test. Otherwise the unfolded histogram can come from a different MC or data. Code that does this can be found in UserCode/grogg/macros/ both rooUnfold.C or WenuJetsRooUnfold.C
The WenuJetsRooUnfold.C is highly dependent on the format of code I use.
rooUnfold.C is more independent but still relies on files with histograms with specific names.
The function void rooUnfold(TString type, TString trainFile, TString unfoldFile, TString njets, Int_t jetNum, bool fitFile) has the most condensed version
The output can be plotted using void plotUnfolding(TString hist_unfolded, double scaleUnfold, TString hist_gen, double scaleGen, TString hist_det, double scaleDet, TString hist_other = "", double scaleOther = 1, double ymax = 135000) which includes optional scale factors. It will produce a plot of the gen, det, unfolded distributions (or other optional distribution), as well as a ratio plot of the unfolded/gen.

SVD changes

You need to change in class src/RooUnfoldResponse.cxx the following:

RooUnfoldResponse::HresponseNoOverflow() const
  const TH2D* h= Hresponse();
  if (!_overflow){
    //return dynamic_cast<TH2D*>(h->Clone());}
    return (TH2D*)(h->Clone());}
  //the dymanic cast needs to be commented out, then it worked for me at least.

For the covariance matrix in class src/RooUnfHistoSvd.cxx:

    for (int i=0; i<ASV.GetNrows();i++){
        for (int j=0; j<ASV.GetNrows();j++){
you need to change the indices

-- KiraGrogg - 28-Dec-2010

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2011-01-14 - unknown
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback