I don’t know how to make projection on a axis from TH2D.
In this folder, I did plot 2D “SA_th23dcp” (with X-axis is th23 and Y-axis is dcp) , From this plot, I want to get two-dimensional chisquare on (theta_23, dcp) and do 1D plot with (dcp,that two-dimensional chisquare). test (1).zip (390.6 KB)
please help me!
Hi Jessica - please create new topics for your questions, instead of adding to old ones. I have moved your question to a new topic now.
What is “two-dimensional chisquare on (theta_23, dcp)”? Suppose you have that as a 2D histogram, how do you expect to get to a “1D plot with (dcp,that two-dimensional chisquare)”?
Let me rephrase, maybe that makes it clear what I do not understand:
you have a rows of dcp, th23, chisq for some binIndexX and binIndexY. You have many rows of those. You now want to plot “(dcp,that two-dimensional chisquare)” - which seems to be a 2D plot, but you say it’s a 1D plot. I can see how you’d plot dcp versus chisq; I do not see how you can produce that from the 2D plot “SA_th23dcp”, or how that is related.
Let me know!
I think SA_th23dcp is the plot on th23 versus dcp. With each value (th23,dcp) will correspond to a value of chisqua that I call it as two dimensional chisquare. Now I want to draw it in the 1D plot (dcp versus chisquare), it corresponds to projection the 2D plot onto dcp.
O I see - the bin content of SA_th23dcp is the chisq value for the pair of (th23,dcp). Now - that’s super dangerous: are you positive that you only ever call
SetBinContent on empty bins? (Check!)
I guess the 1D histogram you’re after should add all all bin content (aka chisq) along th23 for one value of dcp? That would just be
test.C (11.2 KB) you say it, right? it is “dcp”
Sorry, I do not understand your message.
can you check this code test.C (11.2 KB) . It is right or not?
I get many errors, so it seems to not be right:
/home/axel/Downloads/Jessica.PQ/test/test.C:60:12: error: expected unqualified-id double M_PI = TMath::Pi(); ^ /usr/include/math.h:1070:16: note: expanded from macro 'M_PI' # define M_PI 3.14159265358979323846 /* pi */ ^ In file included from input_line_11:1: /home/axel/Downloads/Jessica.PQ/test/test.C:99:14: error: use of undeclared identifier 'h1x' int nbinx = h1x->GetNbinsX(); ^ /home/axel/Downloads/Jessica.PQ/test/test.C:100:14: error: use of undeclared identifier 'h1y' int nbiny = h1y->GetNbinsX(); ^ /home/axel/Downloads/Jessica.PQ/test/test.C:101:41: error: use of undeclared identifier 'h1y' TH1F* dcp = new TH1F("dcp", "", nbiny, h1y->GetBinCenter(1), h1y->GetBinCenter(nbiny)); ^ /home/axel/Downloads/Jessica.PQ/test/test.C:101:63: error: use of undeclared identifier 'h1y' TH1F* dcp = new TH1F("dcp", "", nbiny, h1y->GetBinCenter(1), h1y->GetBinCenter(nbiny)); ^ /home/axel/Downloads/Jessica.PQ/test/test.C:118:12: error: redefinition of 'c1' TCanvas *c1 = new TCanvas(); ^ /home/axel/Downloads/Jessica.PQ/test/test.C:86:14: note: previous definition is here TCanvas *c1 = new TCanvas(); ^ /home/axel/Downloads/Jessica.PQ/test/test.C:127:5: error: use of undeclared identifier 'cpviolation' cpviolation->Write(); ^
As I said,
SA_th23dcp->ProjectionY() - that will give you a
TH1 and should be what you’re after.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.