From 8020fb14c833f5d330787dec379da58baacf6d6e Mon Sep 17 00:00:00 2001 From: morsch Date: Fri, 9 Nov 2001 09:11:24 +0000 Subject: [PATCH] Realisation of AliGenReader that reads the kine tree (TreeK). --- EVGEN/AliGenReaderTreeK.cxx | 99 +++++++++++++++++++++++++++++++++++++ EVGEN/AliGenReaderTreeK.h | 43 ++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 EVGEN/AliGenReaderTreeK.cxx create mode 100644 EVGEN/AliGenReaderTreeK.h diff --git a/EVGEN/AliGenReaderTreeK.cxx b/EVGEN/AliGenReaderTreeK.cxx new file mode 100644 index 00000000000..880c7428541 --- /dev/null +++ b/EVGEN/AliGenReaderTreeK.cxx @@ -0,0 +1,99 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* +$Log$ +*/ +#include +#include +#include + +#include "AliGenReaderTreeK.h" +#include "AliStack.h" +#include "AliHeader.h" +#include "AliRun.h" + +ClassImp(AliGenReaderTreeK); + + +AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader() +{ +// Default constructor + fFileName = NULL; + fStack = 0; + fHeader = 0; + fNcurrent = 0; + fNparticle = 0; + fFile = 0; + fBaseFile = 0; +} + +void AliGenReaderTreeK::Init() +{ +// Initialization +// Connect base file and file to read from + + TTree *ali = gAlice->TreeE(); + if (ali) { + fBaseFile = ali->GetCurrentFile(); + } else { + printf("\n Warning: Basefile cannot be found !\n"); + } + fFile = new TFile(fFileName); +} + +Int_t AliGenReaderTreeK::NextEvent() +{ +// Read the next event +// cd to file with old kine tree + if (!fBaseFile) Init(); + if (fStack) delete fStack; + fStack = new AliStack(1000); + fFile->cd(); +// Connect treeE + TTree* treeE = (TTree*)gDirectory->Get("TE"); + treeE->ls(); + if (fHeader) delete fHeader; + fHeader = 0; + treeE->SetBranchAddress("Header", &fHeader); +// Get next event + treeE->GetEntry(fNcurrent); + fStack = fHeader->Stack(); + fStack->GetEvent(fNcurrent); + +// cd back to base file + fBaseFile->cd(); +// + fNcurrent++; + fNparticle = 0; + Int_t ntrack = fStack->GetNtrack(); + printf("\n Next event contains %d particles", ntrack); + + return ntrack; +} + +TParticle* AliGenReaderTreeK::NextParticle() +{ +// Return next particle + TParticle* part = fStack->Particle(fNparticle); + fNparticle++; + return part; +} + + + + + + diff --git a/EVGEN/AliGenReaderTreeK.h b/EVGEN/AliGenReaderTreeK.h new file mode 100644 index 00000000000..bbe0a65befb --- /dev/null +++ b/EVGEN/AliGenReaderTreeK.h @@ -0,0 +1,43 @@ +#ifndef ALIGENREADERTreeK_H +#define ALIGENREADERTREEK_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#include "AliGenReader.h" +class TFile; +class AliStack; +class AliHeader; + + +class AliGenReaderTreeK : public AliGenReader +{ + public: + AliGenReaderTreeK(); + + AliGenReaderTreeK(const AliGenReaderTreeK &reader){;} + virtual ~AliGenReaderTreeK(){;} + // Initialise + virtual void Init(); + // Read + virtual Int_t NextEvent(); + virtual TParticle* NextParticle(); + AliGenReaderTreeK & operator=(const AliGenReader & rhs); + protected: + Int_t fNcurrent; // points to the next entry + Int_t fNparticle; // Next particle in list + Int_t fNp; // number of particles + TFile *fFile; //! pointer to file + TFile *fBaseFile; //! pointer to base file + AliStack *fStack; //! Particle stack + AliHeader *fHeader; //! Pointer to event header + ClassDef(AliGenReaderTreeK,1) // Read particles from TreeK +}; +#endif + + + + + + -- 2.43.0