ROOT Version: 6.18/00
Platform: Ubuntu 20.04
Compiler: Not Provided
Hello experts,
With reference to this Getting the same histograms after cuts I tried the same, but I’m getting a blank histogram plot in a Canvas. I think the solution would be to replace “GOFF” with a “hist” which will give me a plot. But as I wanted to use each histogram for adding in the later case.
Can you please help me sort out my problem?
Also, I would like to add this three histogram (what I want is to add three values e.g. Total_KE = A + B + C, where A,B and C are the kinetic energy of particles). Will I get a correct result if I just add them?
I attached the code and the root file here default_ccqe_Carbon.root (330.4 KB)
E_had.C (1.3 KB)
Thanks in advance.
#include<iostream>
#include<iomanip>
#include<TFile.h>
#include<TTree.h>
#include<TChain.h>
#include<TCanvas.h>
#include<TLegend.h>
#include "TString.h"
#include "TROOT.h"
using namespace std;
void E_had()
{
const int nbins = 40;
const int min = 0;
const int max = 3;
TFile* file_C12 = new TFile("default_ccqe_Carbon.root","OPEN");
if (!file_C12 || file_C12->IsZombie() ) { delete file_C12; return; }
TTree* t_C12 = (TTree*) file_C12->Get("gst");
if (! t_C12) { delete file_C12; return;}
auto c = new TCanvas();
c->cd();
TH1D* h_C12_default_KE_nucleon = new TH1D("h_C12_default_KE_nucleon "," ", nbins, min,max);
TH1D* h_C12_default_pion_plus = new TH1D ("h_C12_default_pion_plus "," ", nbins, min,max);
TH1D* h_C12_default_pion_0 = new TH1D ("h_C12_default_pion_0 "," ", nbins, min,max);
h_C12_default_KE_nucleon->Sumw2(kTRUE);
// t_C12->Draw("(Ef-0.938)>>h_C12_default_KE_nucleon","cc&&pdgf==2212"," goff");
t_C12->Draw("(Ef-0.13957)>>h_C12_default_pion_plus","cc&&pdgf==211","goff");
t_C12->Draw("(Ef-0.13498)>>h_C12_default_pion_0","cc&&pdgf==111","goff");
TString cut_nucleon;
cut_nucleon = "cc&&pdgf==2212";
t_C12->Project("h_C12_default_KE_nucleon", "(Ef-0.938)", cut_nucleon);
h_C12_default_KE_nucleon->Draw("hist");
c->Update();
}