ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Step.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Step.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 //---------------------------------------------------------------
30 //
31 // G4Step.cc
32 //
33 // Description:
34 // This class represents the Step of a particle tracked.
35 // It includes information of
36 // 1) List of Step points which compose the Step,
37 // 2) static information of particle which generated the
38 // Step,
39 // 3) trackID and parent particle ID of the Step,
40 // 4) termination condition of the Step,
41 //
42 // Contact:
43 // Questions and comments to this code should be sent to
44 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
45 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
46 //
47 // ---------------------------------------------------------------
48 
49 #include "G4Step.hh"
50 
54  : fTotalEnergyDeposit(0.0),fNonIonizingEnergyDeposit(0.0),
55  fStepLength(0.), fpTrack(0),
56  fpSteppingControlFlag(NormalCondition),
57  fFirstStepInVolume(false),
58  fLastStepInVolume(false),
59  fSecondary(nullptr),
60  nSecondaryByLastStep(0), secondaryInCurrentStep(nullptr),
61  fpVectorOfAuxiliaryPointsPointer(nullptr)
62 {
65 
66  secondaryInCurrentStep = new std::vector<CT>;
67 }
68 
72 {
73  delete fpPreStepPoint;
74  fpPreStepPoint = nullptr;
75  delete fpPostStepPoint;
76  fpPostStepPoint = nullptr;
77 
78  secondaryInCurrentStep->clear();
80  secondaryInCurrentStep = nullptr;
81 
82  if (fSecondary != nullptr ) {
83  fSecondary->clear();
84  delete fSecondary;
85  }
86  fSecondary = nullptr;
87 }
88 
89 // Copy Counstructor and assignment operator
90 
94  : fTotalEnergyDeposit(right.fTotalEnergyDeposit),
95  fNonIonizingEnergyDeposit(right.fNonIonizingEnergyDeposit),
96  fStepLength(right.fStepLength),
97  fpTrack(right.fpTrack),
98  fpSteppingControlFlag(right.fpSteppingControlFlag),
99  fFirstStepInVolume(right.fFirstStepInVolume),
100  fLastStepInVolume(right.fLastStepInVolume),
101  nSecondaryByLastStep(right.nSecondaryByLastStep),
102  secondaryInCurrentStep(right.secondaryInCurrentStep),
103  fpVectorOfAuxiliaryPointsPointer(right.fpVectorOfAuxiliaryPointsPointer)
104 {
105  if (right.fpPreStepPoint != nullptr) {
106  fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
107  } else {
108  fpPreStepPoint = new G4StepPoint();
109  }
110  if (right.fpPostStepPoint != nullptr) {
112  } else {
114  }
115 
116  if (right.fSecondary != nullptr) {
117  fSecondary = new G4TrackVector(*(right.fSecondary));
118  } else {
119  fSecondary = new G4TrackVector();
120  }
121 
122  // secondaryInCurrentStep is cleared
123  secondaryInCurrentStep = new std::vector<CT>;
124 }
125 
128 
129 {
130  if (this != &right){
133  fStepLength = right.fStepLength;
134  fpTrack = right.fpTrack;
141 
142  if (fpPreStepPoint != nullptr ) delete fpPreStepPoint;
143  if (right.fpPreStepPoint != nullptr) {
144  fpPreStepPoint = new G4StepPoint(*(right.fpPreStepPoint));
145  } else {
146  fpPreStepPoint = new G4StepPoint();
147  }
148  if (fpPostStepPoint !=nullptr ) delete fpPostStepPoint;
149  if (right.fpPostStepPoint != nullptr) {
151  } else {
153  }
154 
155  if (fSecondary != nullptr ) {
156  fSecondary->clear();
157  delete fSecondary;
158  }
159  if (right.fSecondary != nullptr) {
160  fSecondary = new G4TrackVector(*(right.fSecondary));
161  } else {
162  fSecondary = new G4TrackVector();
163  }
164 
165  // secondaryInCurrentStep is not copied
166  if ( secondaryInCurrentStep != nullptr ) {
167  secondaryInCurrentStep->clear();
168  delete secondaryInCurrentStep;
169  }
170  secondaryInCurrentStep = new std::vector<CT>;
171  }
172  return *this;
173 }
174 
178 {
179  static G4ThreadLocal G4bool isFirstTime = true;
180  if (isFirstTime) {
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()
190 }
191 
195 {
196  static G4ThreadLocal G4bool isFirstTime = true;
197  if (isFirstTime) {
198  isFirstTime = false;
199 #ifdef G4VERBOSE
200  G4Exception( "G4Step::GetDeltaEnergy()","Warning", JustWarning,
201  "This method is obsolete and will be removed soon");
202 #endif
203  }
204 
207 }
208 
210 const std::vector<const G4Track*>* G4Step::GetSecondaryInCurrentStep() const
212 {
213  secondaryInCurrentStep->clear();
214  G4int nSecondary = fSecondary->size();
215  for (G4int i=nSecondaryByLastStep; i<nSecondary; i++) {
216  secondaryInCurrentStep->push_back((*fSecondary)[i]);
217  }
218  return secondaryInCurrentStep;
219 }
220