Hi experts.
I got a problem when i make a new tree from existed ntp.
I take two leaf qc5 and fmax from 3 each Am_test.ntp, Ba_test.ntp, Cd_test.ntp.
And I also make a branch for qc5 , fmax.
So here is the problem. I want to make a new branch for energy.
The energy is just qc5*calibration factor.
But it doesn’t show the correct histogram.
How can i solve this?
void makeTree()
{
  TChain * chain1 = new TChain("ntp");
  TChain * chain2 = new TChain("ntp");
  TChain * chain3 = new TChain("ntp");
  chain1->Add("data/Am_test.ntp.root.00000");
  chain2->Add("data/Ba_test.ntp.root.00000");
  chain3->Add("data/Cd_test.ntp.root.00000");
  float qc5, fmax;
  float  energy =  qc5 * 4.2807603e-3;
  chain1->GetLeaf("pmt11", "qc5")->SetAddress(&qc5);
  chain2->GetLeaf("pmt11", "qc5")->SetAddress(&qc5);
  chain3->GetLeaf("pmt11", "qc5")->SetAddress(&qc5);
  chain1->GetLeaf("pmt11", "fmax")->SetAddress(&fmax);
  chain2->GetLeaf("pmt11", "fmax")->SetAddress(&fmax);
  chain3->GetLeaf("pmt11", "fmax")->SetAddress(&fmax);
  chain1->GetLeaf("pmt11", "energy")->SetAddress(&energy);
  chain2->GetLeaf("pmt11", "energy")->SetAddress(&energy);
  chain3->GetLeaf("pmt11", "energy")->SetAddress(&energy);
  TFile fout("data/tree.root", "recreate");
  TTree * tree1 = new TTree("t1", "t1");
  TTree * tree2 = new TTree("t2", "t2");
  TTree * tree3 = new TTree("t3", "t3");
  tree1->Branch("qc5"   ,   &qc5 );
  tree1->Branch("fmax"  ,   &fmax);
  tree1->Branch("energy", &energy);
  tree2->Branch("qc5"   ,   &qc5 );
  tree2->Branch("fmax"  ,   &fmax);
  tree2->Branch("energy", &energy);
  tree3->Branch("qc5"   ,   &qc5 );
  tree3->Branch("fmax"  ,   &fmax);
  tree3->Branch("energy", &energy);
  int nent1 = chain1->GetEntries();
  for(int i = 0; i < nent1; i++){
    chain1->GetEntry(i);
    tree1->Fill();
  }
  int nent2 = chain2->GetEntries();
  for(int i = 0; i < nent2; i++){
    chain2->GetEntry(i);
    tree2->Fill();
  }
    tree3->Fill();
  }
  tree1->Write();
  tree2->Write();
  tree3->Write();
  fout.Close();
}
This is what i use the code.
  int nent3 = chain3->GetEntries();
  for(int i = 0; i < nent3; i++){
    chain3->GetEntry(i);
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided