Hello,
2 things really. I have a bunch of old PAW routines that take care of about half of the work i need to do. Is there anyway that i can make use of this routines and go on to analyze their output (various histograms) in ROOT?
I have some of the output in an ascii file with the data arranged in columns like so:
1.50000 0.00333 0.00000 0.00000 0.00000 0.00000 0.000E+00 0.000E+00
4.50000 0.00333 0.00000 0.00000 0.00000 0.00000 0.000E+00 0.000E+00
7.50000 0.00333 0.00000 0.00000 0.00000 0.00000 0.000E+00 0.000E+00
10.50000 0.00333 0.00000 0.00000 0.00000 0.00000 0.000E+00 0.000E+00
I took the cernstaff ($ROOTSYS/tutorials/cernstaff.C) example and edited it for my purposes:
[code]{
//Purpose: extract data from ascii tables and save in ROOT tree
gROOT->Reset();
//Struct carrying the corrections and their attriputes for each particle's bin
struct corr_t{
Double_t phi;
Double_t phistep;
Double_t ratio;
Double_t ratiosig;
Double_t sigsig;
Double_t N;
Double_t Nsig;
Double_t miss;
};
corr_t corr;
//open the ASCII file
FILE *fp = fopen("/w/work3602b/goettj/g11/physics/tables/p1_0903.vec","r");
char line[99];
//create a new ROOT file
TFile *f = new TFile("corrdat.root","RECREATE");
//create a TTree
TTree *corrections = new TTree("corr","results from PAW calculations");
//create one branch with all information from the structure
corrections->Branch("corr", &corr.phi,"phi/F:phi:phistep:ratio:ratiosig:sigsig:N:Nsig:miss");
//fill the tree with the values from the ASCII file
//while(fgets(line, sizeof(line), fp) !=NULL){
sscanf(&line[0],"%g%g%g%g%g%g%g",&corr.phi,&corr.phistep,&corr.ratio,&corr.ratiosig,&corr.sigsig,&corr.N,&corr.Nsig,&corr.miss);
printf("%g %g %g %g %g %g %g\n", corr.phi , corr.phistep , corr.ratio , corr.ratiosig , corr.sigsig , corr.N , corr.Nsig , corr.miss);
cout << endl << endl;
corrections->Fill();
}
//check that the tree was created properly
corrections->Print();
//close the input file
fclose(fp);
f->Write();
}[/code]
Everything seems to work fine, except for the fact that instead of saving the values as in the file:
instead it saves:
2.08862e-278 2.18187e+243 9.28602e+242 2.17354e+243 1.71434e+161 1.66881e-307 3.
68978e-313
Am i missing something?
Thanks,
Johnny