Import Geant4 7.0.0 source tree
This commit is contained in:
@@ -0,0 +1,219 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: RE01Trajectory.cc,v 1.1 2004/11/26 07:37:43 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
|
||||
|
||||
#include "RE01Trajectory.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4Circle.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4PrimaryParticle.hh"
|
||||
#include "RE01TrackInformation.hh"
|
||||
|
||||
G4Allocator<RE01Trajectory> myTrajectoryAllocator;
|
||||
|
||||
RE01Trajectory::RE01Trajectory()
|
||||
:G4VTrajectory()
|
||||
{
|
||||
fpParticleDefinition = 0;
|
||||
ParticleName = "";
|
||||
PDGCharge = 0;
|
||||
PDGEncoding = 0;
|
||||
fTrackID = 0;
|
||||
fParentID = 0;
|
||||
fTrackStatus = 0;
|
||||
positionRecord = 0;
|
||||
momentum = G4ThreeVector(0.,0.,0.);
|
||||
vertexPosition = G4ThreeVector(0.,0.,0.);
|
||||
globalTime = 0.;
|
||||
}
|
||||
|
||||
RE01Trajectory::RE01Trajectory(const G4Track* aTrack)
|
||||
:G4VTrajectory()
|
||||
{
|
||||
fpParticleDefinition = aTrack->GetDefinition();
|
||||
ParticleName = fpParticleDefinition->GetParticleName();
|
||||
PDGCharge = fpParticleDefinition->GetPDGCharge();
|
||||
PDGEncoding = fpParticleDefinition->GetPDGEncoding();
|
||||
if(ParticleName=="unknown")
|
||||
{
|
||||
G4PrimaryParticle*pp = aTrack->GetDynamicParticle()->GetPrimaryParticle();
|
||||
if(pp)
|
||||
{
|
||||
if(pp->GetCharge()<DBL_MAX) PDGCharge = pp->GetCharge();
|
||||
PDGEncoding = pp->GetPDGcode();
|
||||
if(pp->GetG4code()!=0)
|
||||
{
|
||||
ParticleName += " : ";
|
||||
ParticleName += pp->GetG4code()->GetParticleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
fTrackID = aTrack->GetTrackID();
|
||||
RE01TrackInformation* trackInfo
|
||||
= (RE01TrackInformation*)(aTrack->GetUserInformation());
|
||||
fTrackStatus = trackInfo->GetTrackingStatus();
|
||||
if(fTrackStatus == 1)
|
||||
{ fParentID = aTrack->GetParentID(); }
|
||||
else if(fTrackStatus == 2)
|
||||
{ fParentID = trackInfo->GetSourceTrackID(); }
|
||||
else
|
||||
{ fParentID = -1; }
|
||||
positionRecord = new RE01TrajectoryPointContainer();
|
||||
positionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition()));
|
||||
momentum = aTrack->GetMomentum();
|
||||
vertexPosition = aTrack->GetPosition();
|
||||
globalTime = aTrack->GetGlobalTime();
|
||||
}
|
||||
|
||||
RE01Trajectory::RE01Trajectory(RE01Trajectory & right)
|
||||
:G4VTrajectory()
|
||||
{
|
||||
ParticleName = right.ParticleName;
|
||||
fpParticleDefinition = right.fpParticleDefinition;
|
||||
PDGCharge = right.PDGCharge;
|
||||
PDGEncoding = right.PDGEncoding;
|
||||
fTrackID = right.fTrackID;
|
||||
fParentID = right.fParentID;
|
||||
fTrackStatus = right.fTrackStatus;
|
||||
positionRecord = new RE01TrajectoryPointContainer();
|
||||
for(size_t i=0;i<right.positionRecord->size();i++)
|
||||
{
|
||||
G4TrajectoryPoint* rightPoint = (G4TrajectoryPoint*)((*(right.positionRecord))[i]);
|
||||
positionRecord->push_back(new G4TrajectoryPoint(*rightPoint));
|
||||
}
|
||||
momentum = right.momentum;
|
||||
vertexPosition = right.vertexPosition;
|
||||
globalTime = right.globalTime;
|
||||
}
|
||||
|
||||
RE01Trajectory::~RE01Trajectory()
|
||||
{
|
||||
size_t i;
|
||||
for(i=0;i<positionRecord->size();i++){
|
||||
delete (*positionRecord)[i];
|
||||
}
|
||||
positionRecord->clear();
|
||||
|
||||
delete positionRecord;
|
||||
}
|
||||
|
||||
void RE01Trajectory::ShowTrajectory(std::ostream& os) const
|
||||
{
|
||||
os << G4endl << "TrackID =" << fTrackID
|
||||
<< " : ParentID=" << fParentID << " : TrackStatus=" << fTrackStatus << G4endl;
|
||||
os << "Particle name : " << ParticleName << " PDG code : " << PDGEncoding
|
||||
<< " Charge : " << PDGCharge << G4endl;
|
||||
os << "Original momentum : " <<
|
||||
G4BestUnit(momentum,"Energy") << G4endl;
|
||||
os << "Vertex : " << G4BestUnit(vertexPosition,"Length")
|
||||
<< " Global time : " << G4BestUnit(globalTime,"Time") << G4endl;
|
||||
os << " Current trajectory has " << positionRecord->size()
|
||||
<< " points." << G4endl;
|
||||
|
||||
for( size_t i=0 ; i < positionRecord->size() ; i++){
|
||||
G4TrajectoryPoint* aTrajectoryPoint = (G4TrajectoryPoint*)((*positionRecord)[i]);
|
||||
os << "Point[" << i << "]"
|
||||
<< " Position= " << aTrajectoryPoint->GetPosition() << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
void RE01Trajectory::DrawTrajectory(G4int) const
|
||||
{
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
G4ThreeVector pos;
|
||||
|
||||
G4Polyline pPolyline;
|
||||
for (size_t i = 0; i < positionRecord->size() ; i++) {
|
||||
G4TrajectoryPoint* aTrajectoryPoint = (G4TrajectoryPoint*)((*positionRecord)[i]);
|
||||
pos = aTrajectoryPoint->GetPosition();
|
||||
pPolyline.push_back( pos );
|
||||
}
|
||||
|
||||
G4Colour colour(0.2,0.2,0.2);
|
||||
if(fpParticleDefinition==G4Gamma::GammaDefinition())
|
||||
colour = G4Colour(0.,0.,1.);
|
||||
else if(fpParticleDefinition==G4Electron::ElectronDefinition()
|
||||
||fpParticleDefinition==G4Positron::PositronDefinition())
|
||||
colour = G4Colour(1.,1.,0.);
|
||||
else if(fpParticleDefinition==G4MuonMinus::MuonMinusDefinition()
|
||||
||fpParticleDefinition==G4MuonPlus::MuonPlusDefinition())
|
||||
colour = G4Colour(0.,1.,0.);
|
||||
else if(fpParticleDefinition->GetParticleType()=="meson")
|
||||
{
|
||||
if(PDGCharge!=0.)
|
||||
colour = G4Colour(1.,0.,0.);
|
||||
else
|
||||
colour = G4Colour(0.5,0.,0.);
|
||||
}
|
||||
else if(fpParticleDefinition->GetParticleType()=="baryon")
|
||||
{
|
||||
if(PDGCharge!=0.)
|
||||
colour = G4Colour(0.,1.,1.);
|
||||
else
|
||||
colour = G4Colour(0.,0.5,0.5);
|
||||
}
|
||||
|
||||
G4VisAttributes attribs(colour);
|
||||
pPolyline.SetVisAttributes(attribs);
|
||||
if(pVVisManager) pVVisManager->Draw(pPolyline);
|
||||
}
|
||||
|
||||
void RE01Trajectory::AppendStep(const G4Step* aStep)
|
||||
{
|
||||
positionRecord->push_back( new G4TrajectoryPoint(aStep->GetPostStepPoint()->
|
||||
GetPosition() ));
|
||||
}
|
||||
|
||||
G4ParticleDefinition* RE01Trajectory::GetParticleDefinition()
|
||||
{
|
||||
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
|
||||
}
|
||||
|
||||
void RE01Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
||||
{
|
||||
if(!secondTrajectory) return;
|
||||
|
||||
RE01Trajectory* seco = (RE01Trajectory*)secondTrajectory;
|
||||
G4int ent = seco->GetPointEntries();
|
||||
for(int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
|
||||
{
|
||||
positionRecord->push_back((*(seco->positionRecord))[i]);
|
||||
}
|
||||
delete (*seco->positionRecord)[0];
|
||||
seco->positionRecord->clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user