Hi, I am being puzzled by a strange problem when I tried to create a TTree file with two branches. My intention was to use each branch to save a vector and the vector’s three components. The related codes are as follows:
double px, py, pz;
double direcx, direcy, direcz;
TTree *tree=new TTree(“EventTree”, “EventTree”);
tree->Branch(“position”, position, "position/D:px/D:py/D:pz/D);
tree->Branch(“direction”, direction, “direction/D:direcx/D:direcy/D:direcz/D”);
void Filltree(double pos, double direc)
for (int j=0;j<3;j++)
position[j] = pos[j];
direction[j] = direc[j];
px=position; py=position; pz=position; direcx=direction; direcy=direction; direcz=direction; tree->Fill();
When I opened the generated root file in TBrowser, I was surprised to find that the values of position, position, position were saved in direcx, direcy and direcz respectively, but components of direction were saved in px, py and pz respectively! They are just exactly reverse!
It seemed to be impossible! What 's wrong with my program? I have checked it for times but failed to get the answer. Thans for your help.