Hi Guys,
I’m trying to get the integral of a plot obtained from a tree.
Here my sample code:
//open a file
TFile *f1 = new TFile("00000.root","READ");
if ( f1->IsOpen() ) cout << "File opened successfully" <<endl;
TTree *t1;
f1->GetObject("tree;2", t1);
if(!t1) {
cerr << "problem in retriving Tree";
return 1;
}
for(int i=0; i<NSEGMENTS; i++){
t1->Draw("C3_ampl:C3_time>>histC3(100002, -1e-6, 5e-6)","","goff",1,i);
TH1F *histC3 = (TH1F*)gDirectory->Get("histC3");
TAxis *axis = histC3->GetXaxis();
int bmin = axis->FindBin(-0.05e-6);
int bmax = axis->FindBin(1e-6);
double integral = histC3->Integral(bmin,bmax);
In my tree I have 200 (NSEGMENTS = 200) different graph, each one composed by 100002 line. But I get always the same value of integral… so I think that this way is not working. How could I do?
Another strange behaviour is, but it is another question, when I try to Draw histC3
I get always the draw with dots and not with lines (I tried also the option “C” but with no success)