TGenerator Is an base class, that defines the interface of ROOT to various event generators. Every event generator should inherit from TGenerator or its subclasses. Derived class can overload the member function GenerateEvent to do the actual event generation (e.g., call PYEVNT or similar). The derived class should overload the member function ImportParticles (both types) to read the internal storage of the generated event into either the internal TObjArray or the passed TClonesArray of TParticles. If the generator code stores event data in the /HEPEVT/ common block Then the default implementation of ImportParticles should suffice. The common block /HEPEVT/ is structed like C typedef struct { Int_t nevhep; // Event number Int_t nhep; // # of particles Int_t isthep[4000]; // Status flag of i'th particle Int_t idhep[4000]; // PDG # of particle Int_t jmohep[4000][2]; // 1st & 2nd mother particle # Int_t jdahep[4000][2]; // 1st & 2nd daughter particle # Double_t phep[4000][5]; // 4-momentum and 1 word Double_t vhep[4000][4]; // 4-position of production } HEPEVT_DEF; C Fortran COMMON/HEPEVT/NEVHEP,NHEP,ISTHEP(4000),IDHEP(4000), + JMOHEP(2,4000),JDAHEP(2,4000),PHEP(5,4000),VHEP(4,4000) INTEGER NEVHEP,NHEP,ISTHEP,IDHEP,JMOHEP,JDAHEP DOUBLE PRECISION PHEP,VHEP The generic member functions SetParameter and GetParameter can be overloaded to set and get parameters of the event generator. Note, if the derived class interfaces a (set of) Fortran common blocks (like TPythia, TVenus does), one better make the derived class a singleton. That is, something like class MyGenerator : public TGenerator { public: static MyGenerator* Instance() { if (!fgInstance) fgInstance = new MyGenerator; return fgInstance; } void GenerateEvent() { ... } void ImportParticles(TClonesArray* a, Option_t opt="") {...} Int_t ImportParticles(Option_t opt="") { ... } Int_t SetParameter(const char* name, Double_t val) { ... } Double_t GetParameter(const char* name) { ... } virtual ~MyGenerator() { ... } protected: MyGenerator() { ... } MyGenerator(const MyGenerator& o) { ... } MyGenerator& operator=(const MyGenerator& o) { ... } static MyGenerator* fgInstance; ClassDef(MyGenerator,0); }; Having multiple objects accessing the same common blocks is not safe. concrete TGenerator classes can be loaded in scripts and subseqent- ly used in compiled code: MyRun.h class MyRun : public TObject { public: static MyRun* Instance() { ... } void SetGenerator(TGenerator* g) { fGenerator = g; } void Run(Int_t n, Option_t* option="") { TFile* file = TFile::Open("file.root","RECREATE"); TTree* tree = new TTree("T","T"); TClonesArray* p = new TClonesArray("TParticles"); tree->Branch("particles", &p); for (Int_t event = 0; event < n; event++) { fGenerator->GenerateEvent(); fGenerator->ImportParticles(p,option); tree->Fill(); } file->Write(); file->Close(); } protected: TGenerator* fGenerator; ClassDef(MyRun,0); }; Config.C void Config() { MyRun* run = MyRun::Instance(); run->SetGenerator(MyGenerator::Instance()); } main.cxx int main(int argc, char** argv) { TApplication app("", 0, 0); gSystem->ProcessLine(".x Config.C"); MyRun::Instance()->Run(10); return 0; } This is especially useful for example with TVirtualMC or similar.
virtual | ~TGenerator() |
void | TObject::AbstractMethod(const char* method) const |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | Browse(TBrowser* b) |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TNamed::Clear(Option_t* option = "") |
virtual TObject* | TNamed::Clone(const char* newname = "") const |
virtual Int_t | TNamed::Compare(const TObject* obj) const |
virtual void | TNamed::Copy(TObject& named) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual void | TNamed::FillBuffer(char*& buffer) |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual void | GenerateEvent() |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
virtual const char* | TObject::GetIconName() const |
virtual TObjArray* | GetListOfParticles() const |
virtual const char* | TNamed::GetName() const |
Int_t | GetNumberOfParticles() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
virtual Double_t | GetParameter(const char*) const |
virtual TParticle* | GetParticle(Int_t i) const |
virtual TObjArray* | GetPrimaries(Option_t* option = "") |
Float_t | GetPtCut() const |
virtual const char* | TNamed::GetTitle() const |
virtual UInt_t | TObject::GetUniqueID() const |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TNamed::Hash() const |
virtual TObjArray* | ImportParticles(Option_t* option = "") |
virtual Int_t | ImportParticles(TClonesArray* particles, Option_t* option = "") |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
virtual Bool_t | TNamed::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TNamed::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
void | TObject::operator delete(void* ptr) |
void | TObject::operator delete(void* ptr, void* vp) |
void | TObject::operator delete[](void* ptr) |
void | TObject::operator delete[](void* ptr, void* vp) |
void* | TObject::operator new(size_t sz) |
void* | TObject::operator new(size_t sz, void* vp) |
void* | TObject::operator new[](size_t sz) |
void* | TObject::operator new[](size_t sz, void* vp) |
virtual void | Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TNamed::Print(Option_t* option = "") const |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
static void | TObject::SetDtorOnly(void* obj) |
virtual void | TNamed::SetName(const char* name)MENU |
virtual void | TNamed::SetNameTitle(const char* name, const char* title) |
static void | TObject::SetObjectStat(Bool_t stat) |
virtual void | SetParameter(const char*, Double_t) |
virtual void | SetPtCut(Float_t ptcut = 0)MENU |
virtual void | TNamed::SetTitle(const char* title = "")MENU |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | SetViewRadius(Float_t rbox = 1000)MENU |
virtual void | SetViewRange(Float_t xmin = -10000, Float_t ymin = -10000, Float_t zmin = -10000, Float_t xmax = 10000, Float_t ymax = 10000, Float_t zmax = 10000)MENU |
virtual void | ShowMembers(TMemberInspector& insp) const |
virtual void | ShowNeutrons(Bool_t show = 1)MENU |
virtual Int_t | TNamed::Sizeof() const |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
TGenerator() | |
TGenerator(const char* name, const char* title = "Generator class") | |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | TObject::MakeZombie() |
TGenerator& | operator=(const TGenerator& tg) |
TGenerator(const TGenerator& tg) |
static TObject::<anonymous> | TObject::kBitMask | |
static TObject::EStatusBits | TObject::kCanDelete | |
static TObject::EStatusBits | TObject::kCannotPick | |
static TObject::EStatusBits | TObject::kHasUUID | |
static TObject::EStatusBits | TObject::kInvalidObject | |
static TObject::<anonymous> | TObject::kIsOnHeap | |
static TObject::EStatusBits | TObject::kIsReferenced | |
static TObject::EStatusBits | TObject::kMustCleanup | |
static TObject::EStatusBits | TObject::kNoContextMenu | |
static TObject::<anonymous> | TObject::kNotDeleted | |
static TObject::EStatusBits | TObject::kObjInCanvas | |
static TObject::<anonymous> | TObject::kOverwrite | |
static TObject::<anonymous> | TObject::kSingleKey | |
static TObject::<anonymous> | TObject::kWriteDelete | |
static TObject::<anonymous> | TObject::kZombie |
TString | TNamed::fName | object identifier |
TObjArray* | fParticles | ->static container of the primary particles |
Float_t | fPtCut | !Pt cut. Do not show primaries below |
Bool_t | fShowNeutrons | !display neutrons if true |
TString | TNamed::fTitle | object title |
Event generator default constructor
It reads the /HEPEVT/ common block which has been filled by the GenerateEvent method. If the event generator does not use the HEPEVT common block, This routine has to be overloaded by the subclasses. The default action is to store only the stable particles (ISTHEP = 1) This can be demanded explicitly by setting the option = "Final" If the option = "All", all the particles are stored.
It reads the /HEPEVT/ common block which has been filled by the GenerateEvent method. If the event generator does not use the HEPEVT common block, This routine has to be overloaded by the subclasses. The function loops on the generated particles and store them in the TClonesArray pointed by the argument particles. The default action is to store only the stable particles (ISTHEP = 1) This can be demanded explicitly by setting the option = "Final" If the option = "All", all the particles are stored.
-*-*-*-*Compute distance from point px,py to objects in event *-* ===================================================== -
-*-*-*-*-*-*-*Execute action corresponding to one event *-* =========================================
Set lower and upper values of the view range