ROOT Version: 6.18/04
Platform: 18.04
Compiler: cc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
Hello co-rooters,
I’m posting here because it looks like it might be a silly mistake happening.
I am reading a root file that contains a TTree
. The trouble is that when I read the file and store the contents of the TBranch
es in a variable I get a value of 4.68242e-3101 instead of the actual value. If I open the file on a root session and
Scan(“*”)` I get what I am expecting to get i.e.
root [15] new TFile("../codes/149Sm_RP_FINAL_pub.root")
(TFile *) 0x563223e94390
root [16] .ls
TFile** ../codes/149Sm_RP_FINAL_pub.root
TFile* ../codes/149Sm_RP_FINAL_pub.root
KEY: TTree resonances;1 Resonance parameters from SAMMY fits
root [18] resonances->Scan("*")
************************************************************************************************************************************************************
* Row * Er * dEr * Gg * dGg * Gn * dGn * Gn0 * dGn0 * TwoG.TwoG * TwoGGn.Tw * dTwoGGn.d * J *
************************************************************************************************************************************************************
* 0 * 0.097 * 0.0001 * -65.62 * 0 * 0.545 * 0.000528 * 1.7498895 * 0.0016953 * 1.125 * 0.613125 * 0.000594 * 4 *
* 1 * 0.8703 * 0.0001 * 60.8 * 0 * -0.749 * 0.000522 * 0.8028738 * -0.000559 * 1.125 * -0.842625 * 0.0005872 * 4 *
* 2 * 4.945 * 0.0001 * 64 * 0 * 1.67 * 0.00169 * 0.7509885 * 0.0007599 * 1.125 * 1.87875 * 0.0019012 * 4 *
* 3 * 6.4347 * 0.0001 * 66 * 0 * 0.847 * 0.0011 * 0.3339021 * 0.0004336 * 1.125 * 0.952875 * 0.0012375 * 4 *
* 4 * 8.9112 * 0.0007 * 56.31 * 1.55 * 1.4 * 0.0103 * 0.4689860 * 0.0034503 * 0.875 * 1.225 * 0.0090125 * 3 *
* 5 * 8.9409 * 0.0002 * 77.86 * 0.27 * 7.19 * 0.0122 * 2.4045746 * 0.0040800 * 1.125 * 8.08875 * 0.013725 * 4 *
* 6 * 9.2017 * 0.0015 * 40.24 * 2.03 * 0.197 * 0.00422 * 0.0649429 * 0.0013911 * 0.875 * 0.172375 * 0.0036925 * 3 *
* 7 * 12.0104 * 0.0001 * 67.58 * 0.32 * 1.74 * 0.00301 * 0.5020772 * 0.0008685 * 0.875 * 1.5225 * 0.0026337 * 3 *
* 8 * 14.8669 * 0.001 * 57.12 * 1.78 * 1.45 * 0.0127 * 0.3760605 * 0.0032937 * 0.875 * 1.26875 * 0.0111125 * 3 *
* 9 * 14.9166 * 0.0003 * 66.85 * 0.59 * 3.96 * 0.0127 * 1.0253219 * 0.0032882 * 1.125 * 4.455 * 0.0142875 * 4 *
* 10 * 15.8713 * 0.0006 * 63.85 * 1.45 * 0.323 * 0.00172 * 0.0810767 * 0.0004317 * 0.875 * 0.282625 * 0.001505 * 3 *
* 11 * 17.1631 * 0.0002 * 64.54 * 0.46 * 1.85 * 0.00387 * 0.4465538 * 0.0009341 * 1.125 * 2.08125 * 0.0043537 * 4 *
* 12 * 23.2562 * 0.0005 * 97.55 * 1.33 * 0.908 * 0.0031 * 0.1882853 * 0.0006428 * 1.125 * 1.0215 * 0.0034875 * 4 *
* 13 * 24.7428 * 0.0017 * 169.2 * 6.41 * 0.452 * 0.00671 * 0.0908686 * 0.0013489 * 1.125 * 0.5085 * 0.0075487 * 4 *
* 14 * 25.282 * 0.0003 * 81.01 * 0.81 * 13.6 * 0.045 * 2.7047877 * 0.0089496 * 0.875 * 11.9 * 0.039375 * 3 *
* 15 * 26.12 * 0.0004 * 61.13 * 0.87 * 2.87 * 0.00843 * 0.5615588 * 0.0016494 * 1.125 * 3.22875 * 0.0094837 * 4 *
* 16 * 28.0194 * 0.0013 * 91.38 * 3.45 * 0.576 * 0.00507 * 0.1088160 * 0.0009578 * 0.875 * 0.504 * 0.0044362 * 3 *
* 17 * 29.945 * 0.0005 * -93.02 * 1.31 * -2.89 * 0.00902 * 0.5281237 * -0.001648 * 0.875 * -2.52875 * 0.0078925 * 3 *
* 18 * 30.8578 * 0.0003 * 71.5 * 0.75 * 8.48 * 0.0311 * 1.5265582 * 0.0055985 * 1.125 * 9.54 * 0.0349875 * 4 *
* 19 * 33.986 * 0.0004 * 88.59 * 0.94 * 5.11 * 0.0155 * 0.8765382 * 0.0026587 * 1.125 * 5.74875 * 0.0174375 * 4 *
* 20 * 40.2614 * 0.0003 * 124.6 * 0.66 * 22.8 * 0.0317 * 3.5932746 * 0.0049959 * 0.875 * 19.95 * 0.0277375 * 3 *
* 21 * 41.3896 * 0.0003 * 77.73 * 0.77 * 22.7 * 0.0536 * 3.5284197 * 0.0083314 * 0.875 * 19.8625 * 0.0469 * 3 *
* 22 * 44.3331 * 0.0002 * 49.51 * 0.15 * 66.3 * 0.208 * 9.9574808 * 0.0312391 * 1.125 * 74.5875 * 0.234 * 4 *
* 23 * 45.124 * 0.0005 * 53.18 * 1.18 * 11 * 0.0238 * 1.6375285 * 0.0035430 * 1.125 * 12.375 * 0.026775 * 4 *
* 24 * 49.3949 * 0.005 * 151.35 * 7.99 * 1.49 * 0.037 * 0.2120045 * 0.0052645 * 1.125 * 1.67625 * 0.041625 * 4 *
Type <CR> to continue or q to quit ==> q
************************************************************************************************************************************************************
(long long) 25
Here’s my code
#include "TTree.h"
#include "TFile.h"
#include "TBranch.h"
#include "TString.h"
#include <vector>
#include <fstream>
#include <iostream>
using namespace std;
void test(TString filename_in){
double Er, dEr, Gg, dGg, Gn, dGn, Gn0, dGn0, TwoG, TwoGGn, dTwoGGn;
int J;
TFile *f_file_in = new TFile(filename_in, "OPEN");
TTree *T_resonances = (TTree*)f_file_in->Get("resonances");
T_resonances->Branch("Er" , &Er);
T_resonances->Branch("dEr" , &dEr);
T_resonances->Branch("Gg" , &Gg);
T_resonances->Branch("dGg" , &dGg);
T_resonances->Branch("Gn" , &Gn);
T_resonances->Branch("dGn" , &dGn);
T_resonances->Branch("Gn0" , &Gn0);
T_resonances->Branch("dGn0" , &dGn0);
T_resonances->Branch("TwoG" , &TwoG);
T_resonances->Branch("TwoGGn" , &TwoGGn);
T_resonances->Branch("dTwoGGn", &dTwoGGn);
T_resonances->Branch("J" , &J);
Long64_t entries = T_resonances->GetEntries();
for (Long64_t i=0; i<entries; ++i){
T_resonances->GetEntry(i);
cout << i << ". Er = " << Er << endl;
}
//T_resonances->Scan("*");
}
The output of the cout
is weird
0. Er = 4.68242e-310
1. Er = 4.68242e-310
2. Er = 4.68242e-310
3. Er = 4.68242e-310
4. Er = 4.68242e-310
5. Er = 4.68242e-310
6. Er = 4.68242e-310
7. Er = 4.68242e-310
8. Er = 4.68242e-310
9. Er = 4.68242e-310
…
Any idea?
FYI, I’m compiling first using .L test.C++
and then executing: test("../codes)/149Sm_RP_FINAL_pub.root"
Thanks in advance!