[Gate-users] Question about getting time information from root file (Olie Scienti)
David Boersma
david.boersma at physics.uu.se
Tue Feb 28 10:11:50 CET 2017
Hi Oliver,
Sorry to let you wait for so long.
Could you try again, replacing:
Float_t globalPosX, energy, time;
with:
Float_t globalPosX, energy;
Double_t time;
You can check the types of this ROOT tree in the source code:
source/general/include/GateRootDefs.hh
If you get crazy numbers for your ROOT tree variables (10e-300, etc)
that is usually a hint that you are using the wrong type for the
variable whose pointer you are passing to SetBranchAddress.
David
Den 22/02/2017 kl. 19:51, skrev Oliver Len Scienti:
> 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();
>
>
>
> _______________________________________________
> Gate-users mailing list
> Gate-users at lists.opengatecollaboration.org
> http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
>
More information about the Gate-users
mailing list