Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
# $Id: GNUmakefile,v 2.2 1998/11/18 18:33:18 kurasige Exp $
# ------------------------------------------------------------
# GNUmakefile for events library. Makoto Asai, 5/9/95.
# ------------------------------------------------------------
name := G4event
ifndef G4INSTALL
G4INSTALL = ../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/tracking/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/particles/leptons/include \
-I$(G4BASE)/particles/leptons/include \
-I$(G4BASE)/particles/bosons/include \
-I$(G4BASE)/particles/hadrons/barions/include \
-I$(G4BASE)/particles/hadrons/ions/include \
-I$(G4BASE)/particles/hadrons/mesons/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/digits+hits/detector/include \
-I$(G4BASE)/digits+hits/hits/include \
-I$(G4BASE)/digits+hits/digits/include \
-I$(G4BASE)/graphics_reps/include \
-I$(G4BASE)/intercoms/include
ifdef G4_STORE_TRAJECTORY
CPPFLAGS += -DG4_STORE_TRAJECTORY
endif
include $(G4INSTALL)/config/common.gmk
.PHONY: global
global: lib
+84
View File
@@ -0,0 +1,84 @@
$Id: History,v 2.7 1998/11/11 11:15:48 asaim Exp $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Nov 11, 98 M.Asai (tag event-00-03-04)
- Optimize G4PrimaryVertex for events such as having huge number
of primaries.
Oct 10, 98 M.Asai (tag event-00-03-03)
- Bug fix in G4PrimaryVertex.
- Add verbosity to G4PrimaryXXX.
Oct 01, 98 M.Asai (tag event-00-03-02)
- Introducing a new inlined method in G4ParticleGun.hh.
Sep. 21, 98 M.Asai (tag event-00-03-01)
- Inclusion of "G4HCofThisEvent.hh" and "G4DCofThisEvent.hh" moved
from "G4Event.cc" to "G4Event.hh", to avoid the link problem on
HP-CC (not aCC).
July 19, 98 M.Asai (tag event-00-01-03)
- More tight check against EoF in G4HEPEvtInterface
July 15, 98 M.Asai (tag event-00-01-02)
July 4, 98 M.Asai (tag event-00-01-01)
- ready for the beta release
June 30, 98 M.Asai (tag event-00-07-01)
- Introduce shortlived particles
June 22, 98 P. Urban
- Preliminary results of tracking optimisation merged into the HEAD.
- tagged as event-00-06-03
June 10, 98 M.Asai
- G4ParticleGunMessenger.cc is modified to catch up the new G4UIcommand
- tagged as event-00-06-02
June 8, 98 M.Asai
- tagged as event-00-06-01
June 6, 98 M.Asai
- G4Event and G4EventManager is updated for the new "digita+hits" scheme
- GNUmakefile is updated
May 6, 98 M.Asai
- G4ParticleGun is cleaned up.
April 29, 98 G.Cosmo (event-00-05-02)
- Removed print-out of track's pointers from verbose level in
G4EventManager.cc (P.Urban)
April 22, 98 M.Asai
- Tagged as event-00-05-01
April 9, 98 G.Cosmo
- Porting on DEC-cxx 6.0.
Removed meaningless usage of "const" qualifier from functions
return type for basic types by value. Modified files:
G4StackManager.hh, G4TrackStack.hh
April 6, 97 M.Nagamatu
- modified G4ParticleGunMessenger.cc to fix the "Unit length" of
/gun/position command.
December 19, 97 G. Cosmo - (alpha03)
- Created.
@@ -0,0 +1,25 @@
// This code implementation is the intellectual property of
// the RD44 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: G4ClassificationOfNewTrack.hh,v 2.0 1998/07/02 16:53:45 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifndef G4ClassificationOfNewTrack_hh
#define G4ClassificationOfNewTrack_hh 1
enum G4ClassificationOfNewTrack
{
fUrgent, // put into the urgent stack
fWaiting, // put into the waiting stack
fPostpone, // postpone to the next event
fKill // kill
};
#endif
+36
View File
@@ -0,0 +1,36 @@
// This code implementation is the intellectual property of
// the RD44 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: G4EvManMessenger.hh,v 2.2 1998/07/12 03:42:11 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4EvManMessenger_h
#define G4EvManMessenger_h 1
#include "G4UImessenger.hh"
class G4EventManager;
class G4UIdirectory;
class G4UIcmdWithoutParameter;
class G4UIcmdWithAnInteger;
class G4EvManMessenger: public G4UImessenger
{
public:
G4EvManMessenger(G4EventManager * fEvMan);
~G4EvManMessenger();
void SetNewValue(G4UIcommand * command,G4String newValues);
G4String GetCurrentValue(G4UIcommand * command);
private:
G4EventManager * fEvManager;
G4UIdirectory* eventDirectory;
G4UIcmdWithoutParameter* abortCmd;
G4UIcmdWithAnInteger* verboseCmd;
};
#endif
+117
View File
@@ -0,0 +1,117 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Event.hh,v 2.2 1998/09/21 02:01:39 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4Event_h
#define G4Event_h 1
#include "globals.hh"
#include "G4Allocator.hh"
#include "G4PrimaryVertex.hh"
#include "G4HCofThisEvent.hh"
#include "G4DCofThisEvent.hh"
#include "G4TrajectoryContainer.hh"
class G4VHitsCollection;
class G4Event
{
public:
G4Event();
G4Event(G4int evID);
~G4Event();
inline void *operator new(size_t);
inline void operator delete(void* anEvent);
int operator==(const G4Event &right) const;
int operator!=(const G4Event &right) const;
void Print() const;
void Draw() const;
private:
// event ID
G4int eventID;
// PrimaryVertex
G4PrimaryVertex* thePrimaryVertex;
G4int numberOfPrimaryVertex;
// HitsCollection
G4HCofThisEvent* HC;
// DigiCollection
G4DCofThisEvent* DC;
// TrajectoryContainer
G4TrajectoryContainer * trajectoryContainer;
public:
inline void SetEventID(G4int i)
{ eventID = i; };
inline G4int GetEventID() const
{ return eventID; };
inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
{
if( thePrimaryVertex == NULL )
{ thePrimaryVertex = aPrimaryVertex; }
else
{ thePrimaryVertex->SetNext( aPrimaryVertex ); }
numberOfPrimaryVertex++;
};
inline G4int GetNumberOfPrimaryVertex() const
{ return numberOfPrimaryVertex; };
inline G4PrimaryVertex* GetPrimaryVertex(G4int i=0) const
{
if( i == 0 )
{ return thePrimaryVertex; }
else if( i > 0 && i < numberOfPrimaryVertex )
{
G4PrimaryVertex* primaryVertex = thePrimaryVertex;
for( int j=0; j<i; j++ )
{
if( primaryVertex == NULL ) return NULL;
primaryVertex = primaryVertex->GetNext();
}
return primaryVertex;
}
else
{ return NULL; }
};
inline void SetHCofThisEvent(G4HCofThisEvent*value)
{ HC = value; };
inline G4HCofThisEvent* GetHCofThisEvent() const
{ return HC; };
inline void SetDCofThisEvent(G4DCofThisEvent*value)
{ DC = value; };
inline G4DCofThisEvent* GetDCofThisEvent() const
{ return DC; };
inline void SetTrajectoryContainer(G4TrajectoryContainer*value)
{ trajectoryContainer = value; };
inline G4TrajectoryContainer* GetTrajectoryContainer() const
{ return trajectoryContainer; };
};
extern G4Allocator<G4Event> anEventAllocator;
inline void* G4Event::operator new(size_t)
{
void* anEvent;
anEvent = (void*)anEventAllocator.MallocSingle();
return anEvent;
}
inline void G4Event::operator delete(void* anEvent)
{
anEventAllocator.FreeSingle((G4Event*)anEvent);
}
#endif
+103
View File
@@ -0,0 +1,103 @@
// This code implementation is the intellectual property of
// the RD44 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: G4EventManager.hh,v 2.2 1998/10/10 10:51:17 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 10/Dec/96 M.Asai
//
#ifndef G4EventManager_h
#define G4EventManager_h 1
#include "evmandefs.hh"
#include "G4StackManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4PrimaryTransformer.hh"
class G4Event;
class G4UserEventAction;
class G4UserStackingAction;
class G4UserTrackingAction;
class G4UserSteppingAction;
class G4EvManMessenger;
#include "G4TrackingManager.hh"
#include "G4Track.hh"
#include "G4Trajectory.hh"
#include "G4TrackStatus.hh"
class G4SDManager;
#include "globals.hh"
//## Class: G4EventManager
// G4EventManager controls an event. This class has only
// one public method, ProcessOneEvent(), which will be
// called by GEANT4.
class G4EventManager
{
public:
G4EventManager();
~G4EventManager();
private:
G4EventManager(const G4EventManager &right);
G4EventManager& operator=(const G4EventManager& right);
public:
void ProcessOneEvent(G4Event* anEvent);
private:
void StackTracks(G4TrackVector *trackVector);
G4Event* currentEvent;
G4StackManager *trackContainer;
G4TrackingManager *trackManager;
G4TrajectoryContainer *trajectoryContainer;
G4int trackIDCounter;
int verboseLevel;
G4SDManager* sdManager;
G4PrimaryTransformer* transformer;
G4UserEventAction* userEventAction;
G4bool tracking;
G4EvManMessenger* theMessenger;
public:
inline const G4Event* GetConstCurrentEvent()
{ return currentEvent; };
inline G4Event* GetNonconstCurrentEvent()
{ return currentEvent; };
inline void AbortCurrentEvent()
{
trackContainer->clear();
if(tracking) trackManager->EventAborted();
};
void SetUserAction(G4UserEventAction* userAction);
inline void SetUserAction(G4UserStackingAction* userAction)
{ trackContainer->SetUserStackingAction(userAction); };
inline void SetUserAction(G4UserTrackingAction* userAction)
{ trackManager->SetUserAction(userAction); };
inline void SetUserAction(G4UserSteppingAction* userAction)
{ trackManager->SetUserAction(userAction); };
inline G4int GetVerboseLevel()
{ return verboseLevel; };
inline void SetVerboseLevel( G4int value )
{
verboseLevel = value;
trackContainer->SetVerboseLevel( value );
transformer->SetVerboseLevel( value );
};
};
#endif
+40
View File
@@ -0,0 +1,40 @@
// This code implementation is the intellectual property of
// the RD44 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: G4HEPEvtInterface.hh,v 2.1 1998/07/12 02:53:50 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4HEPEvtInterface_h
#define G4HEPEvtInterface_h 1
#include <fstream.h>
#include <rw/tpordvec.h>
#include "globals.hh"
#include "G4VPrimaryGenerator.hh"
#include "G4HEPEvtParticle.hh"
class G4PrimaryVertex;
class G4Event;
class G4HEPEvtInterface:public G4VPrimaryGenerator
{
public:
G4HEPEvtInterface(char* evfile);
G4HEPEvtInterface(G4String evfile);
~G4HEPEvtInterface();
void GeneratePrimaryVertex(G4Event* evt);
private:
G4String fileName;
ifstream inputFile;
RWTPtrOrderedVector<G4HEPEvtParticle> HPlist;
};
#endif
+74
View File
@@ -0,0 +1,74 @@
// This code implementation is the intellectual property of
// the RD44 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: G4HEPEvtParticle.hh,v 2.1 1998/07/12 02:53:50 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifndef G4HEPEvtParticle_h
#define G4HEPEvtParticle_h 1
#include "globals.hh"
#include "G4Allocator.hh"
#include "G4PrimaryParticle.hh"
class G4HEPEvtParticle
{
public:
inline void *operator new(size_t);
inline void operator delete(void *aStackedTrack);
G4HEPEvtParticle();
G4HEPEvtParticle(G4PrimaryParticle* pp,
G4int isthep, G4int jdahep1, G4int jdahep2);
~G4HEPEvtParticle();
const G4HEPEvtParticle & operator=(const G4HEPEvtParticle &right);
int operator==(const G4HEPEvtParticle &right) const;
int operator!=(const G4HEPEvtParticle &right) const;
private:
G4PrimaryParticle * theParticle;
G4int ISTHEP; // Status code of the entry
// Set to be 0 after generating links of
// G4PrimaryParticle object
G4int JDAHEP1;
G4int JDAHEP2;
public:
inline G4PrimaryParticle * GetTheParticle()
{ return theParticle; };
inline void Done()
{ ISTHEP *= -1; };
inline G4int GetISTHEP()
{ return ISTHEP; };
inline G4int GetJDAHEP1()
{ return JDAHEP1; };
inline G4int GetJDAHEP2()
{ return JDAHEP2; };
};
extern G4Allocator<G4HEPEvtParticle> aHEPEvtParticleAllocator;
inline void * G4HEPEvtParticle::operator new(size_t)
{
void * aHEPEvtParticle;
aHEPEvtParticle = (void *) aHEPEvtParticleAllocator.MallocSingle();
return aHEPEvtParticle;
}
inline void G4HEPEvtParticle::operator delete(void * aHEPEvtParticle)
{
aHEPEvtParticleAllocator.FreeSingle((G4HEPEvtParticle *) aHEPEvtParticle);
}
#endif
+101
View File
@@ -0,0 +1,101 @@
// This code implementation is the intellectual property of
// the RD44 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: G4ParticleGun.hh,v 2.2 1998/10/01 16:41:52 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4ParticleGun_h
#define G4ParticleGun_h 1
#include "globals.hh"
#include "G4VPrimaryGenerator.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleDefinition.hh"
#include "G4PrimaryVertex.hh"
#include "G4ParticleMomentum.hh"
class G4Event;
class G4ParticleGunMessenger;
class G4ParticleGun:public G4VPrimaryGenerator
{
public:
G4ParticleGun();
G4ParticleGun(G4int numberofparticles);
G4ParticleGun(G4ParticleDefinition * particleDef,
G4int numberofparticles = 1);
virtual ~G4ParticleGun();
G4ParticleGun(const G4ParticleGun &right);
const G4ParticleGun & operator=(const G4ParticleGun &right);
int operator==(const G4ParticleGun &right) const;
int operator!=(const G4ParticleGun &right) const;
virtual void GeneratePrimaryVertex(G4Event* evt);
// Set particle properties to be shoot out
// SetParticleDefinition should be called at first
// By using SetParticleMomentum(), both particle_momentum_direction and
// particle_energy(Kinetic Energy) are determined.
void SetParticleMomentum(G4ParticleMomentum aMomentum);
inline void SetParticleDefinition
(G4ParticleDefinition * aParticleDefinition)
{ particle_definition = aParticleDefinition; }
inline void SetParticleMomentumDirection
(G4ParticleMomentum aMomentumDirection)
{ particle_momentum_direction = aMomentumDirection.unit(); }
inline void SetParticleEnergy(G4double aKineticEnergy)
{ particle_energy = aKineticEnergy; }
inline void SetParticlePosition(G4ThreeVector aPosition)
{ particle_position = aPosition; }
inline void SetParticleTime(G4double aTime)
{ particle_time = aTime; }
inline G4ParticleDefinition* GetParticleDefinition()
{ return particle_definition; }
inline G4ParticleMomentum GetParticleMomentumDirection()
{ return particle_momentum_direction; }
inline G4double GetParticleEnergy()
{ return particle_energy; }
inline G4ThreeVector GetParticlePosition()
{ return particle_position; }
inline G4double GetParticleTime()
{ return particle_time; }
inline void SetParticlePolarization(G4ThreeVector aVal)
{ particle_polarization = aVal; }
inline G4ThreeVector GetParticlePolarization()
{ return particle_polarization; }
inline void SetNumberOfParticles(G4int i)
{ NumberOfParticlesToBeGenerated = i; }
inline G4int GetNumberOfParticles()
{ return NumberOfParticlesToBeGenerated; }
protected:
virtual void SetInitialValues();
G4int NumberOfParticlesToBeGenerated;
G4ParticleDefinition* particle_definition;
G4ParticleMomentum particle_momentum_direction;
G4double particle_energy;
G4ThreeVector particle_position;
G4double particle_time;
G4ThreeVector particle_polarization;
private:
G4ParticleGunMessenger* theMessenger;
};
#endif
@@ -0,0 +1,59 @@
// This code implementation is the intellectual property of
// the RD44 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: G4ParticleGunMessenger.hh,v 2.2 1998/07/12 03:42:15 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifndef G4ParticleGunMessenger_h
#define G4ParticleGunMessenger_h 1
class G4ParticleGun;
class G4ParticleTable;
class G4UIcommand;
class G4UIdirectory;
class G4UIcmdWithoutParameter;
class G4UIcmdWithAString;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWith3Vector;
class G4UIcmdWith3VectorAndUnit;
class G4UIcmdWithAnInteger;
#include "G4UImessenger.hh"
#include "globals.hh"
class G4ParticleGunMessenger: public G4UImessenger
{
public:
G4ParticleGunMessenger(G4ParticleGun * fPtclGun);
~G4ParticleGunMessenger();
public:
void SetNewValue(G4UIcommand * command,G4String newValues);
G4String GetCurrentValue(G4UIcommand * command);
private:
G4ParticleGun * fParticleGun;
G4ParticleTable * particleTable;
private: //commands
G4UIdirectory * gunDirectory;
G4UIcmdWithoutParameter * listCmd;
G4UIcmdWithAString * particleCmd;
G4UIcmdWith3Vector * directionCmd;
G4UIcmdWithADoubleAndUnit * energyCmd;
G4UIcmdWith3VectorAndUnit * positionCmd;
G4UIcmdWithADoubleAndUnit * timeCmd;
G4UIcmdWith3Vector * polCmd;
G4UIcmdWithAnInteger * numberCmd;
};
#endif
+141
View File
@@ -0,0 +1,141 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PrimaryParticle.hh,v 2.2 1998/10/10 10:51:18 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifndef G4PrimaryParticle_h
#define G4PrimaryParticle_h 1
#include "globals.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
class G4ParticleDefinition;
class G4PrimaryParticle
{
public:
inline void *operator new(size_t);
inline void operator delete(void *aStackedTrack);
G4PrimaryParticle();
G4PrimaryParticle(G4int Pcode);
G4PrimaryParticle(G4int Pcode,
G4double px,G4double py,G4double pz);
G4PrimaryParticle(G4ParticleDefinition* Gcode);
G4PrimaryParticle(G4ParticleDefinition* Gcode,
G4double px,G4double py,G4double pz);
~G4PrimaryParticle();
const G4PrimaryParticle & operator=(const G4PrimaryParticle &right);
int operator==(const G4PrimaryParticle &right) const;
int operator!=(const G4PrimaryParticle &right) const;
void Print() const;
private:
G4int PDGcode;
G4ParticleDefinition * G4code;
G4double Px;
G4double Py;
G4double Pz;
G4PrimaryParticle * nextParticle;
G4PrimaryParticle * daughterParticle;
G4int trackID; // This will be set if this particle is
// sent to G4EventManager and converted to
// G4Track. Otherwise = -1.
G4double mass; // This is just for book keeping.
// This will not be used but the mass in
// G4ParticleDefinition will be used.
G4double polX;
G4double polY;
G4double polZ;
public:
void SetPDGcode(G4int Pcode);
inline G4int GetPDGcode() const
{ return PDGcode; };
void SetG4code(G4ParticleDefinition * Gcode);
inline G4ParticleDefinition * GetG4code() const
{ return G4code; };
inline void SetMomentum(G4double px, G4double py, G4double pz)
{
Px = px;
Py = py;
Pz = pz;
};
inline G4ThreeVector GetMomentum() const
{ return G4ThreeVector(Px,Py,Pz); };
inline G4double GetPx() const
{ return Px; };
inline G4double GetPy() const
{ return Py; };
inline G4double GetPz() const
{ return Pz; };
inline void SetNext(G4PrimaryParticle * np)
{
if(nextParticle == NULL)
{ nextParticle = np; }
else
{ nextParticle->SetNext(np); }
};
inline G4PrimaryParticle * GetNext() const
{ return nextParticle; };
inline void SetDaughter(G4PrimaryParticle * np)
{
if(daughterParticle == NULL)
{ daughterParticle = np; }
else
{ daughterParticle->SetNext(np); }
};
inline G4PrimaryParticle * GetDaughter() const
{ return daughterParticle; };
inline void SetTrackID(G4int id)
{ trackID = id; };
inline G4int GetTrackID() const
{ return trackID; };
inline void SetMass(G4double mas)
{ mass = mas; };
inline G4double GetMass() const
{ return mass; };
inline void SetPolarization(G4double px,G4double py,G4double pz)
{
polX = px;
polY = py;
polZ = pz;
};
inline G4ThreeVector GetPolarization() const
{ return G4ThreeVector(polX,polY,polZ); };
inline G4double GetPolX() const { return polX; };
inline G4double GetPolY() const { return polY; };
inline G4double GetPolZ() const { return polZ; };
};
extern G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator;
inline void * G4PrimaryParticle::operator new(size_t)
{
void * aPrimaryParticle;
aPrimaryParticle = (void *) aPrimaryParticleAllocator.MallocSingle();
return aPrimaryParticle;
}
inline void G4PrimaryParticle::operator delete(void * aPrimaryParticle)
{
aPrimaryParticleAllocator.FreeSingle((G4PrimaryParticle *) aPrimaryParticle);
}
#endif
@@ -0,0 +1,55 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PrimaryTransformer.hh,v 2.2 1998/10/10 10:51:18 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4PromaryTransformer_h
#define G4PromaryTransformer_h 1
#include "G4TrackVector.hh"
#include "G4ParticleTable.hh"
#include "globals.hh"
class G4Event;
class G4PrimaryVertex;
#include "G4PrimaryParticle.hh"
class G4PrimaryTransformer
{
public:
G4PrimaryTransformer();
~G4PrimaryTransformer();
G4TrackVector* GimmePrimaries(G4Event* anEvent);
private:
G4TrackVector TV;
G4ParticleTable* particleTable;
G4int verboseLevel;
public:
inline void SetVerboseLevel(G4int vl)
{ verboseLevel = vl; };
private:
void GenerateTracks(G4PrimaryVertex* primaryVertex);
void GenerateSingleTrack(G4PrimaryParticle* primaryParticle,
G4double x0,G4double y0,G4double z0,G4double t0);
void SetDecayProducts(G4PrimaryParticle* mother,
G4DynamicParticle* motherDP);
inline G4ParticleDefinition* GetDefinition(G4PrimaryParticle*pp)
{
G4ParticleDefinition* partDef = pp->GetG4code();
if(!partDef) partDef = particleTable->FindParticle(pp->GetPDGcode());
return partDef;
};
};
#endif
+120
View File
@@ -0,0 +1,120 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PrimaryVertex.hh,v 2.3 1998/11/11 11:19:37 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifndef G4PrimaryVertex_h
#define G4PrimaryVertex_h 1
#include "globals.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4PrimaryParticle.hh"
class G4PrimaryVertex
{
public:
inline void *operator new(size_t);
inline void operator delete(void *aStackedTrack);
G4PrimaryVertex();
G4PrimaryVertex(G4double x0,G4double y0,G4double z0,G4double t0);
G4PrimaryVertex(G4ThreeVector xyz0,G4double t0);
~G4PrimaryVertex();
const G4PrimaryVertex & operator=(const G4PrimaryVertex &right);
int operator==(const G4PrimaryVertex &right) const;
int operator!=(const G4PrimaryVertex &right) const;
void Print() const;
private:
G4double X0;
G4double Y0;
G4double Z0;
G4double T0;
G4PrimaryParticle * theParticle;
G4PrimaryParticle * theTail;
G4PrimaryVertex* nextVertex;
G4int numberOfParticle;
public:
inline G4ThreeVector GetPosition() const
{ return G4ThreeVector(X0,Y0,Z0); }
inline G4double GetX0() const
{ return X0; }
inline G4double GetY0() const
{ return Y0; }
inline G4double GetZ0() const
{ return Z0; }
inline G4double GetT0() const
{ return T0; }
inline G4int GetNumberOfParticle() const
{ return numberOfParticle; }
inline void SetPrimary(G4PrimaryParticle * pp)
{
if(theParticle == NULL)
{
theParticle = pp;
theTail = pp;
}
else
{
theTail->SetNext(pp);
theTail = pp;
}
numberOfParticle++;
}
inline G4PrimaryParticle* GetPrimary(G4int i=0) const
{
if( i == 0 )
{ return theParticle; }
else if( i > 0 && i < numberOfParticle )
{
G4PrimaryParticle* particle = theParticle;
for( int j=0; j<i; j++ )
{
if( particle == NULL ) return NULL;
particle = particle->GetNext();
}
return particle;
}
else
{ return NULL; }
}
inline void SetNext(G4PrimaryVertex* nv)
{
if(nextVertex == NULL)
{ nextVertex = nv; }
else
{ nextVertex->SetNext(nv); }
}
inline G4PrimaryVertex* GetNext() const
{ return nextVertex; }
};
extern G4Allocator<G4PrimaryVertex> aPrimaryVertexAllocator;
inline void * G4PrimaryVertex::operator new(size_t)
{
void * aPrimaryVertex;
aPrimaryVertex = (void *) aPrimaryVertexAllocator.MallocSingle();
return aPrimaryVertex;
}
inline void G4PrimaryVertex::operator delete(void * aPrimaryVertex)
{
aPrimaryVertexAllocator.FreeSingle((G4PrimaryVertex *) aPrimaryVertex);
}
#endif
+97
View File
@@ -0,0 +1,97 @@
// This code implementation is the intellectual property of
// the RD44 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: G4StackManager.hh,v 2.1 1998/07/12 02:53:54 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#ifndef G4StackManager_h
#define G4StackManager_h 1
#include "G4UserStackingAction.hh"
#include "G4StackedTrack.hh"
#include "G4TrackStack.hh"
#include "G4ClassificationOfNewTrack.hh"
#include "G4Track.hh"
#include "G4TrackStatus.hh"
#include "globals.hh"
class G4StackingMessenger;
class G4StackManager
{
public:
G4StackManager();
~G4StackManager();
private:
const G4StackManager & operator=
(const G4StackManager &right);
int operator==(const G4StackManager &right) const;
int operator!=(const G4StackManager &right) const;
public:
G4int PushOneTrack(G4Track *newTrack);
G4Track * PopNextTrack();
G4int PrepareNewEvent();
void ReClassify();
private:
G4UserStackingAction * userStackingAction;
int verboseLevel;
G4TrackStack * urgentStack;
G4TrackStack * waitingStack;
G4TrackStack * postponeStack;
G4StackingMessenger* theMessenger;
public:
inline void clear()
{
ClearUrgentStack();
ClearWaitingStack();
};
inline void ClearUrgentStack()
{ urgentStack->clear(); };
inline void ClearWaitingStack()
{ waitingStack->clear(); };
inline void ClearPostponeStack()
{ postponeStack->clear(); };
inline G4int GetNTotalTrack() const
{ return urgentStack->GetNTrack()
+ waitingStack->GetNTrack()
+ postponeStack->GetNTrack(); };
inline G4int GetNUrgentTrack() const
{ return urgentStack->GetNTrack(); };
inline G4int GetNWaitingTrack() const
{ return waitingStack->GetNTrack(); };
inline G4int GetNPostponedTrack() const
{ return postponeStack->GetNTrack(); };
inline void SetVerboseLevel( int const value )
{ verboseLevel = value; };
inline void SetUserStackingAction(G4UserStackingAction* value)
{
if (userStackingAction) delete userStackingAction;
userStackingAction = value;
userStackingAction->SetStackManager(this);
};
private:
inline G4ClassificationOfNewTrack
DefaultClassification(G4Track *aTrack)
{
G4ClassificationOfNewTrack classification = fUrgent;
if( aTrack->GetTrackStatus() == fPostponeToNextEvent )
{ classification = fPostpone; }
return classification;
};
};
#endif
+76
View File
@@ -0,0 +1,76 @@
// This code implementation is the intellectual property of
// the RD44 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: G4StackedTrack.hh,v 2.1 1998/07/12 02:53:54 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 02/Feb/96 M.Asai
//
#ifndef G4StackedTrack_h
#define G4StackedTrack_h 1
#include "G4Track.hh"
#include "globals.hh"
#include "G4Allocator.hh"
class G4StackedTrack
{
public:
inline void *operator new(size_t);
inline void operator delete(void *aStackedTrack);
G4StackedTrack();
G4StackedTrack(G4Track * aTrack);
~G4StackedTrack();
const G4StackedTrack & operator=(const G4StackedTrack &right);
int operator==(const G4StackedTrack &right) const;
int operator!=(const G4StackedTrack &right) const;
private:
G4double priorityWeight;
G4Track *track;
G4StackedTrack * previousStackedTrack;
G4StackedTrack * nextStackedTrack;
public:
inline G4double GetPriorityWeight() const
{ return priorityWeight; };
inline void SetPriorityWeight(const G4double value)
{ priorityWeight = value; };
inline G4Track * GetTrack() const
{ return track; };
inline G4StackedTrack * GetPrevious() const
{ return previousStackedTrack; };
inline G4StackedTrack * GetNext() const
{ return nextStackedTrack; };
inline void SetPrevious(G4StackedTrack * value)
{ previousStackedTrack = value; };
inline void SetNext(G4StackedTrack * value)
{ nextStackedTrack = value; };
};
extern G4Allocator<G4StackedTrack> aStackedTrackAllocator;
inline void * G4StackedTrack::operator new(size_t)
{
void * aStackedTrack;
aStackedTrack = (void *) aStackedTrackAllocator.MallocSingle();
return aStackedTrack;
}
inline void G4StackedTrack::operator delete(void * aStackedTrack)
{
aStackedTrackAllocator.FreeSingle((G4StackedTrack *) aStackedTrack);
}
#endif
@@ -0,0 +1,35 @@
// This code implementation is the intellectual property of
// the RD44 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: G4StackingMessenger.hh,v 2.2 1998/07/12 03:42:17 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4StackingMessenger_h
#define G4StackingMessenger_h 1
#include "G4UImessenger.hh"
class G4StackManager;
class G4UIdirectory;
class G4UIcmdWithoutParameter;
class G4UIcmdWithAnInteger;
class G4StackingMessenger: public G4UImessenger
{
public:
G4StackingMessenger(G4StackManager* fCont);
~G4StackingMessenger();
void SetNewValue(G4UIcommand * command,G4String newValues);
private:
G4StackManager * fContainer;
G4UIdirectory* stackDir;
G4UIcmdWithoutParameter* statusCmd;
G4UIcmdWithAnInteger* clearCmd;
};
#endif
+52
View File
@@ -0,0 +1,52 @@
// This code implementation is the intellectual property of
// the RD44 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: G4TrackStack.hh,v 2.1 1998/07/12 02:53:55 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#ifndef G4TrackStack_h
#define G4TrackStack_h 1
#include "G4StackedTrack.hh"
#include "globals.hh"
class G4TrackStack
{
public:
G4TrackStack();
~G4TrackStack();
private:
const G4TrackStack & operator=
(const G4TrackStack &right);
int operator==(const G4TrackStack &right) const;
int operator!=(const G4TrackStack &right) const;
public:
void PushToStack(G4StackedTrack * aStackedTrack);
G4StackedTrack * PopFromStack();
void GrabFromStack(G4StackedTrack * aStackedTrack);
void clear();
void TransferTo(G4TrackStack * aStack);
private:
G4int n_stackedTrack;
G4StackedTrack * firstStackedTrack;
G4StackedTrack * lastStackedTrack;
public:
inline G4int GetNTrack() const
{ return n_stackedTrack; };
};
#endif
@@ -0,0 +1,27 @@
// This code implementation is the intellectual property of
// the RD44 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: G4TrajectoryContainer.hh,v 2.0 1998/07/02 16:53:34 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// G4TrajectoryContainer
//
#ifndef G4TrajectoryContainer_h
#define G4TrajectoryContainer_h 1
// TrackManagement
#include "G4Trajectory.hh"
// RWTPtrOrderedVector
#include <rw/tpordvec.h>
typedef RWTPtrOrderedVector<G4Trajectory> G4TrajectoryContainer;
#endif
+33
View File
@@ -0,0 +1,33 @@
// This code implementation is the intellectual property of
// the RD44 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: G4UserEventAction.hh,v 2.1 1998/07/12 02:53:56 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
#ifndef G4UserEventAction_h
#define G4UserEventAction_h 1
class G4EventManager;
class G4UserEventAction
{
public:
virtual ~G4UserEventAction()
{;}
inline void SetEventManager(G4EventManager* value)
{ fpEventManager = value; };
virtual void BeginOfEventAction();
virtual void EndOfEventAction();
protected:
G4EventManager* fpEventManager;
};
#endif
@@ -0,0 +1,104 @@
// This code implementation is the intellectual property of
// the RD44 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: G4UserStackingAction.hh,v 2.1 1998/07/12 02:53:56 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#ifndef G4UserStackingAction_h
#define G4UserStackingAction_h 1
class G4StackManager;
class G4Track;
#include "G4ClassificationOfNewTrack.hh"
class G4UserStackingAction
{
public:
G4UserStackingAction();
virtual ~G4UserStackingAction();
protected:
G4StackManager * stackManager;
public:
inline void SetStackManager(G4StackManager * value)
{ stackManager = value; };
public:
//---------------------------------------------------------------
// vitual methods to be implemented by user
//---------------------------------------------------------------
//
virtual G4ClassificationOfNewTrack
ClassifyNewTrack(G4Track *const aTrack);
//
// Reply G4ClassificationOfNewTrack determined by the
// newly coming G4Track.
//
// enum G4ClassificationOfNewTrack
// {
// fUrgent, // put into the urgent stack
// fWaiting, // put into the waiting stack
// fPostpone, // postpone to the next event
// fKill // kill without stacking
// };
//
// The parent_ID of the track indicates the origin of it.
//
// G4int parent_ID = aTrack->get_parentID();
//
// parent_ID = 0 : primary particle
// > 0 : secondary particle
// < 0 : postponed from the previous event
//
//---------------------------------------------------------------
//
virtual void NewStage();
//
// This method is called by G4StackManager when the urgentStack
// becomes empty and contents in the waitingStack are transtered
// to the urgentStack.
// Note that this method is not called at the begining of each
// event, but "PrepareNewEvent" is called.
//
// In case re-classification of the stacked tracks is needed,
// use the following method to request to G4StackManager.
//
// stackManager->ReClassify();
//
// All of the stacked tracks in the waitingStack will be re-classified
// by "ClassifyNewTrack" method.
// To abort current event, use the following method.
//
// stackManager->clear();
//
// Note that this way is valid and safe only for the case it is called
// from this user class. The more global way of event abortion is
//
// G4UImanager * UImanager = G4UImanager::GetUIpointer();
// UImanager->ApplyCommand("/event/abort");
//
//---------------------------------------------------------------
//
virtual void PrepareNewEvent();
//
// This method is called by G4StackManager at the begining of
// each event.
// Be careful that the urgentStack and the waitingStack of
// G4StackManager are empty at this moment, because this method
// is called before accepting primary particles. Also, note that
// the postponeStack of G4StackManager may have some postponed
// tracks.
//
//---------------------------------------------------------------
};
#endif
@@ -0,0 +1,27 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VPrimaryGenerator.hh,v 2.1 1998/07/12 02:53:57 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4VPrimaryGenerator_h
#define G4VPrimaryGenerator_h 1
class G4Event;
class G4VPrimaryGenerator
{
public:
G4VPrimaryGenerator();
virtual ~G4VPrimaryGenerator();
virtual void GeneratePrimaryVertex(G4Event* evt) = 0;
};
#endif
+12
View File
@@ -0,0 +1,12 @@
// This code implementation is the intellectual property of
// the RD44 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: eventgendefs.hh,v 2.0 1998/07/02 16:53:21 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef EventGenerator_DEBUG
#define EventGenerator_DEBUG
+19
View File
@@ -0,0 +1,19 @@
// This code implementation is the intellectual property of
// the RD44 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: evmandefs.hh,v 2.0 1998/07/02 16:53:42 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
///#define G4EVENTMANAGER_DEBUG 1
///#define G4EVENTMANAGER_DEBUG_0 1
#ifdef G4EVENTMANAGER_DEBUG
#define G4EVENTMANAGER_DEBUG_0 1
#endif
#include "trajectoryControl.hh"
+17
View File
@@ -0,0 +1,17 @@
// This code implementation is the intellectual property of
// the RD44 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: trajectoryControl.hh,v 2.1 1998/10/10 10:51:20 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
////#define G4_STORE_TRAJECTORY 1
//#ifdef G4VISUALIZE
//#ifndef G4_STORE_TRAJECTORY
//#define G4_STORE_TRAJECTORY 1
//#endif
//#endif
+1
View File
@@ -0,0 +1 @@
*.d
+60
View File
@@ -0,0 +1,60 @@
// This code implementation is the intellectual property of
// the RD44 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: G4EvManMessenger.cc,v 2.2 1998/07/12 03:42:25 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// --------------------------------------------------------------------
#include "G4EvManMessenger.hh"
#include "G4EventManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
G4EvManMessenger::G4EvManMessenger(G4EventManager * fEvMan)
:fEvManager(fEvMan)
{
eventDirectory = new G4UIdirectory("/event/");
eventDirectory->SetGuidance("EventManager control commands.");
abortCmd = new G4UIcmdWithoutParameter("/event/abort",this);
abortCmd->SetGuidance("Abort current event.");
abortCmd->AvailableForStates(EventProc);
verboseCmd = new G4UIcmdWithAnInteger("/event/verbose",this);
verboseCmd->SetGuidance("Set Verbose level of event management category.");
verboseCmd->SetGuidance(" 0 : Silent");
verboseCmd->SetGuidance(" 1 : Stacking information");
verboseCmd->SetGuidance(" 2 : More...");
verboseCmd->SetParameterName("level",false);
verboseCmd->SetRange("level>=0");
}
G4EvManMessenger::~G4EvManMessenger()
{
delete abortCmd;
delete verboseCmd;
delete eventDirectory;
}
void G4EvManMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command == verboseCmd )
{ fEvManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues)); }
if( command == abortCmd )
{ fEvManager->AbortCurrentEvent(); }
}
G4String G4EvManMessenger::GetCurrentValue(G4UIcommand * command)
{
G4String cv;
if( command == verboseCmd )
{ cv = verboseCmd->ConvertToString(fEvManager->GetVerboseLevel()); }
return cv;
}
+95
View File
@@ -0,0 +1,95 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Event.cc,v 2.3 1998/09/21 02:02:09 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
// G4Event
#include "G4Event.hh"
#include "G4VVisManager.hh"
//#include "G4HCofThisEvent.hh"
//#include "G4DCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4VDigiCollection.hh"
#include "G4ios.hh"
G4Allocator<G4Event> anEventAllocator;
G4Event::G4Event()
:eventID(0),
thePrimaryVertex(NULL),numberOfPrimaryVertex(0),
DC(NULL),HC(NULL),trajectoryContainer(NULL)
{;}
G4Event::G4Event(G4int evID)
:eventID(evID),
thePrimaryVertex(NULL),numberOfPrimaryVertex(0),
DC(NULL),HC(NULL),trajectoryContainer(NULL)
{;}
G4Event::~G4Event()
{
if(thePrimaryVertex) delete thePrimaryVertex;
if(HC) delete HC;
if(DC) delete DC;
if(trajectoryContainer)
{
trajectoryContainer->clearAndDestroy();
delete trajectoryContainer;
}
}
int G4Event::operator==(const G4Event &right) const
{
return ( eventID == right.eventID );
}
int G4Event::operator!=(const G4Event &right) const
{
return ( eventID != right.eventID );
}
void G4Event::Print() const
{
G4cout << "G4Event " << eventID << endl;
}
void G4Event::Draw() const
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(!pVVisManager) return;
if(trajectoryContainer)
{
G4int n_traj = trajectoryContainer->entries();
for(int i=0;i<n_traj;i++)
{ (*trajectoryContainer)[i]->DrawTrajectory(); }
}
if(HC)
{
G4int n_HC = HC->GetCapacity();
for(int j=0;j<n_HC;j++)
{
G4VHitsCollection * VHC = HC->GetHC(j);
if(VHC) VHC->DrawAllHits();
}
}
if(DC)
{
G4int n_DC = DC->GetCapacity();
for(int j=0;j<n_DC;j++)
{
G4VDigiCollection * VDC = DC->GetDC(j);
if(VDC) VDC->DrawAllDigi();
}
}
}
+219
View File
@@ -0,0 +1,219 @@
// This code implementation is the intellectual property of
// the RD44 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: G4EventManager.cc,v 2.2 1998/07/13 16:50:12 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
#include "G4EventManager.hh"
#include "G4ios.hh"
#include "G4EvManMessenger.hh"
#include "G4Event.hh"
#include "G4UserEventAction.hh"
#include "G4UserStackingAction.hh"
#include "G4SDManager.hh"
G4EventManager::G4EventManager()
:verboseLevel(0),trajectoryContainer(NULL),userEventAction(NULL),
tracking(false),currentEvent(NULL)
{
trackManager = new G4TrackingManager;
transformer = new G4PrimaryTransformer;
trackContainer = new G4StackManager;
theMessenger = new G4EvManMessenger(this);
sdManager = G4SDManager::GetSDMpointerIfExist();
}
// private -> never called
G4EventManager::G4EventManager(const G4EventManager &right) { }
G4EventManager& G4EventManager::operator=(const G4EventManager& right)
{
return *this;
}
G4EventManager::~G4EventManager()
{
delete trackContainer;
delete transformer;
delete trackManager;
delete theMessenger;
if (userEventAction) delete userEventAction;
}
/*
const G4EventManager & G4EventManager::operator=(const G4EventManager &right)
{ }
int G4EventManager::operator==(const G4EventManager &right) const { }
int G4EventManager::operator!=(const G4EventManager &right) const { }
*/
void G4EventManager::ProcessOneEvent(G4Event* anEvent)
{
currentEvent = anEvent;
G4Track * track;
G4TrackStatus istop;
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << "=====================================" << endl;
G4cout << " G4EventManager::ProcessOneEvent() " << endl;
G4cout << "=====================================" << endl;
}
#endif
trackIDCounter = trackContainer->PrepareNewEvent();
#ifdef G4_STORE_TRAJECTORY
trajectoryContainer = NULL;
#endif
sdManager = G4SDManager::GetSDMpointerIfExist();
if(sdManager)
{ currentEvent->SetHCofThisEvent(sdManager->PrepareNewEvent()); }
if(userEventAction) userEventAction->BeginOfEventAction();
#ifdef G4VERBOSE
if ( verboseLevel > 1 )
{
G4cout << currentEvent->GetNumberOfPrimaryVertex()
<< " vertices passed from G4Event." << endl;
}
#endif
StackTracks( transformer->GimmePrimaries( currentEvent ) );
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << trackContainer->GetNTotalTrack() << " primaries "
<< "are passed from G4EventTransformer." << endl;
G4cout << "!!!!!!! Now start processing an event !!!!!!!" << endl;
}
#endif
while( ( track = trackContainer->PopNextTrack() ) != NULL )
{
#ifdef G4VERBOSE
if ( verboseLevel > 1 )
{
G4cout << "Track " << track << " (trackID " << track->GetTrackID()
<< ", parentID " << track->GetParentID()
<< ") is passed to G4TrackingManager." << endl;
}
#endif
tracking = true;
trackManager->ProcessOneTrack( track );
istop = track->GetTrackStatus();
tracking = false;
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << "Track (trackID " << track->GetTrackID()
<< ", parentID " << track->GetParentID()
<< ") is processed with stopping code " << istop << endl;
}
#endif
#ifdef G4_STORE_TRAJECTORY
G4Trajectory * aTrajectory = trackManager->GimmeTrajectory();
if(aTrajectory)
{
if(!trajectoryContainer)
{ trajectoryContainer = new G4TrajectoryContainer; }
trajectoryContainer->insert(aTrajectory);
}
#endif
G4TrackVector * secondaries = trackManager->GimmeSecondaries();
switch (istop)
{
case fStopButAlive:
case fSuspend:
case fPostponeToNextEvent:
trackContainer->PushOneTrack( track );
StackTracks( secondaries );
break;
case fStopAndKill:
StackTracks( secondaries );
delete track;
break;
case fAlive:
G4cout << "Illeagal TrackStatus returned from G4TrackingManager!"
<< endl;
case fKillTrackAndSecondaries:
if( secondaries ) secondaries->clearAndDestroy();
delete track;
break;
}
}
#ifdef G4VERBOSE
if ( verboseLevel > 0 )
{
G4cout << "NULL returned from G4StackManager." << endl;
G4cout << "Terminate current event processing." << endl;
}
#endif
if(sdManager)
{ sdManager->TerminateCurrentEvent(currentEvent->GetHCofThisEvent()); }
#ifdef G4_STORE_TRAJECTORY
currentEvent->SetTrajectoryContainer(trajectoryContainer);
#endif
if(userEventAction) userEventAction->EndOfEventAction();
currentEvent = NULL;
}
void G4EventManager::StackTracks(G4TrackVector *trackVector)
{
G4Track * newTrack;
if( trackVector )
{
size_t n_passedTrack = trackVector->entries();
if( n_passedTrack == 0 ) return;
for( size_t i = 0; i < n_passedTrack; i++ )
{
newTrack = (*trackVector)[ i ];
trackIDCounter++;
newTrack->SetTrackID( trackIDCounter );
trackContainer->PushOneTrack( newTrack );
#ifdef G4VERBOSE
if ( verboseLevel > 1 )
{
G4cout << "A new track " << newTrack
<< " (trackID " << newTrack->GetTrackID()
<< ", parentID " << newTrack->GetParentID()
<< ") is passed to G4StackManager." << endl;
}
#endif
}
trackVector->clear();
}
}
void G4EventManager::SetUserAction(G4UserEventAction* userAction)
{
if (userEventAction) delete userEventAction;
userEventAction = userAction;
userEventAction->SetEventManager(this);
}
+128
View File
@@ -0,0 +1,128 @@
// This code implementation is the intellectual property of
// the RD44 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: G4HEPEvtInterface.cc,v 2.3 1998/07/18 10:34:11 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// --------------------------------------------------------------------
#ifdef WIN32
# include <Strstrea.h>
#else
# include <strstream.h>
#endif
#include "G4ios.hh"
#include "G4HEPEvtInterface.hh"
#include "G4PrimaryVertex.hh"
#include "G4PrimaryParticle.hh"
#include "G4HEPEvtParticle.hh"
#include "G4Event.hh"
G4HEPEvtInterface::G4HEPEvtInterface(char* evfile)
{
inputFile.open(evfile);
fileName = evfile;
}
G4HEPEvtInterface::G4HEPEvtInterface(G4String evfile)
{
const char* fn = evfile.data();
inputFile.open((char*)fn);
fileName = evfile;
}
G4HEPEvtInterface::~G4HEPEvtInterface()
{;}
void G4HEPEvtInterface::GeneratePrimaryVertex(G4Event* evt)
{
int NHEP; // number of entries
inputFile >> NHEP;
if( inputFile.eof() )
{
G4Exception("End-Of-File : HEPEvt input file");
return;
}
for( int IHEP=0; IHEP<NHEP; IHEP++ )
{
G4int ISTHEP; // status code
G4int IDHEP; // PDG code
G4int JDAHEP1; // first daughter
G4int JDAHEP2; // last daughter
G4double PHEP1; // px in GeV
G4double PHEP2; // py in GeV
G4double PHEP3; // pz in GeV
G4double PHEP5; // mass in GeV
inputFile >> ISTHEP >> IDHEP >> JDAHEP1 >> JDAHEP2
>> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5;
// create G4PrimaryParticle object
G4PrimaryParticle* particle
= new G4PrimaryParticle( IDHEP, PHEP1*GeV, PHEP2*GeV, PHEP3*GeV );
particle->SetMass( PHEP5*GeV );
// create G4HEPEvtParticle object
G4HEPEvtParticle* hepParticle
= new G4HEPEvtParticle( particle, ISTHEP, JDAHEP1, JDAHEP2 );
// Store
HPlist.insert( hepParticle );
}
// check if there is at least one particle
if( HPlist.entries() == 0 ) return;
// make connection between daughter particles decayed from
// the same mother
for( int i=0; i<HPlist.entries(); i++ )
{
if( HPlist(i)->GetJDAHEP1() > 0 ) // it has daughters
{
int jda1 = HPlist(i)->GetJDAHEP1()-1; // FORTRAN index starts from 1
int jda2 = HPlist(i)->GetJDAHEP2()-1; // but C++ starts from 0.
G4PrimaryParticle* mother = HPlist(i)->GetTheParticle();
for( int j=jda1; j<=jda2; j++ )
{
G4PrimaryParticle* daughter = HPlist(j)->GetTheParticle();
if(HPlist(j)->GetISTHEP()>0)
{
mother->SetDaughter( daughter );
HPlist(j)->Done();
}
}
}
}
// create G4PrimaryVertex object
G4double x0 = 0.; // vertex point X
G4double y0 = 0.; // vertex point Y
G4double z0 = 0.; // vertex point Z
G4double t0 = 0.; // vertex time
G4PrimaryVertex* vertex = new G4PrimaryVertex(x0,y0,z0,t0);
// put initial particles to the vertex
for( int ii=0; ii<HPlist.entries(); ii++ )
{
if( HPlist(ii)->GetISTHEP() > 0 ) // ISTHEP of daughters had been
// set to negative
{
G4PrimaryParticle* initialParticle = HPlist(ii)->GetTheParticle();
vertex->SetPrimary( initialParticle );
}
}
// clear G4HEPEvtParticles
HPlist.clearAndDestroy();
// Put the vertex to G4Event object
evt->AddPrimaryVertex( vertex );
}
+39
View File
@@ -0,0 +1,39 @@
// This code implementation is the intellectual property of
// the RD44 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: G4HEPEvtParticle.cc,v 2.0 1998/07/02 16:53:56 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4HEPEvtParticle.hh"
G4Allocator<G4HEPEvtParticle> aHEPEvtParticleAllocator;
G4HEPEvtParticle::G4HEPEvtParticle()
{;}
G4HEPEvtParticle::G4HEPEvtParticle(G4PrimaryParticle* pp,
G4int isthep, G4int jdahep1, G4int jdahep2)
:theParticle(pp),ISTHEP(isthep),JDAHEP1(jdahep1),JDAHEP2(jdahep2)
{;}
G4HEPEvtParticle::~G4HEPEvtParticle()
{;}
const G4HEPEvtParticle &
G4HEPEvtParticle::operator=(const G4HEPEvtParticle &right)
{ return *this; }
int G4HEPEvtParticle::operator==(const G4HEPEvtParticle &right) const
{ return false; }
int G4HEPEvtParticle::operator!=(const G4HEPEvtParticle &right) const
{ return true; }
+113
View File
@@ -0,0 +1,113 @@
// This code implementation is the intellectual property of
// the RD44 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: G4ParticleGun.cc,v 2.2 1998/07/13 16:50:14 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// G4ParticleGun
#include "G4ParticleGun.hh"
#include "G4PrimaryParticle.hh"
#include "G4ParticleGunMessenger.hh"
#include "G4Event.hh"
#include "G4ios.hh"
G4ParticleGun::G4ParticleGun()
{
SetInitialValues();
}
G4ParticleGun::G4ParticleGun(G4int numberofparticles)
{
SetInitialValues();
NumberOfParticlesToBeGenerated = numberofparticles;
}
G4ParticleGun::G4ParticleGun
(G4ParticleDefinition * particleDef, G4int numberofparticles)
{
SetInitialValues();
NumberOfParticlesToBeGenerated = numberofparticles;
particle_definition = particleDef;
}
void G4ParticleGun::SetInitialValues()
{
NumberOfParticlesToBeGenerated = 1;
particle_definition = NULL;
G4ThreeVector zero;
particle_momentum_direction = (G4ParticleMomentum)zero;
particle_energy = 0.0;
particle_position = zero;
particle_time = 0.0;
particle_polarization = zero;
theMessenger = new G4ParticleGunMessenger(this);
}
G4ParticleGun::~G4ParticleGun()
{
delete theMessenger;
}
void G4ParticleGun::SetParticleMomentum(G4ParticleMomentum aMomentum)
{
if(particle_definition==NULL)
{
G4cout <<"Particle Definition not defined yet for G4ParticleGun"<< endl;
G4cout <<"Zero Mass is assumed"<<endl;
particle_momentum_direction = aMomentum.unit();
particle_energy = aMomentum.mag();
}
else
{
G4double mass = particle_definition->GetPDGMass();
G4double p = aMomentum.mag();
particle_momentum_direction = aMomentum.unit();
if ((particle_energy>0.0)&&(abs(particle_energy+mass-sqrt(p*p+mass*mass))>keV))
{
G4cout << "G4ParticleGun::" << particle_definition->GetParticleName() << endl;
G4cout << " KineticEnergy and Momentum could be inconsistent" << endl;
G4cout << " (Momentum:" << p/GeV << " GeV/c";
G4cout << " Mass:" << mass/GeV << " GeV/c/c)" << endl;
G4cout << " KineticEnergy is overwritten!! ";
G4cout << particle_energy/GeV << "->";
G4cout << (sqrt(p*p+mass*mass)-mass)/GeV << "GeV" << endl;
}
particle_energy = sqrt(p*p+mass*mass)-mass;
}
}
void G4ParticleGun::GeneratePrimaryVertex(G4Event* evt)
{
if(particle_definition==NULL) return;
// create a new vertex
G4PrimaryVertex* vertex =
new G4PrimaryVertex(particle_position,particle_time);
// create new primaries and set them to the vertex
G4double mass = particle_definition->GetPDGMass();
G4double energy = particle_energy + mass;
G4double pmom = sqrt(energy*energy-mass*mass);
G4double px = pmom*particle_momentum_direction.x();
G4double py = pmom*particle_momentum_direction.y();
G4double pz = pmom*particle_momentum_direction.z();
for( int i=0; i<NumberOfParticlesToBeGenerated; i++ )
{
G4PrimaryParticle* particle =
new G4PrimaryParticle(particle_definition,px,py,pz);
particle->SetMass( mass );
particle->SetPolarization(particle_polarization.x(),
particle_polarization.y(),
particle_polarization.z());
vertex->SetPrimary( particle );
}
evt->AddPrimaryVertex( vertex );
}
+155
View File
@@ -0,0 +1,155 @@
// This code implementation is the intellectual property of
// the RD44 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: G4ParticleGunMessenger.cc,v 2.4 1998/10/01 16:58:31 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4ParticleGunMessenger.hh"
#include "G4ParticleGun.hh"
#include "G4Geantino.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleTable.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4ios.hh"
G4ParticleGunMessenger::G4ParticleGunMessenger(G4ParticleGun * fPtclGun)
:fParticleGun(fPtclGun)
{
particleTable = G4ParticleTable::GetParticleTable();
gunDirectory = new G4UIdirectory("/gun/");
gunDirectory->SetGuidance("Particle Gun control commands.");
listCmd = new G4UIcmdWithoutParameter("/gun/List",this);
listCmd->SetGuidance("List available particles.");
listCmd->SetGuidance(" Invoke G4ParticleTable.");
particleCmd = new G4UIcmdWithAString("/gun/particle",this);
particleCmd->SetGuidance("Set particle to be generated.");
particleCmd->SetGuidance(" (geantino is default)");
particleCmd->SetParameterName("particleName",true);
particleCmd->SetDefaultValue("geantino");
G4String candidateList;
G4int nPtcl = particleTable->entries();
for(G4int i=0;i<nPtcl;i++)
{
candidateList += particleTable->GetParticleName(i);
candidateList += " ";
}
particleCmd->SetCandidates(candidateList);
directionCmd = new G4UIcmdWith3Vector("/gun/direction",this);
directionCmd->SetGuidance("Set momentum direction.");
directionCmd->SetGuidance("Direction needs not to be a unit vector.");
directionCmd->SetParameterName("Px","Py","Pz",true,true);
directionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
energyCmd = new G4UIcmdWithADoubleAndUnit("/gun/energy",this);
energyCmd->SetGuidance("Set kinetic energy.");
energyCmd->SetParameterName("Energy",true,true);
energyCmd->SetDefaultUnit("GeV");
//energyCmd->SetUnitCategory("Energy");
//energyCmd->SetUnitCandidates("eV keV MeV GeV TeV");
positionCmd = new G4UIcmdWith3VectorAndUnit("/gun/position",this);
positionCmd->SetGuidance("Set starting position of the particle.");
positionCmd->SetParameterName("X","Y","Z",true,true);
positionCmd->SetDefaultUnit("cm");
//positionCmd->SetUnitCategory("Length");
//positionCmd->SetUnitCandidates("microm mm cm m km");
timeCmd = new G4UIcmdWithADoubleAndUnit("/gun/time",this);
timeCmd->SetGuidance("Set initial time of the particle.");
timeCmd->SetParameterName("t0",true,true);
timeCmd->SetDefaultUnit("ns");
//timeCmd->SetUnitCategory("Time");
//timeCmd->SetUnitCandidates("ns ms s");
polCmd = new G4UIcmdWith3Vector("/gun/polarization",this);
polCmd->SetGuidance("Set polarization.");
polCmd->SetParameterName("Px","Py","Pz",true,true);
polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
numberCmd = new G4UIcmdWithAnInteger("/gun/number",this);
numberCmd->SetGuidance("Set number of particles to be generated.");
numberCmd->SetParameterName("N",true,true);
numberCmd->SetRange("N>0");
// set initial value to G4ParticleGun
fParticleGun->SetParticleDefinition( G4Geantino::Geantino() );
fParticleGun->SetParticleMomentumDirection( G4ThreeVector(1.0,0.0,0.0) );
fParticleGun->SetParticleEnergy( 1.0*GeV );
fParticleGun->SetParticlePosition(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm));
fParticleGun->SetParticleTime( 0.0*ns );
}
G4ParticleGunMessenger::~G4ParticleGunMessenger()
{
delete listCmd;
delete particleCmd;
delete directionCmd;
delete energyCmd;
delete positionCmd;
delete timeCmd;
delete polCmd;
delete numberCmd;
delete gunDirectory;
}
void G4ParticleGunMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command==listCmd )
{ particleTable->DumpTable(); }
else if( command==particleCmd )
{
G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
if(pd != NULL)
{ fParticleGun->SetParticleDefinition( pd ); }
}
else if( command==directionCmd )
{ fParticleGun->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues)); }
else if( command==energyCmd )
{ fParticleGun->SetParticleEnergy(energyCmd->GetNewDoubleValue(newValues)); }
else if( command==positionCmd )
{ fParticleGun->SetParticlePosition(positionCmd->GetNew3VectorValue(newValues)); }
else if( command==timeCmd )
{ fParticleGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues)); }
else if( command==polCmd )
{ fParticleGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues)); }
else if( command==numberCmd )
{ fParticleGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues)); }
}
G4String G4ParticleGunMessenger::GetCurrentValue(G4UIcommand * command)
{
G4String cv;
if( command==directionCmd )
{ cv = directionCmd->ConvertToString(fParticleGun->GetParticleMomentumDirection()); }
else if( command==particleCmd )
{ cv = fParticleGun->GetParticleDefinition()->GetParticleName(); }
else if( command==energyCmd )
{ cv = energyCmd->ConvertToString(fParticleGun->GetParticleEnergy(),"GeV"); }
else if( command==positionCmd )
{ cv = positionCmd->ConvertToString(fParticleGun->GetParticlePosition(),"cm"); }
else if( command==timeCmd )
{ cv = timeCmd->ConvertToString(fParticleGun->GetParticleTime(),"ns"); }
else if( command==polCmd )
{ cv = polCmd->ConvertToString(fParticleGun->GetParticlePolarization()); }
else if( command==numberCmd )
{ cv = numberCmd->ConvertToString(fParticleGun->GetNumberOfParticles()); }
return cv;
}
+99
View File
@@ -0,0 +1,99 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PrimaryParticle.cc,v 2.3 1998/10/10 10:51:24 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4PrimaryParticle.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4ios.hh"
G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator;
G4PrimaryParticle::G4PrimaryParticle()
:PDGcode(0),G4code(NULL),Px(0.),Py(0.),Pz(0.),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{;}
G4PrimaryParticle::G4PrimaryParticle(G4int Pcode)
:PDGcode(Pcode),Px(0.),Py(0.),Pz(0.),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ G4code = G4ParticleTable::GetParticleTable()->FindParticle(Pcode); }
G4PrimaryParticle::G4PrimaryParticle(G4int Pcode,
G4double px,G4double py,G4double pz)
:PDGcode(Pcode),Px(px),Py(py),Pz(pz),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ G4code = G4ParticleTable::GetParticleTable()->FindParticle(Pcode); }
G4PrimaryParticle::G4PrimaryParticle(G4ParticleDefinition* Gcode)
:G4code(Gcode),Px(0.),Py(0.),Pz(0.),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ PDGcode = Gcode->GetPDGEncoding(); }
G4PrimaryParticle::G4PrimaryParticle(G4ParticleDefinition* Gcode,
G4double px,G4double py,G4double pz)
:G4code(Gcode),Px(px),Py(py),Pz(pz),
nextParticle(NULL),daughterParticle(NULL),trackID(-1),
mass(0.),polX(0.),polY(0.),polZ(0.)
{ PDGcode = Gcode->GetPDGEncoding(); }
G4PrimaryParticle::~G4PrimaryParticle()
{
if(nextParticle != NULL)
{ delete nextParticle; }
if(daughterParticle != NULL)
{ delete daughterParticle; }
}
void G4PrimaryParticle::SetPDGcode(G4int Pcode)
{
PDGcode = Pcode;
G4code = G4ParticleTable::GetParticleTable()->FindParticle(Pcode);
}
void G4PrimaryParticle::SetG4code(G4ParticleDefinition* Gcode)
{
G4code = Gcode;
PDGcode = Gcode->GetPDGEncoding();
}
const G4PrimaryParticle &
G4PrimaryParticle::operator=(const G4PrimaryParticle &right)
{ return *this; }
int G4PrimaryParticle::operator==(const G4PrimaryParticle &right) const
{ return false; }
int G4PrimaryParticle::operator!=(const G4PrimaryParticle &right) const
{ return true; }
void G4PrimaryParticle::Print() const
{
G4cout << "==== PDGcode " << PDGcode << " Particle name ";
if(G4code != NULL)
{ G4cout << G4code->GetParticleName() << endl; }
else
{ G4cout << "is not defined in G4." << endl; }
G4cout << " Momentum ( " << Px << ", " << Py << ", " << Pz << " )" << endl;
G4cout << " Polarization ( " << polX << ", " << polY << ", "
<< polZ << " )" << endl;
if(daughterParticle != NULL)
{
G4cout << ">>>> Daughters" << endl;
daughterParticle->Print();
}
if(nextParticle != NULL)
{ nextParticle->Print(); }
else
{ G4cout << "<<<< End of link" << endl; }
}
+164
View File
@@ -0,0 +1,164 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PrimaryTransformer.cc,v 2.2 1998/10/10 10:51:25 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4PrimaryTransformer.hh"
#include "G4Event.hh"
#include "G4PrimaryVertex.hh"
#include "G4ParticleDefinition.hh"
#include "G4DynamicParticle.hh"
#include "G4Track.hh"
#include "G4ThreeVector.hh"
#include "G4DecayProducts.hh"
#include "G4ios.hh"
G4PrimaryTransformer::G4PrimaryTransformer()
:verboseLevel(0)
{
particleTable = G4ParticleTable::GetParticleTable();
}
G4PrimaryTransformer::~G4PrimaryTransformer()
{;}
G4TrackVector* G4PrimaryTransformer::GimmePrimaries(G4Event* anEvent)
{
TV.clearAndDestroy();
G4int n_vertex = anEvent->GetNumberOfPrimaryVertex();
if(n_vertex==0) return NULL;
for( int i=0; i<n_vertex; i++ )
{ GenerateTracks( anEvent->GetPrimaryVertex(i) ); }
return &TV;
}
void G4PrimaryTransformer::GenerateTracks(G4PrimaryVertex* primaryVertex)
{
G4double X0 = primaryVertex->GetX0();
G4double Y0 = primaryVertex->GetY0();
G4double Z0 = primaryVertex->GetZ0();
G4double T0 = primaryVertex->GetT0();
#ifdef G4VERBOSE
if(verboseLevel>1)
{
G4cout << "G4PrimaryTransformer::PrimaryVertex ("
<< X0 / mm << "(mm),"
<< Y0 / mm << "(mm),"
<< Z0 / mm << "(mm),"
<< T0 / nanosecond << "(nsec))" << endl;
}
#endif
G4PrimaryParticle* primaryParticle = primaryVertex->GetPrimary();
while( primaryParticle != NULL )
{
GenerateSingleTrack( primaryParticle, X0, Y0, Z0, T0 );
primaryParticle = primaryParticle->GetNext();
}
}
void G4PrimaryTransformer::GenerateSingleTrack
(G4PrimaryParticle* primaryParticle,
G4double x0,G4double y0,G4double z0,G4double t0)
{
G4ParticleDefinition* partDef = GetDefinition(primaryParticle);
if((!partDef)||partDef->IsShortLived())
// The particle is not defined in GEANT4, check daughters
{
#ifdef G4VERBOSE
if(verboseLevel>2)
{
G4cout << "Primary particle (PDGcode " << primaryParticle->GetPDGcode()
<< ") --- Ignored" << endl;
}
#endif
G4PrimaryParticle* daughter = primaryParticle->GetDaughter();
while(daughter)
{
GenerateSingleTrack(daughter,x0,y0,z0,t0);
daughter = daughter->GetNext();
}
}
// The particle is defined in GEANT4
else
{
// Create G4DynamicParticle object
#ifdef G4VERBOSE
if(verboseLevel>1)
{
G4cout << "Primary particle (" << partDef->GetParticleName()
<< ") --- Transfered with momentum " << primaryParticle->GetMomentum()
<< endl;
}
#endif
G4DynamicParticle* DP =
new G4DynamicParticle(partDef,primaryParticle->GetMomentum());
DP->SetPolarization(primaryParticle->GetPolX(),
primaryParticle->GetPolY(),
primaryParticle->GetPolZ());
// Set decay products to the DynamicParticle
SetDecayProducts( primaryParticle, DP );
// Create G4Track object
G4Track* track = new G4Track(DP,t0,G4ThreeVector(x0,y0,z0));
// Set parentID to 0 as a primary particle
track->SetParentID(0);
// Store it to G4TrackVector
TV.insert( track );
}
}
void G4PrimaryTransformer::SetDecayProducts
(G4PrimaryParticle* mother, G4DynamicParticle* motherDP)
{
G4PrimaryParticle* daughter = mother->GetDaughter();
if(!daughter) return;
G4DecayProducts* decayProducts = motherDP->GetPreAssignedDecayProducts();
if(!decayProducts)
{
decayProducts = new G4DecayProducts(*motherDP);
motherDP->SetPreAssignedDecayProducts(decayProducts);
}
while(daughter)
{
G4ParticleDefinition* partDef = GetDefinition(daughter);
if(!partDef)
{
#ifdef G4VERBOSE
if(verboseLevel>2)
{
G4cout << " >> Decay product (PDGcode " << daughter->GetPDGcode()
<< ") --- Ignored" << endl;
}
#endif
SetDecayProducts(daughter,motherDP);
}
else
{
#ifdef G4VERBOSE
if(verboseLevel>1)
{
G4cout << " >> Decay product (" << partDef->GetParticleName()
<< ") --- Attached with momentum " << daughter->GetMomentum()
<< endl;
}
#endif
G4DynamicParticle*DP
= new G4DynamicParticle(partDef,daughter->GetMomentum());
decayProducts->PushProducts(DP);
SetDecayProducts(daughter,DP);
}
daughter = daughter->GetNext();
}
}
+66
View File
@@ -0,0 +1,66 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PrimaryVertex.cc,v 2.4 1998/11/11 11:19:42 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4PrimaryVertex.hh"
#include "G4ios.hh"
G4Allocator<G4PrimaryVertex> aPrimaryVertexAllocator;
G4PrimaryVertex::G4PrimaryVertex()
:X0(0.),Y0(0.),Z0(0.),T0(0.),numberOfParticle(0),nextVertex(NULL),
theParticle(NULL),theTail(NULL)
{;}
G4PrimaryVertex::G4PrimaryVertex(
G4double x0,G4double y0,G4double z0,G4double t0)
:X0(x0),Y0(y0),Z0(z0),T0(t0),numberOfParticle(0),nextVertex(NULL),
theParticle(NULL),theTail(NULL)
{;}
G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector xyz0,G4double t0)
:T0(t0),numberOfParticle(0),nextVertex(NULL),
theParticle(NULL),theTail(NULL)
{
X0=xyz0.x();
Y0=xyz0.y();
Z0=xyz0.z();
}
G4PrimaryVertex::~G4PrimaryVertex()
{
if(theParticle != NULL)
{ delete theParticle; }
if(nextVertex != NULL)
{ delete nextVertex; }
}
const G4PrimaryVertex &
G4PrimaryVertex::operator=(const G4PrimaryVertex &right)
{ return *this; }
int G4PrimaryVertex::operator==(const G4PrimaryVertex &right) const
{ return false; }
int G4PrimaryVertex::operator!=(const G4PrimaryVertex &right) const
{ return true; }
void G4PrimaryVertex::Print() const
{
G4cout << "Vertex ( "
<< X0 << ", " << Y0 << ", " << Z0 << ", " << T0 << " )" << endl;
G4cout << "#### Primary particles" << endl;
G4PrimaryParticle* aPrim = theParticle;
if(aPrim != NULL)
{
aPrim->Print();
aPrim = aPrim->GetNext();
}
}
+224
View File
@@ -0,0 +1,224 @@
// This code implementation is the intellectual property of
// the RD44 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: G4StackManager.cc,v 2.2 1998/07/13 16:50:19 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#include "G4StackManager.hh"
#include "G4StackingMessenger.hh"
#include "evmandefs.hh"
#include "G4ios.hh"
G4StackManager::G4StackManager()
:verboseLevel(0),userStackingAction(NULL)
{
theMessenger = new G4StackingMessenger(this);
urgentStack = new G4TrackStack;
waitingStack = new G4TrackStack;
postponeStack = new G4TrackStack;
}
G4StackManager::~G4StackManager()
{
if(userStackingAction) delete userStackingAction;
delete urgentStack;
delete waitingStack;
delete postponeStack;
delete theMessenger;
}
const G4StackManager & G4StackManager::operator=
(const G4StackManager &) { return *this; }
int G4StackManager::operator==(const G4StackManager &)
const{ return false; }
int G4StackManager::operator!=(const G4StackManager &)
const{ return true; }
G4int G4StackManager::PushOneTrack(G4Track *newTrack)
{
G4ClassificationOfNewTrack classification;
if(userStackingAction)
{ classification = userStackingAction->ClassifyNewTrack( newTrack ); }
else
{ classification = DefaultClassification( newTrack ); }
if(classification==fKill) // delete newTrack without stacking
{
#ifdef G4VERBOSE
if( verboseLevel > 0 )
{
G4cout << " ---> G4Track " << newTrack << " (trackID "
<< newTrack->GetTrackID() << ", parentID "
<< newTrack->GetParentID() << ") is not to be stored." << endl;
}
#endif
delete newTrack;
}
else
{
G4StackedTrack * newStackedTrack = new G4StackedTrack( newTrack );
switch (classification)
{
case fUrgent:
urgentStack->PushToStack( newStackedTrack );
break;
case fWaiting:
waitingStack->PushToStack( newStackedTrack );
break;
case fPostpone:
postponeStack->PushToStack( newStackedTrack );
break;
case fKill:
break;
}
}
return GetNUrgentTrack();
}
G4Track * G4StackManager::PopNextTrack()
{
#ifdef G4VERBOSE
if( verboseLevel > 0 )
{
G4cout << "### pop requested out of "
<< GetNUrgentTrack() << " stacked tracks." << endl;
}
#endif
while( GetNUrgentTrack() == 0 )
{
#ifdef G4VERBOSE
if( verboseLevel > 0 ) G4cout << "### " << GetNWaitingTrack()
<< " waiting tracks are re-classified to" << endl;
#endif
waitingStack->TransferTo(urgentStack);
if(userStackingAction) userStackingAction->NewStage();
#ifdef G4VERBOSE
if( verboseLevel > 0 ) G4cout << " " << GetNUrgentTrack()
<< " urgent tracks and " << GetNWaitingTrack()
<< " waiting tracks." << endl;
#endif
if( ( GetNUrgentTrack()==0 ) && ( GetNWaitingTrack()==0 ) ) return NULL;
}
G4StackedTrack * selectedStackedTrack = urgentStack->PopFromStack();
G4Track * selectedTrack = selectedStackedTrack->GetTrack();
#ifdef G4VERBOSE
if( verboseLevel > 1 )
{
G4cout << "Selected G4StackedTrack : " << selectedStackedTrack
<< " with G4Track " << selectedStackedTrack->GetTrack()
<< " (trackID " << selectedStackedTrack->GetTrack()->GetTrackID()
<< ", parentID " << selectedStackedTrack->GetTrack()->GetParentID()
<< ")" << endl;
}
#endif
delete selectedStackedTrack;
return selectedTrack;
}
void G4StackManager::ReClassify()
{
G4StackedTrack * aStackedTrack;
G4TrackStack tmpStack;
if( !userStackingAction ) return;
if( GetNUrgentTrack() == 0 ) return;
urgentStack->TransferTo(&tmpStack);
while( (aStackedTrack=tmpStack.PopFromStack()) != NULL )
{
G4ClassificationOfNewTrack classification =
userStackingAction->ClassifyNewTrack( aStackedTrack->GetTrack() );
switch (classification)
{
case fKill:
delete aStackedTrack->GetTrack();
delete aStackedTrack;
break;
case fUrgent:
urgentStack->PushToStack( aStackedTrack );
break;
case fWaiting:
waitingStack->PushToStack( aStackedTrack );
break;
case fPostpone:
postponeStack->PushToStack( aStackedTrack );
break;
}
}
}
G4int G4StackManager::PrepareNewEvent()
{
if(userStackingAction) userStackingAction->PrepareNewEvent();
G4int n_passedFromPrevious = 0;
if( GetNPostponedTrack() > 0 )
{
#ifdef G4VERBOSE
if( verboseLevel > 0 )
{
G4cout << GetNPostponedTrack()
<< " postponed tracked are now shifted to the stack." << endl;
}
#endif
G4StackedTrack * aStackedTrack;
G4TrackStack tmpStack;
postponeStack->TransferTo(&tmpStack);
while( (aStackedTrack=tmpStack.PopFromStack()) != NULL )
{
G4Track* aTrack = aStackedTrack->GetTrack();
aTrack->SetParentID(-1);
G4ClassificationOfNewTrack classification;
if(userStackingAction)
{ classification = userStackingAction->ClassifyNewTrack( aTrack ); }
else
{ classification = DefaultClassification( aTrack ); }
if(classification==fKill)
{
delete aTrack;
delete aStackedTrack;
}
else
{
aTrack->SetTrackID(++n_passedFromPrevious);
switch (classification)
{
case fUrgent:
urgentStack->PushToStack( aStackedTrack );
break;
case fWaiting:
waitingStack->PushToStack( aStackedTrack );
break;
case fPostpone:
postponeStack->PushToStack( aStackedTrack );
break;
case fKill:
break;
}
}
}
}
return n_passedFromPrevious;
}
+37
View File
@@ -0,0 +1,37 @@
// This code implementation is the intellectual property of
// the RD44 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: G4StackedTrack.cc,v 2.0 1998/07/02 16:54:06 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 02/Feb/96 M.Asai
//
#include "G4StackedTrack.hh"
G4Allocator<G4StackedTrack> aStackedTrackAllocator;
G4StackedTrack::G4StackedTrack()
{ }
G4StackedTrack::G4StackedTrack(G4Track * newTrack)
:track(newTrack),priorityWeight(0.),
previousStackedTrack(NULL),nextStackedTrack(NULL)
{ }
G4StackedTrack::~G4StackedTrack()
{ }
const G4StackedTrack & G4StackedTrack::operator=(const G4StackedTrack &right)
{ return *this; }
int G4StackedTrack::operator==(const G4StackedTrack &right) const
{ return false; }
int G4StackedTrack::operator!=(const G4StackedTrack &right) const
{ return true; }
+80
View File
@@ -0,0 +1,80 @@
// This code implementation is the intellectual property of
// the RD44 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: G4StackingMessenger.cc,v 2.3 1998/07/13 16:50:21 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// --------------------------------------------------------------------
#include "G4StackingMessenger.hh"
#include "G4StackManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4ios.hh"
G4StackingMessenger::G4StackingMessenger(G4StackManager * fCont)
:fContainer(fCont)
{
stackDir = new G4UIdirectory("/event/stack/");
stackDir->SetGuidance("Stack control commands.");
statusCmd = new G4UIcmdWithoutParameter("/event/stack/status",this);
statusCmd->SetGuidance("List current status of the stack.");
clearCmd = new G4UIcmdWithAnInteger("/event/stack/clear",this);
clearCmd->SetGuidance("Clear stacked tracks.");
clearCmd->SetGuidance(" 2 : clear all tracks in all stacks");
clearCmd->SetGuidance(" 1 : clear tracks in the urgent and waiting stacks");
clearCmd->SetGuidance(" 0 : clear tracks in the waiting stack (default)");
clearCmd->SetGuidance("-1 : clear tracks in the urgent stack");
clearCmd->SetGuidance("-2 : clear tracks in the postponed stack");
clearCmd->SetParameterName("level",true);
clearCmd->SetDefaultValue(0);
clearCmd->SetRange("level>=-2&&level<=2");
clearCmd->AvailableForStates(GeomClosed,EventProc);
}
G4StackingMessenger::~G4StackingMessenger()
{
delete statusCmd;
delete clearCmd;
delete stackDir;
}
void G4StackingMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
{
if( command==statusCmd )
{
G4cout << "========================== Current status of the stack =====" << endl;
G4cout << " Number of tracks in the stack" << endl;
G4cout << " Urgent stack : " << fContainer->GetNUrgentTrack() << endl;
G4cout << " Waiting stack : " << fContainer->GetNWaitingTrack() << endl;
G4cout << " Postponed stack : " << fContainer->GetNPostponedTrack() << endl;
}
if( command==clearCmd )
{
G4int vc = clearCmd->GetNewIntValue(newValues);
switch (vc)
{
case 2:
fContainer->ClearPostponeStack();
case 1:
fContainer->ClearUrgentStack();
case 0:
fContainer->ClearWaitingStack();
break;
case -1:
fContainer->ClearUrgentStack();
break;
case -2:
fContainer->ClearPostponeStack();
break;
}
}
}
+135
View File
@@ -0,0 +1,135 @@
// This code implementation is the intellectual property of
// the RD44 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: G4TrackStack.cc,v 2.1 1998/07/12 02:54:07 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#include "G4TrackStack.hh"
G4TrackStack::G4TrackStack()
:n_stackedTrack(0),firstStackedTrack(NULL),lastStackedTrack(NULL)
{;}
G4TrackStack::~G4TrackStack()
{;}
const G4TrackStack & G4TrackStack::operator=(const G4TrackStack &right)
{
n_stackedTrack = right.n_stackedTrack;
firstStackedTrack = right.firstStackedTrack;
lastStackedTrack = right.lastStackedTrack;
return *this;
}
int G4TrackStack::operator==(const G4TrackStack &right) const
{ return (firstStackedTrack==right.firstStackedTrack); }
int G4TrackStack::operator!=(const G4TrackStack &right) const
{ return (firstStackedTrack!=right.firstStackedTrack); }
void G4TrackStack::TransferTo(G4TrackStack * aStack)
{
if(n_stackedTrack==0) return;
if(aStack->n_stackedTrack == 0)
{
*aStack = *this;
}
else
{
aStack->lastStackedTrack->SetNext( firstStackedTrack );
firstStackedTrack->SetPrevious( aStack->lastStackedTrack );
aStack->lastStackedTrack = lastStackedTrack;
aStack->n_stackedTrack += n_stackedTrack;
}
n_stackedTrack = 0;
firstStackedTrack = NULL;
lastStackedTrack = NULL;
}
G4StackedTrack * G4TrackStack::PopFromStack()
{
if( n_stackedTrack == 0 ) return NULL;
G4StackedTrack * aStackedTrack = lastStackedTrack;
GrabFromStack( aStackedTrack );
return aStackedTrack;
}
void G4TrackStack::PushToStack( G4StackedTrack * aStackedTrack )
{
if( n_stackedTrack == 0 )
{
aStackedTrack->SetPrevious( NULL );
firstStackedTrack = aStackedTrack;
}
else
{
lastStackedTrack->SetNext( aStackedTrack );
aStackedTrack->SetPrevious( lastStackedTrack );
}
lastStackedTrack = aStackedTrack;
n_stackedTrack++;
}
void G4TrackStack::GrabFromStack( G4StackedTrack * aStackedTrack )
{
if( n_stackedTrack == 1 )
{
firstStackedTrack = NULL;
lastStackedTrack = NULL;
}
else
{
if( aStackedTrack == firstStackedTrack )
{
firstStackedTrack = aStackedTrack->GetNext();
firstStackedTrack->SetPrevious( NULL );
}
else
{
if( aStackedTrack == lastStackedTrack )
{
lastStackedTrack = aStackedTrack->GetPrevious();
lastStackedTrack->SetNext( NULL );
}
else
{
aStackedTrack->GetPrevious()
->SetNext( aStackedTrack->GetNext() );
aStackedTrack->GetNext()
->SetPrevious( aStackedTrack->GetPrevious() );
}
}
}
n_stackedTrack--;
}
void G4TrackStack::clear()
{
G4StackedTrack * aStackedTrack = firstStackedTrack;
G4StackedTrack * nextStackedTrack;
if ( n_stackedTrack == 0 ) return;
// delete tracks in the stack
while( aStackedTrack != NULL )
{
nextStackedTrack = aStackedTrack->GetNext();
delete aStackedTrack->GetTrack();
delete aStackedTrack;
aStackedTrack = nextStackedTrack;
}
n_stackedTrack = 0;
firstStackedTrack = NULL;
lastStackedTrack = NULL;
}
+19
View File
@@ -0,0 +1,19 @@
// This code implementation is the intellectual property of
// the RD44 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: G4UserEventAction.cc,v 2.1 1998/07/12 02:54:08 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4UserEventAction.hh"
void G4UserEventAction::BeginOfEventAction()
{;}
void G4UserEventAction::EndOfEventAction()
{;}
+37
View File
@@ -0,0 +1,37 @@
// This code implementation is the intellectual property of
// the RD44 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: G4UserStackingAction.cc,v 2.2 1998/07/13 16:50:22 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Last Modification : 09/Dec/96 M.Asai
//
#include "G4UserStackingAction.hh"
#include "G4Track.hh"
#include "G4ios.hh"
G4UserStackingAction::G4UserStackingAction()
{;}
G4UserStackingAction::~G4UserStackingAction()
{;}
G4ClassificationOfNewTrack G4UserStackingAction::ClassifyNewTrack
(G4Track * const aTrack)
{
return fUrgent;
}
void G4UserStackingAction::NewStage()
{;}
void G4UserStackingAction::PrepareNewEvent()
{;}
+21
View File
@@ -0,0 +1,21 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VPrimaryGenerator.cc,v 2.0 1998/07/02 16:54:13 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// G4VPrimaryGenerator
#include "G4VPrimaryGenerator.hh"
G4VPrimaryGenerator::G4VPrimaryGenerator()
{;}
G4VPrimaryGenerator::~G4VPrimaryGenerator()
{;}