00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "G4RichTrajectory.hh"
00046 #include "G4RichTrajectoryPoint.hh"
00047 #include "G4AttDefStore.hh"
00048 #include "G4AttDef.hh"
00049 #include "G4AttValue.hh"
00050 #include "G4UnitsTable.hh"
00051 #include "G4VProcess.hh"
00052
00053
00054 #ifdef G4ATTDEBUG
00055 #include "G4AttCheck.hh"
00056 #endif
00057
00058 #include <sstream>
00059
00060 G4Allocator<G4RichTrajectory> aRichTrajectoryAllocator;
00061
00062 G4RichTrajectory::G4RichTrajectory():
00063 fpRichPointsContainer(0),
00064 fpCreatorProcess(0),
00065 fpEndingProcess(0),
00066 fFinalKineticEnergy(0.)
00067 {}
00068
00069 G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack):
00070 G4Trajectory(aTrack)
00071
00072
00073
00074
00075
00076
00077
00078 {
00079 fpInitialVolume = aTrack->GetTouchableHandle();
00080 fpInitialNextVolume = aTrack->GetNextTouchableHandle();
00081 fpCreatorProcess = aTrack->GetCreatorProcess();
00082
00083
00084 fpFinalVolume = aTrack->GetTouchableHandle();
00085 fpFinalNextVolume = aTrack->GetNextTouchableHandle();
00086 fpEndingProcess = aTrack->GetCreatorProcess();
00087 fFinalKineticEnergy = aTrack->GetKineticEnergy();
00088
00089 fpRichPointsContainer = new RichTrajectoryPointsContainer;
00090 fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
00091 }
00092
00093 G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right):
00094 G4Trajectory(right)
00095 {
00096 fpInitialVolume = right.fpInitialVolume;
00097 fpInitialNextVolume = right.fpInitialNextVolume;
00098 fpCreatorProcess = right.fpCreatorProcess;
00099 fpFinalVolume = right.fpFinalVolume;
00100 fpFinalNextVolume = right.fpFinalNextVolume;
00101 fpEndingProcess = right.fpEndingProcess;
00102 fFinalKineticEnergy = right.fFinalKineticEnergy;
00103 fpRichPointsContainer = new RichTrajectoryPointsContainer;
00104 for(size_t i=0;i<right.fpRichPointsContainer->size();i++)
00105 {
00106 G4RichTrajectoryPoint* rightPoint =
00107 (G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]);
00108 fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
00109 }
00110 }
00111
00112 G4RichTrajectory::~G4RichTrajectory()
00113 {
00114 if (fpRichPointsContainer) {
00115
00116 size_t i;
00117 for(i=0;i<fpRichPointsContainer->size();i++){
00118 delete (*fpRichPointsContainer)[i];
00119 }
00120 fpRichPointsContainer->clear();
00121 delete fpRichPointsContainer;
00122 }
00123 }
00124
00125 void G4RichTrajectory::AppendStep(const G4Step* aStep)
00126 {
00127 fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep));
00128
00129
00130 const G4Track* track = aStep->GetTrack();
00131 const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
00132 if (track->GetCurrentStepNumber() > 0) {
00133 fpFinalVolume = track->GetTouchableHandle();
00134 fpFinalNextVolume = track->GetNextTouchableHandle();
00135 fpEndingProcess = postStepPoint->GetProcessDefinedStep();
00136 fFinalKineticEnergy =
00137 aStep->GetPreStepPoint()->GetKineticEnergy() -
00138 aStep->GetTotalEnergyDeposit();
00139 }
00140 }
00141
00142 void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00143 {
00144 if(!secondTrajectory) return;
00145
00146 G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory;
00147 G4int ent = seco->GetPointEntries();
00148 for(G4int i=1;i<ent;i++) {
00149
00150 fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]);
00151
00152 }
00153 delete (*seco->fpRichPointsContainer)[0];
00154 seco->fpRichPointsContainer->clear();
00155 }
00156
00157 const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
00158 {
00159 G4bool isNew;
00160 std::map<G4String,G4AttDef>* store
00161 = G4AttDefStore::GetInstance("G4RichTrajectory",isNew);
00162 if (isNew) {
00163
00164
00165 *store = *(G4Trajectory::GetAttDefs());
00166
00167 G4String ID;
00168
00169 ID = "IVPath";
00170 (*store)[ID] = G4AttDef(ID,"Initial Volume Path",
00171 "Physics","","G4String");
00172
00173 ID = "INVPath";
00174 (*store)[ID] = G4AttDef(ID,"Initial Next Volume Path",
00175 "Physics","","G4String");
00176
00177 ID = "CPN";
00178 (*store)[ID] = G4AttDef(ID,"Creator Process Name",
00179 "Physics","","G4String");
00180
00181 ID = "CPTN";
00182 (*store)[ID] = G4AttDef(ID,"Creator Process Type Name",
00183 "Physics","","G4String");
00184
00185 ID = "FVPath";
00186 (*store)[ID] = G4AttDef(ID,"Final Volume Path",
00187 "Physics","","G4String");
00188
00189 ID = "FNVPath";
00190 (*store)[ID] = G4AttDef(ID,"Final Next Volume Path",
00191 "Physics","","G4String");
00192
00193 ID = "EPN";
00194 (*store)[ID] = G4AttDef(ID,"Ending Process Name",
00195 "Physics","","G4String");
00196
00197 ID = "EPTN";
00198 (*store)[ID] = G4AttDef(ID,"Ending Process Type Name",
00199 "Physics","","G4String");
00200
00201 ID = "FKE";
00202 (*store)[ID] = G4AttDef(ID,"Final kinetic energy",
00203 "Physics","G4BestUnit","G4double");
00204
00205 }
00206
00207 return store;
00208 }
00209
00210 static G4String Path(const G4TouchableHandle& th)
00211 {
00212 std::ostringstream oss;
00213 G4int depth = th->GetHistoryDepth();
00214 for (G4int i = depth; i >= 0; --i) {
00215 oss << th->GetVolume(i)->GetName()
00216 << ':' << th->GetCopyNumber(i);
00217 if (i != 0) oss << '/';
00218 }
00219 return oss.str();
00220 }
00221
00222 std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
00223 {
00224
00225 std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
00226
00227 if (fpInitialVolume && fpInitialVolume->GetVolume()) {
00228 values->push_back(G4AttValue("IVPath",Path(fpInitialVolume),""));
00229 } else {
00230 values->push_back(G4AttValue("IVPath","None",""));
00231 }
00232
00233 if (fpInitialNextVolume && fpInitialNextVolume->GetVolume()) {
00234 values->push_back(G4AttValue("INVPath",Path(fpInitialNextVolume),""));
00235 } else {
00236 values->push_back(G4AttValue("INVPath","None",""));
00237 }
00238
00239 if (fpCreatorProcess) {
00240 values->push_back(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),""));
00241 G4ProcessType type = fpCreatorProcess->GetProcessType();
00242 values->push_back(G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),""));
00243 } else {
00244 values->push_back(G4AttValue("CPN","None",""));
00245 values->push_back(G4AttValue("CPTN","None",""));
00246 }
00247
00248 if (fpFinalVolume && fpFinalVolume->GetVolume()) {
00249 values->push_back(G4AttValue("FVPath",Path(fpFinalVolume),""));
00250 } else {
00251 values->push_back(G4AttValue("FVPath","None",""));
00252 }
00253
00254 if (fpFinalNextVolume && fpFinalNextVolume->GetVolume()) {
00255 values->push_back(G4AttValue("FNVPath",Path(fpFinalNextVolume),""));
00256 } else {
00257 values->push_back(G4AttValue("FNVPath","None",""));
00258 }
00259
00260 if (fpEndingProcess) {
00261 values->push_back(G4AttValue("EPN",fpEndingProcess->GetProcessName(),""));
00262 G4ProcessType type = fpEndingProcess->GetProcessType();
00263 values->push_back(G4AttValue("EPTN",G4VProcess::GetProcessTypeName(type),""));
00264 } else {
00265 values->push_back(G4AttValue("EPN","None",""));
00266 values->push_back(G4AttValue("EPTN","None",""));
00267 }
00268
00269 values->push_back
00270 (G4AttValue("FKE",G4BestUnit(fFinalKineticEnergy,"Energy"),""));
00271
00272 #ifdef G4ATTDEBUG
00273 G4cout << G4AttCheck(values,GetAttDefs());
00274 #endif
00275
00276 return values;
00277 }