Hello ROOTers,
I received a macro written for ROOT5 and im trying to execute it in ROOT6.22:
void Miniarray_RUN4_barometric_coefficient()
{
// Read the miniarray tree file to evaluate barometric coefficient
// from pressure-shower rate scatter plot
Int_t seconds2007, nanosec, mult, nevents, ntrending,neff;
Int_t nshower[31][5000];
Float_t press,pressure[5000];
for(Int_t is=1; is<=30; is++) {
for(Int_t im=0; im<5000; im++) {
nshower[is][im]=0;
}
}
TChain chain("tree_arduino");
chain.Add("RUN4_prova1.root");
chain.Add("RUN4_2.root");
chain.Add("RUN4_3.root");
chain.Add("RUN4_4.root");
chain.Add("RUN4_5.root");
chain.Add("RUN4_6.root");
//TFile *f = new TFile("RUN4_6.root");
nevents=tree_arduino->GetEntries();
cout<<"N.events: "<<nevents<<endl;
tree_arduino->SetBranchAddress("seconds2007", &seconds2007);
tree_arduino->SetBranchAddress("nanosec", &nanosec);
tree_arduino->SetBranchAddress("mult", &mult);
tree_arduino->GetEntry(0);
Float_t t0=seconds2007;
cout<<"t0= "<<t0<<endl;
Int_t im=0;
for(Int_t iev = 1; iev < nevents; iev++){ //Loop on event-by-event tree_Arduino
tree_arduino->GetEntry(iev);
if(seconds2007<t0+1860) nshower[mult][im]++;
if(seconds2007>t0+1860) {
//cout<<im<<" "<<seconds2007<<" "<<nshower[4][im]<<endl;
im++;
t0=seconds2007;
}
} // End loop on events in the file
TChain chain("tree_trending");
chain.Add("RUN4_prova1.root");
chain.Add("RUN4_2.root");
chain.Add("RUN4_3.root");
chain.Add("RUN4_4.root");
chain.Add("RUN4_5.root");
chain.Add("RUN4_6.root");
tree_trending->SetBranchAddress("press", &press);
tree_trending->SetBranchAddress("seconds2007", &seconds2007);
ntrending = tree_trending->GetEntries();
cout << "Overall number of points: " << ntrending << endl;
for (Int_t itrend = 0; itrend < ntrending; itrend++)
{ //Loop on trending values
tree_trending->GetEntry(itrend);
pressure[itrend] = press;
//cout<<itrend<<" "<<seconds2007<<" "<<press<<endl;
} // End loop
Float_t nshower_integrated[5000];
Int_t mult_min=5;
Int_t mult_max=7;
cout<<"Analysis for events with multiplicity: "<<mult_min<<"-"<<mult_max<<endl;
for(Int_t j = 0; j < ntrending; j++){
nshower_integrated[j]=0;
for(Int_t m = mult_min; m <= mult_max; m++){
nshower_integrated[j]=nshower_integrated[j]+nshower[m][j];
}
}
Float_t average_rate=0.0;
for(Int_t j = 0; j < ntrending; j++){
average_rate=average_rate+nshower_integrated[j];
//cout<<j<<" "<<pressure[j]<<" "<<nshower_integrated[j]<<endl;
}
average_rate=average_rate/ntrending;
cout<<"Average rate of all showers with mult "<<mult_min<<"-"<<mult_max<<" : "<<average_rate<<endl;
TCanvas *c1 = new TCanvas("c1","",1000,700);
TGraph *gr1 = new TGraph(ntrending,pressure,nshower_integrated);
gr1->SetTitle("");
gr1->SetMarkerColor(4);
gr1->SetMarkerStyle(22);
gr1->Draw("AP");
/*
TCanvas *c2 = new TCanvas("c2","",1000,700);
Float_t pressure_notzero[5000],yield_notzero[5000];
Int_t j_notzero=0;
Float_t average_rate=0.0;
for(Int_t j = 0; j < ntrending; j++){
if(nshower_integrated[j]>0) {
yield_notzero[j_notzero]=nshower_integrated[j];
average_rate=average_rate+yield_notzero[j_notzero];
pressure_notzero[j_notzero]=pressure[j];
//cout<<j_notzero<<" "<<pressure_notzero[j_notzero]<<" "<<yield_notzero[j_notzero]<<endl;
j_notzero++;
}
}
j_notzero--;
TGraph *gr2 = new TGraph(j_notzero,pressure_notzero,yield_notzero);
gr2->SetTitle("");
gr2->SetMarkerColor(4);
gr2->SetMarkerStyle(22);
gr2->Draw("AP");
average_rate=average_rate/j_notzero;
cout<<"Average rate (different from 0) with mult: "<<mult_min<<"-"<<mult_max<<" : "<<average_rate<<endl;
cout<<"Number of points with at least one shower in 30': "<<j_notzero<<endl;
*/
}
But doesn’t work:
error: use of undeclared identifier 'tree_arduino'
nevents=tree_arduino->GetEntries();
^
error: use of undeclared identifier 'tree_arduino'
tree_arduino->SetBranchAddress("seconds2007", &seconds2007);
^
error: use of undeclared identifier 'tree_arduino'
tree_arduino->SetBranchAddress("nanosec", &nanosec);
^
error: use of undeclared identifier 'tree_arduino'
tree_arduino->SetBranchAddress("mult", &mult);
^
error: use of undeclared identifier 'tree_arduino'
tree_arduino->GetEntry(0);
^
error: use of undeclared identifier 'tree_arduino'
tree_arduino->GetEntry(iev);
^
error: redefinition of 'chain'
TChain chain("tree_trending");
^
note: previous definition is here
TChain chain("tree_arduino");
^
error: use of undeclared identifier 'tree_trending'
tree_trending->SetBranchAddress("press", &press);
^
error: use of undeclared identifier 'tree_trending'
tree_trending->SetBranchAddress("seconds2007", &seconds2007);
^
error: use of undeclared identifier 'tree_trending'
ntrending = tree_trending->GetEntries();
^
error: use of undeclared identifier 'tree_trending'
tree_trending->GetEntry(itrend);
^
What i can do in order to run it? I post also the root file
RUN4_prova1.root (680,7 KB)
This code run on root5, it is normal that dont run in root6? Why?
Thanks in advance.
ROOT Version: 6.22
Platform: Ubuntu 20.10
Compiler: gcc 9.3