Marc Verderi - IN2P3 SLAC User's Workshop.1 Introduction G EANT4 has been designed to allow users to implement new processes the kernel will treat as any.

Slides:



Advertisements
Similar presentations
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
Advertisements

Development of an Interface for Using EGS4 Physics Processes in Geant4 K.Murakami (KEK) 27/Mar./
Resource Allocation, Deadlock and Banker’s Algorithm Supplementary Notes Dr. R. D. Kent Last modified: Dec. 11, 2006.
Improvement of G4Exception (and an announcement on G4ApplicationState) Makoto Asai (SLAC) on behalf of Architecture team.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
© Copyright QinetiQ 2006 G4 C-S Biasing Based on the G4WrapperProcess Fan Lei Geant4 Biasing Mini Workshop, SLAC 21 March 2007.
1 Chapter 7 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11 th, 2002 Getting Started.
Collaboration Diagrams. Example Building Collaboration Diagrams.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
SystemC: Introduction. SystemC  A C++ based class library and design environment for system-level design.  Suitable for functional description that.
Inheritance in C++ CS-1030 Dr. Mark L. Hornick.
Particles and Processes The full set of lecture notes of this Geant4 Course is available at
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
Progress on generic biasing Marc Verderi LLR – Ecole polytechnique Geant4 Collaboration Meeting Seville September 2013.
Adding a new process CERN User’s Workshop 13 November 2002 V.Ivanchenko, CERN, Budker Institute for Nuclear Physics Based on presentation of M.Verderi.
Geant4 Electromagnetic Physics Introduction V.Ivanchenko, M.Maire, M.Verderi  Process interface  Physics categories  Electromagnetic physics  PhysicsList.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Physics I: Physics Lists Geant4 Tutorial at Jefferson Lab 10 July 2012 Dennis Wright (SLAC) Geant4 9.6 beta.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
C# F 1 CSC 298 Object Oriented Programming (Part 1)
Geant4 Event Biasing Marc Verderi, LLR (Heavily copied from Jane Tinslay, SLAC) June 2007.
Progress on generic biasing Marc Verderi LLR – Ecole polytechnique Geant4 Collaboration Meeting Seville September 2013.
Geant4 internal Classes and Objects Gunter Folger / CERN Geant4 course, Annecy 2008 User Action & Information Classes.
1 Physics I: Physics Lists Paris Geant4 Tutorial 4 June 2007 Marc Verderi Laboratoire Leprince-Ringuet (Heavily copied from D. Wright) Geant4 V8.3.
Gaudi Framework Tutorial, April Algorithm Tools: what they are, how to write them, how to use them.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
Geant4 internal Classes and Objects Geant4 Users’ Tutorial February 2010 Gunter Folger / CERN User Action & Information Classes.
Session 7 Methods Strings Constructors this Inheritance.
Physics processes in general SLAC User’s Workshop February 18 – Marc Verderi Ecole Polytechnique - LLR.
Basics of Primary Particle Generation and Tracking Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector.
Virtual FunctionstMyn1 Virtual Functions A virtual function is declared in a base class by using the keyword virtual. A function that you declare as virtual.
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
V.Ivanchenko Salamanca1 Geant4: Electromagnetic Processes 1  Introduction  Interfaces  PhysicsList  Optical process.
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
More about Java Classes Writing your own Java Classes More about constructors and creating objects.
Physics I: Physics Lists Puebla Geant4 Tutorial 15 June 2010 Dennis Wright Geant4 V9.3.p01.
Geant4 internal Classes and Objects Gunter Folger / CERN MC-PAD, DESY/Hamburg January 2010 User Action & Information Classes.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Physics II : processes Paris Geant4 Tutorial 5 June 2007 Marc Verderi Ecole Polytechnique - LLR.
New approach of Geant4 Low Energy EM models (from version 9.3) Luciano Pandola INFN, Laboratori del Gran Sasso MaGe Joint Workshop, Munich, January 2010.
Maria Grazia Pia Retrieving information from kernel Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
Geant4 KISTI Tutorial Marc Verderi LLR – Ecole polytechnique October 2012 Physics II: Overview, Processes, Production Threshold.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Interaction with the Geant4 kernel
Particles and Processes
Methods Attributes Method Modifiers ‘static’
Interaction with the Geant4 kernel
Review: Two Programming Paradigms
Particles and Processes
C++ for Geant4 users A collection of most useful and/or common features used in and to use Geant4 Marc Verderi LLR – Ecole polytechnique 14/11/2018 Marc.
Inheritance Basics Programming with Inheritance
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002
IMAT5205 Systems Analysis and Design
Physics I: Physics Lists
Particles and Processes
A shortcut to the tracking
Computer Programming with JAVA
Particles and Processes
Today’s Objectives 10-Jul-2006 Announcements Quiz #3
Marc Verderi GEANT4 collaboration meeting 01/10/2002
Geant4: Electromagnetic Physics 4 V.Ivanchenko, BINP & CERN
Introduction to physics and processes
Decay Process Makoto Asai (SLAC)
Particles and Processes
Presentation transcript:

Marc Verderi - IN2P3 SLAC User's Workshop.1 Introduction G EANT4 has been designed to allow users to implement new processes the kernel will treat as any other processes; Processes are designed in a generic/general way: Good, but makes the user to « hit » the meaning of many things; Try to highlight the basics allowing to implement a new process; Indicated by « » marks; Sometimes show some « tricky » details: By sake of completeness; But only a few processes face those tricky issues ! Simple processes are easy to realize !

Marc Verderi - IN2P3 SLAC User's Workshop.2 Layout I.G4VProcess interface overview; i.The mandatory; ii.The optional; II.Number of interaction length; III.Method signatures: i.GetPhysicalInteractionLength; ii.DoIt; iii.G4VParticleChange;

G4VProcess interface overview;

Marc Verderi - IN2P3 SLAC User's Workshop.4 The mandatory; G4VProcess defines 6 pure virtual methods: AtRestGetPhysicalInteractionLength, AtRestDoIt; AlongStepGetPhysicalInteractionLength, AlongStepDoIt; PostStepGetPhysicalInteractionLength, PostStepDoIt. You need to override to implement a new process; Either directly, or by using some itermediate class, like G4VDiscreteProcess; ; The signatures of those methods are described later; G4VProcess defined in source/processes/management;

Marc Verderi - IN2P3 SLAC User's Workshop.5 The optional; G4VProcess defines also several virtual (but non pure-virtual) methods. For example: void BuildPhysicsTable(const G4ParticleDefinition&); Invoked by the run manager, after cuts are (re)set; void StartTracking(): Invoked when G EANT4 starts to track a new track; void EndTracking(); Invoked after the tracking of the track has finished; But several other virtual methods exist. Please review G4VProcess.hh for details;

Marc Verderi - IN2P3 SLAC User's Workshop.6 « Life cycle » of a process 1. Construction; 1. BuildPhysicsTable(); 1. StartTracking(); 1. If particle at rest: 1. AtRestGetPhysicalInteractionLength(); 2. AtRestDoIt(); 2. Else: 1. PostStepGetPhysicalInteractionLength(); 2. AlongStepGetPhysicalInteractionLength(); 3. AlongStepDoIt(); 4. PostStepDoIt(); 2. EndTracking(); 2. Destruction; Stepping loop Tracking loop Implementation mandatory Implementation optional

II.Number of interaction length Speak about: Scheme of the « number of interaction length »

Marc Verderi - IN2P3 SLAC User's Workshop.8 Scheme of « number of interaction length » (2) Then the step occurs with the actual step length L step value; At the beginning of the new step: If the process has limited the previous step (ie its interaction occured), it gets a new N int value; Otherwise, the process converts back L step into a number of « consumed » interaction length, which is substracted to its N int amount; Please review for example G4VDiscreteProcess; Note that all related methods are virtual, allowing to redefine them, if needed.

Marc Verderi - IN2P3 SLAC User's Workshop.9 Scheme of « number of interaction length » (1) G4VProcess and derived classes implement a scheme based on the « number of interaction length » to define the occurence of the interaction: useful for discrete processes, dealing with the exponential law; At the beginning of the tracking the process is given a « number of interaction lenght » N int ; According to the exponential law; At the beginning of each step: The (concrete) process evaluates the current « mean free path » free, given the current material; The « true path length » the process allows to the particle before the interaction occurs is then: N int  free ; This value is returned by GetPhysicalInteractionLength;

Marc Verderi - IN2P3 SLAC User's Workshop.10 Example: G4VDiscreteProcess inline G4double G4VDiscreteProcess::PostStepGetPhysicalInteractionLength( const G4Track& track, G4double previousStepSize, G4ForceCondition* condition) { if ( (previousStepSize <=0.0) || (theNumberOfInteractionLengthLeft<=0.0)) { // beginning of tracking (or just after DoIt of this process) ResetNumberOfInteractionLengthLeft(); } else { //subtract NumberOfInteractionLengthLeft SubtractNumberOfInteractionLengthLeft(previousStepSize); if(theNumberOfInteractionLengthLeft<perMillion) theNumberOfInteractionLengthLeft=0.; } //… //get mean free path currentInteractionLength = GetMeanFreePath(track, previousStepSize, condition); G4double value = theNumberOfInteractionLengthLeft*currentInteractionLength; return value; }

III.Method signatures; Speak about: Method signature of: GetPhysicalInteractionLength and DoIt; G4VParticleChange;

Marc Verderi - IN2P3 SLAC User's Workshop.12 GetPhysicalInteractionLength signature virtual G4double AtRestGetPhysicalInteractionLength( const G4Track& track, G4ForceCondition* condition ) = 0; virtual G4double AlongStepGetPhysicalInteractionLength( const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection ) = 0; virtual G4double PostStepGetPhysicalInteractionLength( const G4Track& track, G4double previousStepSize, G4ForceCondition* condition ) = 0; All methods return a G4double;

Marc Verderi - IN2P3 SLAC User's Workshop.13 G4ForceCondition & G4GPILSelection GetPhysicalInteractionLength methods involve G4ForceCondition & G4GPILSelection; These are two enumerations: They define signals, that processes send to the stepping, to require the treatment they wish from the stepping; Involve  « delicate/tricky » aspects; Defined in source/track;

Marc Verderi - IN2P3 SLAC User's Workshop.14 G4ForceCondition G4ForceCondition (AtRest and PostStep) defines requests for treatment of the DoIt methods. It can take the values: NotForced: Usual case : the DoIt method is invoked if the related GetPhysicalInteractionLength has limited the step; Forced: The related DoIt is applied anyway; Conditionally: The PostStepDoIt is applied if the AlongStep has limited the step; ExclusivelyForced: Only the PostStepDoIt of the process is applied: all other AlongStep and PostStep are ignored;

Marc Verderi - IN2P3 SLAC User's Workshop.15 G4GPILSelection More tricky… G4GPILSelection (AlongStep) defines requests for the treatment of the GetPhysicalInteractionLength methods. It can takes the values: CandidateForSelection: usual case : the process will be « declared » to have limited the step if it returns the smallest length; NotCandidateForSelection: the process will not be « declared » to have limited the step, even if it returns the smallest lenght; In practice, only the multiple-scattering makes use of the « NotCandidateForSelection » signal;

Marc Verderi - IN2P3 SLAC User's Workshop.16 AlongStepGetPhysicalInteractionLength G4double AlongStepGetPhysicalInteractionLength( const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection ). previousStepSize: as before ; currentMinimumStep: is the current step size value, during the loop to determine the step length. proposedSafety, read-write argument: It is the current safety. The process can propose a new safety value; the stepping will retain the smallest one. selection: in practice only the multiple-scattering returns the NotCandidateForSelection  signal.

Marc Verderi - IN2P3 SLAC User's Workshop.17 AtRestGetPhysicalInteractionLength G4double AtRestGetPhysicalInteractionLength( const G4Track& track, G4ForceCondition* condition ); G4double returned is a time; Not a length ! condition can take the values NotForced and Forced;

Marc Verderi - IN2P3 SLAC User's Workshop.18 PostStepGetPhysicalInteractionLength G4double PostStepGetPhysicalInteractionLength( const G4Track& track, G4double previousStepSize, G4ForceCondition* condition ) condition can take the values NotForced, Forced, Conditionally, ExclusivelyForced; previousStepSize is the size of the last step done: Processes usually use this value to update the total amount of interaction length ; This value is also used by the transportation for some optimisation (avoid redoing geometry operations when the last step was « small enough »);

Marc Verderi - IN2P3 SLAC User's Workshop.19 DoIt signature (1) virtual G4VParticleChange* AtRestDoIt( const G4Track& track, const G4Step& step ) = 0; virtual G4VParticleChange* AlongStepDoIt( const G4Track& track, const G4Step& step ) = 0; virtual G4VParticleChange* PostStepDoIt( const G4Track& track, const G4Step& step ) = 0;

Marc Verderi - IN2P3 SLAC User's Workshop.20 DoIt signature (2) All DoIt methods have the same signature: They receive const G4Track and G4Step; Ie they are not allowed to change directly the track, nor the step; They return a G4VParticleChange: This G4VParticleChange returns the changes of the track to the stepping; Not the « delta »; And the eventual creation of secondaries; Need to be familiar with, to implement a process ;

Marc Verderi - IN2P3 SLAC User's Workshop.21 G4VParticleChange (1) G4VParticleChange is defined in source/track It defines the virtual methods: virtual G4Step* UpdateStepForAtRest(G4Step*); virtual G4Step* UpdateStepForAlongStep(G4Step*); virtual G4Step* UpdateStepForPostStep(G4Step*); Which are used to communicate the changes to be applied on the primary; They return the G4Step after having updated it; Each concrete G4VParticleChange should modify only the necessary members of the G4Step; Can be relevant if your G4VParticleChange is often used;

Marc Verderi - IN2P3 SLAC User's Workshop.22 G4VParticleChange (2) To create secondaries created by the process, the following methods have to be used: void SetNumberOfSecondaries(G4int); To declare the maximum number of secondaries which will be created by the process; void AddSecondary(G4Track* aSecondary); Which has to be called for each secondary created; G4VParticleChange also defines an Initialize() method used to initialize the members which will be changed by the process;

Marc Verderi - IN2P3 SLAC User's Workshop.23 G4TrackStatus G4TrackStatus defines the possible status a track can undertake; It is needed when writing a process: fAlive, // Continue the tracking fStopButAlive, // Invoke active rest physics processes and // and kill the current track afterward fStopAndKill, // Kill the current track fKillTrackAndSecondaries, // Kill the current track and also // associated secondaries. fSuspend, // Suspend the current track fPostponeToNextEvent // Postpones the tracking of thecurrent // track to the next event.

Marc Verderi - IN2P3 SLAC User's Workshop.24 Example with G4GammaConversion (1) Example with G4GammaConversion, which uses a particle change defined in the base class G4VDiscreteProcess; G4VParticleChange* G4GammaConversion::PostStepDoIt( const G4Track& aTrack, const G4Step& aStep) { aParticleChange.Initialize(aTrack); //Does the physics… aParticleChange.SetNumberOfSecondaries(2) ; //… G4double localEnergyDeposit = 0.; if (ElectKineEnergy > fminimalEnergy) { //… // create G4DynamicParticle object for the particle1 G4DynamicParticle* aParticle1= new G4DynamicParticle( G4Electron::Electron(), ElectDirection, ElectKineEnergy); aParticleChange.AddSecondary(aParticle1); } else { localEnergyDeposit += ElectKineEnergy;}

Marc Verderi - IN2P3 SLAC User's Workshop.25 Example with G4GammaConversion (2) // the e+ is always created (even with Ekine=0) for further annihilation. //… if (PositKineEnergy < fminimalEnergy) { localEnergyDeposit += PositKineEnergy; PositKineEnergy = 0.;} //… // create G4DynamicParticle object for the particle2 G4DynamicParticle* aParticle2= new G4DynamicParticle( G4Positron::Positron(), PositDirection, PositKineEnergy); aParticleChange.AddSecondary(aParticle2); aParticleChange.SetLocalEnergyDeposit(localEnergyDeposit); // // Kill the incident photon // aParticleChange.SetMomentumChange( 0., 0., 0. ); aParticleChange.SetEnergyChange( 0. ); aParticleChange.SetStatusChange( fStopAndKill ); return G4VDiscreteProcess::PostStepDoIt( aTrack, aStep ); }

Marc Verderi - IN2P3 SLAC User's Workshop.26 Conclusion The addition of a process is something relatively « easy » in G EANT4: Adding a new process only requires the user to write his code for his process: ie no change in the G4 kernel; Note this is possible because of the choice of object oriented technology;