Wichtig für's Compilieren: Man darf nicht
${shell /opt/root/bin/root-config --libs --glibs --cflags}
benutzen, sondern man muß
${shell root-config --libs --glibs --cflags}
verwenden! (Sonst gibt es Probleme mit Klassen in den Branches in Trees.)

Working with TLorentzVector and std::vector (example):

#include <vector>
#include <iostream>
#include "TLorentzVector.h"

using namespace std;

int main(int argc, char **argv) {
  //Deklaration:
  vector<TLorentzVector*>* myVecField;
  //Initialisierung:
  myVecField = new vector<TLorentzVector*>;

  //Elemente hinzufügen:
  for (int i=0; i<3e9; i++) {
    myVecField->push_back(new TLorentzVector);
    (*myVecField)[myVecField->size()-1]->SetPtEtaPhiM(1000*i, 0+i/1000., i*3.14/3., 100);

    //Zugreifen:
    for (int i=0; i < myVecField->size(); i++) {
      cout << i << " - Pt = " << (*myVecField)[i]->Pt() << endl;
    }

    // löschen:
    delete (*myVecField)[myVecField->size()-1];
    myVecField->pop_back();
  }
  return 0;
}

compile with

g++ `root-config --libs --cflags` <name> 

-- ChristianSchroeder - 09 Sep 2009

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2009-10-09 - Schroede
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback