Hi Rooters,
Again a stupid problem

I read 2 ASCII files in 2 different ways and I show the data on the screen, but when I create an object (thant later I will store in a ROOT file an clean) and I try to fill the members inside the “while” loop that I’m using to read, the output ROOT file contains only crap when I’m trying to recover what my new ROOT file contains. I have tried almost all the possibilities: I had created one function to fill the object, I had store the values in a vector tha is being read by an external “for” loop, I had change the shape of the object… always crap, I’m storing different numbers that I’m seein in my screen!
Here you have the part of the code that I use to create the output ROOT file (a part of the main):
[code]…
TFile hfile(RootOut,“RECREATE”,“Data from Raw files”);
…
ifstream infile;
…
//trees and branches---------------------------
CRawData *entry = 0; //the object “entry”, the class CRawData
TTree *tree = new TTree(“Pino”,“RAW data tree”);
tree->Branch(“entries”,“CRawData”,&entry,16000,2);
//opening the files-------------------------------------
FILE *file = fopen(RawIn, “r”);
infile.open(SlowCIn);
Int_t ent = 0; //number of entries
while (!feof(file)) {
reading(file,Traw,Trigch,Datach,th1,th2,th3); //function that reads from one file
cout << "Raw Time passed " << Traw << " TrigCh " << Trigch << endl;
// here I obtein proper values
entry = new CRawData(); // the object again
//reading from SlowCIn
infile >> TimeStart >> Time >> Gas_Pres >> Gas_Temp >> GasTA >> GasTB >> O2cont >> HVFcage;
// put the data on the screen
cout << " Times " << TimeStart << " " << Time << endl;
cout << " Gas P and T " << Gas_Pres << " " << Gas_Temp << endl;
cout << " TA and TB " << GasTA << " " << GasTB << endl;
cout << " O2 and HVFcage " << O2cont << " " << HVFcage << endl;
//building a spectrum
making(th1,th2,th3,array);
for (int i=0;i<1024; i++){
//cout << " spectrum bin : " << array[i] << endl;
}
//store the data in a CRawData object-------------------
build(TimeStart,Time,Gas_Pres,Gas_Temp,GasTA,GasTB,O2cont,HVFcage,array,entry);
tree->Fill();
ent++;
entry->Clear();
}
tree->Print();
cout << " Number of entries : " << ent << endl;
infile.close();
printf( “Reading File SlowCIn Closed\n” );
//“SLowCIn” closed---------------------------------------
if( !fclose(file) )
printf( “Reading File RawIn Closed\n” );
else
{
printf( “Error: file NOT CLOSED\n” );
return 1;
}
hfile.Write();
hfile.Close();
cout<< " Writting File RootOut Closed "<< endl;
-------------------------------------------------------[/code]
With this I’m expecting a Tree with a branch and lot of leaves with serialized information about the members of my object.
After that I try to read one leaf (for example “GasTA”) with this program:
[code]---------------------------------------------------------
int main(int argc, char **argv) //main program
{
//the application
TApplication *myApp = new TApplication(“myApp”,&argc, argv);
TFile *f= new TFile(“algo.root”);
TTree Pino = (TTree)f->Get(“Pino”);
CRawData entry = new CRawData();
Pino->SetBranchAddress(“entries”,&entry);
Pino->SetBranchStatus("",1);
Int_t eventos = (int)Pino->GetEntries();
cout << “Events in the file :” << eventos << endl;
Int_t muestra;
cout << “Events to analyze ?:” << endl;
cin >> muestra;
for(Int_t i=0;i< muestra;i++){
if (i >0){
entry->Clear();}
if (Pino->GetEvent(i)<0){
cout << "la cagaste !" << endl;
continue;
}
cout << "Gas TA" << entry->getGasTB() << endl; //here I'm reading
}//end for
//close the file
f->Close();
//run myApp object
myApp->Run();
return 0;
}// end of main
------------------------------------------------------[/code]
Well, this is a long post, I know, but surely the answer will be short. I need to solve it, so, if I solve it before receiving an answer, I will post the solution ![]()
Thanks in advance!
Cheers!

