//  
// Author: Oliver Maria Kind <mailto: kind@mail.desy.de>
// Update: $Id: HepMCParticle.h,v 1.8 2010/02/15 13:49:13 kendzi Exp $
// Copyright: 2008 (C) Oliver Maria Kind
//
#ifndef HEP_HepMCParticle
#define HEP_HepMCParticle
#ifndef HEP_Particle
#include <HepParticle.h>
#endif
#ifndef ROOT_TRef
#include <TRef.h>
#endif
#ifndef ROOT_TRefArray
#include <TRefArray.h>
#endif
#ifndef HEP_HepMCVertex
#include <HepMCVertex.h>
#endif

class HepMCVertex;

class HepMCParticle : public HepParticle {

protected:
    TRefArray      *fMothers;     // List of mother particles
    TRefArray      *fDaughters;   // List of daughters (if any)
    TRef           *fStartVertex; // Production vertex
    TRef           *fDecayVertex; // Decay vertex (if any)
    Int_t           fMCStatus;    // MC Generator Status Code
                                  // Only the status 1 are used by simulation.
                                  // http://atlas-physics.phyast.pitt.edu/~atlas/documents/simulation_physics/HERWIG_status_codes.pdf
    Bool_t fIsGenerator;          // Returns true on particles that were part of the event that came from the event
                                  // generator. Partilces produced by Geant are returned false
    Bool_t fIsGenNonInteracting;  // Returns true on neutrinos and other non interacting particles such as those from supersymmetry.
                                  // It returns a complete list including any geant secondaries. Is has more partilces than results
                                  // from the combination of IsGenStable and a subseqent selection
                                  // on the IsGenNonInteracting PDG ID codes.
    Bool_t fIsGenStable;          // Returns true on all stable particles. In the case of events from GenzModule these  are all the
                                  // partilces that are passed as input to Geant as either non-interacting or as particles
                                  // that are subsequently interact and decay in Geant.
    Bool_t fIsGenSimulStable;     // Returns true on all stable particles during generation and simulation.
    Bool_t fIsGenInteracting;     // Is a subset of IsGenStable that excludes non interacting particles. It includes electrons, photons,
                                  // muons, and hadrons that are considered as imput to geant such as pions, kaons and KL.
    Bool_t fIsConversion;         // Returns true for the particles that convert into the e+e- pair.
    Bool_t fIsBremsstrahlung;     // Returns true for the input particles in the Bremsstrahlung process.
    
    
public:
    HepMCParticle();
    HepMCParticle(Int_t Id, Int_t PdgCode, Float_t Px, Float_t Py, Float_t Pz,
		  Float_t E, Int_t MCStatus,
		  Bool_t IsGenerator,
		  Bool_t IsGenNonInteracting,
		  Bool_t IsGenStable,
		  Bool_t IsGenSimulStable,
		  Bool_t IsGenInteracting,
		  Bool_t IsConversion,
		  Bool_t IsBremsstrahlung);
    virtual ~HepMCParticle();
    virtual void Clear(Option_t *option = "");
    virtual void Print(Option_t *option = "");
    static void PrintHeader();
    static void PrintFooter();

    Bool_t IsGoodMother();
    Double_t GetBremsLoss();

    inline Bool_t IsGenerator() { return fIsGenerator; }
    inline Bool_t IsGenNonInteracting() { return fIsGenNonInteracting; }
    inline Bool_t IsGenStable() { return fIsGenStable; }
    inline Bool_t IsGenSimulStable() { return fIsGenSimulStable; }
    inline Bool_t IsGenInteracting() { return fIsGenInteracting; }
    inline Bool_t IsConversion() { return fIsConversion; }
    inline Bool_t IsBremsstrahlung() { return fIsBremsstrahlung; }
        
    inline Int_t GetMCStatus() const { return fMCStatus; }
    inline HepMCParticle* DaughterOf(Int_t i = 0) const {
	//
	// Return the mother particle with index i. Most
	// useful for normal particles that have just one
	// mother (default).
	//
	return GetMother(i); 
    }
    inline HepMCParticle* GetMother(Int_t i = 0) const {
	//
	// Return the mother particle with index i. Most
	// useful for normal particles that have just one
	// mother (default).
	//
	return (HepMCParticle*)fMothers->At(i);
    }
    inline HepMCVertex* GetStartVertex() const
            { return (HepMCVertex*)fStartVertex->GetObject(); }
    inline HepMCVertex* ProducedAt() const
	    { return GetStartVertex(); }
    inline HepMCVertex* GetDecayVertex() const
	    { return (HepMCVertex*)fDecayVertex->GetObject(); }
    inline HepMCVertex* DecayedAt() const
	    { return GetDecayVertex(); }
    inline TRefArray* GetDaughters() const { return fDaughters; }
    inline TRefArray* GetMothers() const { return fMothers; }
    inline void AddDaughter(HepMCParticle *Daughter)
	    { fDaughters->Add((TObject*)Daughter); }
    inline void AddMother(HepMCParticle *Mother)
	    { fMothers->Add((TObject*)Mother); }
    inline void SetStartVertex(HepMCVertex *vtx)
	    { *fStartVertex = (TObject*)vtx; }
    inline void SetDecayVertex(HepMCVertex *vtx)
	    { *fDecayVertex = (TObject*)vtx; }
    inline Int_t GetN_Daughters() const
            { return fDaughters->GetEntries(); }
    inline Int_t GetN_Mothers() const
            { return fMothers->GetEntries(); }

    ClassDef(HepMCParticle,6) // HEP MC particle
};
#endif
 HepMCParticle.h:1
 HepMCParticle.h:2
 HepMCParticle.h:3
 HepMCParticle.h:4
 HepMCParticle.h:5
 HepMCParticle.h:6
 HepMCParticle.h:7
 HepMCParticle.h:8
 HepMCParticle.h:9
 HepMCParticle.h:10
 HepMCParticle.h:11
 HepMCParticle.h:12
 HepMCParticle.h:13
 HepMCParticle.h:14
 HepMCParticle.h:15
 HepMCParticle.h:16
 HepMCParticle.h:17
 HepMCParticle.h:18
 HepMCParticle.h:19
 HepMCParticle.h:20
 HepMCParticle.h:21
 HepMCParticle.h:22
 HepMCParticle.h:23
 HepMCParticle.h:24
 HepMCParticle.h:25
 HepMCParticle.h:26
 HepMCParticle.h:27
 HepMCParticle.h:28
 HepMCParticle.h:29
 HepMCParticle.h:30
 HepMCParticle.h:31
 HepMCParticle.h:32
 HepMCParticle.h:33
 HepMCParticle.h:34
 HepMCParticle.h:35
 HepMCParticle.h:36
 HepMCParticle.h:37
 HepMCParticle.h:38
 HepMCParticle.h:39
 HepMCParticle.h:40
 HepMCParticle.h:41
 HepMCParticle.h:42
 HepMCParticle.h:43
 HepMCParticle.h:44
 HepMCParticle.h:45
 HepMCParticle.h:46
 HepMCParticle.h:47
 HepMCParticle.h:48
 HepMCParticle.h:49
 HepMCParticle.h:50
 HepMCParticle.h:51
 HepMCParticle.h:52
 HepMCParticle.h:53
 HepMCParticle.h:54
 HepMCParticle.h:55
 HepMCParticle.h:56
 HepMCParticle.h:57
 HepMCParticle.h:58
 HepMCParticle.h:59
 HepMCParticle.h:60
 HepMCParticle.h:61
 HepMCParticle.h:62
 HepMCParticle.h:63
 HepMCParticle.h:64
 HepMCParticle.h:65
 HepMCParticle.h:66
 HepMCParticle.h:67
 HepMCParticle.h:68
 HepMCParticle.h:69
 HepMCParticle.h:70
 HepMCParticle.h:71
 HepMCParticle.h:72
 HepMCParticle.h:73
 HepMCParticle.h:74
 HepMCParticle.h:75
 HepMCParticle.h:76
 HepMCParticle.h:77
 HepMCParticle.h:78
 HepMCParticle.h:79
 HepMCParticle.h:80
 HepMCParticle.h:81
 HepMCParticle.h:82
 HepMCParticle.h:83
 HepMCParticle.h:84
 HepMCParticle.h:85
 HepMCParticle.h:86
 HepMCParticle.h:87
 HepMCParticle.h:88
 HepMCParticle.h:89
 HepMCParticle.h:90
 HepMCParticle.h:91
 HepMCParticle.h:92
 HepMCParticle.h:93
 HepMCParticle.h:94
 HepMCParticle.h:95
 HepMCParticle.h:96
 HepMCParticle.h:97
 HepMCParticle.h:98
 HepMCParticle.h:99
 HepMCParticle.h:100
 HepMCParticle.h:101
 HepMCParticle.h:102
 HepMCParticle.h:103
 HepMCParticle.h:104
 HepMCParticle.h:105
 HepMCParticle.h:106
 HepMCParticle.h:107
 HepMCParticle.h:108
 HepMCParticle.h:109
 HepMCParticle.h:110
 HepMCParticle.h:111
 HepMCParticle.h:112
 HepMCParticle.h:113
 HepMCParticle.h:114
 HepMCParticle.h:115
 HepMCParticle.h:116
 HepMCParticle.h:117
 HepMCParticle.h:118
 HepMCParticle.h:119