Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

MaGeTrajectory.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * DISCLAIMER                                                       *
00004 // *                                                                  *
00005 // * The following disclaimer summarizes all the specific disclaimers *
00006 // * of contributors to this software. The specific disclaimers,which *
00007 // * govern, are listed with their locations in:                      *
00008 // *   http://cern.ch/geant4/license                                  *
00009 // *                                                                  *
00010 // * Neither the authors of this software system, nor their employing *
00011 // * institutes,nor the agencies providing financial support for this *
00012 // * work  make  any representation or  warranty, express or implied, *
00013 // * regarding  this  software system or assume any liability for its *
00014 // * use.                                                             *
00015 // *                                                                  *
00016 // * This  code  implementation is the  intellectual property  of the *
00017 // * GEANT4 collaboration.                                            *
00018 // * By copying,  distributing  or modifying the Program (or any work *
00019 // * based  on  the Program)  you indicate  your  acceptance of  this *
00020 // * statement, and all its terms.                                    *
00021 // ********************************************************************
00022 //
00023 //
00024 // $Id: MaGeTrajectory.cc,v 1.1.1.1 2004/11/08 17:53:42 gast Exp $
00025 // GEANT4 tag $Name:  $
00026 //
00027 //
00028 // ---------------------------------------------------------------
00029 //
00030 // MaGeTrajectory.cc
00031 //
00032 // Contact:
00033 //   Questions and comments to this code should be sent to
00034 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
00035 //     Makoto  Asai   (e-mail: asai@kekvax.kek.jp)
00036 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
00037 //
00038 // ---------------------------------------------------------------
00039 
00040 
00041 #include "gerdaio/MaGeTrajectory.hh"
00042 #include "gerdaio/MaGeTrajectoryPoint.hh"
00043 
00044 #include "G4ParticleTable.hh"
00045 #include "G4AttDefStore.hh"
00046 #include "G4AttDef.hh"
00047 #include "G4AttValue.hh"
00048 #include "G4UnitsTable.hh"
00049 #include "G4TouchableHistory.hh"
00050 #include "G4ios.hh"
00051 #include <strstream>
00052 #include "G4VProcess.hh"
00053 #include "G4VPhysicalVolume.hh"
00054 
00055 G4Allocator<MaGeTrajectory> MaGeTrajectoryAllocator;
00056 
00057 MaGeTrajectory::MaGeTrajectory()
00058 :  positionRecord(0), fTrackID(0), fParentID(0),
00059    PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
00060    initialMomentum( G4ThreeVector() )
00061 {;}
00062 
00063 MaGeTrajectory::MaGeTrajectory(const G4Track* aTrack)
00064 {
00065    G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
00066    ParticleName = fpParticleDefinition->GetParticleName();
00067    PDGCharge = fpParticleDefinition->GetPDGCharge();
00068    PDGEncoding = fpParticleDefinition->GetPDGEncoding();
00069    fTrackID = aTrack->GetTrackID();
00070    fParentID = aTrack->GetParentID();
00071    initialMomentum = aTrack->GetMomentum();
00072    positionRecord = new MaGeTrajectoryPointContainer();
00073    // Following is for the first trajectory point
00074 /*
00075    if (aTrack->GetVolume()!=0) {
00076      positionRecord->push_back(new MaGeTrajectoryPoint
00077       (aTrack->GetPosition(),aTrack->GetVolume()->GetName()));
00078    }
00079    else {
00080      positionRecord->push_back(new MaGeTrajectoryPoint
00081       (aTrack->GetPosition(), "tempvolume"));
00082    }
00083 */
00084 /*
00085   PROBLEM to be solved: how to get volume name from aTrack
00086 */
00087    positionRecord->push_back(new MaGeTrajectoryPoint(aTrack->GetPosition()));
00088 //   G4cout<<" xxx "<<aTrack->GetVolume()->GetName()<<G4endl;
00089 }
00090 
00091 MaGeTrajectory::MaGeTrajectory(MaGeTrajectory & right):G4VTrajectory()
00092 {
00093   ParticleName = right.ParticleName;
00094   PDGCharge = right.PDGCharge;
00095   PDGEncoding = right.PDGEncoding;
00096   fTrackID = right.fTrackID;
00097   fParentID = right.fParentID;
00098   initialMomentum = right.initialMomentum;
00099   positionRecord = new MaGeTrajectoryPointContainer();
00100 
00101   for(size_t i=0;i<right.positionRecord->size();i++)
00102   {
00103     MaGeTrajectoryPoint* rightPoint = (MaGeTrajectoryPoint*)((*(right.positionRecord))[i]);
00104     positionRecord->push_back(new MaGeTrajectoryPoint(*rightPoint));
00105   }
00106 }
00107 
00108 MaGeTrajectory::~MaGeTrajectory()
00109 {
00110   //  positionRecord->clearAndDestroy();
00111   size_t i;
00112   for(i=0;i<positionRecord->size();i++){
00113     delete  (*positionRecord)[i];
00114   }
00115   positionRecord->clear();
00116 
00117   delete positionRecord;
00118 }
00119 
00120 void MaGeTrajectory::ShowTrajectory(std::ostream& os) const
00121 {
00122   // Invoke the default implementation in G4VTrajectory...
00123   G4VTrajectory::ShowTrajectory(os);
00124   // ... or override with your own code here.
00125 }
00126 
00127 void MaGeTrajectory::DrawTrajectory(G4int i_mode) const
00128 {
00129   // Invoke the default implementation in G4VTrajectory...
00130   G4VTrajectory::DrawTrajectory(i_mode);
00131   // ... or override with your own code here.
00132 }
00133 
00134 const std::map<G4String,G4AttDef>* MaGeTrajectory::GetAttDefs() const
00135 {
00136   G4bool isNew;
00137   std::map<G4String,G4AttDef>* store
00138     = G4AttDefStore::GetInstance("MaGeTrajectory",isNew);
00139   if (isNew) {
00140 
00141     G4String ID("ID");
00142     (*store)[ID] = G4AttDef(ID,"Track ID","Bookkeeping","","G4int");
00143 
00144     G4String PID("PID");
00145     (*store)[PID] = G4AttDef(PID,"Parent ID","Bookkeeping","","G4int");
00146 
00147     G4String PN("PN");
00148     (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
00149 
00150     G4String Ch("Ch");
00151     (*store)[Ch] = G4AttDef(Ch,"Charge","Physics","","G4double");
00152 
00153     G4String PDG("PDG");
00154     (*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
00155 
00156     G4String IMom("IMom");
00157     (*store)[IMom] = G4AttDef(IMom, "Momentum of track at start of trajectory",
00158                               "Physics","","G4ThreeVector");
00159 
00160     G4String NTP("NTP");
00161     (*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
00162 
00163   }
00164   return store;
00165 }
00166 
00167 std::vector<G4AttValue>* MaGeTrajectory::CreateAttValues() const
00168 {
00169   char c[100];
00170   std::ostrstream s(c,100);
00171 
00172   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
00173 
00174   s.seekp(std::ios::beg);
00175   s << fTrackID << std::ends;
00176   values->push_back(G4AttValue("ID",c,""));
00177 
00178   s.seekp(std::ios::beg);
00179   s << fParentID << std::ends;
00180   values->push_back(G4AttValue("PID",c,""));
00181 
00182   values->push_back(G4AttValue("PN",ParticleName,""));
00183 
00184   s.seekp(std::ios::beg);
00185   s << PDGCharge << std::ends;
00186   values->push_back(G4AttValue("Ch",c,""));
00187 
00188   s.seekp(std::ios::beg);
00189   s << PDGEncoding << std::ends;
00190   values->push_back(G4AttValue("PDG",c,""));
00191 
00192   s.seekp(std::ios::beg);
00193   s << G4BestUnit(initialMomentum,"Energy") << std::ends;
00194   values->push_back(G4AttValue("IMom",c,""));
00195 
00196   s.seekp(std::ios::beg);
00197   s << GetPointEntries() << std::ends;
00198   values->push_back(G4AttValue("NTP",c,""));
00199 
00200   return values;
00201 }
00202 
00203 void MaGeTrajectory::AppendStep(const G4Step* aStep)
00204 {
00205 /*
00206    positionRecord->push_back( new MaGeTrajectoryPoint(aStep->GetPostStepPoint()->
00207                                  GetPosition() ));
00208 */
00209     MaGeTrajectoryPoint* oneTrajectoryPoint = new MaGeTrajectoryPoint();
00210     oneTrajectoryPoint->SetPosition(aStep->GetPostStepPoint()->GetPosition());
00211     oneTrajectoryPoint->SetEnergyLost(aStep->GetTotalEnergyDeposit());
00212     oneTrajectoryPoint->SetStepLength(aStep->GetStepLength());
00213 
00214     oneTrajectoryPoint->SetTrackLength(aStep->GetTrack()->GetTrackLength());
00215 
00216     G4TouchableHistory* theTouchable
00217       = (G4TouchableHistory*)(aStep->GetPostStepPoint()->GetTouchable());
00218     if (theTouchable->GetVolume()!=0){
00219       oneTrajectoryPoint->SetVolumeName( theTouchable->GetVolume()->GetName() );
00220     }
00221     else { 
00222       oneTrajectoryPoint->SetVolumeName("outofworld"); 
00223     }
00224     oneTrajectoryPoint->SetProcessName( aStep->GetPostStepPoint()
00225                        ->GetProcessDefinedStep()->GetProcessName() );
00226 
00227     positionRecord->push_back(oneTrajectoryPoint);
00228 }
00229   
00230 G4ParticleDefinition* MaGeTrajectory::GetParticleDefinition()
00231 {
00232    return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
00233 }
00234 
00235 void MaGeTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00236 {
00237   if(!secondTrajectory) return;
00238 
00239   MaGeTrajectory* seco = (MaGeTrajectory*)secondTrajectory;
00240   G4int ent = seco->GetPointEntries();
00241   for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
00242   { 
00243     positionRecord->push_back((*(seco->positionRecord))[i]);
00244     //    positionRecord->push_back(seco->positionRecord->removeAt(1));
00245   }
00246   delete (*seco->positionRecord)[0];
00247   seco->positionRecord->clear();
00248 }
00249 
00250 

Generated on Mon Nov 29 16:58:52 2004 for Majorana Simulation by  doxygen 1.3.9.1