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] [ 10.5 ] [ 10.5.p1 ] [ 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 /examples/extended/runAndEvent/RE01/src/RE01Trajectory.cc (Version 11.3.0) and /examples/extended/runAndEvent/RE01/src/RE01Trajectory.cc (Version 5.2.p2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 /// \file runAndEvent/RE01/src/RE01Trajectory.    
 27 /// \brief Implementation of the RE01Trajector    
 28 //                                                
 29 //                                                
 30 //                                                
 31                                                   
 32 #include "RE01Trajectory.hh"                      
 33                                                   
 34 #include "RE01TrackInformation.hh"                
 35                                                   
 36 #include "G4AttDef.hh"                            
 37 #include "G4AttDefStore.hh"                       
 38 #include "G4AttValue.hh"                          
 39 #include "G4Circle.hh"                            
 40 #include "G4Colour.hh"                            
 41 #include "G4DynamicParticle.hh"                   
 42 #include "G4ParticleTable.hh"                     
 43 #include "G4ParticleTypes.hh"                     
 44 #include "G4Polyline.hh"                          
 45 #include "G4PrimaryParticle.hh"                   
 46 #include "G4UIcommand.hh"                         
 47 #include "G4UnitsTable.hh"                        
 48 #include "G4VVisManager.hh"                       
 49 #include "G4VisAttributes.hh"                     
 50                                                   
 51 G4ThreadLocal G4Allocator<RE01Trajectory>* myT    
 52                                                   
 53 //....oooOO0OOooo........oooOO0OOooo........oo    
 54 RE01Trajectory::RE01Trajectory(const G4Track*     
 55   : G4VTrajectory(), fPositionRecord(0), fPart    
 56 {                                                 
 57   fParticleDefinition = aTrack->GetDefinition(    
 58   fParticleName = fParticleDefinition->GetPart    
 59   fPDGCharge = fParticleDefinition->GetPDGChar    
 60   fPDGEncoding = fParticleDefinition->GetPDGEn    
 61   if (fParticleName == "unknown") {               
 62     G4PrimaryParticle* pp = aTrack->GetDynamic    
 63     if (pp) {                                     
 64       if (pp->GetCharge() < DBL_MAX) fPDGCharg    
 65       fPDGEncoding = pp->GetPDGcode();            
 66       if (pp->GetG4code() != 0) {                 
 67         fParticleName += " : ";                   
 68         fParticleName += pp->GetG4code()->GetP    
 69       }                                           
 70     }                                             
 71   }                                               
 72   fTrackID = aTrack->GetTrackID();                
 73   RE01TrackInformation* trackInfo = (RE01Track    
 74   fTrackStatus = trackInfo->GetTrackingStatus(    
 75   if (fTrackStatus == 1) {                        
 76     fParentID = aTrack->GetParentID();            
 77   }                                               
 78   else if (fTrackStatus == 2) {                   
 79     fParentID = trackInfo->GetSourceTrackID();    
 80   }                                               
 81   else {                                          
 82     fParentID = -1;                               
 83   }                                               
 84   fPositionRecord = new RE01TrajectoryPointCon    
 85   fPositionRecord->push_back(new G4TrajectoryP    
 86   fMomentum = aTrack->GetMomentum();              
 87   fVertexPosition = aTrack->GetPosition();        
 88   fGlobalTime = aTrack->GetGlobalTime();          
 89 }                                                 
 90                                                   
 91 //....oooOO0OOooo........oooOO0OOooo........oo    
 92 RE01Trajectory::~RE01Trajectory()                 
 93 {                                                 
 94   size_t i;                                       
 95   for (i = 0; i < fPositionRecord->size(); i++    
 96     delete (*fPositionRecord)[i];                 
 97   }                                               
 98   fPositionRecord->clear();                       
 99                                                   
100   delete fPositionRecord;                         
101 }                                                 
102                                                   
103 //....oooOO0OOooo........oooOO0OOooo........oo    
104 void RE01Trajectory::ShowTrajectory(std::ostre    
105 {                                                 
106   os << G4endl << "TrackID =" << fTrackID << "    
107      << " : TrackStatus=" << fTrackStatus << G    
108   os << "Particle name : " << fParticleName <<    
109      << "  Charge : " << fPDGCharge << G4endl;    
110   os << "Original momentum : " << G4BestUnit(f    
111   os << "Vertex : " << G4BestUnit(fVertexPosit    
112      << "  Global time : " << G4BestUnit(fGlob    
113   os << "  Current trajectory has " << fPositi    
114                                                   
115   for (size_t i = 0; i < fPositionRecord->size    
116     G4TrajectoryPoint* aTrajectoryPoint = (G4T    
117     os << "Point[" << i << "]"                    
118        << " Position= " << aTrajectoryPoint->G    
119   }                                               
120 }                                                 
121                                                   
122 //....oooOO0OOooo........oooOO0OOooo........oo    
123 void RE01Trajectory::DrawTrajectory() const       
124 {                                                 
125   G4VVisManager* pVVisManager = G4VVisManager:    
126   G4ThreeVector pos;                              
127                                                   
128   G4Polyline pPolyline;                           
129   for (size_t i = 0; i < fPositionRecord->size    
130     G4TrajectoryPoint* aTrajectoryPoint = (G4T    
131     pos = aTrajectoryPoint->GetPosition();        
132     pPolyline.push_back(pos);                     
133   }                                               
134                                                   
135   G4Colour colour(0.2, 0.2, 0.2);                 
136   if (fParticleDefinition == G4Gamma::GammaDef    
137     colour = G4Colour(0., 0., 1.);                
138   else if (fParticleDefinition == G4Electron::    
139            || fParticleDefinition == G4Positro    
140     colour = G4Colour(1., 1., 0.);                
141   else if (fParticleDefinition == G4MuonMinus:    
142            || fParticleDefinition == G4MuonPlu    
143     colour = G4Colour(0., 1., 0.);                
144   else if (fParticleDefinition->GetParticleTyp    
145     if (fPDGCharge != 0.)                         
146       colour = G4Colour(1., 0., 0.);              
147     else                                          
148       colour = G4Colour(0.5, 0., 0.);             
149   }                                               
150   else if (fParticleDefinition->GetParticleTyp    
151     if (fPDGCharge != 0.)                         
152       colour = G4Colour(0., 1., 1.);              
153     else                                          
154       colour = G4Colour(0., 0.5, 0.5);            
155   }                                               
156                                                   
157   G4VisAttributes attribs(colour);                
158   pPolyline.SetVisAttributes(attribs);            
159   if (pVVisManager) pVVisManager->Draw(pPolyli    
160 }                                                 
161                                                   
162 //....oooOO0OOooo........oooOO0OOooo........oo    
163 const std::map<G4String, G4AttDef>* RE01Trajec    
164 {                                                 
165   G4bool isNew;                                   
166   std::map<G4String, G4AttDef>* store = G4AttD    
167   if (isNew) {                                    
168     G4String id("ID");                            
169     (*store)[id] = G4AttDef(id, "Track ID", "B    
170                                                   
171     G4String pid("PID");                          
172     (*store)[pid] = G4AttDef(pid, "Parent ID",    
173                                                   
174     G4String status("Status");                    
175     (*store)[status] = G4AttDef(status, "Track    
176                                                   
177     G4String pn("PN");                            
178     (*store)[pn] = G4AttDef(pn, "Particle Name    
179                                                   
180     G4String ch("Ch");                            
181     (*store)[ch] = G4AttDef(ch, "Charge", "Phy    
182                                                   
183     G4String pdg("PDG");                          
184     (*store)[pdg] = G4AttDef(pdg, "PDG Encodin    
185                                                   
186     G4String imom("IMom");                        
187     (*store)[imom] = G4AttDef(imom, "Momentum     
188                               "G4BestUnit", "G    
189                                                   
190     G4String imag("IMag");                        
191     (*store)[imag] = G4AttDef(imag, "Magnitude    
192                               "Physics", "G4Be    
193                                                   
194     G4String vtxPos("VtxPos");                    
195     (*store)[vtxPos] =                            
196       G4AttDef(vtxPos, "Vertex position", "Phy    
197                                                   
198     G4String ntp("NTP");                          
199     (*store)[ntp] = G4AttDef(ntp, "No. of poin    
200   }                                               
201   return store;                                   
202 }                                                 
203                                                   
204 //....oooOO0OOooo........oooOO0OOooo........oo    
205 std::vector<G4AttValue>* RE01Trajectory::Creat    
206 {                                                 
207   std::vector<G4AttValue>* values = new std::v    
208                                                   
209   values->push_back(G4AttValue("ID", G4UIcomma    
210                                                   
211   values->push_back(G4AttValue("PID", G4UIcomm    
212                                                   
213   values->push_back(G4AttValue("Status", G4UIc    
214                                                   
215   values->push_back(G4AttValue("PN", fParticle    
216                                                   
217   values->push_back(G4AttValue("Ch", G4UIcomma    
218                                                   
219   values->push_back(G4AttValue("PDG", G4UIcomm    
220                                                   
221   values->push_back(G4AttValue("IMom", G4BestU    
222                                                   
223   values->push_back(G4AttValue("IMag", G4BestU    
224                                                   
225   values->push_back(G4AttValue("VtxPos", G4Bes    
226                                                   
227   values->push_back(G4AttValue("NTP", G4UIcomm    
228                                                   
229   return values;                                  
230 }                                                 
231                                                   
232 //....oooOO0OOooo........oooOO0OOooo........oo    
233 void RE01Trajectory::AppendStep(const G4Step*     
234 {                                                 
235   fPositionRecord->push_back(new G4TrajectoryP    
236 }                                                 
237                                                   
238 //....oooOO0OOooo........oooOO0OOooo........oo    
239 void RE01Trajectory::MergeTrajectory(G4VTrajec    
240 {                                                 
241   if (!secondTrajectory) return;                  
242                                                   
243   RE01Trajectory* seco = (RE01Trajectory*)seco    
244   G4int ent = seco->GetPointEntries();            
245   //                                              
246   // initial point of the second trajectory sh    
247   for (int i = 1; i < ent; i++) {                 
248     fPositionRecord->push_back((*(seco->fPosit    
249   }                                               
250   delete (*seco->fPositionRecord)[0];             
251   seco->fPositionRecord->clear();                 
252 }                                                 
253