SwimDefStepper Class Reference

#include <SwimDefStepper.h>

Inheritance diagram for SwimDefStepper:
SwimStepper

List of all members.

Classes

class  DerivFunc

Public Member Functions

 SwimDefStepper ()
 SwimDefStepper (BField *f)
 SwimDefStepper (BField *f, double min, double acc)
virtual ~SwimDefStepper ()
virtual bool StepOnce (SwimParticle &particle, SwimStepData *stepData)

Private Member Functions

void SetUpIntegrator ()

Private Attributes

double fX [6]
double fMinStepSize
double fAcc
BFieldfBfield
SwimDefStepper::DerivFunc fDerivFunc
NmOdeInt fIntegrator

Detailed Description

Definition at line 36 of file SwimDefStepper.h.


Constructor & Destructor Documentation

SwimDefStepper::SwimDefStepper (  )  [inline]

Definition at line 39 of file SwimDefStepper.h.

00039 : fBfield(0) {;}

SwimDefStepper::SwimDefStepper ( BField f  ) 

Definition at line 19 of file SwimDefStepper.cxx.

References SetUpIntegrator().

00019                                         : fBfield(f) 
00020 {
00021   this->SetUpIntegrator();
00022 }

SwimDefStepper::SwimDefStepper ( BField f,
double  min,
double  acc 
)

Definition at line 26 of file SwimDefStepper.cxx.

References SetUpIntegrator().

00026                                                                 : 
00027   fMinStepSize(min),
00028   fAcc(acc),
00029   fBfield(f)
00030 {
00031   this->SetUpIntegrator();
00032 }

virtual SwimDefStepper::~SwimDefStepper (  )  [inline, virtual]

Definition at line 42 of file SwimDefStepper.h.

00042 {;}


Member Function Documentation

void SwimDefStepper::SetUpIntegrator (  )  [private]

Definition at line 36 of file SwimDefStepper.cxx.

References fAcc, fDerivFunc, fIntegrator, fMinStepSize, NmOdeInt::SetAccuracy(), NmOdeInt::SetDerivFunc(), NmOdeInt::SetMinStepSize(), NmOdeInt::SetNvar(), and NmOdeInt::SetScales().

Referenced by SwimDefStepper().

00037 {
00038 //======================================================================
00039 // Purpose: Setup the integrator object
00040 //======================================================================
00041   double s[6] = {1.0,1.0,1.0,  // Typical sizes of x,y,z and
00042                  1.0,1.0,1.0}; // px,py,pz
00043   // Setup the integration object
00044   fIntegrator.SetNvar(6);
00045   fIntegrator.SetScales(s);
00046   fIntegrator.SetAccuracy(fAcc);
00047   fIntegrator.SetMinStepSize(fMinStepSize);
00048   fIntegrator.SetDerivFunc(fDerivFunc);
00049 }

bool SwimDefStepper::StepOnce ( SwimParticle particle,
SwimStepData stepData 
) [virtual]

Reimplemented from SwimStepper.

Definition at line 53 of file SwimDefStepper.cxx.

References SwimParticle::AddRange(), SwimParticle::AddS(), SwimParticle::AddVxB(), Munits::cm2, fBfield, fDerivFunc, fIntegrator, fX, Munits::g, SwimParticle::GetCharge(), SwimStepData::GetIsForward(), SwimParticle::GetMomentum(), SwimParticle::GetPosition(), SwimStepData::GetStepSize(), SwimStepData::GetSwimMaterial(), SwimGeo::GetSwimMaterialDensity(), NmOdeInt::Integrate(), Msg::kDebug, Msg::kError, MSG, SwimDefStepper::DerivFunc::SetChargeBField(), NmOdeInt::SetEndPoint(), NmOdeInt::SetInitialCondition(), SwimParticle::SetMomentum(), SwimParticle::SetPosition(), NmOdeInt::SetStartPoint(), and NmOdeInt::SetStepSize().

00055 {
00056   // Setup step
00057   fX[0] = particle.GetPosition().X();
00058   fX[1] = particle.GetPosition().Y();
00059   fX[2] = particle.GetPosition().Z();
00060   fX[3] = particle.GetMomentum().X();
00061   fX[4] = particle.GetMomentum().Y();
00062   fX[5] = particle.GetMomentum().Z();
00063   double stepSize = stepData->GetStepSize();
00064   // Used to calculate path, range traveled in this step
00065   double density = SwimGeo::GetSwimMaterialDensity(stepData->GetSwimMaterial());
00066   TVector3 startpos, path, startmom, deltamom;
00067   startpos = particle.GetPosition();
00068   startmom = particle.GetMomentum();
00069 
00070   fDerivFunc.SetChargeBField(particle.GetCharge(),fBfield);
00071   // TVector3 Bxyz = fBfield->GetBField(startpos);
00072   // cout << " pos " << fX[0] << " " << fX[1] << " z  " << fX[2] << " " << fX[4]/fX[5] << " "  << fX[5] << endl ;
00073   // cout << " density " << density << endl;
00074   //  cout << " bfield " << Bxyz.X() << " " <<      Bxyz.Y() << " " <<  Bxyz.Z() << " " <<   endl;
00075   // Integrate across the step
00076   fIntegrator.SetInitialCondition(fX);
00077   fIntegrator.SetStartPoint(0.0);
00078   if (stepData->GetIsForward())
00079     fIntegrator.SetEndPoint(stepSize);
00080   else
00081     fIntegrator.SetEndPoint(-stepSize);
00082 
00083   // 20 Feb 2008 - Avoid assert(stepSize>0) in fIntegrator.
00084   if(stepSize > 0){
00085     fIntegrator.SetStepSize(stepSize);
00086   }
00087   else{
00088     MSG("Swim", Msg::kError) << "Unexpected stepSize of " << stepSize << " bailing...\n";
00089     return false;
00090   }
00091 
00092   bool aok = fIntegrator.Integrate(fX);
00093 
00094   // Shuffle to output
00095   TVector3 position;
00096   TVector3 momentum;
00097   double   pModulus2 = fX[3]*fX[3]+fX[4]*fX[4]+fX[5]*fX[5];
00098   position.SetXYZ(fX[0],fX[1],fX[2]);
00099   particle.SetPosition(position);
00100   if (pModulus2!=0.0)
00101     momentum.SetXYZ(fX[3],fX[4],fX[5]);
00102   else
00103     momentum.SetXYZ(0.0,0.0,0.0);
00104   particle.SetMomentum(momentum);
00105 
00106   // Calculate path, range in this step, add to particle totals
00107   path = particle.GetPosition();
00108   
00109   double endz =path[2];
00110   deltamom = particle.GetMomentum();
00111   path -= startpos;
00112   deltamom -= startmom;
00113   particle.AddS(path.Mag());
00114   particle.AddRange(density*path.Mag()/(Munits::g/Munits::cm2));
00115   
00116   MSG("Swim",Msg::kDebug) << " start/end z " << startpos[2] <<  "/" << endz << " density " << density/1000. << " dzds " << fabs(path[2]/path.Mag())  << " dRange  " << density*path.Mag() << endl;
00117 
00118   particle.AddVxB(deltamom.Mag());
00119   
00120   return aok;
00121 }


Member Data Documentation

double SwimDefStepper::fAcc [private]

Definition at line 64 of file SwimDefStepper.h.

Referenced by SetUpIntegrator().

Definition at line 66 of file SwimDefStepper.h.

Referenced by StepOnce().

Definition at line 67 of file SwimDefStepper.h.

Referenced by SetUpIntegrator(), and StepOnce().

Definition at line 68 of file SwimDefStepper.h.

Referenced by SetUpIntegrator(), and StepOnce().

double SwimDefStepper::fMinStepSize [private]

Definition at line 63 of file SwimDefStepper.h.

Referenced by SetUpIntegrator().

double SwimDefStepper::fX[6] [private]

Definition at line 62 of file SwimDefStepper.h.

Referenced by StepOnce().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1