TestSwimParticle.cxx File Reference

#include <iostream>
#include <cstring>
#include "TVector3.h"
#include "Swimmer/SwimSwimmer.h"
#include "Swimmer/SwimStepper.h"
#include "Swimmer/SwimPrintStepAction.h"
#include "Swimmer/SwimParticle.h"
#include "Swimmer/SwimZCondition.h"
#include "Swimmer/SwimMomentumCondition.h"
#include "Conventions/Munits.h"
#include "BField/BField.h"
#include "MessageService/MsgService.h"

Go to the source code of this file.

Classes

class  ConstBField
class  OneOverRBField

Functions

int main (int argc, const char **argv)

Function Documentation

int main ( int  argc,
const char **  argv 
)

Definition at line 62 of file TestSwimParticle.cxx.

References SwimStepper::AddStepAction(), exit(), SwimParticle::GetMomentum(), SwimParticle::GetPosition(), SwimSwimmer::GetStepper(), Munits::GeV, Munits::m, Mphysical::pi, s(), SwimSwimmer::SetStepper(), SwimSwimmer::SwimBackward(), and SwimSwimmer::SwimForward().

00063 {
00064   // Check we've been give the right number of arguments
00065   if (argc<7) {
00066     cerr << "Usage: " << argv[0] << " x y z px py pz [const] [G4]" << endl;
00067     exit(1);
00068   }
00069 
00070   // Set the Bfield to use - don't forget to delete at end of scope
00071   BField *b;
00072 
00073   if (argc>7 && strcmp(argv[7],"const")==0) {
00074     cerr << "Using constant BField\n";
00075     b = new ConstBField();
00076   }
00077   else {
00078     cerr << "Using 1/r BField\n";
00079     b = new OneOverRBField();
00080   }
00081 
00082   // Make a swimmer object using the BField
00083   SwimSwimmer s(b);
00084   
00085   // Determine which stepper to use
00086   // Use the Default stepper if there is no input parameter
00087   if (argc>8 && strcmp(argv[8],"G4")==0) {
00088     // Use the GEANT4 stepper
00089     s.SetStepper("G4");
00090   }
00091   
00092   // Add an action to the stepper - in this case a debug printout
00093   SwimPrintStepAction printStep;
00094   s.GetStepper()->AddStepAction(&printStep);
00095   
00096   // Setup the initial condition for the stepper
00097   double x  = atof(argv[1])*Munits::m;
00098   double y  = atof(argv[2])*Munits::m;
00099   double z  = atof(argv[3])*Munits::m;
00100   double px = atof(argv[4])*Munits::GeV;
00101   double py = atof(argv[5])*Munits::GeV;
00102   double pz = atof(argv[6])*Munits::GeV;
00103   TVector3 position(x,y,z);
00104   TVector3 momentum(px,py,pz);
00105 
00106   // Set up the particle to swim. In this case we're swimming a muon
00107   // so we could have used the default mass and charge,
00108   // ie. SwimParticle(position,momentum)
00109   double muMass   = 0.105658357*Munits::GeV;
00110   double muCharge = -1.0;
00111   SwimParticle muon1(position, momentum, muMass, muCharge);
00112 
00113   // Set the momentum condition for swimming
00114   double pThreshold = 0.5*Munits::GeV;
00115   SwimMomentumCondition pc(pThreshold);
00116 
00117   // Swim the muon particle until the condition is met
00118   bool done1 = s.SwimForward(muon1,pc);
00119   cout << "Momentum Condition Satisfied: " << done1 << endl;
00120 
00121   // Set the Z condition for swimming
00122   SwimZCondition zc(0.0*Munits::m);
00123 
00124   // Swim the muon particle backward
00125   SwimParticle muon2(muon1.GetPosition(),muon1.GetMomentum(),muMass,muCharge);
00126   bool done2 = s.SwimBackward(muon2,zc);
00127   cout << "Z Condition Satisfied: " << done2 << endl;
00128 
00129   // Calculate the momentum difference between swimming forward and backward
00130   // at energy threshold (from momentum condition)
00131   double pi=sqrt(px*px+py*py+pz*pz);
00132   double deltaP = muon2.GetMomentumModulus()-pi;
00133   cout << "Fractional difference in momentum: " << deltaP/pi << endl;
00134   cout << "Momentum Threshold: " << pThreshold << endl;
00135 
00136   // Delete the BField object
00137   delete b;
00138 
00139   return 0;
00140 }


Generated on 8 Jul 2019 for loon by  doxygen 1.6.1