Problem with processing trees with objects

ROOT Version 6.10/08
Scientific Linux release 7.4 (Nitrogen),gcc version 7.2.0 (GCC)


Hello!
During an attempt to process a tree with objects using Class, created by MakeClass I have the following problem:

root [0] .L events.C+
Info in TUnixSystem::ACLiC: creating shared library /gcf/stark/home/shtol/MUMUTRON/./events_C.so
root [1] .L /ceph/groups/sctau/sw/DD4hep-v1.06_gcc72/lib/libDDG4.so
root [2] resp = new events()
(events *) 0x5630d60
root [3] resp->Loop()
10 entries
Entry 0 loaded, ientry=0
Error in TClass::BuildRealData: Inspection for auto_ptrdd4hep::sim::ParticleExtension not supported!
Error in TClass::BuildRealData: Inspection for auto_ptrdd4hep::sim::DataExtension not supported!
Entry 0 get
Event 1: 19 hits
0.00174003 0.00354798 0.00380609 0.00174212 0.00381087 0.00177795 0.00275664 0.00501605 0.00189073 0.00198809 0.00283141 0.0016844 0.00230454 0.00169434 0.00413376 0.00456385 0.00141417 0.00442057 0.00216843 event finished
Entry 1 loaded, ientry=1

*** Break *** segmentation violation

So first event is read normally, but next event reading fails.

Code of the class - processor is:

event.h:

//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Thu Apr 12 11:44:15 2018 by ROOT version 6.10/08
// from TTree EVENT/Geant4 EVENT information
// found on file: simple.root
//////////////////////////////////////////////////////////

#ifndef events_h
#define events_h

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include “/ceph/groups/sctau/sw/DD4hep-v1.06_gcc72/include/DDG4/Geant4Data.h”
#include “/ceph/groups/sctau/sw/DD4hep-v1.06_gcc72/include/DDG4/Geant4Particle.h”

// Header file for the classes stored in the TTree if any.

class events {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain

// Fixed size dimensions of array or collections stored in the TTree if any.

// Declaration of leaf types
vectordd4hep::sim::Geant4Particle* *MCParticles;
vectordd4hep::sim::Geant4Tracker::Hit* *VertexCollection;

// List of branches
TBranch *b_MCParticles; //!
TBranch *b_VertexCollection; //!

events(TTree *tree=0);
virtual ~events();
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);
private:
Int_t event;
};

#endif

#ifdef events_cxx
events::events(TTree *tree) : fChain(0), event(0)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
TFile f = (TFile)gROOT->GetListOfFiles()->FindObject(“simple.root”);
if (!f || !f->IsOpen()) {
f = new TFile(“simple.root”);
}
f->GetObject(“EVENT”,tree);

}
Init(tree);
}

events::~events()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}

Int_t events::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t events::LoadTree(Long64_t entry)
{
// Set the environment to read one 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 events::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).

// Set object pointer
MCParticles = 0;
VertexCollection = 0;
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);

fChain->SetBranchAddress(“MCParticles”, &MCParticles, &b_MCParticles);
fChain->SetBranchAddress(“VertexCollection”, &VertexCollection, &b_VertexCollection);
Notify();
}
Bool_t events::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.

return kTRUE;
}

void events::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t events::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
#endif // #ifdef events_cxx

event.C:

#define events_cxx
#include “events.h”
#include
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>

void events::Loop()
{
// In a ROOT session, you can do:
// root> .L events.C
// root> events t
// root> t.GetEntry(12); // Fill t data members with entry number 12
// root> t.Show(); // Show values of entry 12
// root> t.Show(16); // Read and show values of entry 16
// root> t.Loop(); // Loop on all entries
//

// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus(“branchname”,1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;

Long64_t nentries = fChain->GetEntries();
std::cout<<nentries<<" entries"<<std::endl;
Long64_t nbytes = 0, nb = 0;
event++;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
std::cout<<“Entry “<<jentry<<” loaded, ientry=”<<ientry<<std::endl;
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
std::cout<<“Entry “<<jentry<<” get”<<std::endl;
std::cout<<“Event “<<event<<”: “<size()<<” hits”<<std::endl;
/*for (vectordd4hep::sim::Geant4Tracker::Hit*::iterator it = VertexCollection->begin();
it!=VertexCollection->end(); it++) {
std::cout<<(it)->energyDeposit<<" ";
}
/
for (size_t nhit=1; nhit<=VertexCollection->size(); nhit++) {
std::cout<<(*VertexCollection)[nhit-1]->energyDeposit<<" ";
}
std::cout<<“event finished”<<std::endl;

}
}

It seems proble is solved. There was one more shared library needed.

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