Hello Rooters,
We are trying to implement two dimensional arrays and we are encountering unexpected behaviours.
Within a same tree we declare several TBranches with two dimensional arrays.
While looking at the spectra, one realised that the first TBranch contains elements from the next TBranch.
I t
Please find in the following text more details:
Here are the declaration of the arrays:
In EventAction.hh
...
Double_t** Cl_Cr_KU_En;
Double_t** Cl_Cr_KU_EnAb;
Double_t** Cl_Cr_KU_X;
Double_t** Cl_Cr_KU_Y;
Double_t** Cl_Cr_KU_Z;
Double_t** Cl_Cr_KU_Rho;
Double_t** Cl_Cr_KU_Theta;
Double_t** Cl_Cr_KU_Phi;
Double_t** Cl_Cr_KU_XAb;
Double_t** Cl_Cr_KU_YAb;
Double_t** Cl_Cr_KU_ZAb;
Double_t** Cl_Cr_KU_RhoAb;
Double_t** Cl_Cr_KU_ThetaAb;
Double_t** Cl_Cr_KU_PhiAb;
...
In EventAction.cc:
...
Cl_Cr_KU_En = new Double_t*[nb_ClKU];
Cl_Cr_KU_EnAb = new Double_t*[nb_ClKU];
Cl_Cr_KU_X = new Double_t*[nb_ClKU];
Cl_Cr_KU_Y = new Double_t*[nb_ClKU];
Cl_Cr_KU_Z = new Double_t*[nb_ClKU];
Cl_Cr_KU_XAb = new Double_t*[nb_ClKU];
Cl_Cr_KU_YAb = new Double_t*[nb_ClKU];
Cl_Cr_KU_ZAb = new Double_t*[nb_ClKU];
Cl_Cr_KU_Rho = new Double_t*[nb_ClKU];
Cl_Cr_KU_Theta = new Double_t*[nb_ClKU];
Cl_Cr_KU_Phi = new Double_t*[nb_ClKU];
Cl_Cr_KU_RhoAb = new Double_t*[nb_ClKU];
Cl_Cr_KU_ThetaAb = new Double_t*[nb_ClKU];
Cl_Cr_KU_PhiAb = new Double_t*[nb_ClKU];
...
...
for(int yup=0; yup<nb_ClKU;yup++){
Cl_Cr_KU_En[yup] = new Double_t[4];
Cl_Cr_KU_EnAb[yup] = new Double_t[4];
Cl_Cr_KU_X[yup] = new Double_t[4];
Cl_Cr_KU_Y[yup] = new Double_t[4];
Cl_Cr_KU_Z[yup] = new Double_t[4];
Cl_Cr_KU_XAb[yup] = new Double_t[4];
Cl_Cr_KU_YAb[yup] = new Double_t[4];
Cl_Cr_KU_ZAb[yup] = new Double_t[4];
Cl_Cr_KU_Rho[yup] = new Double_t[4];
Cl_Cr_KU_Theta[yup] = new Double_t[4];
Cl_Cr_KU_Phi[yup] = new Double_t[4];
Cl_Cr_KU_RhoAb[yup] = new Double_t[4];
Cl_Cr_KU_ThetaAb[yup] = new Double_t[4];
Cl_Cr_KU_PhiAb[yup] = new Double_t[4];
}
...
...
fTree2 -> Branch ("Cl_Cr_KU_En", &Cl_Cr_KU_En[0][0], Form("Cl_Cr_KU_En[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_EnAb", &Cl_Cr_KU_EnAb[0][0], Form("Cl_Cr_KU_EnAb[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_X", &Cl_Cr_KU_X[0][0], Form("Cl_Cr_KU_X[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_Y", &Cl_Cr_KU_Y[0][0], Form("Cl_Cr_KU_Y[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_Z", &Cl_Cr_KU_Z[0][0], Form("Cl_Cr_KU_Z[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_Rho", &Cl_Cr_KU_Rho[0][0], Form("Cl_Cr_KU_Rho[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_Theta", &Cl_Cr_KU_Theta[0][0], Form("Cl_Cr_KU_Theta[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_Phi", &Cl_Cr_KU_Phi[0][0], Form("Cl_Cr_KU_Phi[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_XAb", &Cl_Cr_KU_XAb[0][0], Form("Cl_Cr_KU_XAb[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_YAb", &Cl_Cr_KU_YAb[0][0], Form("Cl_Cr_KU_YAb[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_ZAb", &Cl_Cr_KU_ZAb[0][0], Form("Cl_Cr_KU_ZAb[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_RhoAb", &Cl_Cr_KU_RhoAb[0][0], Form("Cl_Cr_KU_RhoAb[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_ThetaAb", &Cl_Cr_KU_ThetaAb[0][0], Form("Cl_Cr_KU_ThetaAb[%i][4]/D", nb_ClKU));
fTree2 -> Branch ("Cl_Cr_KU_PhiAb", &Cl_Cr_KU_PhiAb[0][0], Form("Cl_Cr_KU_PhiAb[%i][4]/D", nb_ClKU));
...
So to be more precise, in the spectra of Cl_Cr_KU_En[3][1], one can observe the content not of an energy but a spectrum corresponding to a position X Y or Z. In the beginning of the array, one observe energy spectra.
In order to remedy to this problem, we changed all the double as Double_t but it did not change the situation.
We thought that the problem might come from the values we were filling in the tree, but by filling each element of the arrays in a separate TBranch we observe the expected values.
If you have any idea how to solve this issue, please help .
Thank you in advance,
Christophe
_ROOT Version: ROOT Version: 6.16/00
Built for macosx64 on Sep 26 2019
_Platform: Mac Osx Mojave 10.14.6
_Compiler: g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.16)
Target: x86_64-apple-darwin18.7.0