| 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: G4SmoothTrajectory.cc,v 1.20 2010/05/29 21:31:03 allison Exp $
|
|---|
| 28 | // GEANT4 tag $Name: tracking-V09-03-03 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // ---------------------------------------------------------------
|
|---|
| 32 | //
|
|---|
| 33 | // G4SmoothTrajectory.cc
|
|---|
| 34 | //
|
|---|
| 35 | // Contact:
|
|---|
| 36 | // Questions and comments to this code 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 | //
|
|---|
| 41 | // ---------------------------------------------------------------
|
|---|
| 42 |
|
|---|
| 43 | #include "G4SmoothTrajectory.hh"
|
|---|
| 44 | #include "G4SmoothTrajectoryPoint.hh"
|
|---|
| 45 | #include "G4ParticleTable.hh"
|
|---|
| 46 | #include "G4AttDefStore.hh"
|
|---|
| 47 | #include "G4AttDef.hh"
|
|---|
| 48 | #include "G4AttValue.hh"
|
|---|
| 49 | #include "G4UIcommand.hh"
|
|---|
| 50 | #include "G4UnitsTable.hh"
|
|---|
| 51 |
|
|---|
| 52 | //#define G4ATTDEBUG
|
|---|
| 53 | #ifdef G4ATTDEBUG
|
|---|
| 54 | #include "G4AttCheck.hh"
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 | G4Allocator<G4SmoothTrajectory> aSmoothTrajectoryAllocator;
|
|---|
| 58 |
|
|---|
| 59 | G4SmoothTrajectory::G4SmoothTrajectory()
|
|---|
| 60 | : positionRecord(0), fTrackID(0), fParentID(0),
|
|---|
| 61 | PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
|
|---|
| 62 | initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
|
|---|
| 63 | {;}
|
|---|
| 64 |
|
|---|
| 65 | G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
|
|---|
| 66 | {
|
|---|
| 67 | G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
|
|---|
| 68 | ParticleName = fpParticleDefinition->GetParticleName();
|
|---|
| 69 | PDGCharge = fpParticleDefinition->GetPDGCharge();
|
|---|
| 70 | PDGEncoding = fpParticleDefinition->GetPDGEncoding();
|
|---|
| 71 | fTrackID = aTrack->GetTrackID();
|
|---|
| 72 | fParentID = aTrack->GetParentID();
|
|---|
| 73 | initialKineticEnergy = aTrack->GetKineticEnergy();
|
|---|
| 74 | initialMomentum = aTrack->GetMomentum();
|
|---|
| 75 | positionRecord = new TrajectoryPointContainer();
|
|---|
| 76 | // Following is for the first trajectory point
|
|---|
| 77 | positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
|
|---|
| 78 |
|
|---|
| 79 | // The first point has no auxiliary points, so set the auxiliary
|
|---|
| 80 | // points vector to NULL (jacek 31/10/2002)
|
|---|
| 81 | positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), NULL));
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory()
|
|---|
| 85 | {
|
|---|
| 86 | ParticleName = right.ParticleName;
|
|---|
| 87 | PDGCharge = right.PDGCharge;
|
|---|
| 88 | PDGEncoding = right.PDGEncoding;
|
|---|
| 89 | fTrackID = right.fTrackID;
|
|---|
| 90 | fParentID = right.fParentID;
|
|---|
| 91 | initialKineticEnergy = right.initialKineticEnergy;
|
|---|
| 92 | initialMomentum = right.initialMomentum;
|
|---|
| 93 | positionRecord = new TrajectoryPointContainer();
|
|---|
| 94 |
|
|---|
| 95 | for(size_t i=0;i<right.positionRecord->size();i++)
|
|---|
| 96 | {
|
|---|
| 97 | G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
|
|---|
| 98 | positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | G4SmoothTrajectory::~G4SmoothTrajectory()
|
|---|
| 103 | {
|
|---|
| 104 | if (positionRecord) {
|
|---|
| 105 | // positionRecord->clearAndDestroy();
|
|---|
| 106 | size_t i;
|
|---|
| 107 | for(i=0;i<positionRecord->size();i++){
|
|---|
| 108 | delete (*positionRecord)[i];
|
|---|
| 109 | }
|
|---|
| 110 | positionRecord->clear();
|
|---|
| 111 | delete positionRecord;
|
|---|
| 112 | }
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
|
|---|
| 116 | {
|
|---|
| 117 | // Invoke the default implementation in G4VTrajectory...
|
|---|
| 118 | G4VTrajectory::ShowTrajectory(os);
|
|---|
| 119 | // ... or override with your own code here.
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | void G4SmoothTrajectory::DrawTrajectory() const
|
|---|
| 123 | {
|
|---|
| 124 | // Invoke the default implementation in G4VTrajectory...
|
|---|
| 125 | G4VTrajectory::DrawTrajectory();
|
|---|
| 126 | // ... or override with your own code here.
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | void G4SmoothTrajectory::DrawTrajectory(G4int i_mode) const
|
|---|
| 130 | {
|
|---|
| 131 | // Invoke the default implementation in G4VTrajectory...
|
|---|
| 132 | G4VTrajectory::DrawTrajectory(i_mode);
|
|---|
| 133 | // ... or override with your own code here.
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
|
|---|
| 137 | {
|
|---|
| 138 | G4bool isNew;
|
|---|
| 139 | std::map<G4String,G4AttDef>* store
|
|---|
| 140 | = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
|
|---|
| 141 | if (isNew) {
|
|---|
| 142 |
|
|---|
| 143 | G4String ID("ID");
|
|---|
| 144 | (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
|
|---|
| 145 |
|
|---|
| 146 | G4String PID("PID");
|
|---|
| 147 | (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
|
|---|
| 148 |
|
|---|
| 149 | G4String PN("PN");
|
|---|
| 150 | (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
|
|---|
| 151 |
|
|---|
| 152 | G4String Ch("Ch");
|
|---|
| 153 | (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
|
|---|
| 154 |
|
|---|
| 155 | G4String PDG("PDG");
|
|---|
| 156 | (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
|
|---|
| 157 |
|
|---|
| 158 | G4String IKE("IKE");
|
|---|
| 159 | (*store)[IKE] =
|
|---|
| 160 | G4AttDef(IKE, "Initial kinetic energy",
|
|---|
| 161 | "Physics","G4BestUnit","G4double");
|
|---|
| 162 |
|
|---|
| 163 | G4String IMom("IMom");
|
|---|
| 164 | (*store)[IMom] = G4AttDef(IMom, "Initial momentum",
|
|---|
| 165 | "Physics","G4BestUnit","G4ThreeVector");
|
|---|
| 166 |
|
|---|
| 167 | G4String IMag("IMag");
|
|---|
| 168 | (*store)[IMag] = G4AttDef
|
|---|
| 169 | (IMag, "Initial momentum magnitude",
|
|---|
| 170 | "Physics","G4BestUnit","G4double");
|
|---|
| 171 |
|
|---|
| 172 | G4String NTP("NTP");
|
|---|
| 173 | (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
|
|---|
| 174 |
|
|---|
| 175 | }
|
|---|
| 176 | return store;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 | std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
|
|---|
| 181 | {
|
|---|
| 182 | std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
|
|---|
| 183 |
|
|---|
| 184 | values->push_back
|
|---|
| 185 | (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
|
|---|
| 186 |
|
|---|
| 187 | values->push_back
|
|---|
| 188 | (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
|
|---|
| 189 |
|
|---|
| 190 | values->push_back(G4AttValue("PN",ParticleName,""));
|
|---|
| 191 |
|
|---|
| 192 | values->push_back
|
|---|
| 193 | (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
|
|---|
| 194 |
|
|---|
| 195 | values->push_back
|
|---|
| 196 | (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
|
|---|
| 197 |
|
|---|
| 198 | values->push_back
|
|---|
| 199 | (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
|
|---|
| 200 |
|
|---|
| 201 | values->push_back
|
|---|
| 202 | (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
|
|---|
| 203 |
|
|---|
| 204 | values->push_back
|
|---|
| 205 | (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
|
|---|
| 206 |
|
|---|
| 207 | values->push_back
|
|---|
| 208 | (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
|
|---|
| 209 |
|
|---|
| 210 | #ifdef G4ATTDEBUG
|
|---|
| 211 | G4cout << G4AttCheck(values,GetAttDefs());
|
|---|
| 212 | #endif
|
|---|
| 213 |
|
|---|
| 214 | return values;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
|
|---|
| 218 | {
|
|---|
| 219 | // (jacek 30/10/2002)
|
|---|
| 220 | positionRecord->push_back(
|
|---|
| 221 | new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
|
|---|
| 222 | aStep->GetPointerToVectorOfAuxiliaryPoints()));
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
|
|---|
| 226 | {
|
|---|
| 227 | return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
|---|
| 231 | {
|
|---|
| 232 | if(!secondTrajectory) return;
|
|---|
| 233 |
|
|---|
| 234 | G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
|
|---|
| 235 | G4int ent = seco->GetPointEntries();
|
|---|
| 236 | for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
|
|---|
| 237 | {
|
|---|
| 238 | positionRecord->push_back((*(seco->positionRecord))[i]);
|
|---|
| 239 | // positionRecord->push_back(seco->positionRecord->removeAt(1));
|
|---|
| 240 | }
|
|---|
| 241 | delete (*seco->positionRecord)[0];
|
|---|
| 242 | seco->positionRecord->clear();
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|