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
al.Write () ;
f.Close () ;
return 0 ;
}
This archive was generated by hypermail 2.2.0 : Fri Jan 08 2010 - 17:50:01 CET