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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 /tracking/src/G4SmoothTrajectory.cc (Version 11.3.0) and /tracking/src/G4SmoothTrajectory.cc (Version 8.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // G4SmoothTrajectory class implementation     <<  23 //
                                                   >>  24 // $Id: G4SmoothTrajectory.cc,v 1.15 2005/05/03 17:48:51 allison Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-08-00 $
                                                   >>  26 //
                                                   >>  27 //
                                                   >>  28 // ---------------------------------------------------------------
                                                   >>  29 //
                                                   >>  30 // G4SmoothTrajectory.cc
 27 //                                                 31 //
 28 // Contact:                                        32 // Contact:
 29 //   Questions and comments to this code shoul     33 //   Questions and comments to this code should be sent to
 30 //     Katsuya Amako  (e-mail: Katsuya.Amako@k     34 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
 31 //     Makoto  Asai   (e-mail: asai@slac.stanf <<  35 //     Makoto  Asai   (e-mail: asai@kekvax.kek.jp)
 32 //     Takashi Sasaki (e-mail: Takashi.Sasaki@     36 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
 33 // ------------------------------------------- <<  37 //
                                                   >>  38 // ---------------------------------------------------------------
 34                                                    39 
 35 #include "G4SmoothTrajectory.hh"                   40 #include "G4SmoothTrajectory.hh"
 36 #include "G4ClonedSmoothTrajectory.hh"         <<  41 #include "G4SmoothTrajectoryPoint.hh"
 37                                                <<  42 #include "G4ParticleTable.hh"
 38 #include "G4AttDef.hh"                         << 
 39 #include "G4AttDefStore.hh"                        43 #include "G4AttDefStore.hh"
                                                   >>  44 #include "G4AttDef.hh"
 40 #include "G4AttValue.hh"                           45 #include "G4AttValue.hh"
 41 #include "G4ParticleTable.hh"                  << 
 42 #include "G4SmoothTrajectoryPoint.hh"          << 
 43 #include "G4UIcommand.hh"                          46 #include "G4UIcommand.hh"
 44 #include "G4UnitsTable.hh"                         47 #include "G4UnitsTable.hh"
 45 #include "G4AutoLock.hh"                       << 
 46                                                    48 
 47 namespace {                                    <<  49 //#define G4ATTDEBUG
 48  G4Mutex CloneSmoothTrajectoryMutex = G4MUTEX_ << 
 49 }                                              << 
 50                                                << 
 51 // #define G4ATTDEBUG                          << 
 52 #ifdef G4ATTDEBUG                                  50 #ifdef G4ATTDEBUG
 53 #  include "G4AttCheck.hh"                     <<  51 #include "G4AttCheck.hh"
 54 #endif                                             52 #endif
 55                                                    53 
 56 G4Allocator<G4SmoothTrajectory>*& aSmoothTraje <<  54 G4Allocator<G4SmoothTrajectory> aSmoothTrajectoryAllocator;
 57 {                                              <<  55 
 58   G4ThreadLocalStatic G4Allocator<G4SmoothTraj <<  56 G4SmoothTrajectory::G4SmoothTrajectory()
 59   return _instance;                            <<  57 :  positionRecord(0), fTrackID(0), fParentID(0),
 60 }                                              <<  58    PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
                                                   >>  59    initialMomentum( G4ThreeVector() )
                                                   >>  60 {;}
 61                                                    61 
 62 G4SmoothTrajectory::G4SmoothTrajectory(const G     62 G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
 63 {                                                  63 {
 64   G4ParticleDefinition* fpParticleDefinition = <<  64    G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
 65   ParticleName = fpParticleDefinition->GetPart <<  65    ParticleName = fpParticleDefinition->GetParticleName();
 66   PDGCharge = fpParticleDefinition->GetPDGChar <<  66    PDGCharge = fpParticleDefinition->GetPDGCharge();
 67   PDGEncoding = fpParticleDefinition->GetPDGEn <<  67    PDGEncoding = fpParticleDefinition->GetPDGEncoding();
 68   fTrackID = aTrack->GetTrackID();             <<  68    fTrackID = aTrack->GetTrackID();
 69   fParentID = aTrack->GetParentID();           <<  69    fParentID = aTrack->GetParentID();
 70   initialKineticEnergy = aTrack->GetKineticEne <<  70    initialMomentum = aTrack->GetMomentum();
 71   initialMomentum = aTrack->GetMomentum();     <<  71    positionRecord = new TrajectoryPointContainer();
 72   positionRecord = new G4TrajectoryPointContai <<  72    // Following is for the first trajectory point
 73                                                <<  73    positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
 74   // Following is for the first trajectory poi <<  74 
 75   //                                           <<  75    // The first point has no auxiliary points, so set the auxiliary
 76   positionRecord->push_back(new G4SmoothTrajec <<  76    // points vector to NULL (jacek 31/10/2002)
 77                                                <<  77    positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), NULL));
 78   // The first point has no auxiliary points,  << 
 79   // points vector to NULL                     << 
 80   //                                           << 
 81   positionRecord->push_back(new G4SmoothTrajec << 
 82 }                                                  78 }
 83                                                    79 
 84 G4SmoothTrajectory::G4SmoothTrajectory(G4Smoot <<  80 G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory()
 85 {                                                  81 {
 86   ParticleName = right.ParticleName;               82   ParticleName = right.ParticleName;
 87   PDGCharge = right.PDGCharge;                     83   PDGCharge = right.PDGCharge;
 88   PDGEncoding = right.PDGEncoding;                 84   PDGEncoding = right.PDGEncoding;
 89   fTrackID = right.fTrackID;                       85   fTrackID = right.fTrackID;
 90   fParentID = right.fParentID;                     86   fParentID = right.fParentID;
 91   initialKineticEnergy = right.initialKineticE << 
 92   initialMomentum = right.initialMomentum;         87   initialMomentum = right.initialMomentum;
 93   positionRecord = new G4TrajectoryPointContai <<  88   positionRecord = new TrajectoryPointContainer();
 94                                                    89 
 95   for (auto& i : *right.positionRecord) {      <<  90   for(size_t i=0;i<right.positionRecord->size();i++)
 96     auto rightPoint = (G4SmoothTrajectoryPoint <<  91   {
                                                   >>  92     G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
 97     positionRecord->push_back(new G4SmoothTraj     93     positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
 98   }                                                94   }
 99 }                                                  95 }
100                                                    96 
101 G4VTrajectory* G4SmoothTrajectory::CloneForMas << 
102 {                                              << 
103   G4AutoLock lock(&CloneSmoothTrajectoryMutex) << 
104   auto* cloned = new G4ClonedSmoothTrajectory( << 
105   return cloned;                               << 
106 }                                              << 
107                                                << 
108 G4SmoothTrajectory::~G4SmoothTrajectory()          97 G4SmoothTrajectory::~G4SmoothTrajectory()
109 {                                                  98 {
110   if (positionRecord != nullptr) {             <<  99   //  positionRecord->clearAndDestroy();
111     for (auto& i : *positionRecord) {          << 100   size_t i;
112       delete i;                                << 101   for(i=0;i<positionRecord->size();i++){
113     }                                          << 102     delete  (*positionRecord)[i];
114     positionRecord->clear();                   << 
115     delete positionRecord;                     << 
116   }                                               103   }
                                                   >> 104   positionRecord->clear();
                                                   >> 105 
                                                   >> 106   delete positionRecord;
117 }                                                 107 }
118                                                   108 
119 void G4SmoothTrajectory::ShowTrajectory(std::o    109 void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
120 {                                                 110 {
121   // Invoke the default implementation in G4VT    111   // Invoke the default implementation in G4VTrajectory...
122   //                                           << 
123   G4VTrajectory::ShowTrajectory(os);              112   G4VTrajectory::ShowTrajectory(os);
124                                                << 
125   // ... or override with your own code here.     113   // ... or override with your own code here.
126 }                                                 114 }
127                                                   115 
128 void G4SmoothTrajectory::DrawTrajectory() cons << 116 void G4SmoothTrajectory::DrawTrajectory(G4int i_mode) const
129 {                                                 117 {
130   // Invoke the default implementation in G4VT    118   // Invoke the default implementation in G4VTrajectory...
131   //                                           << 119   G4VTrajectory::DrawTrajectory(i_mode);
132   G4VTrajectory::DrawTrajectory();             << 
133                                                << 
134   // ... or override with your own code here.     120   // ... or override with your own code here.
135 }                                                 121 }
136                                                   122 
137 const std::map<G4String, G4AttDef>* G4SmoothTr << 123 const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
138 {                                                 124 {
139   G4bool isNew;                                   125   G4bool isNew;
140   std::map<G4String, G4AttDef>* store = G4AttD << 126   std::map<G4String,G4AttDef>* store
                                                   >> 127     = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
141   if (isNew) {                                    128   if (isNew) {
                                                   >> 129 
142     G4String ID("ID");                            130     G4String ID("ID");
143     (*store)[ID] = G4AttDef(ID, "Track ID", "P << 131     (*store)[ID] = G4AttDef(ID,"Track ID","Bookkeeping","","G4int");
144                                                   132 
145     G4String PID("PID");                          133     G4String PID("PID");
146     (*store)[PID] = G4AttDef(PID, "Parent ID", << 134     (*store)[PID] = G4AttDef(PID,"Parent ID","Bookkeeping","","G4int");
147                                                   135 
148     G4String PN("PN");                            136     G4String PN("PN");
149     (*store)[PN] = G4AttDef(PN, "Particle Name << 137     (*store)[PN] = G4AttDef(PN,"Particle Name","Bookkeeping","","G4String");
150                                                   138 
151     G4String Ch("Ch");                            139     G4String Ch("Ch");
152     (*store)[Ch] = G4AttDef(Ch, "Charge", "Phy << 140     (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
153                                                   141 
154     G4String PDG("PDG");                          142     G4String PDG("PDG");
155     (*store)[PDG] = G4AttDef(PDG, "PDG Encodin << 143     (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Bookkeeping","","G4int");
156                                                << 
157     G4String IKE("IKE");                       << 
158     (*store)[IKE] = G4AttDef(IKE, "Initial kin << 
159                                                   144 
160     G4String IMom("IMom");                        145     G4String IMom("IMom");
161     (*store)[IMom] = G4AttDef(IMom, "Initial m << 146     (*store)[IMom] = G4AttDef(IMom, "Momentum of track at start of trajectory",
                                                   >> 147             "Physics","G4BestUnit","G4ThreeVector");
162                                                   148 
163     G4String IMag("IMag");                        149     G4String IMag("IMag");
164     (*store)[IMag] =                           << 150     (*store)[IMag] = G4AttDef
165       G4AttDef(IMag, "Initial momentum magnitu << 151       (IMag, "Magnitude of momentum of track at start of trajectory",
                                                   >> 152        "Physics","G4BestUnit","G4double");
166                                                   153 
167     G4String NTP("NTP");                          154     G4String NTP("NTP");
168     (*store)[NTP] = G4AttDef(NTP, "No. of poin << 155     (*store)[NTP] = G4AttDef(NTP,"No. of points","Bookkeeping","","G4int");
                                                   >> 156 
169   }                                               157   }
170   return store;                                   158   return store;
171 }                                                 159 }
172                                                   160 
                                                   >> 161 
173 std::vector<G4AttValue>* G4SmoothTrajectory::C    162 std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
174 {                                                 163 {
175   auto values = new std::vector<G4AttValue>;   << 164   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
176                                                << 
177   values->push_back(G4AttValue("ID", G4UIcomma << 
178                                                   165 
179   values->push_back(G4AttValue("PID", G4UIcomm << 166   values->push_back
                                                   >> 167     (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
180                                                   168 
181   values->push_back(G4AttValue("PN", ParticleN << 169   values->push_back
                                                   >> 170     (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
182                                                   171 
183   values->push_back(G4AttValue("Ch", G4UIcomma << 172   values->push_back(G4AttValue("PN",ParticleName,""));
184                                                   173 
185   values->push_back(G4AttValue("PDG", G4UIcomm << 174   values->push_back
                                                   >> 175     (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
186                                                   176 
187   values->push_back(G4AttValue("IKE", G4BestUn << 177   values->push_back
                                                   >> 178     (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
188                                                   179 
189   values->push_back(G4AttValue("IMom", G4BestU << 180   values->push_back
                                                   >> 181     (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
190                                                   182 
191   values->push_back(G4AttValue("IMag", G4BestU << 183   values->push_back
                                                   >> 184     (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
192                                                   185 
193   values->push_back(G4AttValue("NTP", G4UIcomm << 186   values->push_back
                                                   >> 187     (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
194                                                   188 
195 #ifdef G4ATTDEBUG                                 189 #ifdef G4ATTDEBUG
196   G4cout << G4AttCheck(values, GetAttDefs());  << 190    G4cout << G4AttCheck(values,GetAttDefs());
197 #endif                                            191 #endif
198                                                   192 
199   return values;                                  193   return values;
200 }                                                 194 }
201                                                   195 
202 void G4SmoothTrajectory::AppendStep(const G4St    196 void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
203 {                                                 197 {
204   positionRecord->push_back(new G4SmoothTrajec << 198   // (jacek 30/10/2002)
205     aStep->GetPostStepPoint()->GetPosition(),  << 199   positionRecord->push_back(
                                                   >> 200       new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
                                                   >> 201           aStep->GetPointerToVectorOfAuxiliaryPoints()));
206 }                                                 202 }
207                                                << 203   
208 G4ParticleDefinition* G4SmoothTrajectory::GetP    204 G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
209 {                                                 205 {
210   return (G4ParticleTable::GetParticleTable()- << 206    return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
211 }                                                 207 }
212                                                   208 
213 void G4SmoothTrajectory::MergeTrajectory(G4VTr    209 void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
214 {                                                 210 {
215   if (secondTrajectory == nullptr) return;     << 211   if(!secondTrajectory) return;
216                                                   212 
217   auto seco = (G4SmoothTrajectory*)secondTraje << 213   G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
218   G4int ent = seco->GetPointEntries();            214   G4int ent = seco->GetPointEntries();
219                                                << 215   for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
220   // initial point of the second trajectory sh << 216   { 
221   //                                           << 
222   for (G4int i = 1; i < ent; ++i) {            << 
223     positionRecord->push_back((*(seco->positio    217     positionRecord->push_back((*(seco->positionRecord))[i]);
                                                   >> 218     //    positionRecord->push_back(seco->positionRecord->removeAt(1));
224   }                                               219   }
225   delete (*seco->positionRecord)[0];              220   delete (*seco->positionRecord)[0];
226   seco->positionRecord->clear();                  221   seco->positionRecord->clear();
227 }                                                 222 }
                                                   >> 223 
                                                   >> 224 
228                                                   225