Home | News | Documentation | Download

Calculate cross section

hi im trying out this example https://twiki.cern.ch/twiki/bin/view/Main/UnitsHiggsTutorial#Delphes___
and adding some of my own root files,

im trying to calculate the cross section, with equation x = N events / Luminosity
when creating rootfile with Delphes i set nevents to be 25000, is it the same defination with ntot that im declaring here?

i set luminosity to be 250fb-

#include "TH1.h"
#include "TSystem.h"

#ifdef __CLING__
R__LOAD_LIBRARY(libDelphes)
#include "classes/DelphesClasses.h"
#include "external/ExRootAnalysis/ExRootTreeReader.h"
#include "external/ExRootAnalysis/ExRootResult.h"
#endif

void SigBckStack(){
  gSystem->Load("libDelphes");
  gStyle->SetOptStat(0);  

  TFile *f_sig = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_h125_4mu_zd50.root");
  TFile *f_bkg = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_Background_zz4lep.root");
  TFile *f_bkg2 = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_Background_pph4l.root");
  
  TH1F *h_sig = (TH1F*)f_sig->Get("HiggsMass")->Clone("h_sig");
  TH1F *h_bkg = (TH1F*)f_bkg->Get("HiggsMass")->Clone("h_bkg");
  TH1F *h_bkg2 = (TH1F*)f_bkg2->Get("HiggsMass")->Clone("h_bkg2");

  float lumi = 250;

  float ntot_sig = 25000;
  float ntot_bkg = 25000;
  float ntot_bkg2 = 25000;
    
  h_sig->Scale(ntot_sig/lumi);
    cout << "Signal cross section " << ntot_sig/lumi << endl;
  h_bkg->Scale(ntot_bkg/lumi);
    cout << "Bkg cross section " << ntot_bkg/lumi << endl;
  h_bkg2->Scale(ntot_bkg2/lumi);
  cout << "Bkg cross section " << ntot_bkg2/lumi << endl;
    
  TCanvas *c = new TCanvas("c","c");
  
  h_sig->SetFillColor(kRed);
  h_bkg->SetFillColor(kWhite);
  h_bkg2->SetFillColor(kBlue);

  THStack *h_stack = new THStack();
  h_stack->Add(h_bkg);
  h_stack->Add(h_bkg2);
  h_stack->Add(h_sig);
 h_stack->Draw("HIST");
  
  h_stack->SetMaximum(h_bkg->GetMaximum()*2);
  
  c->SaveAs("HiggsMass.png");
}

but i am getting this error;

 warning: null passed to a callee that requires a non-null argument [-Wnonnull]
  TH1F *h_sig = (TH1F*)f_sig->Get("HiggsMass")->Clone("h_sig");

please suggest me a way to fix this/point out my mistake, thank you so much!

Please read tips for efficient and successful posting and posting code

_ROOT Version:_6.22
Platform: mac catalina 10.15.16
Compiler: Apple clang version 11.0.3 (clang-1103.0.32.29)


Hi,

This probably means that

f_sig->Get("HiggsMass")`

returns a nullptr. You should check if the open file , f_sig, contains that histogram. You can try for example by calling f_sig->ls()

Lorenzo