QwGeant4
QweakSimTrackInformation.cc
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // ---------------------------
4 // | Doxygen File Information |
5 // ---------------------------
6 //
7 /**
8 
9  \file QweakSimTrackInformation.cc
10 
11  $Revision: 1.2 $
12  $Date: 2005/12/27 19:15:27 $
13 
14  \author Klaus Hans Grimm
15 
16 */
17 
18 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
19 
21 
22 // geant4 includes
23 #include "G4Track.hh"
24 #include "G4ParticleDefinition.hh"
25 
26 // user includes
27 #include "QweakSimTrackHistory.hh"
28 
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 // Primary Track info
31 // based on http://geant4.slac.stanford.edu/Tips/index.html
32 
33 G4Allocator<QweakSimTrackInformation> aTrackInformationAllocator;
34 
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
37 {
38  //G4cout << G4endl << "###### Calling QweakSimTrackInformation::QweakSimTrackInformation() " << G4endl << G4endl;
39 
40  Initialize();
41 
42  //G4cout << G4endl << "###### Leaving QweakSimTrackInformation::QweakSimTrackInformation() " << G4endl << G4endl;
43 }
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 {
48  //G4cout << G4endl << "###### Calling/Leaving QweakSimTrackInformation::~QweakSimTrackInformation() " << G4endl << G4endl;
49 }
50 
52 {
53 
54  primaryTrackID = aTrack->GetTrackID();
55  particleDefinition = aTrack->GetDefinition();
56 
57  G4double tmpE = -1.0*MeV;
58  CerenkovHitEnergy.push_back(tmpE);
59  ParticleHistory.push_back(aTrack->GetDefinition());
60  ParentEnergy.push_back(aTrack->GetTotalEnergy());
61  ParticleCreatorProcess.push_back("Primary");
62  OriginVertex.push_back(aTrack->GetPosition());
63 
64  primaryPosition = aTrack->GetPosition();
65  primaryMomentum = aTrack->GetMomentum();
66  primaryEnergy = aTrack->GetTotalEnergy();
67  primaryKineticEnergy = aTrack->GetKineticEnergy();
68  primaryTime = aTrack->GetGlobalTime();
69 
70  trackingStatus = 0;
72 
73  sourceTrackID = -1;
74  sourceDefinition = 0;
75  sourcePosition = G4ThreeVector(0.,0.,0.);
76  sourceMomentum = G4ThreeVector(0.,0.,0.);
77  sourceEnergy = 0.;
78  sourceTime = 0.;
79 
82  cerenkovImpactPosition = G4ThreeVector(0.,0.,0.);
83  cerenkovImpactMomentum = G4ThreeVector(0.,0.,0.);
85  cerenkovImpactTime = 0.;
86 }
87 
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 {
92  //G4cout << G4endl << "###### Calling QweakSimTrackInformation::QweakSimTrackInformation(const QweakSimTrackInformation* aTrackInfo) " << G4endl << G4endl;
93 
94 
95  // Return TrackInfo which can not derived from G4Track
96  // Must be filled/provided manually
97 // primaryQ2 = aTrackInfo->primaryQ2;
98 // crossSection = aTrackInfo->crossSection;
99 // crossSectionWeight = aTrackInfo->crossSectionWeight;
100 // primaryEventNumber = aTrackInfo->primaryEventNumber;
101  //----------
102  primaryTrackID = aTrackInfo->primaryTrackID;
104  primaryPosition = aTrackInfo->primaryPosition;
105  primaryMomentum = aTrackInfo->primaryMomentum;
106  primaryEnergy = aTrackInfo->primaryEnergy;
107  primaryTime = aTrackInfo->primaryTime;
108  //---------
109  sourceTrackID = aTrackInfo->sourceTrackID;
110  sourceDefinition = aTrackInfo->sourceDefinition;
111  sourcePosition = aTrackInfo->sourcePosition;
112  sourceMomentum = aTrackInfo->sourceMomentum;
113  sourceEnergy = aTrackInfo->sourceEnergy;
114  sourceTime = aTrackInfo->sourceTime;
117  //---------
126  //---------
127  trackingStatus = aTrackInfo->trackingStatus;
129  //---------
130 
131  ParticleHistory.resize(aTrackInfo->ParticleHistory.size());
132  ParentEnergy.resize(aTrackInfo->ParticleHistory.size());
133  CerenkovHitEnergy.resize(aTrackInfo->ParticleHistory.size());
134  ParticleCreatorProcess.resize(aTrackInfo->ParticleHistory.size());
135  OriginVertex.resize(aTrackInfo->ParticleHistory.size());
136  for(size_t i = 0; i < aTrackInfo->ParticleHistory.size(); i++)
137  {
138  ParticleHistory[i] = aTrackInfo->ParticleHistory[i];
139  ParentEnergy[i] = aTrackInfo->ParentEnergy[i];
140  CerenkovHitEnergy[i] = aTrackInfo->CerenkovHitEnergy[i];
142  OriginVertex[i] = aTrackInfo->OriginVertex[i];
143  }
144 
145 }
146 
147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
149 {
150  sourceTrackID = aTrack->GetTrackID();
151  sourceDefinition = aTrack->GetDefinition();
152  sourcePosition = aTrack->GetPosition();
153  sourceMomentum = aTrack->GetMomentum();
154  sourceEnergy = aTrack->GetTotalEnergy();
155  sourceTime = aTrack->GetGlobalTime();
156  sourceOriginPosition = aTrack->GetVertexPosition();
157  sourceOriginEnergy = aTrack->GetVertexKineticEnergy();
158 
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163 {
164  cerenkovImpactTrackID = aTrack->GetTrackID();
165  cerenkovImpactDefinition = aTrack->GetDefinition();
166  cerenkovImpactPosition = aTrack->GetPosition();
167  cerenkovImpactMomentum = aTrack->GetMomentum();
168  cerenkovImpactEnergy = aTrack->GetTotalEnergy();
169  cerenkovImpactTime = aTrack->GetGlobalTime();
170  cerenkovImpactOriginPosition = aTrack->GetVertexPosition();
171  cerenkovImpactOriginEnergy = aTrack->GetVertexKineticEnergy();
172 }
173 
174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 {
177 
178  QweakSimTrackHistory* theTrackHistory = new QweakSimTrackHistory();
179 
180  theTrackHistory->AddTrackInfo(aTrack);
181 
182  theCerenkovTrackHistory.push_back(theTrackHistory);
183 }
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187 {
188 // G4cout << "###### Calling QweakSimTrackInformation::PrintPrimaryTrackInfo() " << G4endl;
189 
190  G4cout << "########################################################################" << G4endl;
191  G4cout << "Primary Track ID = " << primaryTrackID << G4endl;
192  G4cout << "Primary Particle Name = " << particleDefinition->GetParticleName() << G4endl;
193  G4cout << "Primary Particle Energy [GeV] = " << primaryEnergy/GeV << G4endl;
194  G4cout << "Primary Start Position [mm] = " << primaryPosition << G4endl;
195  G4cout << "------------------------------------------------------------------------" << G4endl;
196 // G4cout << "Primary track with Q2 = " << primaryQ2 << G4endl;
197 // G4cout << "Primary track with CS = " << crossSection << G4endl;
198 // G4cout << "Primary track with CSW = " << crossSectionWeight << G4endl;
199 // G4cout << "Primary track event number = " << primaryEventNumber << G4endl;
200  G4cout << "########################################################################" << G4endl;
201 
202 // G4cout << "###### Leaving QweakSimTrackInformation::PrintPrimaryTrackInfo() " << G4endl;
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207 {
208 // G4cout << "###### Calling QweakSimTrackInformation::PrintSourceTrackInfo() " << G4endl;
209 
210  G4cout << "########################################################################" << G4endl;
211  G4cout << "Source Track ID = " << sourceTrackID << G4endl;
212  G4cout << "Source Particle Name = " << sourceDefinition->GetParticleName() << G4endl;
213  G4cout << "Source Particle Energy [GeV] = " << sourceEnergy/GeV << G4endl;
214  G4cout << "Source Particle Position [mm] = " << sourcePosition << G4endl;
215  G4cout << "Source Origin Position [mm] = " << sourceOriginPosition << G4endl;
216  G4cout << "Source Origin Energy [GeV] = " << sourceOriginEnergy << G4endl;
217  G4cout << "########################################################################" << G4endl;
218 
219 // G4cout << "###### Leaving QweakSimTrackInformation::PrintSourceTrackInfo() " << G4endl;
220 }
221 
222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 {
225 // G4cout << "###### Calling QweakSimTrackInformation::PrintCerenkovImpactTrackInfo() " << G4endl;
226 
227  G4cout << "########################################################################" << G4endl;
228  G4cout << "Cerenkov Impact Track ID = " << cerenkovImpactTrackID << G4endl;
229  G4cout << "Cerenkov Impact Particle Name = " << cerenkovImpactDefinition->GetParticleName() << G4endl;
230  G4cout << "Cerenkov Impact Particle Energy [GeV] = " << cerenkovImpactEnergy/GeV << G4endl;
231  G4cout << "Cerenkov Impact Particle Position [mm] = " << cerenkovImpactPosition << G4endl;
232  G4cout << "Cerenkov Impact Origin Position [mm] = " << cerenkovImpactOriginPosition << G4endl;
233  G4cout << "Cerenkov Impact Origin Energy [GeV] = " << cerenkovImpactOriginEnergy << G4endl;
234  G4cout << "########################################################################" << G4endl;
235 
236 // G4cout << "###### Leaving QweakSimTrackInformation::PrintCerenkovImpactTrackInfo() " << G4endl;
237 }
238 
239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
241 {
242  //G4cout << G4endl << "###### Calling QweakSimTrackInformation::Initialize() " << G4endl << G4endl;
243 
244  primaryTrackID = 0;
245  particleDefinition = 0;
246  primaryPosition = G4ThreeVector(0.0,0.0,0.0);
247  primaryMomentum = G4ThreeVector(0.0,0.0,0.0);
248  primaryEnergy = 0.0;
249  primaryTime = 0.0;
250 
251  ParticleHistory.resize(0);
252  ParentEnergy.resize(0);
253  CerenkovHitEnergy.resize(0);
254  ParticleCreatorProcess.resize(0);
255  OriginVertex.resize(0);
256 
257 // primaryQ2 = 0.0;
258 // crossSection = 0.0;
259 // crossSectionWeight = 0.0;
260 // primaryEventNumber = 0;
261 
262  trackingStatus = 0;
264 
265  sourceTrackID = -1;
266  sourceTrackID = -1;
267  sourceDefinition = 0;
268  sourcePosition = G4ThreeVector(0.,0.,0.);
269  sourceMomentum = G4ThreeVector(0.,0.,0.);
270  sourceEnergy = 0.;
271  sourceTime = 0.;
272  sourceOriginPosition = G4ThreeVector(0.,0.,0.);
273  sourceOriginEnergy = 0.;
274 
278  cerenkovImpactPosition = G4ThreeVector(0.,0.,0.);
279  cerenkovImpactMomentum = G4ThreeVector(0.,0.,0.);
281  cerenkovImpactTime = 0.;
282  cerenkovImpactOriginPosition = G4ThreeVector(0.,0.,0.);
284 
285 
286 
287  theCerenkovTrackHistory.clear();
288  theCerenkovTrackHistory.resize(0);
289 
290  //G4cout << G4endl << "###### Leaving QweakSimTrackInformation::Initialize() " << G4endl << G4endl;
291 
292 }
293 
295 {
296  if(ind < 0 || ind >= GetParticleHistoryLength()) {
297  CerenkovHitEnergy.push_back(eng);
298  return;
299  }
300 
301  CerenkovHitEnergy[ind] = eng;
302 }
303 
305 {
306  if (CerenkovHitEnergy.size() == 0) return -1.0;
307  if (ind < 0 || ind >= (G4int) CerenkovHitEnergy.size()) return CerenkovHitEnergy[0];
308  return CerenkovHitEnergy[ind];
309 }
310 
312 {
313  if (ParticleHistory.size() == 0) return NULL;
314  if (ind > (G4int) ParticleHistory.size() - 1) return ParticleHistory[0];
315  return ParticleHistory[ind];
316 }
317 
319 {
320  if (ParentEnergy.size() == 0) return -1.0;
321  if (ind > (G4int) ParentEnergy.size() - 1) return ParentEnergy[0];
322  return ParentEnergy[ind];
323 }
324 
326 {
327  if (ParticleCreatorProcess.size() == 0) return "None";
328  if (ind > (G4int) ParticleCreatorProcess.size() - 1) return "None";
329  return ParticleCreatorProcess[ind];
330 }
331 
333 {
334  G4ThreeVector vec(-10000*cm,-10000*cm,-10000*cm);
335 
336  if (OriginVertex.size() == 0) return vec;
337  if (ind > (G4int) OriginVertex.size() - 1) return vec;
338  return OriginVertex[ind];
339 }
340 
341 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< G4ThreeVector > OriginVertex
G4double GetParentEnergyAtIndex(G4int ind)
G4ParticleDefinition * cerenkovImpactDefinition
G4ParticleDefinition * GetParticleDefinitionAtIndex(G4int ind)
G4ParticleDefinition * particleDefinition
void StoreCerenkovHitEnergy(G4int ind, G4double eng)
std::vector< G4ParticleDefinition * > ParticleHistory
G4ParticleDefinition * sourceDefinition
void AddTrackInfo(const G4Track *aTrack)
std::vector< G4String > ParticleCreatorProcess
void AddTrackInfoToCerenkovTrackHistory(const G4Track *aTrack)
void SetSourceTrackInformation(const G4Track *aTrack)
std::vector< G4double > CerenkovHitEnergy
std::vector< QweakSimTrackHistory * > theCerenkovTrackHistory
G4double GetCerenkovHitEnergyAtIndex(G4int ind)
Class with additional track information like Q2.
void SetImpactTrackInformationForCerenkov(const G4Track *aTrack)
G4ThreeVector GetOriginVertex(G4int ind)
G4Allocator< QweakSimTrackInformation > aTrackInformationAllocator
std::vector< G4double > ParentEnergy
G4String GetCreatorProcessAtIndex(G4int ind)