ROOT without running root...

From: Mattias Davidsson (mattias@quark.lu.se)
Date: Wed Feb 23 2000 - 17:05:35 MET


Hi!

I'm trying to use the classes of ROOT and the jetfinder package together
with some events producd
by pythia as explained by the short program below. When I run the
executable with the

//std::cout << "class: " << output->ClassName() << std::endl;

line (at the bottom) uncommented I get the following:

Fatal in <TClass::TClass>: ROOT system not initialized
aborting
Abort (core dumped)

Why is this? Ie why does it work with the line commented using the ROOT
classes etc?

PS. I'm quite new to ROOT and c++ ....

example program:
////////////////////////

#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <fstream>
#include <list>
#include <string>
#include <vector>
#include "Pythia.h"
#include "LorentzVector.h"
#include "JetFindDict.h"

//
//  This program produces DIS events from pythia, adds the stable
particles
//  to a TObjArray (veclist). The aim is then to feed these 4-vectors
//  to the jetfinder package. See bottom for troubles.
//





int main() {

  const char* frame="CMS";
  int iframe=3;
  const char* beam="gamma/e+";
  int ibeam=8;
  const char* target="p+";
  int itarget=2;
  double E=297.2E0;

  double y_cut=0.E0;


  //  Choose jet finding scheme. Jade with y_cut
  pydat1_.mstu[46-1]=4;      // MSTU(46)=4
  pydat1_.paru[45-1]=y_cut; // PARU(45)=y_cut

  //  Disable preclustering and don't ignore neutrinos
  pydat1_.paru[43-1]=0.E0;  // PARU(43)=0
  pydat1_.mstu[41-1]=1;     // MSTU(41)=1

  // Setup ROOT jet finder
  JadeJetFinder  *jetf = new JadeJetFinder(0.004);


  // Select DIS process in PYTHIA.
  pysubs_.msel=1;       // MSEL=0
  pysubs_.msub[1-1]=1;  // MSUB(1)=1

  //Initialize Pythia
  pyinit_(frame,beam,target,&E,iframe,ibeam,itarget);

  // Declare a 3 vector a'la ROOT
  TVector3* vec3  = new TVector3();
  if(vec3) delete vec3;

  //Declare the 4 vector a'la ROOT
  TLorentzVector* vec4 = new TLorentzVector();
  if(vec4) delete vec4;

  // Declare 4vector list a'la ROOT
  TObjArray* veclist = new TObjArray();
  if(veclist) veclist->Delete();

  // Read out 1'st 4 vector
  TObject* output = new TObject();

  // Temporary 3 vector a'la ROOT
  Float_t Pvec3[3];


  // Main event loop
  int events=10;
  for (long iev=0;iev<events;iev++){
    pyevnt_();
    long nlist=2;
    if (iev < 3) pylist_(&nlist);

    //    jade jet1;
    //   jet1.set_y(y_cut);
    //    jet1.set_s(pow(92.1,2));
    int N=pyjets_.n;
    for(int i=9; i<=N; i++) {
      if (pyjets_.k[1-1][i-1]==1 && pyjets_.k[2-1][i-1]!=22) {  //
Stable particle (not photon)
 //TLorentzVector vec(pyjets_.p[1-1][i-1],pyjets_.p[2-1][i-1],
 //     pyjets_.p[3-1][i-1],pyjets_.p[4-1][i-1]);
 Pvec3[0] = pyjets_.p[1-1][i-1];
 Pvec3[0] = pyjets_.p[2-1][i-1];
 Pvec3[0] = pyjets_.p[3-1][i-1];
 Float_t  E_part = pyjets_.p[4-1][i-1];
 vec3 = new TVector3(Pvec3);
 vec4 = new TLorentzVector(*vec3,E_part);
 veclist->Add(vec4);
 delete vec3;
       }
    }
    // Perform Jet finding
    // jetf->setEvent(veclist);
    // jetf->setYCut(0.010);
    //   jetf->doFindJets();

    // std::cout << "Nof jets: " << jetf->njets() << std::endl;
     int Njet=0;
    pyclus_(&Njet);
    std::cout << "Pythia: " << Njet << std::endl;
  }
  output = veclist->First();
  // if the line below (the std::cout line) is uncommented, running the
program is sais that
  // I have to Initialize ROOT... Why? Ie. what is so special about the
line
  // below? All the stuff above worked. (not if you uncomment the
jetf->lines
  // then the same problem appears...
  std::cout << "class: " << output->ClassName() << std::endl;
  delete veclist;


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mattias Davidsson,   http://www.quark.lu.se/~mattias
 +46 (0)46 222 76 83
Department of elementary particle physics
Box 118 SE-221 00
Lund, Sweden
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:19 MET