Proof- problem with vector<TLorentzVector>

Dear Proof experts,
I have the following problem:
I have made a new class from my root ntuple (using code]TTree::MakeSelector().). I have some branches in my root file from type:vector e.g.
TBranch *b_muon4mom and I set the branch addresses and branch pointers with:
std::vector *muon4mom
fChain->SetBranchAddress(“muon4mom”, &muon4mom, &b_muon4mom).

When I try to run with my class on my root ntuple everything works well as long as I do not try to read the branches of the type: vector, e.g. when I try to print e.g the size of the vector muon4mom or when I try to fill a histogram reading the vector muon4mom proof crashes (see output_crash file)
I run over my root files with:

TChain *c = new TChain(“ZTree”)
c->Add(“my_file.root”)
p = TProof::Open("");
c->SetProof();
c->Process(“ZTree.C+”);

I was looking for a solution in the Root talk forums and found often that creating a dictionary could solve a similar problem. Therefore I added the lines:

#ifdef MAKECINT
#pragma link C++ class std::vector< int >+;
#pragma link C++ class std::vector< std::vector< int > >+;
#pragma link C++ class std::vector< std::vector< float > >+;
#pragma link C++ class std::vector< std::vector< double > >+;
#pragma link C++ class std::vector< float >;
#pragma link C++ class std::vector< std::string>;
#pragma link C++ class std::vector< std::vector< string > >+;
#pragma link C++ class std::vector< TLorentzVector >+;
#pragma link C++ class std::vector< TString >+;
#pragma link C++ class std::vector< std::vector< TLorentzVector > >+;
#pragma link C++ class std::vector< std::vector< double > >+;

but also this did not solve my problem :frowning:
I never used Proof before and have no experience with it. Maybe someone can help me to solve my problem? The root files that I try to read are ok and I could run and fill histograms with a class made with TTree::MakeClass().

Thanks a lot for your help.
Janet
output_crash.tar.zip (1.87 KB)
ZTree.h (2.65 KB)
ZTree.C (2.5 KB)

Hi,

you probably shouldn’t use SetMakeClass(1) which is only needed to access the data in “non-object style”, i.e. as C-arrays of data members.

In Terminate() you must check the hNmuons and all the others are != 0 before calling Write() on them. You also should not call Form(), first because you only use a string literal, and second because you should be using TString::Format() instead of the deprecated Form().

Cheers, Axel.

Thanks a lot Axel, with your changes it works now ! :slight_smile: