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: http://hepunx.rl.ac.uk/~adye/software/unfold/RooUnfold.html
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:
gSystem->Load("/storage/RooUnfold-1.0.2/libRooUnfold");
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 dummy histograms, 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
  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:

TH2D*
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++){
            _covmatrix(i,j)=(_xini->GetBinContent(i))*W(i,j)*(_xini->GetBinContent(j));
        }
     }
you need to change the indices
            _covmatrix(i,j)=(_xini->GetBinContent(i+1))*W(i,j)*(_xini->GetBinContent(j+1));

-- KiraGrogg - 28-Dec-2010

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2010-12-28 - unknown
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

  • Edit
  • Attach
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