1 / 12

Kinematics

Kinematics. G4VUserPrimaryGeneratorAction. G4VUserPrimaryGeneratorAction is one of the mandatory classes the user has to derive a concrete class from In the concrete class, one must specify how the primary event should be generated

rhonda
Télécharger la présentation

Kinematics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Kinematics

  2. G4VUserPrimaryGeneratorAction • G4VUserPrimaryGeneratorAction is one of the mandatory classes the user has to derive a concrete class from • In the concrete class, one must specify how the primary event should be generated • G4VUserPrimaryGeneratoAction has a pure virtual method named GeneratePrimaries(), invoked at the beginning of each event. This method receives (as an argument) a pointer to the current G4Event which must then be filled with particles that will then be tracked trough the detector GeneratePrimaries(G4Event* anEvent);

  3. The primary event • The primary event (kinematics) is made of G4PrimaryParticles G4PrimaryParticle(G4int PDGcode,G4double Px,G4double Py,G4double Pz) G4PrimaryParticle(G4ParticleDefinition *pDef, G4double Px,G4double Py, G4double Pz) • Primary particles are associated to their production vertex (of type G4PrimaryVertex) G4PrimaryVertex(G4double Vx,G4double Vy,G4double vz,G4double T0) G4PrimaryVertex(G4ThreeVector Vpos,G4double T0) • Primary particles are associated to the primary vertex by means of the primary vertex’ method AddPrimary AddPrimary(G4PrimaryParticle* aParticle) • Vertices are given to the event by means of AddPrimaryVertex AddPrimaryVertex(G4PrimaryVertex *aVertex)

  4. G4VPrimaryGenerator • The GeneratePrimaries() in G4VPrimaryGeneratorAction is invoked at the beginning of each event to fill up a G4Event with particles to be tracked through the simulated detector • To provide the possibility of having different ways of generating the kinematics of an event available in the same simulation program, Geant4 provides an abstract generator class (G4VPrimaryGenerator) which users can inherit from to implement their preferred way of generating an event. • The (purely abstract) method that users must implement and where the actual generation of an event will take place is • GeneratePrimaryEvent(G4Event* an Event) • The PrimaryGeneratorAction can then be used for switching between various PrimaryGenerator’s

  5. An example of PrimaryGeneratorAction #ifndef MyPrimaryGeneratorAction_H #define MyPrimaryGeneratorAction_H #include “G4VUserPrimaryGeneratorAction.hh” class MyTestBeam; class G4Event; class MyPrimaryGeneratorAction: public G4VUserPrimaryGeneratorAction{ public: MyPrimaryGeneratorAction(); ~MyPrimaryGeneratorAction(); void GeneratePrimaries(G4Event* anEvent); private: MyTestBeam *tBeam; }; #endif

  6. An example of PrimaryGeneratorAction (2) #include “MyPrimaryGeneratorAction.hh” #include “G4Event.hh” #include “MyTestBeam.hh” #include “G4ThreeVector.hh” #include “G4Geantino.hh” #include “globals.hh” MyPrimaryGeneratorAction::MyPrimaryGeneratorAction() { tBeam=new MyTestBeam(); }

  7. An example of PrimaryGeneratorAction (3) MyPrimaryGeneratorAction::~MyPrimaryGeneratorAction() { delete tBeam; } void MyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { cout<<“Generating the kinematics for event “<<anEvent->GetEventId()<<endl; tBeam->GeneratePrimaryVertex(anEvent); }

  8. Generation of an event • The primary generator should be selected in the constructor of the concrete class derived from G4VUserPrimaryGeneratorAction • This particle generator must then be destroyed in the destructor • In the previous example we make use of a class (MyTestBeam) which is a predefined primary particle generator (G4VPrimaryGenerator) • G4VUserPrimaryGeneratoAction has a pure virtual method named GeneratePrimaries(), invoked at the beginning of each event. In this method, one must invoke the GeneratePrimaryVertex() method of the G4VPrimaryGenerator concrete class that one instanciated

  9. An example of PrimaryGenerator #ifndef MyTestBeam_H #define MyTestBeam_H #include “G4VPrimaryGenerator.hh” #include “G4ThreeVector.hh” #include “G4PrimaryVertex.hh” #include “G4ParticleDefinition.hh” #include “G4ParticleMomentum.hh” #include “G4Event.hh” class MyTestBeam: public G4VPrimaryGenerator { public: MyTestBeam(); void GeneratePrimaryVertex(G4Event *evt); private: G4ParticleDefinition *beamParticleDefinition; G4ParticleMomentum beamMomentum; G4double beamEnergy; G4ThreeVector beamVertex; G4double beamTime; } #endif

  10. An example of PrimaryGenerator (2) // MyTestBeam.cc #include “G4Event.hh” #include “MyTestBeam.hh” #include “G4Electron.hh” #include “G4PrimaryParticle.hh” MyTestBeam::MyTestBeam() { beamParticleDefinition=G4Electron::ElectronDefinition(); beamEnergy=10*GeV; beamMomentum=G4ParticleMomentum(1.,0.,0); beamVertex=G4ThreeVector(0.,0.,-100); beamTime=0; } MyTestBeam::GeneratePrimaryVertex(G4Event *evt) { G4PrimaryVertex *vt=new G4PrimaryVertex(beamVertex,beamTime); G4double px=beamEnergy*beamMomentum.x(); G4double px=beamEnergy*beamMomentum.x(); G4double px=beamEnergy*beamMomentum.x(); G4PrimaryParticle *particle=new G4PrimaryParticle(beamParticleDefinition,px,py,pz); vt->AddPrimary(particle); evt->AddPrimaryVertex(vt); }

  11. G4ParticleGun • G4ParticleGun is a primary particle generator provided by Geant4. It generates primary particles with a given momentum and position • Randomization of energy, momentum and position is not provided directly by G4ParticleGun but it can be realized by invoking several of its methods; this must be done in GeneratePrimaries() before invoking generatePrimaryVertex() • The following methods are provided for G4ParticleGun void SetParticleDefinition(G4ParticleDefinition*) void SetParticleMomentum(G4ParticleMomentum) void SetParticleMomentumDirection(G4ThreeVector) void SetParticleEnergy(G4double) void SetParticleTime(G4double) void SetParticlePosition(G4ThreeVector) void SetParticlePolarization(G4ThreeVector) void SetNumberOfParticles(G4int)

  12. kinematics • The aim of the exercise is to implement a PrimaryGeneratorAction, 4- generator (flat generation of particles in eta-phi) • Use G4ParticleGun as a first attempt (the test beam generator is trivial in this case), then try and implement your own PrimaryGenerator • Use G4UniformRand() from Randomize.hh is you need a random number generator (flat distribution in ]0,1[)

More Related