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

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Mon, 11 Jan 2010 16:33:26 +0100


Hi,

 The dictionary for a std::vector< ROOT::Math::XYZTVector> is already provided in ROOT in the libGenVector library. You don't need to re-generate again. You just need to link your application with libGenVector.

Just do:

g++ -o makeTTree `root-config --cflags --glibs` -lGenVector makeTTree.cpp

 Best Regards

 Lorenzo

On Jan 8, 2010, at 5:11 PM, Roel Aaij wrote:

> Dear Pietro,
> 
> As you mention in your other mail, you need a dictionary. There are 2
> ways of generating and using it, rootcint or genreflex and cintex. I
> think using rootcint is easier, so I'll explain that one.
> 
> I've attached a file named LinkDef.h, you'll need it to generate the
> dictionary. rootcint -h explains its syntax. You'll need to run these
> commands to create, compile and link your program:
> 
> source ~/Desktop/setupRoot5.25.sh
> rootcint -f dict.cpp -c -p Math/LorentzVector.h LinkDef.h
> c++ `root-config --cflags` -c makeTTree.cpp
> c++ `root-config --cflags` -c dict.cpp
> c++ -o makeTTree -L`root-config --libdir` -lCore -lTree -lGenVector
> makeTTree.o dict.o
> 
> Greetings, Roel Aaij
> 

>> 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 ;
>> }
>>

>
> <LinkDef.h> Received on Mon Jan 11 2010 - 16:33:31 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 12 2010 - 05:50:02 CET