00001
00002 #ifndef BDSContinuousSR_h
00003 #define BDSContinuousSR_h 1
00004
00005 #include "BDSGlobalConstants.hh"
00006
00007 #include "G4ios.hh"
00008 #include "globals.hh"
00009 #include "Randomize.hh"
00010 #include "G4VDiscreteProcess.hh"
00011 #include "G4Track.hh"
00012 #include "G4Step.hh"
00013 #include "G4Gamma.hh"
00014 #include "G4Electron.hh"
00015 #include "G4Positron.hh"
00016 #include "G4OrderedTable.hh"
00017 #include "G4PhysicsTable.hh"
00018 #include "G4PhysicsLogVector.hh"
00019 #include "BDSComptonEngine.hh"
00020 #include "BDSMaterials.hh"
00021 #include "Randomize.hh"
00022
00023 #include "G4ChordFinder.hh"
00024 #include "G4FieldManager.hh"
00025 #include "G4MagIntegratorDriver.hh"
00026 #include "G4MagIntegratorStepper.hh"
00027 #include "G4FieldTrack.hh"
00028
00029 #include "G4MagIntegratorDriver.hh"
00030
00031 #include "G4Navigator.hh"
00032 #include "G4AffineTransform.hh"
00033
00034 extern G4double BDSLocalRadiusOfCurvature;
00035
00036 class BDSContinuousSR : public G4VDiscreteProcess
00037 {
00038 public:
00039
00040 BDSContinuousSR(const G4String& processName = "contSR");
00041
00042 ~BDSContinuousSR();
00043
00044 G4bool IsApplicable(const G4ParticleDefinition&);
00045
00046 G4double GetMeanFreePath(const G4Track& track,
00047 G4double previousStepSize,
00048 G4ForceCondition* condition );
00049
00050 G4VParticleChange *PostStepDoIt(const G4Track& track,
00051 const G4Step& step);
00052
00053 G4double SynGenC(G4double xmin);
00054 G4double SynRadC(G4double x);
00055
00056 protected:
00057
00058 private:
00059
00060
00061 BDSContinuousSR & operator=(const BDSContinuousSR &right);
00062 BDSContinuousSR(const BDSContinuousSR&);
00063
00064 G4double nExpConst;
00065 G4double CritEngFac;
00066
00067 private:
00068 };
00069
00070 inline G4bool
00071 BDSContinuousSR::IsApplicable(const G4ParticleDefinition& particle)
00072 {
00073 return( (&particle == G4Electron::Electron())
00074 ||(&particle == G4Positron::Positron()) );
00075 }
00076
00077 inline G4double
00078 BDSContinuousSR::GetMeanFreePath(const G4Track& track,
00079 G4double,
00080 G4ForceCondition* ForceCondition)
00081 {
00082 *ForceCondition = NotForced ;
00083
00084 G4double rfact = 1.;
00085
00086
00087
00088
00089 G4double MeanFreePath;
00090 G4FieldManager* TheFieldManager=
00091 track.GetVolume()->GetLogicalVolume()->GetFieldManager();
00092
00093 if(track.GetTotalEnergy()<BDSGlobalConstants::Instance()->GetThresholdCutCharged())
00094 return DBL_MAX;
00095
00096
00097
00098
00099
00100 if(TheFieldManager)
00101 {
00102 const G4Field* pField = TheFieldManager->GetDetectorField() ;
00103 G4ThreeVector globPosition = track.GetPosition() ;
00104 G4double globPosVec[3], FieldValueVec[3]={0.} ;
00105 globPosVec[0] = globPosition.x() ;
00106 globPosVec[1] = globPosition.y() ;
00107 globPosVec[2] = globPosition.z() ;
00108
00109 if(pField)
00110 pField->GetFieldValue( globPosVec, FieldValueVec ) ;
00111
00112 G4double Blocal= FieldValueVec[1];
00113 if ( FieldValueVec[0]!=0.)
00114 Blocal=sqrt(Blocal*Blocal+FieldValueVec[0]*FieldValueVec[0]);
00115
00116
00117
00118 if(track.GetMaterial()==BDSMaterials::Instance()->GetMaterial("Vacuum")&&Blocal !=0 )
00119 {
00120 G4ThreeVector InitMag=track.GetMomentum();
00121
00122
00123
00124 G4AffineTransform tf(track.GetTouchable()->GetHistory()->GetTopTransform().Inverse());
00125 const G4RotationMatrix Rot=tf.NetRotation();
00126 const G4ThreeVector Trans=-tf.NetTranslation();
00127 InitMag=Rot*InitMag;
00128
00129
00130 G4double Rlocal=(InitMag.z()/GeV)/(0.299792458 * Blocal/tesla) *m;
00131
00132 MeanFreePath=
00133 fabs(Rlocal)/(track.GetTotalEnergy()*nExpConst);
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 return rfact * MeanFreePath;
00144 }
00145 else
00146 return DBL_MAX;
00147 }
00148 else
00149 return DBL_MAX;
00150
00151 }
00152
00153
00154
00155 #endif