Please read tips for efficient and successful posting and posting code
Please fill also the fields below. Note that root -b -q
will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug
from the ROOT prompt to pre-populate a topic.
_ROOT Version: 6.30/06
_Platform: Ubuntu 20.04
_Compiler: g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Madgraph 3.5.6
Hello all,
So I have some .root files from madgraph+delphes. The cluster I’m working on just updated and I have just reinstalled and recompiled ROOT, madgraph, and madgraph software like Delphes and ExROOTAnalysis. Before all of this my code worked as expected. However now something is going wrong.
My main analysis code begins with this
int main(int argc, const char * argv[])
{
//Pulls and arranges data as needed.
TChain chain("Delphes");
const char* EventType = argv[1];
cout << EventType<< endl;
for(int i=2; i<argc; i++)
{
chain.Add(argv[i]);
cout << argv[i]<< endl;
}
ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
Long64_t NumEntries = treeReader->GetEntries();
cout << "There are "<< NumEntries <<" Entries." <<endl;
TClonesArray *branchJet = treeReader->UseBranch("Jet");
TClonesArray *branchElectron = treeReader->UseBranch("Electron");
TClonesArray *branchMuon;
if (hasMu) branchMuon = treeReader->UseBranch("Muon");
TClonesArray *branchMET;
if (hasMET) branchMET = treeReader->UseBranch("MET");
...
When I try to pass a single file it gives this
<bash stuff>$ <path to analysis>/JetFake/main <path to data>/Events/run_21/tag_1_delphes_events.root
Warning in <TClassTable::Add>: class ExRootTreeReader already in TClassTable
Warning in <TClassTable::Add>: class ExRootTreeWriter already in TClassTable
Warning in <TClassTable::Add>: class ExRootTreeBranch already in TClassTable
Warning in <TClassTable::Add>: class ExRootResult already in TClassTable
Warning in <TClassTable::Add>: class ExRootClassifier already in TClassTable
Warning in <TClassTable::Add>: class ExRootFilter already in TClassTable
<path to data>/Events/run_21/tag_1_delphes_events.root
There are 0 Entries.
** WARNING: cannot access branch 'Jet', return NULL pointer
** WARNING: cannot access branch 'Electron', return NULL pointer
** WARNING: cannot access branch 'Muon', return NULL pointer
------------------
no event analyzed
------------------
I have another file that just opens and counts the number of events, called read_root_file
which begins like this
int main(int argc, char** argv) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <path_to_root_file>" << std::endl;
return 1;
}
const char* file_path = argv[1];
TFile* file = TFile::Open(file_path);
if (!file || file->IsZombie()) {
std::cerr << "Error opening ROOT file: " << file_path << std::endl;
return 1;
}
TKey* key;
TIter next(file->GetListOfKeys());
while ((key = (TKey*)next())) {
TObject* obj = key->ReadObj();
if (obj->IsA()->InheritsFrom(TTree::Class())) {
TTree* tree = (TTree*)obj;
std::cout << "Tree name: " << tree->GetName() << std::endl;
std::cout << "Number of entries: " << tree->GetEntries() << std::endl;
TObjArray* branches = tree->GetListOfBranches();
for (int i = 0; i < branches->GetEntries(); ++i) {
TBranch* branch = (TBranch*)branches->At(i);
// std::cout << " Branch name: " << branch->GetName() << std::endl;
TObjArray* leaves = branch->GetListOfLeaves();
for (int j = 0; j < leaves->GetEntries(); ++j) {
TLeaf* leaf = (TLeaf*)leaves->At(j);
// std::cout << " Leaf name: " << leaf->GetName() << std::endl;
}
}
}
}
This file confirms that the file I’m passing to the analysis file is not empty.
If I pass more than one file into the analysis file, then it counts only events in the files other than the first file, and then breaks in a segmentation violation when I get to this line TStyle *st1 = new TStyle("st1","my style");
(venv2) <bash stuff>:<path to analysis>/JetFake/main <path to data>/Events/run_21/tag_1_delphes_events.root <path to data>/Events/run_02/tag_1_delphes_events.root <path to data>/Events/run_01/tag_2_delphes_events.root
Warning in <TClassTable::Add>: class ExRootTreeReader already in TClassTable
Warning in <TClassTable::Add>: class ExRootTreeWriter already in TClassTable
Warning in <TClassTable::Add>: class ExRootTreeBranch already in TClassTable
Warning in <TClassTable::Add>: class ExRootResult already in TClassTable
Warning in <TClassTable::Add>: class ExRootClassifier already in TClassTable
Warning in <TClassTable::Add>: class ExRootFilter already in TClassTable
<path to data>/Events/run_21/tag_1_delphes_events.root
<path to data>/Events/run_02/tag_1_delphes_events.root
<path to data>/Events/run_01/tag_2_delphes_events.root
There are 387 Entries.
Loading Events ...
Histo time
*** Break *** segmentation violation
Segmentation fault (core dumped)
I don’t know if this is one problem, two, or more. I didn’t change anything about the code since it ran properly before the update. I tried changing the for-loop over the arguments to start at 1, but that didn’t seem to change anything.
Thanks,
Dyson