Re: std::vector of LorentzVectors in a TTree: dictionary problems

From: Pietro Govoni <Pietro.Govoni_at_mib.infn.it>
Date: Fri, 8 Jan 2010 16:55:25 +0100


PS I forgot to say, the error I get is the following, when I run the code:

Error in <TTree::Branch>: The class requested (vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >) for the branch "arr5" refer to an stl collection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >)

On Jan 8, 2010, at 4:01 PM, Pietro Govoni wrote:

> Hello Rooters!
>
> I am trying and saving a:
>
> std::vector<ROOT::Math::XYZTVector>
>
> as a branch in a root tree, with the lines you can find below, in root 5.25.
>
> This is surely feasible, since it is done in the mathcoreVectorCollection.C tutorial (executed in the root terminal after compiled linking).
> Nevertheless, I cannot reproduce the miracle with my own (c++ compiled) code, what am I missing?
>
> Thank you very much!
>
> pietro
>
>
> // ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
>
>
>
> #include "TFile.h"
> #include "TClonesArray.h"
> #include "TTree.h"
> #include "TLorentzVector.h"
> #include "TMath.h"
> #include "Math/Vector4D.h"
> #include <vector>
>
> #include "TRandom.h"
> #include "TStopwatch.h"
> #include "TSystem.h"
> #include "TH1D.h"
> #include "TCanvas.h"
>
>
> /*
> source ~/Desktop/setupRoot5.25.sh
> c++ -o makeTTree `root-config --cflags --glibs` makeTTree.cpp
> */
>
>
> int main ()
> {
> TFile f ("tree.root","recreate") ;
> f.cd () ;
> TTree al ("al","example with TClonesArray") ;
> std::vector<ROOT::Math::XYZTVector> * arr5 = new std::vector<ROOT::Math::XYZTVector> ;
> al.Branch ("arr5", "std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >", &arr5);
>
> //PG loop over events
> for (int iEvent = 0 ; iEvent < 100 ; ++iEvent)
> {
> arr5->clear () ;
> for (int iEntry = 0 ; iEntry < 5 ; ++iEntry)
> {
> arr5->push_back (ROOT::Math::XYZTVector (2., 2., 2., 2.)) ;
> al.Fill () ;
> } //PG loop over events
> } //PG loop over events
>
> al.Write () ;
> f.Close () ;
>
> return 0 ;
> }
>

Received on Fri Jan 08 2010 - 16:55:35 CET

This archive was generated by hypermail 2.2.0 : Fri Jan 08 2010 - 17:50:01 CET