Problem in storing pythia events in TTree

Hi!

I am trying to make tree.cc example work in Pythia8. [code]// File: tree.cc
// This is a simple test program.
// Modified by Rene Brun and Axcel Naumann to put the Pythia::event
// into a TTree.
// Copyright © 2014 Torbjorn Sjostrand

// Header file to access Pythia 8 program elements.
#include
#include “Pythia8/Pythia.h”
//#include “Pythia8/Pythia.h”

// ROOT, for saving Pythia events as trees in a file.
#include “TTree.h”
#include “TFile.h”

using namespace Pythia8;

int main() {

// Create Pythia instance and set it up to generate hard QCD processes
// above pTHat = 20 GeV for pp collisions at 14 TeV.
Pythia pythia;
pythia.readString(“HardQCD:all = on”);
pythia.readString(“PhaseSpace:pTHatMin = 20.”);
pythia.readString(“Beams:eCM = 14000.”);
// pythia.init();
pythia.init();

// Set up the ROOT TFile and TTree.
TFile *file = TFile::Open(“pytree.root”,“recreate”);
Event *event = &pythia.event;
TTree *T = new TTree(“T”,“event”);
T->Branch(“event”,&event);

// Begin event loop. Generate event; skip if generation aborted.
for (int iEvent = 0; iEvent < 10; ++iEvent) {
if (!pythia.next()) continue;

// Fill the pythia event into the TTree.
// Warning: the files will rapidly become large if all events
// are saved. In some cases it may be convenient to do some
// processing of events and only save those that appear
// interesting for future analyses.
T->Fill();

// End event loop.
}

// Statistics on event generation.
pythia.stat();

// Write tree.
T->Print();
T->Write();
delete file;

// Done.
return 0;
}
[/code]

On running the tree.exe file, I get the following error:

and the TTree contains the following

[code]************

  • Row *

  •    0 *
    
  •    1 *
    
  •    2 *
    
  •    3 *
    
  •    4 *
    
  •    5 *
    
  •    6 *
    
  •    7 *
    
  •    8 *
    
  •    9 *
    

[/code]

That is, I guess no events were stored. I tried solving the problem by re-building ROOT with ./configure --enable-pythia8. The version of ROOT that I am using now is 5.34/24, and it gives the exact same error (before rebuilding I was using 5.34/18).

Can someone please help me with this?

Thanks in advance,
Aman

I guess the error message you get makes clear that you cannot add such object is a TTree.
Did you find a solution meanwhile ?

see $ROOTSYS/tutorials/pythia/pythiaExample.C

Rene