hi, im trying to apply weights to each of my events for each branch sample
void W(){
gStyle->SetOptStat(1111);// untk print no of events
// root file
TFile *f_sig20 = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_h125_4e_zd20.root");
//TFile *f_sig40 = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_h125_4e_zd40.root");
// TFile *f_sig60 = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_h125_4e_zd60.root");
TFile *f_bkg_zz4lep = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_Background_ZZ4LEP500k.root");
TFile *f_bkg_pph4l = new TFile("/Users/applestudio/Desktop/rootFILES/4LAnalyzer_Background_pph4l500k.root");
TTree *sig20 = (TTree*) f_sig20->Get("mZb_4e");
TTree *bkg_zz4lep = (TTree*) f_bkg_zz4lep->Get("mZb_4e");
TTree *bkg_pph4l = (TTree*) f_bkg_pph4l->Get("mZb_4e");
/*TH1F *h_sig20 = (TH1F*)f_sig20->Get("mZb_4e")->Clone("h_sig20");
TH1F *h_sig40 = (TH1F*)f_sig40->Get("mZb_4e")->Clone("h_sig40");
TH1F *h_sig60 = (TH1F*)f_sig60->Get("mZb_4e")->Clone("h_sig60");
TH1F *h_bkg_zz4lep = (TH1F*)f_bkg_zz4lep->Get("mZb_4e")->Clone("h_bkg_zz4lep");
TH1F *h_bkg_pph4l = (TH1F*)f_bkg_pph4l->Get("mZb_4e")->Clone("h_bkg_pph4l");*/
//250fb = 250000pb
float lumi = 250000;
double nevents = 25000;
double backevents = 500000;
double BR_SMHiggs = 1.25e-4;
double xs = 48.58;
double ATLASUP = 0.01;//based on ATLAS CL upper limit = 10e-3
double xs_zz4lep = 0.02836;//from mg5
double xs_pph4lep = 0.0010652;//from mg5
// normalize using weight to SM Higgs crossection & BR (total events 25k)
double signal_weight = xs*ATLASUP*BR_SMHiggs*lumi/nevents;
cout << "signal_weight =" << signal_weight << ".\n";
double zz4lep_weight = xs_zz4lep*lumi/backevents;
cout << "zz4lep_weight =" << zz4lep_weight << ".\n";
double pph4l_weight = xs_pph4lep*lumi/backevents;
cout << "pph4l_weight =" << pph4l_weight << ".\n";
//applying weight to first sample branch and creating new branch for weighted events
TH1F *sig20w = new TH1F("sig20w","sig20w",50,12.0,120.0);
Long64_t nentries = sig20->GetEntries();
for(Long64_t i=0; i<nentries; i++)
{
sig20w->Fill(sig20->GetEntry(i), signal_weight);
}
TH1F *zz4lep_w = new TH1F("zz4lep_w","zz4lep_w",50,12.0,120.0);
Long64_t Zentries = bkg_zz4lep->GetEntries();
for(Long64_t i=0; i<Zentries; i++)
{
zz4lep_w->Fill(bkg_zz4lep->GetEntry(i), zz4lep_weight);
}
TH1F *pph4l_w = new TH1F("pph4l_w","pph4l_w",50,12.0,120.0);
Long64_t Pentries = bkg_pph4l->GetEntries();
for(Long64_t i=0; i<Pentries; i++)
{
pph4l_w->Fill(bkg_pph4l->GetEntry(i), pph4l_weight);
}
//stack normalized samples
TCanvas *c = new TCanvas("c","c");
sig20->SetFillColor(kMagenta-9);
// h_sig40->SetFillColor(kCyan-9);
// h_sig60->SetFillColor(kYellow-9);
bkg_zz4lep->SetFillColor(kBlue+2);
bkg_pph4l->SetFillColor(kRed+1);
THStack *hs = new THStack("hs", "z_{b} mass");
hs->Add(sig20w);
//hs->Add(h_sig40);
//hs->Add(h_sig60);
hs->Add(zz4lep_w);
hs->Add(pph4l_w);
hs->Draw("HIST,nostack");
hs->GetXaxis()->SetTitle("mass of z_{b} (4e channel)");
hs->GetYaxis()->SetTitle("Number of Events");
hs->GetXaxis()->SetRangeUser(12,80);
/*TLegend *leg = new TLegend(0.9,0.7,0.7,0.9);
leg->SetHeader("Sample");
leg->AddEntry("h_sig20","mZ_{b} = 20GeV","f");
leg->AddEntry("h_sig40","mZ_{b} = 40GeV","f");
leg->AddEntry("h_sig60","mZ_{b} = 60GeV","f");
leg->AddEntry("h_bkg_zz4lep","zz4l","f");
leg->AddEntry("h_bkg_pph4l","pph4l","f");
leg->Draw();*/
c->SaveAs("cuba25k.eps");
}
however this is my output
signal_weight =0.00060725.
zz4lep_weight =0.01418.
pph4l_weight =0.0005326.
*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCling.so] TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCore.so] TApplication::ExecuteFile(char const*, int*, bool) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libRint.so] TRint::HandleTermInput() (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCore.so] TUnixSystem::CheckDescriptors() (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCore.so] TSystem::InnerLoop() (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCore.so] TSystem::Run() (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libCore.so] TApplication::Run(bool) (no debug info)
[/usr/local/Cellar/root/6.22.02/lib/root/libRint.so] TRint::Run(bool) (no debug info)
[/usr/local/Cellar/root/6.22.02/bin/root.exe] main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)
im not sure where i went wrong,
thankyou
Please read tips for efficient and successful posting and posting code
_ROOT Version:6.22
Platform: Not Provided
Compiler: Not Provided