ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Hi Everyone !
I have two trees in my root file. The names are “dklfv”(variable inside D0_P4) & “pion”(variable name is pi_P4). I want to save these variables in a new tree. I have made an empty tree(nEmcPhotons). I want to save information in my newly made two branches(nPhot & mom). I am attaching the code I have written and the error I am getting. Please sort out the problem.
Thanks in Advance.
void ds()
{
TFile *f = new TFile("peter.root", "recreate");
float nPhot;
float E[500];
float mom;
TTree* nEmcPhotons = new TTree("nEmcPhotons", "EMC Photons");
nEmcPhotons->Branch("nPhot", &nPhot, "nPhot/F");
nEmcPhotons->Branch("E", &E, "E[nPhot]/F");
nEmcPhotons->Branch("mom", &mom, "mom/F");
TFile* f2= new TFile("/home/souvik/root_work/lfv1.root");
TTree* t2=(TTree*)f2->Get("dklfv");
float pd3[4];
t2->SetBranchAddress("D0_P4", &pd3);
TH1F *hist2 = new TH1F("", " ", 50, 1.7, 2.1);
Int_t n_tot2 = (int)t2->GetEntries();
TLorentzVector v1(2.,2.,3.,4.);
TVector3 p = v1.Vect();
for (int i=0;i<100; i++)
{
t2->GetEntry(i);
TLorentzVector D0_fvec(pd3);
float fMomentum = D0_fvec.M();
{
nPhot->Fill(fMomentum);
}
}
TFile* f1= new TFile("/home/souvik/root_work/lfv1.root");
TTree* t1=(TTree*)f1->Get("pion");
float pd1[4];
t1->SetBranchAddress("pi_P4", &pd1);
TH1F *hist1 = new TH1F("", " ", 50, 0.13956, 0.13958);
TCanvas* c1 = new TCanvas();
c1->Divide(3,2);
c1->cd(1);
Int_t n_tot2_1 = (Int_t)t1->GetEntries();
for (int i=0;i<n_tot2_1; i++)
{
t1->GetEntry(i);
TLorentzVector D0_fvec(pd1);
float fMomentum = D0_fvec.Mag();
{
mom->Fill(fMomentum);
}
}
f->Write();
}
Error:
error: member reference type 'float' is not a pointer
nPhot->Fill(fMomentum);
member reference type 'float' is not a pointer
mom->Fill(fMomentum);