G4SmoothTrajectory.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4SmoothTrajectory.cc 67009 2013-01-29 16:00:21Z gcosmo $
00028 //
00029 //
00030 // ---------------------------------------------------------------
00031 //
00032 // G4SmoothTrajectory.cc
00033 //
00034 // Contact:
00035 //   Questions and comments to this code should be sent to
00036 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
00037 //     Makoto  Asai   (e-mail: asai@kekvax.kek.jp)
00038 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
00039 //
00040 // ---------------------------------------------------------------
00041 
00042 #include "G4SmoothTrajectory.hh"
00043 #include "G4SmoothTrajectoryPoint.hh"
00044 #include "G4ParticleTable.hh"
00045 #include "G4AttDefStore.hh"
00046 #include "G4AttDef.hh"
00047 #include "G4AttValue.hh"
00048 #include "G4UIcommand.hh"
00049 #include "G4UnitsTable.hh"
00050 
00051 //#define G4ATTDEBUG
00052 #ifdef G4ATTDEBUG
00053 #include "G4AttCheck.hh"
00054 #endif
00055 
00056 G4Allocator<G4SmoothTrajectory> aSmoothTrajectoryAllocator;
00057 
00058 G4SmoothTrajectory::G4SmoothTrajectory()
00059 :  positionRecord(0), fTrackID(0), fParentID(0),
00060    PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
00061    initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
00062 {;}
00063 
00064 G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
00065 {
00066    G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
00067    ParticleName = fpParticleDefinition->GetParticleName();
00068    PDGCharge = fpParticleDefinition->GetPDGCharge();
00069    PDGEncoding = fpParticleDefinition->GetPDGEncoding();
00070    fTrackID = aTrack->GetTrackID();
00071    fParentID = aTrack->GetParentID();
00072    initialKineticEnergy = aTrack->GetKineticEnergy();
00073    initialMomentum = aTrack->GetMomentum();
00074    positionRecord = new TrajectoryPointContainer();
00075    // Following is for the first trajectory point
00076    positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
00077 
00078    // The first point has no auxiliary points, so set the auxiliary
00079    // points vector to NULL (jacek 31/10/2002)
00080    positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), 0));
00081 }
00082 
00083 G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory()
00084 {
00085   ParticleName = right.ParticleName;
00086   PDGCharge = right.PDGCharge;
00087   PDGEncoding = right.PDGEncoding;
00088   fTrackID = right.fTrackID;
00089   fParentID = right.fParentID;
00090   initialKineticEnergy = right.initialKineticEnergy;
00091   initialMomentum = right.initialMomentum;
00092   positionRecord = new TrajectoryPointContainer();
00093 
00094   for(size_t i=0;i<right.positionRecord->size();i++)
00095   {
00096     G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
00097     positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
00098   }
00099 }
00100 
00101 G4SmoothTrajectory::~G4SmoothTrajectory()
00102 {
00103   if (positionRecord) {
00104     //  positionRecord->clearAndDestroy();
00105     size_t i;
00106     for(i=0;i<positionRecord->size();i++){
00107       delete  (*positionRecord)[i];
00108     }
00109     positionRecord->clear();
00110     delete positionRecord;
00111   }
00112 }
00113 
00114 void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
00115 {
00116   // Invoke the default implementation in G4VTrajectory...
00117   G4VTrajectory::ShowTrajectory(os);
00118   // ... or override with your own code here.
00119 }
00120 
00121 /***
00122 void G4SmoothTrajectory::DrawTrajectory() const
00123 {
00124   // Invoke the default implementation in G4VTrajectory...
00125   G4VTrajectory::DrawTrajectory();
00126   // ... or override with your own code here.
00127 }
00128 ***/
00129 
00130 void G4SmoothTrajectory::DrawTrajectory(G4int i_mode) const
00131 {
00132   // Invoke the default implementation in G4VTrajectory...
00133   G4VTrajectory::DrawTrajectory(i_mode);
00134   // ... or override with your own code here.
00135 }
00136 
00137 const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
00138 {
00139   G4bool isNew;
00140   std::map<G4String,G4AttDef>* store
00141     = G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
00142   if (isNew) {
00143 
00144     G4String ID("ID");
00145     (*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
00146 
00147     G4String PID("PID");
00148     (*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
00149 
00150     G4String PN("PN");
00151     (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
00152 
00153     G4String Ch("Ch");
00154     (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
00155 
00156     G4String PDG("PDG");
00157     (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
00158 
00159     G4String IKE("IKE");
00160     (*store)[IKE] = 
00161       G4AttDef(IKE, "Initial kinetic energy",
00162                "Physics","G4BestUnit","G4double");
00163 
00164     G4String IMom("IMom");
00165     (*store)[IMom] = G4AttDef(IMom, "Initial momentum",
00166                               "Physics","G4BestUnit","G4ThreeVector");
00167 
00168     G4String IMag("IMag");
00169     (*store)[IMag] = G4AttDef
00170       (IMag, "Initial momentum magnitude",
00171        "Physics","G4BestUnit","G4double");
00172 
00173     G4String NTP("NTP");
00174     (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
00175 
00176   }
00177   return store;
00178 }
00179 
00180 
00181 std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
00182 {
00183   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
00184 
00185   values->push_back
00186     (G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
00187 
00188   values->push_back
00189     (G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
00190 
00191   values->push_back(G4AttValue("PN",ParticleName,""));
00192 
00193   values->push_back
00194     (G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
00195 
00196   values->push_back
00197     (G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
00198 
00199   values->push_back
00200     (G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
00201 
00202   values->push_back
00203     (G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
00204 
00205   values->push_back
00206     (G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
00207 
00208   values->push_back
00209     (G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
00210 
00211 #ifdef G4ATTDEBUG
00212    G4cout << G4AttCheck(values,GetAttDefs());
00213 #endif
00214 
00215   return values;
00216 }
00217 
00218 void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
00219 {
00220   // (jacek 30/10/2002)
00221   positionRecord->push_back(
00222       new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
00223                                   aStep->GetPointerToVectorOfAuxiliaryPoints()));
00224 }
00225   
00226 G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
00227 {
00228    return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
00229 }
00230 
00231 void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00232 {
00233   if(!secondTrajectory) return;
00234 
00235   G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
00236   G4int ent = seco->GetPointEntries();
00237   for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
00238   { 
00239     positionRecord->push_back((*(seco->positionRecord))[i]);
00240     //    positionRecord->push_back(seco->positionRecord->removeAt(1));
00241   }
00242   delete (*seco->positionRecord)[0];
00243   seco->positionRecord->clear();
00244 }
00245 
00246 

Generated on Mon May 27 17:49:51 2013 for Geant4 by  doxygen 1.4.7