| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4RichTrajectory.cc,v 1.6 2006/10/16 13:43:43 allison Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $
|
|---|
| 29 | //
|
|---|
| 30 | // ---------------------------------------------------------------
|
|---|
| 31 | //
|
|---|
| 32 | // G4RichTrajectory.cc
|
|---|
| 33 | //
|
|---|
| 34 | // Contact:
|
|---|
| 35 | // Questions and comments on G4Trajectory, on which this is based,
|
|---|
| 36 | // should be sent to
|
|---|
| 37 | // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
|---|
| 38 | // Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
|---|
| 39 | // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
|---|
| 40 | // and on the extended code to:
|
|---|
| 41 | // John Allison (e-mail: John.Allison@manchester.ac.uk)
|
|---|
| 42 | // Joseph Perl (e-mail: perl@slac.stanford.edu)
|
|---|
| 43 | //
|
|---|
| 44 | // ---------------------------------------------------------------
|
|---|
| 45 |
|
|---|
| 46 | #include "G4RichTrajectory.hh"
|
|---|
| 47 | #include "G4RichTrajectoryPoint.hh"
|
|---|
| 48 | #include "G4AttDefStore.hh"
|
|---|
| 49 | #include "G4AttDef.hh"
|
|---|
| 50 | #include "G4AttValue.hh"
|
|---|
| 51 | #include "G4VProcess.hh"
|
|---|
| 52 |
|
|---|
| 53 | //#define G4ATTDEBUG
|
|---|
| 54 | #ifdef G4ATTDEBUG
|
|---|
| 55 | #include "G4AttCheck.hh"
|
|---|
| 56 | #endif
|
|---|
| 57 |
|
|---|
| 58 | G4Allocator<G4RichTrajectory> aRichTrajectoryAllocator;
|
|---|
| 59 |
|
|---|
| 60 | G4RichTrajectory::G4RichTrajectory():
|
|---|
| 61 | fpRichPointsContainer(0),
|
|---|
| 62 | fpInitialVolume(0),
|
|---|
| 63 | fpInitialNextVolume(0),
|
|---|
| 64 | fpCreatorProcess(0)
|
|---|
| 65 | {}
|
|---|
| 66 |
|
|---|
| 67 | G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack):
|
|---|
| 68 | G4Trajectory(aTrack) // Note: this initialises the base class data
|
|---|
| 69 | // members and, unfortunately but never mind,
|
|---|
| 70 | // creates a G4TrajectoryPoint in
|
|---|
| 71 | // TrajectoryPointContainer that we cannot
|
|---|
| 72 | // access because it's private. We store the
|
|---|
| 73 | // same information (plus more) in a
|
|---|
| 74 | // G4RichTrajectoryPoint in the
|
|---|
| 75 | // RichTrajectoryPointsContainer
|
|---|
| 76 | {
|
|---|
| 77 | fpInitialVolume = aTrack->GetVolume();
|
|---|
| 78 | fpInitialNextVolume = aTrack->GetNextVolume();
|
|---|
| 79 | fpCreatorProcess = aTrack->GetCreatorProcess();
|
|---|
| 80 | fpRichPointsContainer = new RichTrajectoryPointsContainer;
|
|---|
| 81 | // Insert the first rich trajectory point (see note above)...
|
|---|
| 82 | fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right):
|
|---|
| 86 | G4Trajectory(right)
|
|---|
| 87 | {
|
|---|
| 88 | fpInitialVolume = right.fpInitialVolume;
|
|---|
| 89 | fpInitialNextVolume = right.fpInitialNextVolume;
|
|---|
| 90 | fpCreatorProcess = right.fpCreatorProcess;
|
|---|
| 91 | fpRichPointsContainer = new RichTrajectoryPointsContainer;
|
|---|
| 92 | for(size_t i=0;i<right.fpRichPointsContainer->size();i++)
|
|---|
| 93 | {
|
|---|
| 94 | G4RichTrajectoryPoint* rightPoint =
|
|---|
| 95 | (G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]);
|
|---|
| 96 | fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
|
|---|
| 97 | }
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | G4RichTrajectory::~G4RichTrajectory()
|
|---|
| 101 | {
|
|---|
| 102 | if (fpRichPointsContainer) {
|
|---|
| 103 | // fpRichPointsContainer->clearAndDestroy();
|
|---|
| 104 | size_t i;
|
|---|
| 105 | for(i=0;i<fpRichPointsContainer->size();i++){
|
|---|
| 106 | delete (*fpRichPointsContainer)[i];
|
|---|
| 107 | }
|
|---|
| 108 | fpRichPointsContainer->clear();
|
|---|
| 109 | delete fpRichPointsContainer;
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | void G4RichTrajectory::AppendStep(const G4Step* aStep)
|
|---|
| 114 | {
|
|---|
| 115 | fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep));
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
|---|
| 119 | {
|
|---|
| 120 | if(!secondTrajectory) return;
|
|---|
| 121 |
|
|---|
| 122 | G4Trajectory::MergeTrajectory(secondTrajectory);
|
|---|
| 123 |
|
|---|
| 124 | G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory;
|
|---|
| 125 | G4int ent = seco->GetPointEntries();
|
|---|
| 126 | for(G4int i=1;i<ent;i++) {
|
|---|
| 127 | // initial point of the second trajectory should not be merged
|
|---|
| 128 | fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]);
|
|---|
| 129 | // fpRichPointsContainer->push_back(seco->fpRichPointsContainer->removeAt(1));
|
|---|
| 130 | }
|
|---|
| 131 | delete (*seco->fpRichPointsContainer)[0];
|
|---|
| 132 | seco->fpRichPointsContainer->clear();
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
|
|---|
| 136 | {
|
|---|
| 137 | G4bool isNew;
|
|---|
| 138 | std::map<G4String,G4AttDef>* store
|
|---|
| 139 | = G4AttDefStore::GetInstance("G4RichTrajectory",isNew);
|
|---|
| 140 | if (isNew) {
|
|---|
| 141 |
|
|---|
| 142 | // Get att defs from base class...
|
|---|
| 143 | *store = *(G4Trajectory::GetAttDefs());
|
|---|
| 144 |
|
|---|
| 145 | G4String ID;
|
|---|
| 146 |
|
|---|
| 147 | ID = "IVN";
|
|---|
| 148 | (*store)[ID] = G4AttDef(ID,"Initial Volume Name",
|
|---|
| 149 | "Physics","","G4String");
|
|---|
| 150 |
|
|---|
| 151 | ID = "INVN";
|
|---|
| 152 | (*store)[ID] = G4AttDef(ID,"Initial Next Volume Name",
|
|---|
| 153 | "Physics","","G4String");
|
|---|
| 154 |
|
|---|
| 155 | ID = "CPN";
|
|---|
| 156 | (*store)[ID] = G4AttDef(ID,"Creator Process Name",
|
|---|
| 157 | "Physics","","G4String");
|
|---|
| 158 |
|
|---|
| 159 | ID = "CPTN";
|
|---|
| 160 | (*store)[ID] = G4AttDef(ID,"Creator Process Type Name",
|
|---|
| 161 | "Physics","","G4String");
|
|---|
| 162 |
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | return store;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
|
|---|
| 169 | {
|
|---|
| 170 | // Create base class att values...
|
|---|
| 171 | std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
|
|---|
| 172 |
|
|---|
| 173 | values->push_back(G4AttValue("IVN",fpInitialVolume->GetName(),""));
|
|---|
| 174 |
|
|---|
| 175 | values->push_back(G4AttValue("INVN",fpInitialNextVolume->GetName(),""));
|
|---|
| 176 |
|
|---|
| 177 | if (fpCreatorProcess) {
|
|---|
| 178 | values->push_back(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),""));
|
|---|
| 179 | G4ProcessType type = fpCreatorProcess->GetProcessType();
|
|---|
| 180 | values->push_back(G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),""));
|
|---|
| 181 | } else {
|
|---|
| 182 | values->push_back(G4AttValue("CPN","User Defined",""));
|
|---|
| 183 | values->push_back(G4AttValue("CPTN","User",""));
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | #ifdef G4ATTDEBUG
|
|---|
| 187 | G4cout << G4AttCheck(values,GetAttDefs());
|
|---|
| 188 | #endif
|
|---|
| 189 |
|
|---|
| 190 | return values;
|
|---|
| 191 | }
|
|---|