Hi,
I have a mysterious problem with filling a simple tree.
I am using root 5.15.50 compiled on RedHat 7.3.
I get segmentation fault at the level of filling up the tree.
I ran my gdb debugger and the following message came about:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1026 (LWP 10582)]
0x401f7e51 in TClass::Streamer () from /cern/root/lib/libCore.so.3.03
(gdb) list
386 Delay(2*CLK_TCK);
387 }
388 }
389
390 /*lint -esym(714,testStaDAQ) */
391 void main (int argc, char *argv[])
392 {
393 extern char *optarg;
394 extern int optind;
395 int errflg = 0;
(gdb)
the code is attached,
thanks in advance,
Masoud
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <signal.h>
#include <setjmp.h>
#include "TROOT.h"
#include "TClass.h"
#include "TTree.h"
#include "TFile.h"
#include "cross.h"
#include "event_structure.h"
#include "tree.h"
#include "TF1.h"
#include "TRandom.h"
#define MP 938.27231
#define sqr(x) ((x)*(x))
TFile *f;
static TTree *tree;
extern track_t track;
extern Island_t *Islands;
extern float PbalCoord[2][576];
static int NoLine;
static const Int_t bufsize=16384; //16384 = 2^14
static jmp_buf tree_environment;
static void fpe_handler(int sig);
extern "C"
int BookTree()
{
// initialize no. of lines
NoLine=0;
// Book ntuple
printf("\n<I> Book ntuple .. \n\n");
// Create a new ROOT file
f = new TFile("ppg.root","RECREATE");
// Create a TTree
tree = new TTree("t","ppg data");
// Set auto save
const Int_t autos=1000;
tree->SetAutoSave(autos);
// Create branches with all information of salad track No. 1
tree->Branch("mul1",&mul1,"mul1/I",bufsize);
tree->Branch("th1",&th1,"th1/F",bufsize);
tree->Branch("ph1",&ph1,"ph1/F",bufsize);
tree->Branch("en1",en1,"en11/F:en12/F:en13/F",bufsize);
// Create branches with all information of salad track No. 2
tree->Branch("mul2",&mul2,"mul2/I",bufsize);
tree->Branch("th2",&th2,"th2/F",bufsize);
tree->Branch("ph2",&ph2,"ph2/F",bufsize);
tree->Branch("en2",en2,"en21/F:en22/F:en23/F",bufsize);
// Create branches with all information of pball track
tree->Branch("mulg",&mulg,"mulg/I",bufsize);
tree->Branch("thg",thg,"thg1/F:thg2/F:thg3/F:thg4/F:thg5/F:thg6/F:thg7/F:thg8/F:thg9/F:thg10/F",bufsize);
tree->Branch("phg",phg,"phg1/F:phg2/F:phg3/F:phg4/F:phg5/F:phg6/F:phg7/F:phg8/F:phg9/F:phg10/F",bufsize);
tree->Branch("delta",delta,"delta1/F:delta2/F:delta3/F:delta4/F:delta5/F:delta6/F:delta7/F:delta8/F:delta9/F:delta10/F",bufsize);
tree->Branch("energy",energy,"energy1/F:energy2/F:energy3/F:energy4/F:energy5/F:energy6/F:energy7/F:energy8/F:energy9/F:energy10/F",bufsize);
// Create branches with all information of reconstruction
tree->Branch("parity",&parity,"parity/I",bufsize);
tree->Branch("e1r",&e1r,"e1r/F",bufsize);
tree->Branch("e2r",&e2r,"e2r/F",bufsize);
tree->Branch("egr",&egr,"egr/F",bufsize);
tree->Branch("phgr",&phgr,"phgr/F",bufsize);
return(0);
}
extern "C"
int FillTree(int i,int j,int k,float recon[4][6],int rec_parity)
{
int cnt,id;
const int SaladSci=24;
// initialize signal
//signal(SIGSEGV,fpe_handler);
// initilization
parity=0;
th1=0.;
ph1=0.;
th2=0.;
ph2=0.;
for(cnt=0;cnt<MAX_SALAD;cnt++) {
en1[cnt]=0.;
en2[cnt]=0.;
}
for(cnt=0;cnt<MAX_PBALL;cnt++) {
thg[cnt]=0.;
phg[cnt]=0.;
delta[cnt]=0.;
energy[cnt]=0.;
e1r=0.;
e2r=0.;
egr=0.;
phgr=0.;
}
// salad part, track No.1
mul1=0;
th1 = track.salad[i].the;
ph1 = track.salad[i].phi;
for(cnt=0;cnt<SaladSci && mul1 < MAX_SALAD-1;cnt++)
if(track.salad[i].ene_e[cnt])
en1[mul1++] = track.salad[i].ene_e[cnt];
// salad part, track No.2
mul2=0;
th2 = track.salad[j].the;
ph2 = track.salad[j].phi;
for(cnt=0;cnt<SaladSci && mul2 < MAX_SALAD-1;cnt++)
if(track.salad[j].ene_e[cnt])
en2[mul2++] = track.salad[j].ene_e[cnt];
// plastic ball part
mulg=0;
for(cnt=0;cnt<Islands[k].no && mulg < MAX_PBALL-1;cnt++) {
id=Islands[k].memb[cnt];
thg[cnt] = PbalCoord[0][id];
phg[cnt] = PbalCoord[1][id];
delta[cnt] = Islands[k].delta[cnt];
energy[cnt] = Islands[k].energy[cnt];
mulg++;
}
// reconstruction part
parity = (Int_t) rec_parity;
e1r = (Float_t) recon[0][0]-MP;
e2r = (Float_t) recon[1][0]-MP;
egr = (Float_t) recon[2][0];
phgr = (Float_t) recon[2][5];
// fill ntuple
tree->Fill();
// jump
if(setjmp(tree_environment)) {
printf("<I> Event bypassed !\n");
return 0;
}
// no of line
NoLine++;
return(0);
}
extern "C"
int CloseTree()
{
// close ntuple
printf("\n<I> close tree .. \n");
tree->Print();
f->Write();
f->Close();
// no of lines
// printf("\n<I> %i written in the tree \n",NoLine);
return(0);
}
extern "C"
double MyRand()
{
return gRandom->Rndm();
}
void fpe_handler(int sig)
{
printf("<E> segmentation fault ...\n");
longjmp(tree_environment,1);
}
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET