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

LCDG4PrimaryGeneratorAction Class Reference

#include <LCDG4PrimaryGeneratorAction.hh>

Inheritance diagram for LCDG4PrimaryGeneratorAction:

Inheritance graph
[legend]
Collaboration diagram for LCDG4PrimaryGeneratorAction:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LCDG4PrimaryGeneratorAction ()
 LCDG4PrimaryGeneratorAction (G4VPrimaryGenerator *)
 ~LCDG4PrimaryGeneratorAction ()
void SetConeRadius (G4double rad)
void SetPartGunEnergy (G4double energy)
void SetPartGunType (G4String partType)
void SetupParticleGun ()
void GeneratePrimaries (G4Event *anEvent)
void SetHEPEvtGenerator (G4bool f)
G4bool GetHEPEvtGenerator ()

Private Attributes

G4VPrimaryGeneratorHEPEvt
G4ParticleGun * particleGun
LCDG4PrimaryGeneratorMessengermessenger
G4bool useHEPEvt
G4double coneRad
G4String partName
G4double partEnergy

Constructor & Destructor Documentation

LCDG4PrimaryGeneratorAction::LCDG4PrimaryGeneratorAction  ) 
 

Definition at line 16 of file LCDG4PrimaryGeneratorAction.cc.

References GeV, partEnergy, and SetupParticleGun().

00017   : useHEPEvt(false), coneRad(0), partName("mu-")
00018 {
00019   partEnergy = 2*GeV;
00020   SetupParticleGun();
00021 }

LCDG4PrimaryGeneratorAction::LCDG4PrimaryGeneratorAction G4VPrimaryGenerator  ) 
 

Definition at line 26 of file LCDG4PrimaryGeneratorAction.cc.

References HEPEvt, messenger, SetupParticleGun(), and useHEPEvt.

00027   : useHEPEvt(true), coneRad(0), partName("mu-")
00028 {
00029   HEPEvt=pgen;
00030   SetupParticleGun();
00031   messenger = new LCDG4PrimaryGeneratorMessenger(this);
00032   useHEPEvt = true;
00033 }

LCDG4PrimaryGeneratorAction::~LCDG4PrimaryGeneratorAction  ) 
 

Definition at line 38 of file LCDG4PrimaryGeneratorAction.cc.

References HEPEvt, messenger, and particleGun.

00038                                                           {
00039   if (HEPEvt) {
00040     delete HEPEvt;
00041     HEPEvt=0;
00042   }
00043   if(particleGun) delete particleGun;
00044   if(messenger) delete messenger;
00045 }


Member Function Documentation

void LCDG4PrimaryGeneratorAction::GeneratePrimaries G4Event *  anEvent  ) 
 

Definition at line 77 of file LCDG4PrimaryGeneratorAction.cc.

References coneRad, LCDG4McPartManager::GetPointer(), HEPEvt, LCDG4McPartManager::MCparticles, partEnergy, particleGun, partName, LCDMcPart::Set4Momentum(), LCDMcPart::SetChargeFromPid(), LCDMcPart::SetGenStatus(), LCDMcPart::SetParentTag(), LCDMcPart::SetParticleID(), LCDMcPart::SetPosition(), and useHEPEvt.

00077                                                                     {
00078 
00079   if (useHEPEvt) {
00080     // reading events from a file
00081     HEPEvt->GeneratePrimaryVertex(anEvent);
00082   }
00083   else {
00084     // generating random particles within a cone of radius coneRad
00085     double dTheta, dPhi, dR2;
00086     do {
00087       dTheta = RandFlat::shoot(-coneRad, coneRad);
00088       dPhi = RandFlat::shoot(-coneRad, coneRad);
00089       dR2 = dTheta*dTheta + dPhi*dPhi;
00090     } while( dR2 > coneRad*coneRad );
00091 
00092     // setup particle direction within a coneRad of 
00093     double theta = asin(1) + dTheta;
00094     double phi = asin(1) + dPhi;
00095     double kx = sin(theta)*cos(phi);
00096     double ky = sin(theta)*sin(phi);
00097     double kz = cos(theta);
00098     particleGun->SetParticleMomentumDirection(G4ThreeVector(kx,ky,kz));
00099 
00100     // select charge based on even or odd event
00101     G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
00102     G4ParticleDefinition* particle;
00103     static int ievt=0;
00104     if( ievt%2 ) particle = particleTable->FindParticle(partName);
00105     else  particle = particleTable->FindAntiParticle(partName);
00106     particleGun->SetParticleDefinition(particle);
00107     ievt++;
00108 
00109     // particle energy
00110     particleGun->SetParticleEnergy(partEnergy);
00111 
00112     // generate particle
00113     particleGun->GeneratePrimaryVertex(anEvent);
00114 
00115     // Make a new LCDMcPart object from the particle generated
00116     LCDMcPart* part = new LCDMcPart();
00117 
00118     G4int status = 1;  // final state
00119     G4int pdgid = particleGun->GetParticleDefinition()->GetPDGEncoding();
00120     part->SetGenStatus(status);
00121     part->SetParticleID(pdgid);
00122     part->SetChargeFromPid(pdgid);
00123 
00124     Hep3Vector position = particleGun->GetParticlePosition();
00125     part->SetPosition(position);
00126 
00127     double mass = particleGun->GetParticleDefinition()->GetPDGMass();
00128     double energy = particleGun->GetParticleEnergy();
00129     double pmom = sqrt(energy*energy-mass*mass);
00130     Hep3Vector momentum = pmom*particleGun->GetParticleMomentumDirection();
00131 
00132     HepLorentzVector momentum4;
00133     momentum4.setPx( momentum.x() );
00134     momentum4.setPy( momentum.y() );
00135     momentum4.setPz( momentum.z() );
00136     momentum4.setE( energy );
00137     part->Set4Momentum(momentum4);
00138     part->SetParentTag( 0 );
00139 
00140     // store it with the manager
00141     LCDG4McPartManager::GetPointer()->MCparticles.push_back(part);
00142   }
00143 }

G4bool LCDG4PrimaryGeneratorAction::GetHEPEvtGenerator  )  [inline]
 

Definition at line 39 of file LCDG4PrimaryGeneratorAction.hh.

References useHEPEvt.

00039 { return useHEPEvt; }

void LCDG4PrimaryGeneratorAction::SetConeRadius G4double  rad  )  [inline]
 

Definition at line 22 of file LCDG4PrimaryGeneratorAction.hh.

References coneRad.

00022 { coneRad = rad; }

void LCDG4PrimaryGeneratorAction::SetHEPEvtGenerator G4bool  f  )  [inline]
 

Definition at line 38 of file LCDG4PrimaryGeneratorAction.hh.

References useHEPEvt.

00038 { useHEPEvt = f; }

void LCDG4PrimaryGeneratorAction::SetPartGunEnergy G4double  energy  )  [inline]
 

Definition at line 23 of file LCDG4PrimaryGeneratorAction.hh.

References partEnergy.

00023 { partEnergy=energy; }

void LCDG4PrimaryGeneratorAction::SetPartGunType G4String  partType  )  [inline]
 

Definition at line 24 of file LCDG4PrimaryGeneratorAction.hh.

References partName.

00024 { partName = partType; }

void LCDG4PrimaryGeneratorAction::SetupParticleGun  ) 
 

Definition at line 47 of file LCDG4PrimaryGeneratorAction.cc.

References cm, messenger, partEnergy, particleGun, partName, and useHEPEvt.

Referenced by LCDG4PrimaryGeneratorAction().

00047                                                    {
00048   // For seeding the random number generator, see EventAction class.
00049   // EventAction was chosen in order to allow resetting the seed for 
00050   // every event, in case we want to use fixed seeds.
00051 
00052   G4int n_particle = 1;
00053   particleGun = new G4ParticleGun(n_particle);
00054   G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
00055   G4String particleName;
00056 
00057   // particle type
00058   G4ParticleDefinition* particle = particleTable->FindParticle(partName);
00059   particleGun->SetParticleDefinition(particle);
00060 
00061   // particle vertex
00062   particleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,0.*cm));
00063 
00064   // particle direction (theta,phi)
00065   particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,1.,0.));
00066 
00067   // particle energy
00068   particleGun->SetParticleEnergy(partEnergy);
00069 
00070   messenger = new LCDG4PrimaryGeneratorMessenger(this);
00071   useHEPEvt = false;
00072 }


Member Data Documentation

G4double LCDG4PrimaryGeneratorAction::coneRad [private]
 

Definition at line 33 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), and SetConeRadius().

G4VPrimaryGenerator* LCDG4PrimaryGeneratorAction::HEPEvt [private]
 

Definition at line 29 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), LCDG4PrimaryGeneratorAction(), and ~LCDG4PrimaryGeneratorAction().

LCDG4PrimaryGeneratorMessenger* LCDG4PrimaryGeneratorAction::messenger [private]
 

Definition at line 31 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by LCDG4PrimaryGeneratorAction(), SetupParticleGun(), and ~LCDG4PrimaryGeneratorAction().

G4double LCDG4PrimaryGeneratorAction::partEnergy [private]
 

Definition at line 35 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), LCDG4PrimaryGeneratorAction(), SetPartGunEnergy(), and SetupParticleGun().

G4ParticleGun* LCDG4PrimaryGeneratorAction::particleGun [private]
 

Definition at line 30 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), SetupParticleGun(), and ~LCDG4PrimaryGeneratorAction().

G4String LCDG4PrimaryGeneratorAction::partName [private]
 

Definition at line 34 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), SetPartGunType(), and SetupParticleGun().

G4bool LCDG4PrimaryGeneratorAction::useHEPEvt [private]
 

Definition at line 32 of file LCDG4PrimaryGeneratorAction.hh.

Referenced by GeneratePrimaries(), GetHEPEvtGenerator(), LCDG4PrimaryGeneratorAction(), SetHEPEvtGenerator(), and SetupParticleGun().


The documentation for this class was generated from the following files:
Generated on Thu Oct 7 18:45:06 2004 for LCDG4 by doxygen 1.3.4