Thank you for your respond. Here is one of the .png file, there are many of these histograms that I would like to get Integral then plot a TGraph vs run-number.
{
TGraph *g = new TGraph();
g->SetTitle("number of tracks;run number;dcalphaboard integral");
Int_t ifirst = 1; // the first run
Int_t ilast = 79; // the last run
for (Int_t i = ifirst; i <= ilast; i++) {
// open the "i"-th ROOT file, retrieve the "dcalphaboard" and then ...
Double_t integ = dcalphaboard->Integral();
Double_t runno = i;
g->SetPoint(g->GetN(), runno, integ); // add the "next" point to the graph
// ... close the "i"-th ROOT file (deletes "dcalphaboard")
}
g->Draw("AL");
}
I am reading in these histogram from a file of several other different histograms. Then I am trying to calculate all the normalized integrals of these histograms. Then plotting these normalized integral against run number using TGraph and save new histograms to a new file.
From the code below, I have messed up the code some where but not sure where, need some help, please.
i_ntracks = new TGraph();
i_ntracks->SetName(“i_ntracks”);
TCanvas *ac = new TCanvas(“ac”,“ac”,800,600);
while ( runflist >> rootfile )
{
run = getrun(rootfile);
Double_t n_maxbins;
t_file[n_runs] = new TFile(rootfile,“READ”);
htrig[n_runs] = (TH1*)t_file[n_runs]->Get(“htrig”)
Double_t nevents = htrig[n_runs]->GetBinContent(1);
//trying to go over all the run number
for(int inbins = 1; inbins <= n_maxbins;inbins ++)
{
for (int iarm=0; iarm<2; iarm++)
{
for (int iside=0; iside<2; iside++)
{
name = “h_dcalphaboard”; name += iarm; name += iside;
h_dcalphaboard[n_runs][iarm][iside] = (TH2*)t_file[n_runs]->Get(name);
Double_t intgel = h_dcalphaboard[n_runs][iarm][iside] ->Integral()/htrig[nruns]->GetBinContent(1);//finding the normalized number of tracks
}
h_dcalphaboard[n_runs][iarm][iside]->Fill( intgel, n_runs );//fill histogram with intgel and run number
//print intgel and Tgraph
TGraph * f = new TGraph;
TFile *savefile = new TFile(“dcalpha.root”,“RECREATE”);//save to file
}