Convert 2 canvas in to 2 histogam in the same plot

Continuing the discussion from Convert 2 canvas in to 2 histogam:

Something is wrong with the link you posted …

Hi Couet
thanks for your reply!
Hi Expert,

I tried to convert 2 canvas in to 2 histogam in the same plot , but when I compiling the macro I have just one plot with error message(*):
This is my code:
TFile f1(“acceptboostedZp1.root”,“read”);
TCanvas c1 = (TCanvas)f1.Get(“cacc”);
TH1F h = (TH1F)c1->GetPrimitive(“hr_be_copy”);
c1->Clear();
c1->Draw();
h->Draw();

TFile f2(“acceptboostedZp.root”,“read”);
TCanvas c2 = (TCanvas)f2.Get(“cacc”);
TH1F h1;
TIter next(l);
//h1 = (TH1F
)c2->GetPrimitive(“hr_be_copy”);
//c2->Clear();
c2->Draw();
TCanvas c3;
h1->Draw();

h->Draw(“L”);
}

ERrot message:

*** Break *** segmentation violation

There was a crash.
This is the entire stack trace of all threads:
#0 0x00007f5fe298795c in __libc_waitpid (pid=4687, stat_loc=stat_loc
entry=0x7fff1451cc80, options=options
entry=0) at …/sysdeps/unix/sysv/linux/waitpid.c:31
#1 0x00007f5fe2909232 in do_system (line=) at …/sysdeps/posix/system.c:148
#2 0x00007f5fe363e5c3 in TUnixSystem::StackTrace() () from /home/souad/Downloads/root/lib/libCore.so
#3 0x00007f5fe36402cc in TUnixSystem::DispatchSignals(ESignals) () from /home/souad/Downloads/root/lib/libCore.so
#4
#5 __memmove_ssse3_back () at …/sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:2683
#6 0x00007f5fe35b3ae2 in TString::Replace(int, int, char const*, int) () from /home/souad/Downloads/root/lib/libCore.so
#7 0x00007f5fe37fd608 in G__G__Base2_10_0_15(G__value*, char const*, G__param*, int) () from /home/souad/Downloads/root/lib/libCore.so
#8 0x00007f5fe1f8f8cd in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) () from /home/souad/Downloads/root/lib/libCint.so
#9 0x00007f5fe2033797 in G__execute_call () from /home/souad/Downloads/root/lib/libCint.so
#10 0x00007f5fe2033b55 in G__call_cppfunc () from /home/souad/Downloads/root/lib/libCint.so
#11 0x00007f5fe20130c7 in G__interpret_func () from /home/souad/Downloads/root/lib/libCint.so
#12 0x00007f5fe20009f1 in G__getfunction () from /home/souad/Downloads/root/lib/libCint.so
#13 0x00007f5fe20e6e05 in G__getstructmem(int, G__FastAllocString&, char*, int, char*, int*, G__var_array*, int) () from /home/souad/Downloads/root/lib/libCint.so
#14 0x00007f5fe20de33a in G__getvariable () from /home/souad/Downloads/root/lib/libCint.so
#15 0x00007f5fe1fdaaa9 in G__getitem () from /home/souad/Downloads/root/lib/libCint.so
#16 0x00007f5fe1fe0425 in G__getexpr () from /home/souad/Downloads/root/lib/libCint.so
#17 0x00007f5fe20625f3 in G__exec_statement () from /home/souad/Downloads/root/lib/libCint.so
#18 0x00007f5fe201462c in G__interpret_func () from /home/souad/Downloads/root/lib/libCint.so
#19 0x00007f5fe2000a4f in G__getfunction () from /home/souad/Downloads/root/lib/libCint.so
#20 0x00007f5fe1fdafb6 in G__getitem () from /home/souad/Downloads/root/lib/libCint.so
#21 0x00007f5fe1fe0425 in G__getexpr () from /home/souad/Downloads/root/lib/libCint.so
#22 0x00007f5fe1febcfb in G__calc_internal () from /home/souad/Downloads/root/lib/libCint.so
#23 0x00007f5fe206fe5f in G__process_cmd () from /home/souad/Downloads/root/lib/libCint.so
#24 0x00007f5fe3602130 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /home/souad/Downloads/root/lib/libCore.so
#25 0x00007f5fe35fe7cb in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /home/souad/Downloads/root/lib/libCore.so
#26 0x00007f5fe356c08c in TApplication::ExecuteFile(char const*, int*, bool) () from /home/souad/Downloads/root/lib/libCore.so
#27 0x00007f5fe356b5c0 in TApplication::ProcessLine(char const*, bool, int*) () from /home/souad/Downloads/root/lib/libCore.so
#28 0x00007f5fe31b8239 in TRint::HandleTermInput() () from /home/souad/Downloads/root/lib/libRint.so
#29 0x00007f5fe363fa95 in TUnixSystem::CheckDescriptors() () from /home/souad/Downloads/root/lib/libCore.so
#30 0x00007f5fe36405ba in TUnixSystem::DispatchOneEvent(bool) () from /home/souad/Downloads/root/lib/libCore.so
#31 0x00007f5fe35c3536 in TSystem::InnerLoop() () from /home/souad/Downloads/root/lib/libCore.so
#32 0x00007f5fe35c4140 in TSystem::Run() () from /home/souad/Downloads/root/lib/libCore.so
#33 0x00007f5fe35697bf in TApplication::Run(bool) () from /home/souad/Downloads/root/lib/libCore.so
#34 0x00007f5fe31b945e in TRint::Run(bool) () from /home/souad/Downloads/root/lib/libRint.so
#35 0x0000000000400fdc in main ()
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
#5 __memmove_ssse3_back () at …/sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:2683
#6 0x00007f5fe35b3ae2 in TString::Replace(int, int, char const*, int) () from /home/souad/Downloads/root/lib/libCore.so

Root > Function macro_canvas() busy flag cleared

Can Someone please help me to fix this error.

Hi can someone help me please I need this histogram

Hi couet,

Could you please answer me for my message below I need this histogram to do.

Hi,
maybe it’s not the clever way to do it. But if you open the file and draw the canvas, then you can right click on the histogram and select SaveAs() and choose the name of the root file where to save the histogram.
This new file has only the histogram in it.

Then you can open the two file separately and draw the histograms with the two histogram().

Cheers,
Stefano

This thread is a duplicate of this one: Convert canvas to histogram in the same plot
Please use the other one.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.