Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

MCTruth.h

Go to the documentation of this file.
00001 //  $Header: /nfs/slac/g/glast/ground/cvs/instrument/instrument/MCTruth.h,v 1.9 2001/08/23 06:05:27 burnett Exp $
00002 //
00003 //
00004 
00005 #ifndef __MCTruth_H
00006 #define __MCTruth_H
00007 
00008 // includes
00009 #include "instrument/GlastDetector.h"
00010 #include "facilities/bpkt_streams.h"
00011 
00012 // forward declarations
00013 class DetectorVisitor;
00014 class Generator;
00015 
00022 class MCTruth : public GlastDetector
00023 {
00024 protected:
00026     MCTruth (const DOM_Element& elem);
00027     
00028 public:
00029     // type declarations
00030     typedef unsigned int    id_type;
00031     
00032     class _Factory : public GlastDetector::_Factory {
00033     public:
00034         virtual xml::PersistentObject*   create(const DOM_Element& elem) { 
00035             return new MCTruth(elem); 
00036         }
00037     };
00038     class _Particle {
00039     public:
00040         virtual void    write ( std::ostream&) const {};
00041         virtual void    write_data ( bpkt::ostream& ) const {};
00042         virtual void    read ( std::istream&) {};
00043         virtual void    read_data ( bpkt::istream& ) {};
00044         virtual void    printOn ( std::ostream& ) const {};
00045         
00046         // accss to quantities
00047         virtual double  int_material_Z () const {return -1;};
00048         
00049         virtual Point position()const{return Point();}
00050         virtual Vector momentum()const{return Vector();}
00051         virtual double energy()const {return 0;}
00052         virtual long id()const {return 9999;}
00053         virtual std::string name()const{return std::string("not set");}
00054 
00056         virtual void setPosition(const Point& pos){}
00057         virtual void setMomentum(const Vector& p){}
00058         virtual void setEnergy(double e){}
00059         virtual void setName(const std::string& name){}
00060        
00061         
00062         virtual Generator*  generator () const { return (Generator*)0;}
00063     };
00064     
00065     
00071     class   ParticleData : public  _Particle{
00072     public:  
00073         // declare how the children are stored
00074         typedef std::vector<ParticleData*>  ChildList;
00075         
00076         // ctor/dtor
00077         ParticleData () {}
00078         virtual ~ParticleData (){};
00079         
00080         void    read (std::istream& in);
00081         virtual void    write ( std::ostream&) const;
00082 
00083         
00085         Point position()const{return m_pos;}
00086         Vector momentum()const{return m_p;}
00087         double energy()const{return m_energy;;}
00088         long id()const{return m_idcode;}
00089         std::string name()const{return m_name;}
00090 
00092         void setPosition(const Point& pos){m_pos=pos;}
00093         void setMomentum(const Vector& p){m_p=p;}
00094         void setEnergy(double e){m_energy = e;}
00095         void setName(const std::string& name){m_name=name;}
00096     private:    
00097         long    m_idcode;   // some particle ID code
00098         int     m_status;   // some particle status code
00099         Vector  m_p;        // momentum
00100         Point   m_pos;      // position
00101         Vector  m_dir;      // initial direction
00102         double  m_energy;       // energy
00103         std::string m_name;
00104         
00105         ChildList  m_kids;  // list of child particles
00106         
00107     };
00108     
00110 
00112     MCTruth( _Particle* p = 0);
00113     
00114     virtual ~MCTruth();
00115     
00116     // visitation
00117     virtual void accept(DetectorVisitor&);
00118     virtual void accept(DetectorConverter&);
00119     virtual void accept(DetectorConverter&) const;
00120     
00121     // GlastDetector overrides
00122     virtual bool empty ()const { return false;}
00123     virtual void read (std::istream& in) { in >> m_id; m_particle->read (in); } 
00124     virtual void write (std::ostream& out) const 
00125     { out << m_id; m_particle->write (out); }
00126     virtual void printOn (std::ostream& out) const 
00127     { if( m_particle ) m_particle->printOn (out); 
00128     else{ out << "MCTruth: no particle object"; } }
00129     virtual const char* nameOf () const { return "MCTruth"; }
00130     
00131     // access
00132     const _Particle*    particle () const { return m_particle; }
00133     _Particle*      particle () { return m_particle; }
00134     void    particle (_Particle* p) { m_particle = p; }
00135     
00136     const id_type&  id () const { return m_id; }
00137     void            id ( const id_type& anid ) { m_id = anid; }
00138     
00139     Generator*  generator(){return particle()->generator();}
00140     
00141     // singleton
00142     static  MCTruth*    instance () { return s_instance; }
00143     
00144     // "persistence"
00145     static const GlastDetector::_PersistKey classPersistKey;
00146     //  virtual DOM_Element&   persist (DOM_Element& e) const 
00147     virtual DOM_Element   persist (DOM_Element& e) const 
00148     { return GlastDetector::persist(e); }
00149     
00150     protected:
00151         // "persistence"
00152         virtual const GlastDetector::_PersistKey&   persistKey () const
00153         { return classPersistKey; }
00154         
00155         // friends
00156         friend class _Factory;
00157         
00158     private: 
00159         // private data members
00160         _Particle*  m_particle; // some abstract particle representation
00161         id_type     m_id;           // id type for the current event.
00162         
00163         // static data members
00164         static MCTruth* s_instance; // singleton instance
00165 };
00166 #endif

Generated at Wed Nov 21 12:22:39 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000