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.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/optical/wls/src/WLSTrajectory.cc (Version 11.3.0) and /examples/extended/optical/wls/src/WLSTrajectory.cc (Version 10.6)


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