GeoSwimApplication Class Reference

#include <GeoSwimApplication.h>

Inheritance diagram for GeoSwimApplication:
MCAppUser

List of all members.

Public Member Functions

virtual Gctrak_tGctrak () const
 GeoSwimApplication (const char *name, const char *title)
virtual ~GeoSwimApplication ()
virtual void GeneratePrimaries ()
virtual void BeginEvent ()
virtual void BeginPrimary ()
virtual void PreTrack ()
virtual void Stepping ()
virtual void PostTrack ()
virtual void FinishPrimary ()
virtual void FinishEvent ()
GeoSwimStackGetStack () const
void SetZCondition (GeoSwimZCondition &c)
void SetDirection (Int_t idir)
void SetHallSize (TVector3 min, TVector3 max)
bool GetSatisfied ()
Double_t GetS ()
Double_t GetRange ()

Private Member Functions

bool IsExiting ()

Private Attributes

GeoSwimStackfGeoSwimStack
VldRange fVldRange
Double_t fZCondition
TLorentzVector fInitMomentum
TLorentzVector fInitPosition
Int_t fDir
bool fSatisfied
Bool_t fExitLiner
Int_t fStep
Double_t fS
Double_t fRange
Float_t fPreVect [7]
TVector3 fHallMin
TVector3 fHallMax
Gctrak_tfGctrak
Gcflag_tfGcflag
 GCTRAK common structure.

Detailed Description

Definition at line 83 of file GeoSwimApplication.h.


Constructor & Destructor Documentation

GeoSwimApplication::GeoSwimApplication ( const char *  name,
const char *  title 
)

Definition at line 55 of file GeoSwimApplication.cxx.

References gcomad, Msg::kDebug, MSG, PASSCHARD, and PASSCHARL.

00056   : MCAppUser(name,title),fGeoSwimStack(0),
00057     fExitLiner(false)
00058 {
00059   // Normal constructor
00060 
00061   MSG("GeoSwim",Msg::kDebug) << "GeoSwimApplication normal ctor @ " 
00062                                << this << endl;
00063   fGeoSwimStack = new GeoSwimStack();
00064 
00065   MSG("GeoSwim",Msg::kDebug) << "Get address of common GCTRAK"  << endl;
00066   gcomad(PASSCHARD("GCTRAK"),(int*&) fGctrak  PASSCHARL("GCTRAK"));
00067   MSG("GeoSwim",Msg::kDebug) << "Get address of common GCFLAG"  << endl;
00068   gcomad(PASSCHARD("GCFLAG"),(int*&) fGcflag  PASSCHARL("GCFLAG"));
00069 
00070 }

GeoSwimApplication::~GeoSwimApplication (  )  [virtual]

Definition at line 73 of file GeoSwimApplication.cxx.

References fGeoSwimStack, Msg::kDebug, and MSG.

00073                                         {
00074   // delete all the owned sub-objects
00075 
00076   MSG("GeoSwim",Msg::kDebug) << "GeoSwimApplication dtor @ " 
00077                                << this << endl;
00078  
00079   if ( fGeoSwimStack ) delete fGeoSwimStack; fGeoSwimStack = 0;
00080 
00081 }


Member Function Documentation

void GeoSwimApplication::BeginEvent (  )  [virtual]

Implements MCAppUser.

Definition at line 84 of file GeoSwimApplication.cxx.

References MCApplication::Instance(), Msg::kDebug, and MSG.

00084                                     {    
00085 
00086 
00087   bool toswim = true;
00088   const_cast<MCApplication&>(MCApplication::Instance()).SwitchMedia(toswim);
00089 
00090   MSG("GeoSwim",Msg::kDebug) << "GeoSwimApplication::BeginEvent " 
00091                            << endl;
00092 
00093 }

void GeoSwimApplication::BeginPrimary (  )  [virtual]

Implements MCAppUser.

Definition at line 96 of file GeoSwimApplication.cxx.

References gGeoManager.

00096                                       {    
00097   gGeoManager->SetTminTmax(999999,-999999); // sec
00098   
00099 }

void GeoSwimApplication::FinishEvent (  )  [virtual]

Implements MCAppUser.

Definition at line 262 of file GeoSwimApplication.cxx.

References fGeoSwimStack, Msg::kDebug, and MSG.

00262                                      {    
00263 
00264   MSG("GeoSim",Msg::kDebug) << "GeoSwimApplication::FinishEvent " << endl;
00265 
00266   fGeoSwimStack -> Reset();
00267 
00268 } 

void GeoSwimApplication::FinishPrimary (  )  [virtual]

Implements MCAppUser.

Definition at line 255 of file GeoSwimApplication.cxx.

References Msg::kDebug, and MSG.

00255                                        {    
00256 
00257   MSG("GeoSim",Msg::kDebug) << "GeoSwimApplication::FinishPrimary " << endl;
00258 
00259 } 

virtual Gctrak_t* GeoSwimApplication::Gctrak (  )  const [inline, virtual]

Definition at line 87 of file GeoSwimApplication.h.

References fGctrak.

00087 {return fGctrak;}

virtual void GeoSwimApplication::GeneratePrimaries (  )  [inline, virtual]

Implements MCAppUser.

Definition at line 93 of file GeoSwimApplication.h.

00093 {}

Double_t GeoSwimApplication::GetRange (  ) 

Definition at line 309 of file GeoSwimApplication.cxx.

References fRange.

Referenced by GeoSwimmer::Swim().

00310 { 
00311   return fRange;
00312 }

Double_t GeoSwimApplication::GetS (  ) 

Definition at line 302 of file GeoSwimApplication.cxx.

References fS.

Referenced by GeoSwimmer::Swim().

00303 { 
00304   return fS;
00305 }

bool GeoSwimApplication::GetSatisfied (  ) 

Definition at line 295 of file GeoSwimApplication.cxx.

References fSatisfied.

Referenced by GeoSwimmer::Swim().

00296 { 
00297   return fSatisfied;
00298 }

GeoSwimStack* GeoSwimApplication::GetStack (  )  const [inline, virtual]

Implements MCAppUser.

Definition at line 102 of file GeoSwimApplication.h.

References fGeoSwimStack.

00102 { return fGeoSwimStack; }

bool GeoSwimApplication::IsExiting (  )  [private]

Definition at line 230 of file GeoSwimApplication.cxx.

References fExitLiner.

Referenced by Stepping().

00230                                    {    
00231   if ( gMC -> IsTrackExiting() ) {
00232     if ( std::string(gMC -> CurrentVolName() ) == "LINR" ) {
00233       fExitLiner = true;
00234     }
00235   }
00236   else if ( gMC -> IsTrackEntering() && fExitLiner ) {
00237     if ( std::string(gMC -> CurrentVolName() ) == "MARS" ) {
00238       return true;
00239     }
00240   }
00241 
00242   return false;
00243   
00244 }

void GeoSwimApplication::PostTrack (  )  [virtual]

Implements MCAppUser.

Definition at line 247 of file GeoSwimApplication.cxx.

References fExitLiner, Msg::kDebug, and MSG.

00247                                    {    
00248   fExitLiner = false; // reset exit flag
00249   
00250   MSG("GeoSwim",Msg::kDebug) << "GeoSwimApplication::PostTrack" << endl;
00251 
00252 }

void GeoSwimApplication::PreTrack (  )  [virtual]

Implements MCAppUser.

Definition at line 102 of file GeoSwimApplication.cxx.

References fGcflag, fInitMomentum, fInitPosition, fRange, fS, fStep, and Gcflag_t::nrndm.

00102                                   {    
00103   //
00104   // User actions at beginning of each track
00105   // Called by TGeant3gu::gutrak() before calling g3track.
00106   gMC->TrackPosition(fInitPosition);
00107   gMC->TrackMomentum(fInitMomentum);
00108   fGcflag->nrndm[0] = 0;
00109   fGcflag->nrndm[1] = 0;
00110   fStep = 0;
00111   fS = 0.;
00112   fRange = 0.;
00113 }

void GeoSwimApplication::SetDirection ( Int_t  idir  ) 

Definition at line 280 of file GeoSwimApplication.cxx.

References fDir.

Referenced by GeoSwimmer::Swim().

00281 { 
00282   fDir = idir;
00283 }

void GeoSwimApplication::SetHallSize ( TVector3  min,
TVector3  max 
)

Definition at line 287 of file GeoSwimApplication.cxx.

References fHallMax, and fHallMin.

Referenced by GeoSwimmer::Initialize().

00288 { 
00289   fHallMin = min;
00290   fHallMax = max;
00291 }

void GeoSwimApplication::SetZCondition ( GeoSwimZCondition c  ) 

Definition at line 272 of file GeoSwimApplication.cxx.

References Munits::cm, fSatisfied, fZCondition, and GeoSwimZCondition::GetZFinal().

Referenced by GeoSwimmer::Swim().

00273 { 
00274   fSatisfied = false;
00275   fZCondition = c.GetZFinal()/Munits::cm;
00276 }

void GeoSwimApplication::Stepping (  )  [virtual]

Implements MCAppUser.

Definition at line 116 of file GeoSwimApplication.cxx.

References MuELoss::a, Munits::cm, Gctrak_t::destep, MuELoss::e, fDir, fGctrak, fHallMax, fHallMin, fInitMomentum, fInitPosition, fPreVect, fRange, fS, fSatisfied, fStep, fZCondition, g3ekbin, Gctrak_t::gekin, Gctrak_t::getot, IsExiting(), Msg::kDebug, Msg::kWarning, MSG, and Gctrak_t::vect.

00116                                   {    
00117   //
00118   // User actions at each step
00119   // Called by TGeant3gu::gustep 
00120 
00121   TLorentzVector pos;
00122   gMC->TrackPosition(pos);
00123   TLorentzVector mom;
00124   gMC->TrackMomentum(mom);
00125   Float_t a=0.,z=0.,dens=0.,radl=0.,absl=0.;
00126   Float_t small = 1e-04;
00127   Int_t curmat;
00128   curmat = gMC->CurrentMaterial(a,z,dens,radl,absl);
00129 
00130   // Increasing energy in case of backward swimming: E' = E - dE + 2*dE.
00131   if(fDir==-1){
00132     fGctrak->gekin = fGctrak->gekin + 2.*fGctrak->destep;
00133     fGctrak->getot = fGctrak->gekin + gMC->TrackMass();
00134     fGctrak->vect[6] = sqrt((fGctrak->getot+gMC->TrackMass())*fGctrak->gekin);
00135     g3ekbin();
00136   }
00137 
00138   float lastS = fS;
00139   float lastRange = fRange;
00140   fS += gMC->TrackStep();
00141   fRange += dens*gMC->TrackStep();
00142 
00143   if((fInitPosition.Z() < fZCondition && pos.Z() >= fZCondition)
00144      || (fInitPosition.Z() > fZCondition  && pos.Z() <= fZCondition)) {
00145 
00146     MSG("GeoSwim",Msg::kDebug) << "Condition satisfied" << endl;
00147     fSatisfied = true;
00148 
00149     // Correction of position, energy and direction.
00150     float frac = (TMath::Abs(pos.Z()-fPreVect[2]) > small) ?
00151       (fZCondition-fPreVect[2])/(pos.Z()-fPreVect[2]):
00152       0.;
00153 
00154     //  S and Range
00155     fS = lastS +(fS-lastS)*frac;
00156     fRange = lastRange + (fRange-lastRange)*frac;
00157 
00158     // Position
00159     fGctrak->vect[0] = fPreVect[0]+(fGctrak->vect[0]-fPreVect[0])*frac;
00160     fGctrak->vect[1] = fPreVect[1]+(fGctrak->vect[1]-fPreVect[1])*frac;
00161     fGctrak->vect[2] = fPreVect[2]+(fGctrak->vect[2]-fPreVect[2])*frac;
00162 
00163     // Direction
00164     TVector3 direction(fGctrak->vect[3]*frac + fPreVect[3]*(1.-frac),
00165                        fGctrak->vect[4]*frac + fPreVect[4]*(1.-frac),
00166                        fGctrak->vect[5]*frac + fPreVect[5]*(1.-frac));
00167     direction = direction.Unit();
00168     fGctrak->vect[3] = direction.x();
00169     fGctrak->vect[4] = direction.y();
00170     fGctrak->vect[5] = direction.z();
00171     // Momentum and energy
00172     fGctrak->vect[6] = (fGctrak->vect[6]*frac + fPreVect[6]*(1.-frac));
00173     fGctrak->getot = pow(fGctrak->vect[6],2) + pow(gMC->TrackMass(),2);
00174     // Strop Run and return "satisfied"
00175     gMC->StopTrack();
00176     return;
00177   }
00178 
00179   if ( IsExiting() ) {
00180     MSG("GeoSwim",Msg::kDebug) 
00181       << "Track is entering MARS from LINR, call StopTrack" << endl;
00182     fSatisfied = false;
00183     gMC -> StopTrack();  
00184     return;
00185   }
00186 
00187   if(fInitMomentum.Z()*mom.Z()<0.){
00188     MSG("GeoSwim",Msg::kDebug)
00189       << "Negative Momentum\n";
00190     fSatisfied = false;
00191     gMC->StopTrack();
00192     return;
00193   }    
00194 
00195   fStep++;
00196   if(fStep>10000){
00197     MSG("GeoSwim",Msg::kWarning)
00198       << "GeoSwimApplication::Stepping more than 10000 steps"
00199       << fInitPosition.X() << " " << fInitPosition.Y() << " "
00200       << fInitPosition.Z() << " " << fInitMomentum.X() << " "
00201       << fInitMomentum.Y() << " " << fInitMomentum.Z() << " "
00202       << pos.X() << " " << pos.Y() << " " << pos.Z() << " "
00203       << fZCondition << endl;
00204     fSatisfied = false;
00205     gMC->StopTrack();
00206     return;
00207   }    
00208 
00209   if (pos.X() > fHallMax.X()/Munits::cm ||
00210       pos.X() < fHallMin.X()/Munits::cm ||
00211       pos.Y() > fHallMax.Y()/Munits::cm ||
00212       pos.Y() < fHallMin.Y()/Munits::cm ||
00213       pos.Z() > fHallMax.Z()/Munits::cm ||
00214       pos.Z() < fHallMin.Z()/Munits::cm) {
00215     MSG("GeoSwim",Msg::kDebug)
00216       << "GeoSwimmer::Swim Out of hall"
00217       << pos.X() << " " << pos.Y() << " " << pos.Z() << "\n";
00218     fSatisfied = false;
00219     gMC -> StopTrack();  
00220     return;
00221   }
00222 
00223   // Store /GCTRAK/VECT(7) as the status of previous step
00224   for(int i=0;i<7;i++){
00225       fPreVect[i]=fGctrak->vect[i];
00226   }
00227 }


Member Data Documentation

Int_t GeoSwimApplication::fDir [private]

Definition at line 122 of file GeoSwimApplication.h.

Referenced by SetDirection(), and Stepping().

Definition at line 124 of file GeoSwimApplication.h.

Referenced by IsExiting(), and PostTrack().

GCTRAK common structure.

Definition at line 134 of file GeoSwimApplication.h.

Referenced by PreTrack().

Definition at line 133 of file GeoSwimApplication.h.

Referenced by Gctrak(), and Stepping().

Definition at line 117 of file GeoSwimApplication.h.

Referenced by FinishEvent(), GetStack(), and ~GeoSwimApplication().

TVector3 GeoSwimApplication::fHallMax [private]

Definition at line 131 of file GeoSwimApplication.h.

Referenced by SetHallSize(), and Stepping().

TVector3 GeoSwimApplication::fHallMin [private]

Definition at line 130 of file GeoSwimApplication.h.

Referenced by SetHallSize(), and Stepping().

TLorentzVector GeoSwimApplication::fInitMomentum [private]

Definition at line 120 of file GeoSwimApplication.h.

Referenced by PreTrack(), and Stepping().

TLorentzVector GeoSwimApplication::fInitPosition [private]

Definition at line 121 of file GeoSwimApplication.h.

Referenced by PreTrack(), and Stepping().

Float_t GeoSwimApplication::fPreVect[7] [private]

Definition at line 128 of file GeoSwimApplication.h.

Referenced by Stepping().

Double_t GeoSwimApplication::fRange [private]

Definition at line 127 of file GeoSwimApplication.h.

Referenced by GetRange(), PreTrack(), and Stepping().

Double_t GeoSwimApplication::fS [private]

Definition at line 126 of file GeoSwimApplication.h.

Referenced by GetS(), PreTrack(), and Stepping().

Definition at line 123 of file GeoSwimApplication.h.

Referenced by GetSatisfied(), SetZCondition(), and Stepping().

Int_t GeoSwimApplication::fStep [private]

Definition at line 125 of file GeoSwimApplication.h.

Referenced by PreTrack(), and Stepping().

Definition at line 118 of file GeoSwimApplication.h.

Double_t GeoSwimApplication::fZCondition [private]

Definition at line 119 of file GeoSwimApplication.h.

Referenced by SetZCondition(), and Stepping().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1