Greetings,
I seem to be having an issue with saving multi-dimensional branches in a TTree.
Here is a clip of my code.
void gamma_Trial_III(){
const Int_t len = 10;
TChain *chain = new TChain("Lep");
CLIPPED Branch Setting due to this not related to problem
TTree *t4 = new TTree("Lep_Tree","Lep_Tree");
Int_t photon_num;
Float_t mm_PEpEmGam[len][len], mm_EpEmGam[len][len], mE_PEpEmGam[len][len];
t4->Branch("photon_num",&photon_num,"photon_num/I");
Int_t Ngam;
t4->Branch("Ngam",&Ngam,"Ngam/I");
t4->Branch("mm_EpEmGam",&mm_EpEmGam,"mm_EpEmGam[photon_num][Ngam]/F");
t4->Branch("mm_PEpEmGam",&mm_PEpEmGam,"mm_PEpEmGam[photon_num][Ngam]/F");
t4->Branch("mE_PEpEmGam",&mE_PEpEmGam,"mE_PEpEmGam[photon_num][Ngam]/F");
CLIPPED constant variable initialzation
//----------------Initializing Lorentz Vectors -------------------------------------
TLorentzVector vT, vEg, vP, vEp, vEm, vGamma, vGamma1, vGamma_cor; //vGamma1 used for invariatnt mass with gamma
vT.SetPxPyPzE(0.0, 0.0, 0.0, M_P);
for( Int_t i = 0; i < nEvent; i++){ //nEvent
chain->GetEntry(i);
if(photon_number==0){continue;}
//-------------------momenta squared-----------------------------------
Double_t p2_P = P_Px*P_Px + P_Py*P_Py + P_Pz*P_Pz;
Double_t p2_Ep = Ep_Px*Ep_Px + Ep_Py*Ep_Py + Ep_Pz*Ep_Pz;
Double_t p2_Em = Em_Px*Em_Px + Em_Py*Em_Py + Em_Pz*Em_Pz;
//---------------------------Energy -----------------------------------
Double_t E_P = sqrt(p2_P + M_P*M_P);
Double_t E_Ep = sqrt(p2_Ep + Melectron*Melectron);
Double_t E_Em = sqrt(p2_Em + Melectron*Melectron);
//----------------setting Lorentz Vectors -------------------------------------
vP.SetPxPyPzE(P_Px, P_Py, P_Pz, E_P);
vEp.SetPxPyPzE(Ep_Px, Ep_Py, Ep_Pz, E_Ep);
vEm.SetPxPyPzE(Em_Px, Em_Py, Em_Pz, E_Em);
TLorentzVector IV_EpEmVec = (vEp + vEm);
TLorentzVector IV_PEpEmVec = (vP + vEp + vEm);
for (Int_t j = 0; j<photon_number; j++){
vEg.SetPxPyPzE(0.0, 0.0, IN_photon_E[j], IN_photon_E[j]);
for (Int_t q = 0; q<Ngam; q++){
//----------------setting Outgoing Gamma Lorentz Vector -------------------------------------
vGamma.SetPxPyPzE(Phot_Px[q], Phot_Py[q], Phot_Pz[q], Phot_P[q]);
//----------------------------------------missing mass vectors w/Outgoing Gamma ----------------------------------------------------------------
TLorentzVector MM_EpEmGamVec = (vEg + vT) - (vEp + vEm + vGamma);
TLorentzVector MM_PEpEmGamVec = (vEg + vT) - (vP + vEp + vEm + vGamma);
TLorentzVector MM_PEmGamVec = (vEg + vT) - (vP + vEm + vGamma);
mm_EpEmGam[j][q] = MM_EpEmGamVec.M();
mm_PEpEmGam[j][q] = MM_PEpEmGamVec.M();
mE_PEpEmGam[j][q] = MM_PEpEmGamVec.E();
} // Closes loop of outgoing gamma
} //closes loop of incoming gamma
t4->Fill();
}
t4->Write();
f.Close();
}
The full program will run, but it fills the branches with 0.
However if I ask to std::cout<<mE_PEpEmGam[j][q] <<endl; during the running of the program, it screen outputs reasonable numbers, but never fills the branch with these numbers.
Help please.
Thanks
Michael