00001
00002 #ifndef BDSSynchrotronRadiation_h
00003 #define BDSSynchrotronRadiation_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 BDSMaterials* theMaterials;
00035 extern G4double BDSLocalRadiusOfCurvature;
00036
00037 class BDSSynchrotronRadiation : public G4VDiscreteProcess
00038 {
00039 public:
00040
00041 BDSSynchrotronRadiation(const G4String& processName = "BDSSynchRad");
00042
00043 ~BDSSynchrotronRadiation();
00044
00045 G4bool IsApplicable(const G4ParticleDefinition&);
00046
00047 G4double GetMeanFreePath(const G4Track& track,
00048 G4double previousStepSize,
00049 G4ForceCondition* condition );
00050
00051 G4VParticleChange *PostStepDoIt(const G4Track& track,
00052 const G4Step& step);
00053
00054 G4double SynGenC(G4double xmin);
00055 G4double SynRadC(G4double x);
00056
00057 protected:
00058
00059 private:
00060
00061 BDSSynchrotronRadiation & operator=(const BDSSynchrotronRadiation &right);
00062
00063 BDSSynchrotronRadiation(const BDSSynchrotronRadiation&);
00064
00065 G4double nExpConst;
00066 G4double CritEngFac;
00067 G4int MeanFreePathCounter;
00068
00069 private:
00070 };
00071
00072 inline G4bool
00073 BDSSynchrotronRadiation::IsApplicable(const G4ParticleDefinition& particle)
00074 {
00075 return( (&particle == G4Electron::Electron())
00076 ||(&particle == G4Positron::Positron()) );
00077 }
00078
00079 inline G4double
00080 BDSSynchrotronRadiation::GetMeanFreePath(const G4Track& track,
00081 G4double PreviousStepSize,
00082 G4ForceCondition* ForceCondition)
00083 {
00084 *ForceCondition = NotForced ;
00085
00086
00087
00088 G4double MeanFreePath;
00089 G4FieldManager* TheFieldManager=
00090 track.GetVolume()->GetLogicalVolume()->GetFieldManager();
00091
00092 if(track.GetTotalEnergy()<BDSGlobals->GetThresholdCutCharged())
00093 return DBL_MAX;
00094
00095
00096
00097
00098
00099 if(TheFieldManager)
00100 {
00101 const G4Field* pField = TheFieldManager->GetDetectorField() ;
00102 G4ThreeVector globPosition = track.GetPosition() ;
00103 G4double globPosVec[3], FieldValueVec[3] ;
00104 globPosVec[0] = globPosition.x() ;
00105 globPosVec[1] = globPosition.y() ;
00106 globPosVec[2] = globPosition.z() ;
00107
00108 if(pField)
00109 pField->GetFieldValue( globPosVec, FieldValueVec ) ;
00110
00111 G4double Blocal= FieldValueVec[1];
00112 if ( FieldValueVec[0]!=0.)
00113 Blocal=sqrt(Blocal*Blocal+FieldValueVec[0]*FieldValueVec[0]);
00114
00115
00116
00117 if(track.GetMaterial()==theMaterials->GetMaterial("Vacuum")&&Blocal !=0 )
00118 {
00119 G4ThreeVector InitMag=track.GetMomentum();
00120
00121
00122
00123 G4AffineTransform tf(track.GetTouchable()->GetHistory()->GetTopTransform().Inverse());
00124 const G4RotationMatrix Rot=tf.NetRotation();
00125 const G4ThreeVector Trans=-tf.NetTranslation();
00126 InitMag=Rot*InitMag;
00127
00128
00129 G4double Rlocal=(InitMag.z()/GeV)/(0.299792458 * Blocal/tesla) *m;
00130
00131 MeanFreePath=
00132 fabs(Rlocal)/(track.GetTotalEnergy()*nExpConst);
00133
00134 MeanFreePath /= BDSGlobals->GetSynchMeanFreeFactor();
00135
00136 if(MeanFreePathCounter==BDSGlobals->GetSynchMeanFreeFactor())
00137 MeanFreePathCounter=0;
00138
00139
00140
00141
00142
00143
00144
00145 return MeanFreePath;
00146 }
00147 else
00148 return DBL_MAX;
00149 }
00150 else
00151 return DBL_MAX;
00152
00153 }
00154
00155
00156
00157 #endif