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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 9.4.p2)


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