[Gate-users] Question about getting time information from root file (Olie Scienti)
Oliver Len Scienti
oliepickford1 at hotmail.co.uk
Wed Feb 22 19:51:29 CET 2017
Hello there,
I am trying to convert the information in the root file into a txt format for processing with a different program, however whenever I write out the time variable it comes out as all 0's or all some ridiculously large (or small) number: the number itself varies even between runs on the same root file.
I include below the relevant bits of code I am using to extract the data: any help as to why I can't seem to read out the time variable would be appreciated!
A few notes: I tried extracting the time variable as integer instead of float and that didn't work. Also I checked with the TBroswer that there are a range of time values and there are, so not sure why I can only seem to extract all of the same nonsense values.
// Take the single tree, containing the position, energy and time
TTree* singlesTree = (TTree*)file->Get( "Singles" );
// Declare variables
Float_t globalPosX, energy, time;
//Source values
singlesTree->SetBranchAddress( "globalPosX", &globalPosX );
singlesTree->SetBranchAddress( "time", &time );
singlesTree->SetBranchAddress( "energy", &energy );
//open output file
ofstream outputfile;
outputfile.open ("ConversionTest.txt");
if (outputfile.is_open())
{
for( Int_t ijk = 0; ijk != entriesSingleTree; ++ijk ) //loop over tree
{
singlesTree->GetEntry( ijk );
outputfile << globalPosX << " " << time << " " << energy << "\n"; //write values to file
}
}
outputfile.close();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opengatecollaboration.org/mailman/private/gate-users/attachments/20170222/cfb364b1/attachment-0001.html>
More information about the Gate-users
mailing list