Hi. I almost feel embarrassed posting this as it should be an easy thing to do!
I have two triggers A and B. Each can be 0 or 1.
I have made a TH2F 2D lego plot from the comparison of these triggers:
MyNtuple->Draw(“A:B” ,"","Lego);
I get a lego plot of 4 ‘cubes’ showing the quantities of (A & B), (A & !B), (!A & B) and (!A & !B) as expected.
I want to get the Numerical values for each of these ‘cubes’. ie. I want to h0->GetBinContents()
but I can’t. Here’s a snippet of the code:
...
//Define histogram.
TH2F *h0 = new TH2F("h0","Trigger_Stuff", 2, 0., 2., 2, 0., 2.);
//Histogram two triggers in to h0.
MyNtuple->Draw("TriggerA:TriggerB>>h0","","LEGO");
//Get 'linearized' bin number
int bin = h0->GetBin(0,0); //Have also tried GetBin(0,0,0)
double trueNeg = h0->GetBinContent(bin);
int bin = h0->GetBin(0,1); // Have also tried GetBin(0,1,0)
double falseNeg = h0->GetBinContent(bin);
cout << "True Negative: " << trueNeg << endl;
cout << "False Negative: " << falseNeg << endl;
...
I am receiving some numbers, but they are wrong.
Please let me know if you require the complete code in order to help.
Ultimately, I want to calculate the number of true positive, true negative, false positive and false negative occurrences of trigger A w.r.t Trigger B.
Any help is greatly appreciated. Thanks.
Alan.
Hi Rene.
Thanks for the prompt reply.
I should have mentioned that I had already tried this method, as in the following code example. I’ve included the actual TH2 histo declaration and the line that drags the data from the nTuple, just incase I am doing something wrong here.
Note that the bin numbering goes from 0 to nbinsx+1 and 0 to nbinsy+1 where 0 is the underflow bin and
nbinsx+1 the overflow bin. So in your case to access the first fin in x and bin, you should call GetBinContent(1,1).