Geant4 v9.3 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course.

Slides:



Advertisements
Similar presentations
Geant4 v9.2p02 Speed up Makoto Asai (SLAC) Geant4 Tutorial Course.
Advertisements

Status and Recent Developments Makoto Asai (SLAC) On Behalf of the Geant4 Collaboration May 26 th, 2007 Third McGill Workshop on Monte Carlo Techniques.
Geant4 v9.2p02 Kernel III Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Scoring I Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Particle Gun Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Geant4 v9.2p02 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course.
Improvement of G4Exception (and an announcement on G4ApplicationState) Makoto Asai (SLAC) on behalf of Architecture team.
Primary particle generation Makoto Asai (SLAC) Geant4 Users CERN Nov. 12 th, 2002.
Scoring I Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,
Makoto Asai (SLAC) Geant4 Users CERN Nov. 15 th, 2002 Customizing Run Management.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 12 th, 2002 Detector Sensitivity.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Detector Sensitivity.
Nested Parameterization
Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
6 March 2006 G4NAMU Geant4 Developments J. Perl 1 SLAC - Redwood Room 6 March Geant4 North American Medical.
Recent and on-going developments in Kernel Makoto Asai (SLAC) 4 th Geant4 Space Users’ Workshop November 6 th, 2006.
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
Some tips for geometries of medical applications Makoto Asai (SLAC)
parameterisation The aim of the exercise is again to build a lead-scintillator calorimeter, this time though the calorimeter will be a trapezoid.
Other GEANT4 capabilities Event biasing Parameterisation (fast simulation) Scoring Persistency Parallelisation and integration in a distributed computing.
Geant4 v9.3p01 Kernel III Makoto Asai (SLAC) Geant4 Tutorial Course.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Maria Grazia Pia Detector Response Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
UI command Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
山下智弘 JST CREST/ 神戸大学 Borrowing especially from presentations of M. Asai(SLAC) Geant4 Japan Oct, RCNS, based on Geant4 9.0.p01.
User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)
Alex Howard - Event Biasing Geant4 Users - Lisbon Event biasing and Variance Reduction - Geometrical Alex Howard, CERN Geant4 Users Workshop, Lisbon.
Geant4 internal Classes and Objects Geant4 Users’ Tutorial February 2010 Gunter Folger / CERN User Action & Information Classes.
Geant zemi 2007/1/11. Sensitive detector In a simulation, we want to know –Position and time of the particle at the detector –Momentum and energy of the.
Cristian Bungau ThorEA Meeting - Oxford - April 2010.
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.
A Thread-Parallel Geant4 with Shared Geometry Gene Cooperman and Xin Dong College of Computer and Information Science Northeastern University 360 Huntington.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
Read-out and detector response
Geometry 3 I.Hrivnacova IPN, Orsay Most slides thanks to M. Asai, SLAC Cours Paris June 2007.
Interaction with the Geant4 kernel
Biasing and scoring
J. Apostolakis, M. Asai, G. Cosmo, A. Howard
Makoto Asai (SLAC) Geant4 Tutorial Course
Interaction with the Geant4 kernel
CS250 Introduction to Computer Science II
Biasing and scoring
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.
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Geant4 introduction 2008/03/18 Nobu Katayama KEK
Makoto Asai (SLAC) Geant4 Tutorial Course
Read-out and detector response
Makoto Asai (SLAC) Geant4 Tutorial Course
Detector sensitivity Makoto Asai (SLAC Computing Services)
Makoto Asai (SLAC) Geant4 Tutorial Course
Read-out and detector response
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
Makoto Asai (SLAC) Geant4 Tutorial Course
CIS 199 Final Review.
Customizing Run Management
Primary particle Makoto Asai (SLAC Computing Services)
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002
Geant4: Detector description module
Presentation transcript:

Geant4 v9.3 Scoring II Makoto Asai (SLAC) Geant4 Tutorial Course

Contents Retrieving information from Geant4 Command-based scoring Add a new scorer/filter to command-based scoring Define scorers in the tracking volume Accumulate scores for a run Scoring II - M.Asai (SLAC)2 This talk Previous talk

Geant4 v9.3 Add a new scorer/filter to command-based scorers

Scorer base class G4VPrimitiveScorer is the abstract base of all scorer classes. To make your own scorer you have to implement at least: –Constructor –Initialize() Initialize G4THitsMap map object –ProcessHits() Get the physics quantity you want from G4Step, etc. and fill the map –Clear() –GetIndex() Convert three copy numbers into an index of the map G4PSEnergyDeposit3D could be a good example. Create your own messenger class to define /score/quantity/ command. –Refer to G4ScorerQuantityMessenger class. Scoring II - M.Asai (SLAC)4

Filter class G4VSDFilter –Abstract base class which you can use to make your own filter class G4VSDFilter { public: G4VSDFilter(G4String name); virtual ~G4VSDFilter(); public: virtual G4bool Accept(const G4Step*) const = 0; … Create your own messenger class to define /score/filter/ command. –Refer to G4ScorerQuantityMessenger class. Scoring II - M.Asai (SLAC)5

Geant4 v9.3 Define scorers to the tracking volume

Class diagram Scoring II - M.Asai (SLAC)7 G4LogicalVolume G4VSensitiveDetector G4MultiFunctionalDetector userSensitiveDetector G4Event G4HCofThisEvent G4VHitsCollection G4THitsCollection G4THitsMap userHitsCollection or userHitsMap G4VHit userHit G4VPrimitiveSensitivity Concrete class provided by G4 Abstract base class provided by G4 Template class provided by G4 User’s class G4PSDoseScorerhits map has kind of G4PSDoseScorerhits mapG4PSDoseScorerhits mapG4PSDoseScorerhits mapG4PSDoseScorerhits map 0..1 n 1 n n n n 1

example MyDetectorConstruction::Construct() { … G4LogicalVolume* myCellLog = new G4LogicalVolume(…); G4VPhysicalVolume* myCellPhys = new G4PVParametrised(…); G4MultiFunctionalDetector* myScorer = new G4MultiFunctionalDetector(“myCellScorer”); G4SDManager::GetSDMpointer()->AddNewDetector(myScorer); myCellLog->SetSensitiveDetector(myScorer); G4VPrimitiveSensitivity* totalSurfFlux = new G4PSFlatSurfaceFlux(“TotalSurfFlux”); myScorer->Register(totalSurfFlux); G4VPrimitiveSensitivity* totalDose = new G4PSDoseDeposit(“TotalDose”); myScorer->Register(totalDose); } Scoring II - M.Asai (SLAC)8 You may register arbitrary number of primitive scorers.

Keys of G4THitsMap All provided primitive scorer classes use G4THitsMap. By default, the copy number is taken from the physical volume to which G4MultiFunctionalDetector is assigned. –If the physical volume is placed only once, but its (grand-)mother volume is replicated, use the second argument of the constructor of the primitive scorer to indicate the level where the copy number should be taken. e.g. G4PSCellFlux(G4Steing name, G4int depth=0) See exampleN07 –If your indexing scheme is more complicated (e.g. utilizing copy numbers of more than one hierarchies), you can override the virtual method GetIndex() provided for all the primitive scorers. Scoring II - M.Asai (SLAC)9 CopyNo 0 Copy No 0 CopyNo 0 Copy No 0 CopyNo 0 Copy No 0 Copy No 0 Copy No 1Copy No 2 Scorer A Scorer B Key should be taken from upper geometry hierarchy

Creating your own scorer Scoring II - M.Asai (SLAC)10 Though we provide most commonly-used scorers, you may want to create your own. –If you believe your requirement is quite common, just let us know, so that we will add a new scorer. G4VPrimitiveScorer is the abstract base class. class G4VPrimitiveScorer { public: G4VPrimitiveScorer(G4String name, G4int depth=0); virtual ~G4VPrimitiveScorer(); protected: virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*) = 0; virtual G4int GetIndex(G4Step*); public: virtual void Initialize(G4HCofThisEvent*); virtual void EndOfEvent(G4HCofThisEvent*); virtual void clear(); … };

G4VSDFilter G4VSDFilter can be attached to G4VSensitiveDetector and/or G4VPrimitiveSensitivity to define which kinds of tracks are to be scored. –E.g., surface flux of protons can be scored by G4PSFlatSurfaceFlux with a filter that accepts protons only. Scoring II - M.Asai (SLAC)11 G4VSensitiveDetector G4MultiFunctionalDetectoruserSensitiveDetector G4VPrimitiveSensitivity G4PSDoseScorer G4VSDFilter G4SDParticleFilter userFilter G4SDParticleFilter

example… MyDetectorConstruction::Construct() { … G4LogicalVolume* myCellLog = new G4LogicalVolume(…); G4VPhysicalVolume* myCellPhys = new G4PVParametrised(…); G4MultiFunctionalDetector* myScorer = new G4MultiFunctionalDetector(“myCellScorer”); G4SDManager::GetSDMpointer()->AddNewDetector(myScorer); myCellLog->SetSensitiveDetector(myScorer); G4VPrimitiveSensitivity* totalSurfFlux = new G4PSFlatSurfaceFlux(“TotalSurfFlux”); myScorer->Register(totalSurfFlux); G4VPrimitiveSensitivity* protonSufFlux = new G4PSFlatSurfaceFlux(“ProtonSurfFlux”); G4VSDFilter* protonFilter = new G4SDParticleFilter(“protonFilter”); protonFilter->Add(“proton”); protonSurfFlux->SetFilter(protonFilter); myScorer->Register(protonSurfFlux); } Scoring II - M.Asai (SLAC)12

Geant4 v9.3 Accumulate scores for a run

Class diagram Scoring II - M.Asai (SLAC)14 G4LogicalVolume G4VSensitiveDetector G4MultiFunctionalDetector userSensitiveDetector G4Event G4HCofThisEvent G4VHitsCollection G4THitsCollection G4THitsMap userHitsCollection or userHitsMap G4VHit userHit G4VPrimitiveSensitivity Concrete class provided by G4 Abstract base class provided by G4 Template class provided by G4 User’s class G4PSDoseScorerhits map has kind of G4PSDoseScorerhits mapG4PSDoseScorerhits mapG4PSDoseScorerhits mapG4PSDoseScorerhits map 0..1 n 1 n n n n 1

Score == G4THitsMap At the end of successful event, G4Event has a vector of G4THitsMap as the scores. Create your own Run class derived from G4Run, and implement RecordEvent(const G4Event*) virtual method. Here you can get all output of the event so that you can accumulate the sum of an event to a variable for entire run. –RecordEvent(const G4Event*) is automatically invoked by G4RunManager. –Your run class object should be instantiated in GenerateRun() method of your UserRunAction. Scoring II - M.Asai (SLAC)15

Customized run class #include “G4Run.hh” #include “G4Event.hh” #include “G4THitsMap.hh” Class MyRun : public G4Run { public: MyRun(); virtual ~MyRun(); virtual void RecordEvent(const G4Event*); private: G4int nEvent; G4int totalSurfFluxID, protonSurfFluxID, totalDoseID; G4THitsMap totalSurfFlux; G4THitsMap protonSurfFlux; G4THitsMap totalDose; public: … access methods … }; Scoring II - M.Asai (SLAC)16 Implement how you accumulate event data

Customized run class MyRun::MyRun() : nEvent(0) { G4SDManager* SDM = G4SDManager::GetSDMpointer(); totalSurfFluxID = SDM->GetCollectionID("myCellScorer/TotalSurfFlux"); protonSurfFluxID = SDM->GetCollectionID("myCellScorer/ProtonSurfFlux"); totalDoseID = SDM->GetCollectionID("myCellScorer/TotalDose"); } Scoring II - M.Asai (SLAC)17 name of G4MultiFunctionalDetector object name of G4VPrimitiveSensitivity object

Customized run class void MyRun::RecordEvent(const G4Event* evt) { nEvent++; G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); G4THitsMap * eventTotalSurfFlux = (G4THitsMap *)(HCE->GetHC(totalSurfFluxID)); G4THitsMap * eventProtonSurfFlux = (G4THitsMap *)(HCE->GetHC(protonSurfFluxID)); G4THitsMap * eventTotalDose = (G4THitsMap *)(HCE->GetHC(totalDose)); totalSurfFlux += *eventTotalSurfFlux; protonSurfFlux += *eventProtonSurfFlux; totalDose += *eventTotalDose; } Scoring II - M.Asai (SLAC)18 No need of loops. += operator is provided !

RunAction with customized run G4Run* MyRunAction::GenerateRun() { return (new MyRun()); } void MyRunAction::EndOfRunAction(const G4Run* aRun) { const MyRun* theRun = (const MyRun*)aRun; // … analyze / record / print-out your run summary // MyRun object has everything you need … } As you have seen, to accumulate event data, you do NOT need –Event / tracking / stepping action classes All you need are your Run and RunAction classes. Refer to exampleN07 Scoring II - M.Asai (SLAC)19