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 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /track/src/G4Step.cc (Version 11.3.0) and /track/src/G4Step.cc (Version 11.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4Step class implementation                     26 // G4Step class implementation
 27 //                                                 27 //
 28 // Authors:                                        28 // Authors:
 29 //   Katsuya Amako  (e-mail: Katsuya.Amako@kek     29 //   Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
 30 //   Takashi Sasaki (e-mail: Takashi.Sasaki@ke     30 //   Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
 31 // Revisions:                                      31 // Revisions:
 32 //   Hisaya Kurashige, 1998-2007                   32 //   Hisaya Kurashige, 1998-2007
 33 // -------------------------------------------     33 // --------------------------------------------------------------------
 34                                                    34 
 35 #include "G4Step.hh"                               35 #include "G4Step.hh"
 36                                                    36 
 37 // -------------------------------------------     37 // --------------------------------------------------------------------
 38 G4Step::G4Step()                                   38 G4Step::G4Step()
 39 {                                                  39 {
 40   fpPreStepPoint  = new G4StepPoint();             40   fpPreStepPoint  = new G4StepPoint();
 41   fpPostStepPoint = new G4StepPoint();             41   fpPostStepPoint = new G4StepPoint();
 42                                                    42 
 43   secondaryInCurrentStep = new std::vector<con     43   secondaryInCurrentStep = new std::vector<const G4Track*>;
 44 }                                                  44 }
 45                                                    45 
 46 // -------------------------------------------     46 // --------------------------------------------------------------------
 47 G4Step::~G4Step()                                  47 G4Step::~G4Step()
 48 {                                                  48 {
 49   delete fpPreStepPoint;                           49   delete fpPreStepPoint;
                                                   >>  50   fpPreStepPoint = nullptr;
 50   delete fpPostStepPoint;                          51   delete fpPostStepPoint;
                                                   >>  52   fpPostStepPoint = nullptr;
 51                                                    53 
                                                   >>  54   secondaryInCurrentStep->clear();
 52   delete secondaryInCurrentStep;                   55   delete secondaryInCurrentStep;
 53   delete fSecondary;                           <<  56   secondaryInCurrentStep = nullptr;
                                                   >>  57 
                                                   >>  58   if(fSecondary != nullptr)
                                                   >>  59   {
                                                   >>  60     fSecondary->clear();
                                                   >>  61     delete fSecondary;
                                                   >>  62   }
                                                   >>  63   fSecondary = nullptr;
 54 }                                                  64 }
 55                                                    65 
 56 // -------------------------------------------     66 // --------------------------------------------------------------------
 57 G4Step::G4Step(const G4Step& right)                67 G4Step::G4Step(const G4Step& right)
 58   : fTotalEnergyDeposit(right.fTotalEnergyDepo     68   : fTotalEnergyDeposit(right.fTotalEnergyDeposit)
 59   , fNonIonizingEnergyDeposit(right.fNonIonizi     69   , fNonIonizingEnergyDeposit(right.fNonIonizingEnergyDeposit)
 60   , fStepLength(right.fStepLength)                 70   , fStepLength(right.fStepLength)
 61   , fpTrack(right.fpTrack)                         71   , fpTrack(right.fpTrack)
 62   , fpSteppingControlFlag(right.fpSteppingCont     72   , fpSteppingControlFlag(right.fpSteppingControlFlag)
 63   , fFirstStepInVolume(right.fFirstStepInVolum     73   , fFirstStepInVolume(right.fFirstStepInVolume)
 64   , fLastStepInVolume(right.fLastStepInVolume)     74   , fLastStepInVolume(right.fLastStepInVolume)
 65   , nSecondaryByLastStep(right.nSecondaryByLas     75   , nSecondaryByLastStep(right.nSecondaryByLastStep)
 66   , secondaryInCurrentStep(right.secondaryInCu     76   , secondaryInCurrentStep(right.secondaryInCurrentStep)
 67   , fpVectorOfAuxiliaryPointsPointer(right.fpV     77   , fpVectorOfAuxiliaryPointsPointer(right.fpVectorOfAuxiliaryPointsPointer)
 68 {                                                  78 {
 69   if(right.fpPreStepPoint != nullptr)              79   if(right.fpPreStepPoint != nullptr)
 70   {                                                80   {
 71     fpPreStepPoint = new G4StepPoint(*(right.f     81     fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
 72   }                                                82   }
 73   else                                             83   else
 74   {                                                84   {
 75     fpPreStepPoint = new G4StepPoint();            85     fpPreStepPoint = new G4StepPoint();
 76   }                                                86   }
 77   if(right.fpPostStepPoint != nullptr)             87   if(right.fpPostStepPoint != nullptr)
 78   {                                                88   {
 79     fpPostStepPoint = new G4StepPoint(*(right.     89     fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
 80   }                                                90   }
 81   else                                             91   else
 82   {                                                92   {
 83     fpPostStepPoint = new G4StepPoint();           93     fpPostStepPoint = new G4StepPoint();
 84   }                                                94   }
 85                                                    95 
 86   if(right.fSecondary != nullptr)                  96   if(right.fSecondary != nullptr)
 87   {                                                97   {
 88     fSecondary = new G4TrackVector(*(right.fSe     98     fSecondary = new G4TrackVector(*(right.fSecondary));
 89   }                                                99   }
 90   else                                            100   else
 91   {                                               101   {
 92     fSecondary = new G4TrackVector();             102     fSecondary = new G4TrackVector();
 93   }                                               103   }
 94                                                   104 
 95   // secondaryInCurrentStep is cleared            105   // secondaryInCurrentStep is cleared
 96   secondaryInCurrentStep = new std::vector<con    106   secondaryInCurrentStep = new std::vector<const G4Track*>;
 97 }                                                 107 }
 98                                                   108 
 99 // -------------------------------------------    109 // --------------------------------------------------------------------
100 G4Step& G4Step::operator=(const G4Step& right)    110 G4Step& G4Step::operator=(const G4Step& right)
101 {                                                 111 {
102   if(this != &right)                              112   if(this != &right)
103   {                                               113   {
104     fTotalEnergyDeposit              = right.f    114     fTotalEnergyDeposit              = right.fTotalEnergyDeposit;
105     fNonIonizingEnergyDeposit        = right.f    115     fNonIonizingEnergyDeposit        = right.fNonIonizingEnergyDeposit;
106     fStepLength                      = right.f    116     fStepLength                      = right.fStepLength;
107     fpTrack                          = right.f    117     fpTrack                          = right.fpTrack;
108     fpSteppingControlFlag            = right.f    118     fpSteppingControlFlag            = right.fpSteppingControlFlag;
109     fFirstStepInVolume               = right.f    119     fFirstStepInVolume               = right.fFirstStepInVolume;
110     fLastStepInVolume                = right.f    120     fLastStepInVolume                = right.fLastStepInVolume;
111     nSecondaryByLastStep             = right.n    121     nSecondaryByLastStep             = right.nSecondaryByLastStep;
112     secondaryInCurrentStep           = right.s    122     secondaryInCurrentStep           = right.secondaryInCurrentStep;
113     fpVectorOfAuxiliaryPointsPointer = right.f    123     fpVectorOfAuxiliaryPointsPointer = right.fpVectorOfAuxiliaryPointsPointer;
114                                                   124 
115     delete fpPreStepPoint;                     << 125     if(fpPreStepPoint != nullptr)
116                                                << 126     {
                                                   >> 127       delete fpPreStepPoint;
                                                   >> 128     }
117     if(right.fpPreStepPoint != nullptr)           129     if(right.fpPreStepPoint != nullptr)
118     {                                             130     {
119       fpPreStepPoint = new G4StepPoint(*(right    131       fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
120     }                                             132     }
121     else                                          133     else
122     {                                             134     {
123       fpPreStepPoint = new G4StepPoint();         135       fpPreStepPoint = new G4StepPoint();
124     }                                             136     }
125                                                << 137     if(fpPostStepPoint != nullptr)
126     delete fpPostStepPoint;                    << 138     {
127                                                << 139       delete fpPostStepPoint;
                                                   >> 140     }
128     if(right.fpPostStepPoint != nullptr)          141     if(right.fpPostStepPoint != nullptr)
129     {                                             142     {
130       fpPostStepPoint = new G4StepPoint(*(righ    143       fpPostStepPoint = new G4StepPoint(*(right.fpPostStepPoint));
131     }                                             144     }
132     else                                          145     else
133     {                                             146     {
134       fpPostStepPoint = new G4StepPoint();        147       fpPostStepPoint = new G4StepPoint();
135     }                                             148     }
136                                                   149 
137     if(fSecondary != nullptr)                     150     if(fSecondary != nullptr)
138     {                                             151     {
139       fSecondary->clear();                        152       fSecondary->clear();
140       delete fSecondary;                          153       delete fSecondary;
141     }                                             154     }
142     if(right.fSecondary != nullptr)               155     if(right.fSecondary != nullptr)
143     {                                             156     {
144       fSecondary = new G4TrackVector(*(right.f    157       fSecondary = new G4TrackVector(*(right.fSecondary));
145     }                                             158     }
146     else                                          159     else
147     {                                             160     {
148       fSecondary = new G4TrackVector();           161       fSecondary = new G4TrackVector();
149     }                                             162     }
150                                                   163 
151     // secondaryInCurrentStep is not copied       164     // secondaryInCurrentStep is not copied
152     if(secondaryInCurrentStep != nullptr)         165     if(secondaryInCurrentStep != nullptr)
153     {                                             166     {
154       secondaryInCurrentStep->clear();            167       secondaryInCurrentStep->clear();
155       delete secondaryInCurrentStep;              168       delete secondaryInCurrentStep;
156     }                                             169     }
157     secondaryInCurrentStep = new std::vector<c    170     secondaryInCurrentStep = new std::vector<const G4Track*>;
158   }                                               171   }
159   return *this;                                   172   return *this;
160 }                                                 173 }
161                                                   174 
162 // -------------------------------------------    175 // --------------------------------------------------------------------
                                                   >> 176 G4ThreeVector G4Step::GetDeltaMomentum() const
                                                   >> 177 {
                                                   >> 178   static G4ThreadLocal G4bool isFirstTime = true;
                                                   >> 179   if(isFirstTime)
                                                   >> 180   {
                                                   >> 181     isFirstTime = false;
                                                   >> 182 #ifdef G4VERBOSE
                                                   >> 183     G4Exception("G4Step::GetDeltaMomentum()", "Warning", JustWarning,
                                                   >> 184                 "This method is obsolete and will be removed soon");
                                                   >> 185 #endif
                                                   >> 186   }
                                                   >> 187 
                                                   >> 188   return fpPostStepPoint->GetMomentum() - fpPreStepPoint->GetMomentum();
                                                   >> 189 }
                                                   >> 190 
                                                   >> 191 // --------------------------------------------------------------------
                                                   >> 192 G4double G4Step::GetDeltaEnergy() const
                                                   >> 193 {
                                                   >> 194   static G4ThreadLocal G4bool isFirstTime = true;
                                                   >> 195   if(isFirstTime)
                                                   >> 196   {
                                                   >> 197     isFirstTime = false;
                                                   >> 198 #ifdef G4VERBOSE
                                                   >> 199     G4Exception("G4Step::GetDeltaEnergy()", "Warning", JustWarning,
                                                   >> 200                 "This method is obsolete and will be removed soon");
                                                   >> 201 #endif
                                                   >> 202   }
                                                   >> 203 
                                                   >> 204   return fpPostStepPoint->GetKineticEnergy() -
                                                   >> 205          fpPreStepPoint->GetKineticEnergy();
                                                   >> 206 }
                                                   >> 207 
                                                   >> 208 // --------------------------------------------------------------------
163 const std::vector<const G4Track*>* G4Step::Get    209 const std::vector<const G4Track*>* G4Step::GetSecondaryInCurrentStep() const
164 {                                                 210 {
165   secondaryInCurrentStep->clear();                211   secondaryInCurrentStep->clear();
166   std::size_t nSecondary = fSecondary->size(); << 212   G4int nSecondary = fSecondary->size();
167   for(std::size_t i = nSecondaryByLastStep; i  << 213   for(G4int i = nSecondaryByLastStep; i < nSecondary; ++i)
168   {                                               214   {
169     secondaryInCurrentStep->push_back((*fSecon    215     secondaryInCurrentStep->push_back((*fSecondary)[i]);
170   }                                               216   }
171   return secondaryInCurrentStep;                  217   return secondaryInCurrentStep;
172 }                                                 218 }
173                                                   219