I don't understand the ERROR message ?

From: Jayoung Wu (jayoung@glue.umd.edu)
Date: Tue Feb 24 1998 - 18:23:47 MET


Hi,
I am trying to read an ascii file("mmi.50") and create a ROOT
file("aticdata.root") using a ROOT Tree structure.
The file name for that is "maketree.C".
However when I execute it in root it gives the following error message:

root [1] .x maketree.C
Error: No symbol maketree() in current scope  FILE: LINE:0
NULL
*** Interpreter error recovered ***

Do you have any idea about it?
Actually my code("maketree.C") is not completed yet.
To create a Tree I added just following lines:
	//* Reset the environment
  	gROOT->Reset();

	//* Create a new ROOT binary machine independant file
  	TFile *f = new TFile("aticdata.root","RECREATE");

	// input file
  	fp = fopen("/export/data/aticd8/jay8/mcmurdoi/mmi.50","rt");

	//* Create a ROOT Tree and branches
  	TTree *tree = new TTree("EVENT","Event Tree");
  	TBranch *branch1 = tree->Branch("SUM",&sum,"sum/F");
  	TBranch *branch2 = tree->Branch("INTRPOS",intrpos,"intrpos/F");
  	TBranch *branch3 = tree->Branch("BGO",bgo,"bgo/F");

Except those everything is just plain C for reading a ascii file.
 
--------------------------------------------------------------------------
The following is "maketree.C".

----
Thanks a lot!
Jayoung Wu



#include <stdio.h>

#define NUMOFEVENTS 10
#define MAXLINE 100

int NumberOfChar(char s[],char c);
void ReplaceWithBlank(char s[],char c);


int NumberOfChar(char s[],char c)
{
  int i;
  int n=0;
  for (i=0; s[i]!='\0'; i++) if(s[i]==c) n++;
  return n;
}


void ReplaceWithBlank(char s[],char c)
{
  int i,j;
  for(i=j=0; s[i]!='\0'; i++)
    if(s[i]!=c) 
      s[j++]=s[i];
    else
      s[j++]=' ';
}




main()
{
  FILE   *fp;
  Int_t  event;
  Int_t  theno;
  Int_t  i,j,k;
  Int_t  l;
  Char_t line[110];
  Char_t s1[30],s2[30],s3[30],s4[30],s5[30],s6[30],s7[30],s8[30],s9[30],s0[30];

// variables to save information
  Int_t    evno;
  Long_t   rndm[2];
  Int_t    pid;
  Float_t  ke;
  Int_t    area;
  Int_t    flag;
  Float_t  ipos[3];
  Float_t  imom[3];
  Float_t  theta, phi;
  Float_t  intrpos[3];
  Float_t  inconly[10];
  Float_t  si1[28][11][4], si2[28][11][4], si3[28][10][4], si4[28][10][4];
  Float_t  scn1[2][43], scn2[2][36], scn3[2][25];
  Float_t  bgo[10][2][20];
  Float_t  sum;

//* Reset the environment
  gROOT->Reset();

//* Create a new ROOT binary machine independant file
  TFile *f = new TFile("aticdata.root","RECREATE");

// input file
  fp = fopen("/export/data/aticd8/jay8/mcmurdoi/mmi.50","rt");

//* Create a ROOT Tree and branches
  TTree *tree = new TTree("EVENT","Event Tree");
  TBranch *branch1 = tree->Branch("SUM",&sum,"sum/F");
  TBranch *branch2 = tree->Branch("INTRPOS",intrpos,"intrpos/F");
  TBranch *branch3 = tree->Branch("BGO",bgo,"bgo/F");





// read data
  for(event=1; event<=NUMOFEVENTS; event++)
    {

// initialize with 0
      for(i=0; i<28; i++)
	for(j=0; j<11; j++)
	  for(k=0; k<4; k++)
	    {
	      si1[i][j][k]=0.0;
	      si2[i][j][k]=0.0;
	    }

      for(i=0; i<28; i++)
	for(j=0; j<10; j++)
	  for(k=0; k<4; k++)
	    {
	      si3[i][j][k]=0.0;
	      si4[i][j][k]=0.0;
	    }
      
      for(i=0; i<2; i++)
	for(j=0; j<43; j++) scn1[i][j]=0.0;

      for(i=0; i<2; i++)
	for(j=0; j<36; j++) scn2[i][j]=0.0;

      for(i=0; i<2; i++)
	for(j=0; j<25; j++) scn3[i][j]=0.0;

      for(i=0; i<10; i++)
	for(j=0; j<2; j++)
	  for(k=0; k<20; k++) bgo[i][j][k]=0.0;
      

// incident information
      fscanf(fp,"%s%s%d,%s%s%ld%ld",s1,s2,&evno,s4,s5,&rndm[0],&rndm[1]);

      fscanf(fp,"%s%s%s%s%d%s%s%f%s%s%d%s%s%d",
	     s1,s2,s3,s4,&pid,s5,s6,&ke,s7,s8,&area,s9,s0,&flag);

      fscanf(fp,"%s%s%s%f%f%f",
	     s1,s2,s3,&ipos[0],&ipos[1],&ipos[2]);

      fscanf(fp,"%s%s%s%f%f%f",
	     s1,s2,s3,&imom[0],&imom[1],&imom[2]);

      fscanf(fp,"%s%s%s%s%s%f%f",
	     s1,s2,s3,s4,s5,&theta,&phi);

// 1st intr. position
      fscanf(fp,"%s%s%s%s%s%s%f%f%f",
	     s1,s2,s3,s4,s5,s6,&intrpos[0],&intrpos[1],&intrpos[2]);

// incident only information(sili, scn)
      fscanf(fp,"%s%s%s%s%s",s1,s2,s3,s4,s5);
      
      for(i=0; i<=9; i++) 
	fscanf(fp,"%s%g%s",s1,&inconly[i],s2);


// ENERGY DEPOSITION EACH SILICON LAYER
      fscanf(fp,"%s%s%s%s%s%s",s1,s2,s3,s4,s5,s6);
      fscanf(fp,"%s%s%s%d",s1,s2,s3,&l); //SILICON LAYER = 1
      fgets(line,MAXLINE,fp);
      
      fgets(line,MAXLINE,fp);
      theno = NumberOfChar(line,'[');

      while(theno)
	{
	  int   itemp[5]={0,0,0,0,0};
	  float temp[5]={0.,0.,0.,0.,0.};
	      
	  ReplaceWithBlank(line,'[');
	  ReplaceWithBlank(line,']');
	      
	  if(theno == 1)
	    sscanf(line,"%d%g",&itemp[0],&temp[0]);
	  else if(theno == 2)
	    sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
	  else if(theno == 3)
	    sscanf(line,"%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		   &itemp[2],&temp[2]);
	  else if(theno == 4)
	    sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],&temp[3]);
	  else if(theno == 5)
	    sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],
		   &itemp[3],&temp[3],&itemp[4],&temp[4]);
	  else
	    printf("Error on Reading Edep in SILICON: theno=%d\n",theno);
	    
	  for(j=1; j<=theno; j++)
	    {
	      int iy,ix,ip; //iy is ladder no.
		  
	      iy = (itemp[j-1]-1)/44 + 1;
	      ix = (itemp[j-1]-(iy-1)*44-1)/4 + 1;
	      ip = itemp[j-1]-(iy-1)*44-(ix-1)*4;

	      si1[iy-1][ix-1][ip-1] = temp[j-1];
	    }

	  fgets(line,MAXLINE,fp);
	  theno = NumberOfChar(line,'[');
	}

      fscanf(fp,"%s%s%s%d",s1,s2,s3,&l); //SILICON LAYER = 2
      fgets(line,MAXLINE,fp);
      
      fgets(line,MAXLINE,fp);
      theno = NumberOfChar(line,'[');

      while(theno)
	{
	  int   itemp[5]={0,0,0,0,0};
	  float temp[5]={0.,0.,0.,0.,0.};
	      
	  ReplaceWithBlank(line,'[');
	  ReplaceWithBlank(line,']');
	      
	  if(theno == 1)
	    sscanf(line,"%d%g",&itemp[0],&temp[0]);
	  else if(theno == 2)
	    sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
	  else if(theno == 3)
	    sscanf(line,"%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		   &itemp[2],&temp[2]);
	  else if(theno == 4)
	    sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],&temp[3]);
	  else if(theno == 5)
	    sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],
		   &temp[3],&itemp[4],&temp[4]);
	  else
	    printf("Error on Reading Edep in SILICON: theno=%d\n",theno);
	    
	  for(j=1; j<=theno; j++)
	    {
	      int iy,ix,ip; //iy is ladder no.
		  
	      iy = (itemp[j-1]-1)/44 + 1;
	      ix = (itemp[j-1]-(iy-1)*44-1)/4 + 1;
	      ip = itemp[j-1]-(iy-1)*44-(ix-1)*4;

	      si2[iy-1][ix-1][ip-1] = temp[j-1];
	    }

	  fgets(line,MAXLINE,fp);
	  theno = NumberOfChar(line,'[');
	}

      fscanf(fp,"%s%s%s%d",s1,s2,s3,&l); //SILICON LAYER = 3
      fgets(line,MAXLINE,fp);
      
      fgets(line,MAXLINE,fp);
      theno = NumberOfChar(line,'[');

      while(theno)
	{
	  int   itemp[5]={0,0,0,0,0};
	  float temp[5]={0.,0.,0.,0.,0.};
	      
	  ReplaceWithBlank(line,'[');
	  ReplaceWithBlank(line,']');
	      
	  if(theno == 1)
	      sscanf(line,"%d%g",&itemp[0],&temp[0]);
	  else if(theno == 2)
	    sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
	  else if(theno == 3)
	    sscanf(line,"%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		   &itemp[2],&temp[2]);
	  else if(theno == 4)
	    sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],&temp[3]);
	  else if(theno == 5)
	    sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],
		   &temp[3],&itemp[4],&temp[4]);
	  else
	    printf("Error on Reading Edep in SILICON: theno=%d\n",theno);
	    
	  for(j=1; j<=theno; j++)
	    {
	      int iy,ix,ip; //iy is ladder no.
		  
	      iy = (itemp[j-1]-1)/40 + 1;
	      ix = (itemp[j-1]-(iy-1)*40-1)/4 + 1;
	      ip = itemp[j-1]-(iy-1)*40-(ix-1)*4;

	      si3[iy-1][ix-1][ip-1] = temp[j-1];
	    }

	  fgets(line,MAXLINE,fp);
	  theno = NumberOfChar(line,'[');
	}

      fscanf(fp,"%s%s%s%d",s1,s2,s3,&l); //SILICON LAYER = 4
      fgets(line,MAXLINE,fp);
      
      fgets(line,MAXLINE,fp);
      theno = NumberOfChar(line,'[');

      while(theno)
	{
	  int   itemp[5]={0,0,0,0,0};
	  float temp[5]={0.,0.,0.,0.,0.};
	      
	  ReplaceWithBlank(line,'[');
	  ReplaceWithBlank(line,']');
	      
	  if(theno == 1)
	      sscanf(line,"%d%g",&itemp[0],&temp[0]);
	  else if(theno == 2)
	    sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
	  else if(theno == 3)
	    sscanf(line,"%d%g%d%%d%gg",&itemp[0],&temp[0],&itemp[1],&temp[1],
		   &itemp[2],&temp[2]);
	  else if(theno == 4)
	    sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],&temp[3]);
	  else if(theno == 5)
	    sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],
		   &itemp[1],&temp[1],&itemp[2],&temp[2],&itemp[3],
		   &temp[3],&itemp[4],&temp[4]);
	  else
	    printf("Error on Reading Edep in SILICON: theno=%d\n",theno);
	    
	  for(j=1; j<=theno; j++)
	    {
	      int iy,ix,ip; //iy is ladder no.
		  
	      iy = (itemp[j-1]-1)/40 + 1;
	      ix = (itemp[j-1]-(iy-1)*40-1)/4 + 1;
	      ip = itemp[j-1]-(iy-1)*40-(ix-1)*4;

	      si4[iy-1][ix-1][ip-1] = temp[j-1];
	    }

	  fgets(line,MAXLINE,fp);
	  theno = NumberOfChar(line,'[');
	}

//energy deposition in each scintillator layer
      fgets(line,MAXLINE,fp);   //ENERGY DEPOSITION EACH SCINTILLATOR LAYER
      fgets(line,MAXLINE,fp);   //read blank line

      for(k=1; k<=3; k++)   //1-SCN1, 2-SCN2, 3-SCN3
	{
	  for(i=1; i>=0; i--)   //1-upper, 0-lower
	    {
	      fgets(line,MAXLINE,fp); //LAYER=SCN1X(upper), LAYER=SCN1Y(lower) 
	      fgets(line,MAXLINE,fp);
	      theno = NumberOfChar(line,'[');

	      while(theno)
		{
		  int   itemp[5]={0,0,0,0,0};
		  float temp[5]={0.,0.,0.,0.,0.};
	      
		  ReplaceWithBlank(line,'[');
		  ReplaceWithBlank(line,']');
	      
		  if(theno == 1)
		    sscanf(line,"%d%g",&itemp[0],&temp[0]);
		  else if(theno == 2)
		    sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
		  else if(theno == 3)
		    sscanf(line,"%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
			   &itemp[2],&temp[2]);
		  else if(theno == 4)
		    sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
			   &itemp[2],&temp[2],&itemp[3],&temp[3]);
		  else if(theno == 5)
		    sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
			   &itemp[2],&temp[2],&itemp[3],&temp[3],
			   &itemp[4],&temp[4]);
		  else
		    printf("Error on Reading Edep in SILICON: theno=%d\n",
			   theno);
	    
		  for(j=1; j<=theno; j++)
		    {
		      int is; //iy is strip no.
		  
		      is = itemp[j-1];

		      if (k==1)                     //SCN1
			scn1[i][is-1] = temp[j-1];
		      else if (k==2)                //SCN2
			scn2[i][is-1] = temp[j-1];
		      else                          //SCN3
			scn3[i][is-1] = temp[j-1];
		    }

		  fgets(line,MAXLINE,fp);
		  theno = NumberOfChar(line,'[');
		}
	    }
	}

// energy deposition in each bgo crystal bar
      fgets(line,MAXLINE,fp);   //ENERGY DEPOSITION EACH BGO CRYSTAL BAR
      fgets(line,MAXLINE,fp);   //read blank line

      for(i=1; i<=5; i++)   //1,3,5,7,9-odd layer
	{
	  fgets(line,MAXLINE,fp); //BGO LAYER = 1,... BGO LAYER = 9
	  fgets(line,MAXLINE,fp);
	  theno = NumberOfChar(line,'[');

	  while(theno)
	    {
	      int   itemp[5]={0,0,0,0,0};
	      float temp[5]={0.,0.,0.,0.,0.};
	      
	      ReplaceWithBlank(line,'[');
	      ReplaceWithBlank(line,']');
	      
	      if(theno == 1)
		sscanf(line,"%d%g",&itemp[0],&temp[0]);
	      else if(theno == 2)
		sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
	      else if(theno == 3)
		sscanf(line,"%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		       &itemp[2],&temp[2]);
	      else if(theno == 4)
		sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		       &itemp[2],&temp[2],&itemp[3],&temp[3]);
	      else if(theno == 5)
		  sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		   &itemp[2],&temp[2],&itemp[3],&temp[3],&itemp[4],&temp[4]);
	      else
		printf("Error on Reading Edep in SILICON: theno=%d\n",theno);
	    
	      for(j=1; j<=theno; j++)
		{
		  int ix; //BGO layer no(1,3,5,7,9) 
		  int iy; //upper(2) or lower(1)
		  int iz; //crystal no(1-20)
		  
		  ix = 2*i-1;
		  iy = (itemp[j-1]-1)/20 + 1;
		  iz = itemp[j-1] - (iy-1)*20;
		  bgo[ix-1][iy-1][iz-1] = temp[j-1];
		}

	      fgets(line,MAXLINE,fp);
	      theno = NumberOfChar(line,'[');
	    }
	}

      for(i=1; i<=5; i++)   //2,4,6,8,10-even layer
	{
	  fgets(line,MAXLINE,fp); //BGO LAYER = 2,... BGO LAYER = 10
	  fgets(line,MAXLINE,fp);
	  theno = NumberOfChar(line,'[');

	  while(theno)
	    {
	      int   itemp[5]={0,0,0,0,0};
	      float temp[5]={0.,0.,0.,0.,0.};
	      
	      ReplaceWithBlank(line,'[');
	      ReplaceWithBlank(line,']');
	      
	      if(theno == 1)
		sscanf(line,"%d%g",&itemp[0],&temp[0]);
	      else if(theno == 2)
		sscanf(line,"%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1]);
	      else if(theno == 3)
		sscanf(line,"%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		       &itemp[2],&temp[2]);
	      else if(theno == 4)
		sscanf(line,"%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		       &itemp[2],&temp[2],&itemp[3],&temp[3]);
	      else if(theno == 5)
		sscanf(line,"%d%g%d%g%d%g%d%g%d%g",&itemp[0],&temp[0],&itemp[1],&temp[1],
		   &itemp[2],&temp[2],&itemp[3],&temp[3],&itemp[4],&temp[4]);
	      else
		printf("Error on Reading Edep in SILICON: theno=%d\n",theno);
	    
	      for(j=1; j<=theno; j++)
		{
		  int ix; //BGO layer no(2,4,6,8,10) 
		  int iy; //upper(2) or lower(1)
		  int iz; //crystal no(1-20)
		  
		  ix = 2*i;
		  iy = (itemp[j-1]-1)/20 + 1;
		  iz = itemp[j-1] - (iy-1)*20;
		  bgo[ix-1][iy-1][iz-1] = temp[j-1];
		}

	      fgets(line,MAXLINE,fp);
	      theno = NumberOfChar(line,'[');
	    }
	}
// total energy deposit in BGO
      fscanf(fp,"%s%s%g\n",s1,s2,&sum);
    }
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET