ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4TrackList.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4TrackList.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 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
28 //
29 // History:
30 // -----------
31 // 10 Oct 2011 M.Karamitros created
32 //
33 // -------------------------------------------------------------------
34 
35 /*
36  * G4FastList.cc
37  *
38  * Created on: 18 nov. 2014
39  * Author: kara
40  */
41 
42 #include "G4TrackList.hh"
43 
45 template<>
47 {
48  G4IT* __IT = GetIT(__track);
49  G4FastListNode<G4Track>* __trackListNode = __IT->GetListNode();
50  // TODO : complete the exception
51  if (__trackListNode == 0)
52  {
53  G4ExceptionDescription exceptionDescription;
54  exceptionDescription << "This track " << GetIT(__track)->GetName();
55  exceptionDescription << " was not connected to any trackList ";
56  G4Exception("G4FastList<OBJECT>::Unflag", "G4TrackList003", FatalErrorInArgument,
57  exceptionDescription);
58  return 0;
59  }
60  return __trackListNode;
61 }
62 
64 template<>
66 {
68 
69  G4Step* __step = const_cast<G4Step*>(__track->GetStep());
70  if (__step)
71  {
72  if (__step->GetfSecondary())
73  __step->DeleteSecondaryVector();
74  delete __step;
75  }
76  delete __track;
77 }
78 
79 
80 template<>
82  {
83  if(fpObject)
84  {
86  }
87  }
88 
89 
91 template<>
93 {
94  return (GetIT(track)->GetListNode()->fListRef->fpList == this);
95 }
96 
98 template<>
100 {
101  G4IT* __iTrack = GetIT(__track);
102  G4FastListNode<G4Track>* __trackListNode = __iTrack->GetListNode();
103 
104  if (__trackListNode != 0)
105  {
106  // Suggestion move the node to this list
107  if (__trackListNode->fAttachedToList)
108  {
109  G4ExceptionDescription exceptionDescription;
110  exceptionDescription << "This track " << __iTrack->GetName();
111  exceptionDescription << " is already attached to a TrackList ";
112  G4Exception("G4FastList<OBJECT>::Flag", "G4TrackList001",
114  exceptionDescription);
115  }
116  } else
117  {
118  __trackListNode = new G4FastListNode<G4Track>(__track);
119  __iTrack->SetListNode(__trackListNode);
120  }
121 
122  __trackListNode->fAttachedToList = true;
123  __trackListNode->fListRef = fListRef;
124  return __trackListNode;
125 }
126 
128 template<>
130 {
131  if (__trackListNode->fListRef->fpList != this)
132  {
133  G4Track* track = __trackListNode->GetObject();
134  G4ExceptionDescription exceptionDescription;
135  exceptionDescription << "The track " << GetIT(track)->GetName()
136  << " with trackID " << track->GetTrackID()
137  << " is not correctly linked to a TrackList."
138  << G4endl
139  << "You are probably trying to withdraw this track "
140  << "from the list but it probably does not belong to "
141  << "this track list." << G4endl;
142  G4Exception("G4FastList<OBJECT>::CheckFlag", "G4FastList002",
143  FatalErrorInArgument, exceptionDescription);
144  }
145 }
146 
148 template<>
150 {
151  G4FastListNode<G4Track>* __node = Unflag(__track);
152  G4FastListNode<G4Track>* __next = __node->GetNext();
153  Unhook(__node);
154  __node->DetachYourSelf();
155  delete __node;
156  return __next;
157 }
158 
159 
161 template<>
163 {
164  G4IT* __IT = GetIT(__track);
165  G4FastListNode<G4Track>* __trackListNode = __IT->GetListNode();
166  // TODO : complete the exception
167  if (__trackListNode == 0)
168  {
169  return 0;
170  }
171  return __trackListNode;
172 }
173 
175 template<>
177 {
178  G4IT* __IT = GetIT(__track);
179  G4FastListNode<G4Track>* __trackListNode = __IT->GetListNode();
180 
181  if(__trackListNode == 0) return 0;
182  if(__trackListNode->fListRef == nullptr) return 0;
183 
184  return __trackListNode->fListRef->fpList;
185 }
186