Hi everyone
I want to draw 3 different histograms with the same name TH1F inside 3 chains on one TProfile histogram. Only appears the canvas.
#include "TFile.h"
#include "TProfile.h"
#include "TCanvas.h"
#include "TDirectory.h"
______________________________________________________
{
TFile *f=new TFile("Test.root");
TCanvas *c = new TCanvas("c","c",1000,1000);
gDirectory->cd("run/XXX/TauMon/Expert");
TProfile *h1;
std::vector<TString>Hist=
{
"chain1",
"chain2",
"chain3",
};
cout<<"5"<<endl;
for (int i=0; i<Hist.size();i++){
gDirectory->cd(Hist[i]+"/TypeOfHistogram/Efficiency");
h1=(TProfile*)f->Get("MyHist");
if (i>0){
h1->Draw("same");
gDirectory->cd("../../../");
}
else {
h1->Draw();
gDirectory->cd("../../../");
}
}
}
The error on terminal:
#0 0x00007f71cac9c687 in __GI___waitpid (pid=11214, stat_loc=stat_loc
entry=0x7ffdae89c668, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1 0x00007f71cac07067 in do_system (line=<optimised out>) at ../sysdeps/posix/system.c:149
#2 0x00007f71cb8ab1b3 in TUnixSystem::Exec (shellcmd=<optimised out>, this=0x561d391a7b80) at /home/ryse/Productos/root-6.18.00/core/unix/src/TUnixSystem.cxx:2106
#3 TUnixSystem::StackTrace (this=0x561d391a7b80) at /home/ryse/Productos/root-6.18.00/core/unix/src/TUnixSystem.cxx:2400
#4 0x00007f71c60a1055 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /home/ryse/Productos/test_build/lib/libCling.so
#5 0x00007f71c60a0a5b in cling_runtime_internal_throwIfInvalidPointer () from /home/ryse/Productos/test_build/lib/libCling.so
#6 0x00007f71cc061a87 in ?? ()
#7 0x0000000000000000 in ?? ()
Error in <TRint::HandleTermInput()>: cling::InvalidDerefException caught: Trying to dereference null pointer or trying to call routine taking non-null arguments
ROOT Version: 6.18
Platform: ubtuntu 16.04
Compiler: GNU compiler