`I have multiple input root files (150 files)from different directories, and I intend to incorporate all of them into my code. However, when I run the code, it seems to only process the last file, even though I have tested it with just two files. Strangely, I'm not encountering any error messages.
Additionally, I'm facing another issue. When I open a new TBrowser, I find that I can't access my histograms. Below is a section of my code (header file)for reference:`
class inclphoton {
public:
TTree *fChain;
Int_t fCurrent;
vector<float> *ttdata_presel_photonPt;
TBranch *b_ttdata_presel_photonPt;
std::vector<std::string> files;
inclphoton(TTree *tree = nullptr);
virtual ~inclphoton();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
};
#endif
#ifdef inclphoton_cxx
inclphoton::inclphoton(TTree *tree) : fChain(0)
{
TH1::AddDirectory(kFALSE);
files.push_back("/userdata/incPhoton/data15/user.data15periodd.n181.periodD.DAOD_STDM2.grp23_v01_p3984_ANALYSIS_ntuples/user.26552633._000001.ANALYSIS.root");
files.push_back("/userdata/incPhoton/data15/user..data15periodd.n181.periodD.DAOD_STDM2.grp23_v01_p3984_ANALYSIS_ntuples/user.26552633._000002.ANALYSIS.root");
//files.push_back("/userdata/incPhoton/data15/user..data15periodd.n181.periodD.DAOD_STDM2.grp23_v01_p3984_ANALYSIS_ntuples/user.26552633._000003.ANALYSIS.root");
if (!tree) {
TFile *f;
for (const auto& fileName : files) {
std::cout << "Processing file: " << fileName << std::endl;
f = TFile::Open(fileName.c_str());
if (!f || !f->IsOpen()) {
std::cerr << "Error opening file: " << fileName << std::endl;
continue;
}
f->ls();
f->GetObject("analysis", tree);
std::cout<< "////////////////////////////////////////////"<<std::endl;
std::cout << "Total entries in fChain: " << tree->GetEntries() << std::endl;
}
}
Init(tree);
}
inclphoton::~inclphoton()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t inclphoton::GetEntry(Long64_t entry)
{
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t inclphoton::LoadTree(Long64_t entry)
{
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
void inclphoton::Init(TTree *tree)
{
ttdata_presel_photonPt = 0;
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("ttdata_presel_photonPt", &ttdata_presel_photonPt, &b_ttdata_presel_photonPt);
Notify();
}
Bool_t inclphoton::Notify()
{
return kTRUE;
}
void inclphoton::Show(Long64_t entry)
{
if (!fChain) return;
fChain->Show(entry);
}
Int_t inclphoton::Cut(Long64_t entry)
{
return 1;
}
#endif
I would appreciate any insights or suggestions on resolving these issues. Thank you!