Trouble finding name of TTree when creating a TChain

Hi, I am trying to create a TChain of 10 files and then create a plot of them. I am getting an error that says: Error in TChain::LoadTree: Cannot find tree with name Uranium in file… for each of the ten files. I believe I am missing a step in creating the TChain but I am not sure what it is. Here is the code:

#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include "TFile.h"
#include "TTree.h"

void mergedData(){

  TChain *chain = new TChain("Uranium");
  chain->Add("U/merged_data_0.root");
  chain->Add("U/merged_data_1.root");
  chain->Add("U/merged_data_2.root");
  chain->Add("U/merged_data_3.root");
  chain->Add("U/merged_data_4.root");
  chain->Add("U/merged_data_5.root");
  chain->Add("U/merged_data_6.root");
  chain->Add("U/merged_data_7.root");
  chain->Add("U/merged_data_8.root");
  chain->Add("U/merged_data_9.root");

  TCanvas *c1 = new TCanvas("c1");
  chain->Draw("fluka_Z:fluka_A-fluka_Z","fluka_lifetime<1e-3");
  c1->Print("Uranium.pdf");
}

Hi Zach,

that’s exactly that. In your code

TChain *chain = new TChain("Uranium");

creates a TChain of files to process TTrees called “Uranium”, see the ctor description. And these files of yours probably do not have the TTree with this name, am I right?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.