Hi,
I have this class named Q where i can save the value and the error of a Q object.
I am analyzing a lot of data so i thought to separate in two macros the analysis so that in the first one i simply evaluate some arrays of Q objects from the data (that is going to take a while) and in the second one i will evaluate what i need for the analysis from the arrays of the Q objects.
So in the first macro i had calculated the arrays
Q N_peak[Nfs][Netabin+1][Nptbin+1][NmTcut][Ndistpeak][Ndistbkg];
Q N_bkg_lower[Nfs][Netabin+1][Nptbin+1][NmTcut][Ndistpeak][Ndistbkg];
Q N_bkg_upper[Nfs][Netabin+1][Nptbin+1][NmTcut][Ndistpeak][Ndistbkg];
Q N_bkg_both[Nfs][Netabin+1][Nptbin+1][NmTcut][Ndistpeak][Ndistbkg];
but now i don’t know how to pass them to the second macro because i tried to use a TTree and save it in a TFile but it didn’t work, maybe i made some mistakes.
here what i wrote:
in the first macro
TFile* fout = new TFile("prepare_fey_output.root" , "recreate");
TTree *tree = new TTree("Tree_prepare_fey", "Tree_prepare_fey");
tree->Branch("N_peak", N_peak, "N_peak/D");
tree->Branch("N_bkg_lower", N_bkg_lower, "N_bkg_lower/D");
tree->Branch("N_bkg_upper", N_bkg_upper, "N_bkg_upper/D");
tree->Branch("N_bkg_both", N_bkg_both, "N_bkg_both/D");
tree->Fill();
fout->Write();
in the second macro
TFile *file = new TFile("prepare_fey_output.root", "READ");
// Ottieni il TTree dal file
TTree *tree = dynamic_cast<TTree*>(file->Get("Tree_prepare_fey"));
// Collega i rami del TTree agli array
tree->SetBranchAddress("N_peak", N_peak);
tree->SetBranchAddress("N_bkg_lower", N_bkg_lower);
tree->SetBranchAddress("N_bkg_upper", N_bkg_upper);
tree->SetBranchAddress("N_bkg_both", N_bkg_both);
// Leggi il TTree
tree->GetEntry(0);
// Chiudi il file
file->Close();