[827] | 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 | // |
---|
[1340] | 27 | // $Id: G4SmoothTrajectory.cc,v 1.22 2010/07/19 13:41:21 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: tracking-V09-03-08 $ |
---|
[827] | 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(""), |
---|
[1196] | 62 | initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() ) |
---|
[827] | 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(); |
---|
[1196] | 73 | initialKineticEnergy = aTrack->GetKineticEnergy(); |
---|
[827] | 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) |
---|
[1340] | 81 | positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), 0)); |
---|
[827] | 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; |
---|
[1196] | 91 | initialKineticEnergy = right.initialKineticEnergy; |
---|
[827] | 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 | |
---|
[1337] | 122 | /*** |
---|
[1293] | 123 | void G4SmoothTrajectory::DrawTrajectory() const |
---|
| 124 | { |
---|
| 125 | // Invoke the default implementation in G4VTrajectory... |
---|
| 126 | G4VTrajectory::DrawTrajectory(); |
---|
| 127 | // ... or override with your own code here. |
---|
| 128 | } |
---|
[1337] | 129 | ***/ |
---|
[1293] | 130 | |
---|
[827] | 131 | void G4SmoothTrajectory::DrawTrajectory(G4int i_mode) const |
---|
| 132 | { |
---|
| 133 | // Invoke the default implementation in G4VTrajectory... |
---|
| 134 | G4VTrajectory::DrawTrajectory(i_mode); |
---|
| 135 | // ... or override with your own code here. |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const |
---|
| 139 | { |
---|
| 140 | G4bool isNew; |
---|
| 141 | std::map<G4String,G4AttDef>* store |
---|
| 142 | = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew); |
---|
| 143 | if (isNew) { |
---|
| 144 | |
---|
| 145 | G4String ID("ID"); |
---|
| 146 | (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int"); |
---|
| 147 | |
---|
| 148 | G4String PID("PID"); |
---|
| 149 | (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int"); |
---|
| 150 | |
---|
| 151 | G4String PN("PN"); |
---|
| 152 | (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String"); |
---|
| 153 | |
---|
| 154 | G4String Ch("Ch"); |
---|
| 155 | (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double"); |
---|
| 156 | |
---|
| 157 | G4String PDG("PDG"); |
---|
| 158 | (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int"); |
---|
| 159 | |
---|
[1196] | 160 | G4String IKE("IKE"); |
---|
| 161 | (*store)[IKE] = |
---|
| 162 | G4AttDef(IKE, "Initial kinetic energy", |
---|
| 163 | "Physics","G4BestUnit","G4double"); |
---|
| 164 | |
---|
[827] | 165 | G4String IMom("IMom"); |
---|
[1196] | 166 | (*store)[IMom] = G4AttDef(IMom, "Initial momentum", |
---|
[827] | 167 | "Physics","G4BestUnit","G4ThreeVector"); |
---|
| 168 | |
---|
| 169 | G4String IMag("IMag"); |
---|
| 170 | (*store)[IMag] = G4AttDef |
---|
[1196] | 171 | (IMag, "Initial momentum magnitude", |
---|
[827] | 172 | "Physics","G4BestUnit","G4double"); |
---|
| 173 | |
---|
| 174 | G4String NTP("NTP"); |
---|
| 175 | (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int"); |
---|
| 176 | |
---|
| 177 | } |
---|
| 178 | return store; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const |
---|
| 183 | { |
---|
| 184 | std::vector<G4AttValue>* values = new std::vector<G4AttValue>; |
---|
| 185 | |
---|
| 186 | values->push_back |
---|
| 187 | (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),"")); |
---|
| 188 | |
---|
| 189 | values->push_back |
---|
| 190 | (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),"")); |
---|
| 191 | |
---|
| 192 | values->push_back(G4AttValue("PN",ParticleName,"")); |
---|
| 193 | |
---|
| 194 | values->push_back |
---|
| 195 | (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),"")); |
---|
| 196 | |
---|
| 197 | values->push_back |
---|
| 198 | (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),"")); |
---|
| 199 | |
---|
| 200 | values->push_back |
---|
[1196] | 201 | (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),"")); |
---|
| 202 | |
---|
| 203 | values->push_back |
---|
[827] | 204 | (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),"")); |
---|
| 205 | |
---|
| 206 | values->push_back |
---|
| 207 | (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),"")); |
---|
| 208 | |
---|
| 209 | values->push_back |
---|
| 210 | (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),"")); |
---|
| 211 | |
---|
| 212 | #ifdef G4ATTDEBUG |
---|
| 213 | G4cout << G4AttCheck(values,GetAttDefs()); |
---|
| 214 | #endif |
---|
| 215 | |
---|
| 216 | return values; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | void G4SmoothTrajectory::AppendStep(const G4Step* aStep) |
---|
| 220 | { |
---|
| 221 | // (jacek 30/10/2002) |
---|
| 222 | positionRecord->push_back( |
---|
| 223 | new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(), |
---|
| 224 | aStep->GetPointerToVectorOfAuxiliaryPoints())); |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition() |
---|
| 228 | { |
---|
| 229 | return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName)); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) |
---|
| 233 | { |
---|
| 234 | if(!secondTrajectory) return; |
---|
| 235 | |
---|
| 236 | G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory; |
---|
| 237 | G4int ent = seco->GetPointEntries(); |
---|
| 238 | for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged |
---|
| 239 | { |
---|
| 240 | positionRecord->push_back((*(seco->positionRecord))[i]); |
---|
| 241 | // positionRecord->push_back(seco->positionRecord->removeAt(1)); |
---|
| 242 | } |
---|
| 243 | delete (*seco->positionRecord)[0]; |
---|
| 244 | seco->positionRecord->clear(); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | |
---|