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 ] [ 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/field/field04/src/F04Trajectory.cc (Version 11.3.0) and /examples/extended/field/field04/src/F04Trajectory.cc (Version 10.1)


  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 // $Id: F04Trajectory.cc 76690 2013-11-14 08:45:07Z gcosmo $
 26 //                                                 27 //
 27 /// \file field/field04/src/F04Trajectory.cc       28 /// \file field/field04/src/F04Trajectory.cc
 28 /// \brief Implementation of the F04Trajectory     29 /// \brief Implementation of the F04Trajectory class
 29 //                                                 30 //
 30                                                    31 
 31 #include "F04Trajectory.hh"                    << 
 32                                                << 
 33 #include "F04TrajectoryPoint.hh"               << 
 34                                                << 
 35 #include "G4AttDef.hh"                             32 #include "G4AttDef.hh"
 36 #include "G4AttDefStore.hh"                    << 
 37 #include "G4AttValue.hh"                           33 #include "G4AttValue.hh"
 38 #include "G4ParticleTable.hh"                  <<  34 #include "G4AttDefStore.hh"
                                                   >>  35 
 39 #include "G4UIcommand.hh"                          36 #include "G4UIcommand.hh"
 40 #include "G4UnitsTable.hh"                         37 #include "G4UnitsTable.hh"
 41                                                    38 
 42 // #define G4ATTDEBUG                          <<  39 #include "F04Trajectory.hh"
                                                   >>  40 #include "F04TrajectoryPoint.hh"
                                                   >>  41 #include "G4ParticleTable.hh"
                                                   >>  42 
                                                   >>  43 //#define G4ATTDEBUG
 43 #ifdef G4ATTDEBUG                                  44 #ifdef G4ATTDEBUG
 44 #  include "G4AttCheck.hh"                     <<  45 #include "G4AttCheck.hh"
 45 #endif                                             46 #endif
 46                                                    47 
 47 G4ThreadLocal G4Allocator<F04Trajectory>* F04T <<  48 G4ThreadLocal G4Allocator<F04Trajectory>* F04TrajectoryAllocator=0;
 48                                                    49 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 50                                                    51 
 51 F04Trajectory::F04Trajectory() {}              <<  52 F04Trajectory::F04Trajectory()
                                                   >>  53     : fpPointsContainer(0), fTrackID(0), fParentID(0),
                                                   >>  54       fPDGCharge(0.0), fPDGEncoding(0), fParticleName(""),
                                                   >>  55       fInitialMomentum(G4ThreeVector()) {;}
 52                                                    56 
 53 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 54                                                    58 
 55 F04Trajectory::F04Trajectory(const G4Track* aT     59 F04Trajectory::F04Trajectory(const G4Track* aTrack)
 56 {                                                  60 {
 57   G4ParticleDefinition* particleDefinition = a <<  61     G4ParticleDefinition * particleDefinition = aTrack->GetDefinition();
 58   fParticleName = particleDefinition->GetParti <<  62     fParticleName = particleDefinition->GetParticleName();
 59   fPDGCharge = particleDefinition->GetPDGCharg <<  63     fPDGCharge = particleDefinition->GetPDGCharge();
 60   fPDGEncoding = particleDefinition->GetPDGEnc <<  64     fPDGEncoding = particleDefinition->GetPDGEncoding();
 61   fTrackID = aTrack->GetTrackID();             <<  65     fTrackID = aTrack->GetTrackID();
 62   fParentID = aTrack->GetParentID();           <<  66     fParentID = aTrack->GetParentID();
 63   fInitialMomentum = aTrack->GetMomentum();    <<  67     fInitialMomentum = aTrack->GetMomentum();
 64   fpPointsContainer = new TrajectoryPointConta <<  68     fpPointsContainer = new TrajectoryPointContainer();
 65   // Following is for the first trajectory poi <<  69     // Following is for the first trajectory point
 66   fpPointsContainer->push_back(new F04Trajecto <<  70     fpPointsContainer->push_back(new F04TrajectoryPoint(aTrack));
 67 }                                                  71 }
 68                                                    72 
 69 //....oooOO0OOooo........oooOO0OOooo........oo     73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    74 
 71 F04Trajectory::F04Trajectory(F04Trajectory& ri <<  75 F04Trajectory::F04Trajectory(F04Trajectory & right) : G4VTrajectory()
 72 {                                              <<  76 {
 73   fParticleName = right.fParticleName;         <<  77     fParticleName = right.fParticleName;
 74   fPDGCharge = right.fPDGCharge;               <<  78     fPDGCharge = right.fPDGCharge;
 75   fPDGEncoding = right.fPDGEncoding;           <<  79     fPDGEncoding = right.fPDGEncoding;
 76   fTrackID = right.fTrackID;                   <<  80     fTrackID = right.fTrackID;
 77   fParentID = right.fParentID;                 <<  81     fParentID = right.fParentID;
 78   fInitialMomentum = right.fInitialMomentum;   <<  82     fInitialMomentum = right.fInitialMomentum;
 79   fpPointsContainer = new TrajectoryPointConta <<  83     fpPointsContainer = new TrajectoryPointContainer();
 80                                                <<  84 
 81   for (size_t i = 0; i < right.fpPointsContain <<  85     for(size_t i=0;i<right.fpPointsContainer->size();++i) {
 82     auto rightPoint = (F04TrajectoryPoint*)((* <<  86         F04TrajectoryPoint* rightPoint
 83     fpPointsContainer->push_back(new F04Trajec <<  87             = (F04TrajectoryPoint*)((*(right.fpPointsContainer))[i]);
 84   }                                            <<  88         fpPointsContainer->push_back(new F04TrajectoryPoint(*rightPoint));
                                                   >>  89     }
 85 }                                                  90 }
 86                                                    91 
 87 //....oooOO0OOooo........oooOO0OOooo........oo     92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 88                                                    93 
 89 F04Trajectory::~F04Trajectory()                    94 F04Trajectory::~F04Trajectory()
 90 {                                                  95 {
 91   for (size_t i = 0; i < fpPointsContainer->si <<  96     for(size_t i=0;i<fpPointsContainer->size();++i){
 92     delete (*fpPointsContainer)[i];            <<  97         delete  (*fpPointsContainer)[i];
 93   }                                            <<  98     }
 94   fpPointsContainer->clear();                  <<  99     fpPointsContainer->clear();
 95                                                   100 
 96   delete fpPointsContainer;                    << 101     delete fpPointsContainer;
 97 }                                                 102 }
 98                                                   103 
 99 //....oooOO0OOooo........oooOO0OOooo........oo    104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100                                                   105 
101 void F04Trajectory::ShowTrajectory(std::ostrea    106 void F04Trajectory::ShowTrajectory(std::ostream& os) const
102 {                                                 107 {
103   // Invoke the default implementation in G4VT << 108     // Invoke the default implementation in G4VTrajectory...
104   G4VTrajectory::ShowTrajectory(os);           << 109     G4VTrajectory::ShowTrajectory(os);
105   // ... or override with your own code here.  << 110     // ... or override with your own code here.
                                                   >> 111 }
                                                   >> 112 
                                                   >> 113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 114 
                                                   >> 115 void F04Trajectory::DrawTrajectory() const
                                                   >> 116 {
                                                   >> 117     // Invoke the default implementation in G4VTrajectory...
                                                   >> 118     G4VTrajectory::DrawTrajectory();
                                                   >> 119     // ... or override with your own code here.
106 }                                                 120 }
107                                                   121 
108 //....oooOO0OOooo........oooOO0OOooo........oo    122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109                                                   123 
110 void F04Trajectory::AppendStep(const G4Step* a    124 void F04Trajectory::AppendStep(const G4Step* aStep)
111 {                                                 125 {
112   fpPointsContainer->push_back(new F04Trajecto << 126     fpPointsContainer->push_back(new F04TrajectoryPoint(aStep));
113 }                                                 127 }
114                                                   128 
115 //....oooOO0OOooo........oooOO0OOooo........oo    129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116                                                   130 
117 G4ParticleDefinition* F04Trajectory::GetPartic    131 G4ParticleDefinition* F04Trajectory::GetParticleDefinition()
118 {                                                 132 {
119   return (G4ParticleTable::GetParticleTable()- << 133     return (G4ParticleTable::GetParticleTable()->FindParticle(fParticleName));
120 }                                                 134 }
121                                                   135 
122 //....oooOO0OOooo........oooOO0OOooo........oo    136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123                                                   137 
124 void F04Trajectory::MergeTrajectory(G4VTraject    138 void F04Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
125 {                                                 139 {
126   if (!secondTrajectory) return;               << 140     if(!secondTrajectory) return;
127                                                   141 
128   auto second = (F04Trajectory*)secondTrajecto << 142     F04Trajectory* second = (F04Trajectory*)secondTrajectory;
129   G4int ent = second->GetPointEntries();       << 143     G4int ent = second->GetPointEntries();
130   // initial point of the second trajectory sh << 144     // initial point of the second trajectory should not be merged
131   for (G4int i = 1; i < ent; ++i) {            << 145     for(G4int i=1; i<ent; ++i) {
132     fpPointsContainer->push_back((*(second->fp << 146         fpPointsContainer->push_back((*(second->fpPointsContainer))[i]);
133   }                                            << 147     }
134   delete (*second->fpPointsContainer)[0];      << 148     delete (*second->fpPointsContainer)[0];
135   second->fpPointsContainer->clear();          << 149     second->fpPointsContainer->clear();
136 }                                                 150 }
137                                                   151 
138 //....oooOO0OOooo........oooOO0OOooo........oo    152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139                                                   153 
140 const std::map<G4String, G4AttDef>* F04Traject << 154 const std::map<G4String,G4AttDef>* F04Trajectory::GetAttDefs() const
141 {                                                 155 {
142   G4bool isNew;                                << 156     G4bool isNew;
143   std::map<G4String, G4AttDef>* store = G4AttD << 157     std::map<G4String,G4AttDef>* store
                                                   >> 158         = G4AttDefStore::GetInstance("Trajectory",isNew);
                                                   >> 159 
                                                   >> 160     if (isNew) {
                                                   >> 161 
                                                   >> 162       G4String ID("ID");
                                                   >> 163       (*store)[ID] = G4AttDef(ID,"Track ID","Bookkeeping","","G4int");
144                                                   164 
145   if (isNew) {                                 << 165       G4String PID("PID");
146     G4String ID("ID");                         << 166       (*store)[PID] = G4AttDef(PID,"Parent ID","Bookkeeping","","G4int");
147     (*store)[ID] = G4AttDef(ID, "Track ID", "B << 
148                                                   167 
149     G4String PID("PID");                       << 168       G4String PN("PN");
150     (*store)[PID] = G4AttDef(PID, "Parent ID", << 169       (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
151                                                   170 
152     G4String PN("PN");                         << 171       G4String Ch("Ch");
153     (*store)[PN] = G4AttDef(PN, "Particle Name << 172       (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
154                                                   173 
155     G4String Ch("Ch");                         << 174       G4String PDG("PDG");
156     (*store)[Ch] = G4AttDef(Ch, "Charge", "Phy << 175       (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
157                                                   176 
158     G4String PDG("PDG");                       << 177       G4String IMom("IMom");
159     (*store)[PDG] = G4AttDef(PDG, "PDG Encodin << 178       (*store)[IMom] = G4AttDef(IMom,
                                                   >> 179                        "Momentum of track at start of trajectory",
                                                   >> 180                        "Physics","G4BestUnit","G4ThreeVector");
160                                                   181 
161     G4String IMom("IMom");                     << 182       G4String IMag("IMag");
162     (*store)[IMom] = G4AttDef(IMom, "Momentum  << 183       (*store)[IMag] = G4AttDef(IMag,
163                               "G4BestUnit", "G << 184                        "Magnitude of momentum of track at start of trajectory",
                                                   >> 185                        "Physics","G4BestUnit","G4double");
164                                                   186 
165     G4String IMag("IMag");                     << 187         G4String NTP("NTP");
166     (*store)[IMag] = G4AttDef(IMag, "Magnitude << 188         (*store)[NTP] = G4AttDef(NTP,"No. of points","Bookkeeping","","G4int");
167                               "Physics", "G4Be << 
168                                                   189 
169     G4String NTP("NTP");                       << 190     }
170     (*store)[NTP] = G4AttDef(NTP, "No. of poin << 191     return store;
171   }                                            << 
172   return store;                                << 
173 }                                                 192 }
174                                                   193 
175 //....oooOO0OOooo........oooOO0OOooo........oo    194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176                                                   195 
177 std::vector<G4AttValue>* F04Trajectory::Create    196 std::vector<G4AttValue>* F04Trajectory::CreateAttValues() const
178 {                                                 197 {
179   auto values = new std::vector<G4AttValue>;   << 198   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
180                                                   199 
181   values->push_back(G4AttValue("ID", G4UIcomma << 200   values->push_back
                                                   >> 201     (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
182                                                   202 
183   values->push_back(G4AttValue("PID", G4UIcomm << 203   values->push_back
                                                   >> 204     (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
184                                                   205 
185   values->push_back(G4AttValue("PN", fParticle << 206   values->push_back(G4AttValue("PN",fParticleName,""));
186                                                   207 
187   values->push_back(G4AttValue("Ch", G4UIcomma << 208   values->push_back
                                                   >> 209     (G4AttValue("Ch",G4UIcommand::ConvertToString(fPDGCharge),""));
188                                                   210 
189   values->push_back(G4AttValue("PDG", G4UIcomm << 211   values->push_back
                                                   >> 212     (G4AttValue("PDG",G4UIcommand::ConvertToString(fPDGEncoding),""));
190                                                   213 
191   values->push_back(G4AttValue("IMom", G4BestU << 214   values->push_back
                                                   >> 215     (G4AttValue("IMom",G4BestUnit(fInitialMomentum,"Energy"),""));
192                                                   216 
193   values->push_back(G4AttValue("IMag", G4BestU << 217   values->push_back
                                                   >> 218     (G4AttValue("IMag",G4BestUnit(fInitialMomentum.mag(),"Energy"),""));
194                                                   219 
195   values->push_back(G4AttValue("NTP", G4UIcomm << 220   values->push_back
                                                   >> 221     (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
196                                                   222 
197 #ifdef G4ATTDEBUG                                 223 #ifdef G4ATTDEBUG
198   G4cout << G4AttCheck(values, GetAttDefs());  << 224   G4cout << G4AttCheck(values,GetAttDefs());
199 #endif                                            225 #endif
200   return values;                               << 226     return values;
201 }                                                 227 }
202                                                   228