Error: Function() is not defined in current scope :0:

Hello,

[code]#include
#include

using namespace std;

char rootfile[200];
int qie,depth,ieta;

void Analyzer(int runno){

/* ifstream in(“RunList.txt”,ios::in);

if (in.fail()) {
cout<<“there is no RunList.txt”<<endl; }
while(!(in.eof())){
in>>runno;
*/

sprintf(rootfile,"/Users/Erkurt/Desktop/!!!THESIS!!!/BURNIN Thesis/ROOTFILES/Run_%d.root",runno);
TFile *f = new TFile(rootfile);

stringstream outfile;
outfile<<runno<<"_Ntuple.root";
TFile *f1 = new TFile(outfile.str().c_str(),“RECREATE”);
outfile.str("");

int HV[] = {650,700};
TH2F *HistGain[2];
stringstream voltage;
for(const int hv=0;hv<2;hv++) {
voltage<<HV[hv]<<“GainVsChannel”;
HistGain[hv] = new TH2F(voltage.str().c_str(),voltage.str().c_str(),55,0,50,1000,0,2500000);
voltage.str("");
}

ifstream input(“map.txt”);

if (input.fail()){
cout<<“map.txt is not available”<<endl;
}
int count = 0;
while(!(input.eof())){
input>>qie>>ieta>>depth;
for(int hv=0;hv<2;hv++){
for(int db=0;db<2;db++) {

      //  count++;                                                                                                                                                             
      // cout<<count;          
 TString histnameLED,histnamePED;
      stringstream ledname,pedname;               		     			histnamePED.Form("/Analyzer/QIEsSumPED%d_QiECh_%d_DBOX_%d_eta_%d_D_%d",HV[hv],qie,db,ieta,depth);
  pedname<<histnamePED;
  ledname<<histnameLED;

  TH1F *HistLED = (TH1F*)f->Get(ledname.str().c_str());
  TH1F *HistPED = (TH1F*)f->Get(pedname.str().c_str());
  ledname.str("");
  pedname.str("");
  //      cout<<ledname.str().c_str()<<endl;                                                                                                                                   

       if(HistLED && HistPED) {

         LEDMEAN = HistLED->GetMean();
         PEDMEAN = HistPED->GetMean();
         LEDRMS = HistLED->GetRMS();
         PEDRMS = HistPED->GetRMS();



       double TRUEMEAN = LEDMEAN - PEDMEAN;
       double TRUERMS = sqrt(pow(LEDRMS,2)+pow(PEDRMS,2));
       double NPE = 1.15*pow(TRUEMEAN,2)/pow(TRUERMS,2);
       double GAIN = TRUEMEAN*2.6*10000/NPE/1.6;

       cout<<GAIN<<endl;

               if (GAIN>0) {

                 HistGain[hv]->Fill((qie+db*24),GAIN);
                 HistGain[hv]->GetXaxis()->SetTitle("Channel");
                 HistGain[hv]->GetYaxis()->SetTitle("Gain");
                 HistGain[hv]->SetMarkerColor(kRed);
                 HistGain[hv]->SetMarkerStyle(8);

               }
       }
    }

      HistGain[hv]->Draw();
        }

}

f1->Write();
// in.close();
input.close();
f1->Close();
f->Close();
}[/code]

[quote]Error: Function Analyzer() is not defined in current scope :0:
*** Interpreter error recovered ***[/quote]

I correctly run this code before this error, but now something miss from my observation. Root file runs by TBrowser , and i controlled its path, and also controlled its macro name Analyzer.C.
I didn’t understand anything about that.

Cheers,
Thanks for your help
Ersel
Run_3048.root (690 KB)

Hi,

if you wish to run this code in a macro called Analyzer.C you should pass a parameter to it (the run number)

root -b -q 'Analyzer.C(123456)'

see root.cern.ch/root/htmldoc/guide … ot-session .

If not, at the prompt, the usual syntax will do the job:

root[0] .L Analyzer.C
root[1] Analyzer(123456)

Cheers,
D

1 Like