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

MCParticle.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/gismo/gismo/MCParticle.h,v 1.4 2001/05/31 19:40:07 chehtman Exp $
00002 //
00003 //
00004 #ifndef GISMO_MCPARTICLE_H
00005 #define GISMO_MCPARTICLE_H
00006 
00007 #include "gismo/GParticle.h"
00008 #include "geometry/Ray.h"
00009 
00010 #include "gismo/Interactor.h"
00011 
00012 class Medium;
00013 class Track;
00014 
00016 
00020 class MCParticle : public GParticle
00021 {
00022     
00023 public:
00025     MCParticle(long id, float mass=-1);
00027     MCParticle(const char*, float mass=-1);
00029     MCParticle(const PData*, float mass=-1);
00031     MCParticle(const MCParticle&);
00032     
00034     ~MCParticle();
00035  
00037     enum Status {ALIVE, DECAYED, INTERACTED,
00038         LEFT, STOPPED, LOOPING,
00039         LOST, STUCK, PRIMARY, SHOWER};
00040     
00042     MCParticle::Status status() const;
00044     void setStatus(MCParticle::Status);
00045     
00047     static int   saveTrack;
00048     
00050     float energyLoss()const;
00051     
00053     virtual void propagate(const Medium *);
00054     
00056     const MCParticle* parent()const;
00057     
00059     MCParticle* child(int i)const;
00060     
00062     virtual GParticle* addChild(const PData*, float mass=-1);
00063     
00065     int interact(const Medium*);
00067     float interactionLength(const Medium*);
00068     
00069     
00071     static void addInteractor(Interactor *);
00072     
00073     void printOn( std::ostream& ) const;
00074     
00075     
00077     static int stepCount();
00078     int generationCount();
00079     float stepLength();
00080     float arclength();
00081     float currentTime();
00082     Point position(float s) const;
00083     Point position() const;
00084     Vector direction(float s) const;
00085     Vector direction() const;
00086     
00088     const Ray* segment()const{return s_segment;}
00089     
00091     const Medium *medium() const;
00092     
00094     Interactor* interactor()const{ return pData->interaction();}
00095     
00097     const Track* track()const { return _track;}
00098     
00100     static const Medium*  getCurrentMedium () { return currentMedium; }
00101     
00102 protected:
00103     
00104     Track* _track;
00105     // geometric path used for drawing
00106     
00107     Status _status;
00108     // current status
00109     
00110     const Medium *lastMedium;
00111     // pointer to medium in which track ends
00112     
00113     
00114     float checkStep();
00115     void stepBy(float, Ray&);
00116     void endStep();
00117     
00118     
00119     // following are static since they are only needed during propagation,
00120     // which is done a particle at a time while alive
00121     
00122     static Ray *        s_segment;        // Trajectory of last step
00123     static double    startingEnergy; // energy at start of step
00124     
00125     static float    arcLength;  // total distance swum so far
00126     static float    properTime; // total proper time since creation.
00127     static float    timeOfDecay;        // actual decay time
00128     static float    step;         // distance of present step
00129     
00130     static int stepcount;
00131     // step counter
00132     static int generation;
00133     // generation counter
00134     
00135     static float    turnAngle;  
00136     // total angular deflection so far (propagation parameter)
00137     
00138     static float elossFraction;
00139     // the maximum fraction of energy loss allowed for a step
00140     
00141     static float ecut;
00142     // the minimum energy allowed if losing energy in a medium
00143     
00144     static const Medium* currentMedium;
00145     // the current medium
00146     
00147     
00148     //  Define some limits used for propagation
00149     static const float MAX_TIME;   //nsec...
00150     static const float MAX_BEND;   //radians .. 5 loops...
00151     static const int   MAX_GENERATION;  //limits depth of a shower
00152     static const int   MAX_STEPS;   // limits number of steps for a particle
00153     
00154 };
00155 
00156 inline MCParticle::Status MCParticle::status()const{return _status;}
00157 inline void MCParticle::setStatus(MCParticle::Status s){_status = s;}
00158 inline float MCParticle::energyLoss()const {return startingEnergy-e();}
00159 
00160 inline int MCParticle::stepCount()      {return stepcount;}
00161 inline int MCParticle::generationCount(){return generation;}
00162 
00163 
00164 inline float MCParticle::stepLength(){return step;}
00165 inline float MCParticle::arclength(){return arcLength;}
00166 inline float MCParticle::currentTime(){return properTime;}
00167 inline Point MCParticle::position() const
00168 {return GParticle::position();}
00169 inline Vector MCParticle::direction() const
00170 {return GParticle::direction();}
00171 inline Point MCParticle::position(float s) const
00172 { if(s_segment)return s_segment->position(s);
00173 else       return GParticle::position();
00174 }
00175 inline Vector MCParticle::direction(float s) const
00176 {if(s_segment) return s_segment->direction(s);
00177 else         return GParticle::direction();
00178 }
00179 
00180 inline int MCParticle::interact(const Medium* m){
00181     return pData->interaction()->interact(this,m);}
00182 inline float MCParticle::interactionLength(const Medium* m){
00183     return pData->interaction()->interactionLength(this,m);}
00184 
00185 inline const Medium *
00186 MCParticle::medium()const {return lastMedium;}
00187 
00188 
00189 #endif
00190 

Generated at Mon Nov 26 18:18:33 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000