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

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


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:01:28 CET

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