we need the minimal amount of running, self-contained code that shows this problem. Given your info so far I don’t see any issue: root [0] TH3F *histo = new TH3F("h3","h3",10,0.,1.,11,0.,1.,12,0.,1.)
root [1] TH2D* projection = histo->Project3D("xy")
Cheers, Axel.
Thanks for the quick answer. I was cleaning the code before uploading and decided to give another try changing one line and now it works, before I had:
Hello all
I’m stuck with a similar problem but I can’t work out how to solve it from this thread and I would be very grateful for some help. I am trying to project a TH3F onto a TH2.
In COMPILED code I have (3dhisto is a previously declared TH3F):
TH2 proj2=3dhisto->Project3D(“xz”);
This doesn’t compile. It returns error: invalid conversion from TH1*' toTH2’
So I do
TH1 *proj1=3dhisto->Project3D(“xz”);
This compiles, but gives segmentation violation when I try to run it.
Projecting onto a 1D histo compiles and runs fine. E.g:
TH1 *proj1=3dhisto->Project3D(“x”);
So I can see there’s a problem with the pointer that I’m returning but I’m not sure what to do… cast the TH2* as a TH1*?
I would be very grateful for any help!
Thanks very much in advance
Sarah
Thank you Rene that command compiled and ran fine once I put it in a separate macro to do the plotting. For some reason it wouldn’t run when the command was in the .C file that I use for my analysis, but it probably shouldn’t be in there anyway!
Sarah