2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter...

22
2006/11/10 Pasadena 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Scorer and Sensitive Detector Filter Detector Filter Tsukasa Aso Tsukasa Aso Toyama National College of Maritime T Toyama National College of Maritime T echnology, echnology, JST CREST JST CREST
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

Transcript of 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter...

Page 1: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

2006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT 11

Scorer and Sensitive Detector Scorer and Sensitive Detector FilterFilter

Tsukasa AsoTsukasa AsoToyama National College of Maritime Technology,Toyama National College of Maritime Technology,JST CRESTJST CREST

Page 2: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

222006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

How should we do for scoring efficiently?How should we do for scoring efficiently?

What object does have particle information?What object does have particle information? G4StepG4Step object has a particle information of particular step object has a particle information of particular step G4Step object has a pointer to G4Step object has a pointer to G4TrackG4Track

Where can we pick the particle information up?Where can we pick the particle information up? (Where is G4Step/G4Track object accessible?)(Where is G4Step/G4Track object accessible?)

G4UserTrackingActionG4UserTrackingAction (G4Track) (G4Track) Not recommendedNot recommended Called every time when a track starts and endsCalled every time when a track starts and ends

G4UserSteppingActtionG4UserSteppingActtion (G4Step) (G4Step) Not recommendedNot recommended Called every time when a track makes a stepCalled every time when a track makes a step

G4VSensitiveDetectorG4VSensitiveDetector (G4Step) (G4Step) RecommendedRecommended Called only when a track is in an assigned logical volumeCalled only when a track is in an assigned logical volume

Geant4 offers two kinds of scorers using G4VSensitiveDetectorGeant4 offers two kinds of scorers using G4VSensitiveDetector Develop your own SensitiveDetector/Hits/HitsCollection classesDevelop your own SensitiveDetector/Hits/HitsCollection classes Use Primitive Scorers and Sensitive Detector FiltersUse Primitive Scorers and Sensitive Detector Filters

ROI

Page 3: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

332006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Basic Geant4 scoring functionality Basic Geant4 scoring functionality

Geant4 provides Geant4 provides two abstract base classestwo abstract base classes and and one template classone template class for user to define his/her own detector sensitivity.for user to define his/her own detector sensitivity.

G4VSensitiveDetector G4VSensitiveDetector The user has to provide his/her own implementation of the deteThe user has to provide his/her own implementation of the detector response to create ctor response to create hit(s)hit(s) using the information of G4Step. using the information of G4Step.

G4VHit G4VHit Hit is Hit is a snapshota snapshot of the physical interaction of a track or an ac of the physical interaction of a track or an accumulation of interactions of tracks in the sensitive region of yocumulation of interactions of tracks in the sensitive region of your detector.ur detector.

G4THitsCollection (G4VHitsCollection)G4THitsCollection (G4VHitsCollection)Hit Collection is a container for storing G4VHit objects. G4THitsHit Collection is a container for storing G4VHit objects. G4THitsCollection uses Collection uses a STL vectora STL vector..

Page 4: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

442006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

How to setup? How to setup?

Implements your own G4VSensitiveDetector class and G4VHits classImplements your own G4VSensitiveDetector class and G4VHits class G4VSensitiveDetectorG4VSensitiveDetector

Define your Scoring class derived from G4VSensitiveDetector classDefine your Scoring class derived from G4VSensitiveDetector classImplements Implements bool processHits(G4Step* aStep,G4TouchabkeHistory*)bool processHits(G4Step* aStep,G4TouchabkeHistory*) met method to create ( or update ) your Hit object and store the Hit in HitsCollection hod to create ( or update ) your Hit object and store the Hit in HitsCollection objectobject

G4VHitG4VHitDefine your Hit class derived from G4VHit classDefine your Hit class derived from G4VHit classDeclare member variables and access methods which you want to scoreDeclare member variables and access methods which you want to score

Assign G4VSensitiveDetector to a particular logical volumeAssign G4VSensitiveDetector to a particular logical volume The G4VSensitiveDetector is automatically called in the particular logical The G4VSensitiveDetector is automatically called in the particular logical

volume by kernel volume by kernel The HitsCollection is automatically stored in The HitsCollection is automatically stored in G4EventG4Event

Get Event or Run Summary Use user hooks G4UserEventAction, G4UserRunAction classes

Page 5: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

552006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Feature of Primitive Scorer based on Feature of Primitive Scorer based on G4VSensitiveDetectorG4VSensitiveDetector

Concrete Primitive scorer classes (v.8.0~)Concrete Primitive scorer classes (v.8.0~) A set of classes for getting physical quantities rather than hits A set of classes for getting physical quantities rather than hits

(snapshot of interaction)(snapshot of interaction)

Physical quantity is sampled and scored for each geometrical cell.Physical quantity is sampled and scored for each geometrical cell.

Include both of an algorithm and a hit collectionInclude both of an algorithm and a hit collection

Users can skip over implementing sensitive detector and Users can skip over implementing sensitive detector and hit classes.hit classes.

I do not need to do this!!

Page 6: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

662006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Primitive Scorer ClassesPrimitive Scorer Classes There are three types of classes,There are three types of classes,

G4MultiFunctionalDetectorG4MultiFunctionalDetector G4VPrimitiveScorerG4VPrimitiveScorer

G4THitsMap = Hits collection for storing physical quantityG4THitsMap = Hits collection for storing physical quantity G4VSDFilterG4VSDFilter

Enable to filter particle information for scoringEnable to filter particle information for scoring

G4VSensitiveDetector

G4MultiFunctionalDetectoruserSensitiveDetector

G4VPrimitiveScrer

G4PSDoseScorerG4PSDoseScorer

G4PSDoseScorerG4PSDoseScorer

G4PSDoseScorer

G4VSDFilter

G4SDParticleFilterG4SDParticleFilter

userFilter

G4SDParticleFilterG4SDParticleFilter

G4SDParticleFilterG4SDParticleFilter

Page 7: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

772006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

G4MultiFunctionalDetectorG4MultiFunctionalDetector

G4MultiFunctionalDetectorG4MultiFunctionalDetector is a concrete class derived from is a concrete class derived from

G4VSensitiveDetectorG4VSensitiveDetector It should be set to It should be set to a logical volumea logical volume as a kind of sensitive detector. as a kind of sensitive detector.

It takes arbitrary number of It takes arbitrary number of G4VPrimitiveScorerG4VPrimitiveScorer classes. classes.

By registering By registering G4VPrimitiveScorerG4VPrimitiveScorer classes, you can define the scoring classes, you can define the scoring

detector of your need.detector of your need.

Each Each G4VPrimitiveScorerG4VPrimitiveScorer class accumulates class accumulates one physics quantityone physics quantity for for each each

physical volumephysical volume..

For example, For example, G4PSDoseScorerG4PSDoseScorer (a concrete class of G4VPrimitiveScorer (a concrete class of G4VPrimitiveScorer

provided by Geant4) accumulates provided by Geant4) accumulates dose for each cell.dose for each cell.

By using By using G4MultiFunctionalDetectorG4MultiFunctionalDetector and provided concrete and provided concrete

G4VPrimitiveScorer G4VPrimitiveScorer classes, you do not need to know how to implement classes, you do not need to know how to implement

sensitive detector and hit classes.sensitive detector and hit classes.

Page 8: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

882006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

List of provided primitive scorersList of provided primitive scorersConcrete Primitive Scorers ( See Application Developers Guide 4.4.6 )Concrete Primitive Scorers ( See Application Developers Guide 4.4.6 )

Track lengthTrack lengthG4PSTrackLength, G4PSPassageTrackLengthG4PSTrackLength, G4PSPassageTrackLength

Deposited energyDeposited energyG4PSEnergyDepsit, G4PSDoseDepositG4PSEnergyDepsit, G4PSDoseDeposit

Current/FluxCurrent/FluxG4PSFlatSurfaceCurrent, G4PSSphereSurfaceCurrent, G4PSPassageCurrent, G4PSFlatSurfaceCurrent, G4PSSphereSurfaceCurrent, G4PSPassageCurrent, G4PSFlatSurfaceFlux, G4PSCellFlux, G4PSPassageCellFluxG4PSFlatSurfaceFlux, G4PSCellFlux, G4PSPassageCellFlux

OthersOthersG4PSMinKinEAtGeneration, G4PSNofSecondary, G4PSNofStep, G4PSMinKinEAtGeneration, G4PSNofSecondary, G4PSNofStep, G4PSCellChargeG4PSCellCharge

angle

V : Volume

L : Total step length in the cell.

SurfaceCurrent :SurfaceCurrent :Count number Count number of of injecting partiinjecting particles cles at defined surat defined surface.face.

SurfaceFlux :SurfaceFlux :Sum up 1/cos(angSum up 1/cos(angle) of injecting partle) of injecting particlesiclesat defined surfaceat defined surface

CellFlux :CellFlux :Sum of L / V of injectiSum of L / V of injecting particles ng particles in the geometrical cell.in the geometrical cell.

Page 9: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

992006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

List of SD Filter classesList of SD Filter classes

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.

G4SDChargedFilter, G4SDNeutralFilterG4SDChargedFilter, G4SDNeutralFilter Accept only charged/neutral tracks, respectivelyAccept only charged/neutral tracks, respectively

G4SDKineticEnergyFilterG4SDKineticEnergyFilter Accepts tracks within the defined range of kinetic energyAccepts tracks within the defined range of kinetic energy

G4SDParticleFilterG4SDParticleFilter Accepts tracks of registered particle typesAccepts tracks of registered particle types

G4SDParticleWithEnergyFilterG4SDParticleWithEnergyFilter Accepts tracks of registered particle types within the defined range of kinetic Accepts tracks of registered particle types within the defined range of kinetic

energyenergyG4VSDFilterG4VSDFilter

Abstract base class which you can use to make your own filterAbstract base class which you can use to make your own filter

Page 10: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

10102006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

For example…For example…

MyDetectorConstruction::Construct()

{

… snippet …

G4LogicalVolume* myCellLog = new G4LogicalVolume(…);

G4VPhysicalVolume* myCellPhys = new G4PVParametrised(…);

G4MultiFunctionalDetector* myScorer = new G4MultiFunctionalDetector(“myCellScorer”);

G4SDManager::GetSDMpointer()->AddNewDetector(myScorer);

myCellLog->SetSensitiveDetector(myScorer);

G4VPrimitiveScorer* totalSurfFlux = new G4PSFlatSurfaceFlux(“TotalSurfFlux”);

myScorer->RegisterPrimitive(totalSurfFlux);

G4VPrimitiveScorer* protonSufFlux = new G4PSFlatSurfaceFlux(“ProtonSurfFlux”);

G4VSDFilter* protonFilter = new G4SDParticleFilter(“protonFilter”);

protonFilter->Add(“proton”);

protonSurfFlux->SetFilter(protonFilter);

myScorer->RegisterPrimitive(protonSurfFlux);

}

See example “novice/N07”

Page 11: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

11112006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

for examplefor exampleIf you need to get spectrumIf you need to get spectrum

…. snippet G4MultiFunctionalDetector* MFDet = new G4MultiFunctionalDetector(…); ….. //--- Surface Current for gamma with energy bin. // This example creates four primitive scorers. // 4 bins with energy --- Primitive Scorer Name // 1. to 10 KeV, gammaSurfCurr000 // 10 keV to 100 KeV, gammaSurfCurr001 // 100 keV to 1 MeV, gammaSurfCurr002 // 1 MeV to 10 MeV. gammaSurfCurr003 // char name[16]; for ( G4int i = 0; i < 4; i++){ std::sprintf(name,"gammaSurfCurr%03d",i); G4String psgName(name); G4double kmin = std::pow(10.,(G4double)i)*keV; G4double kmax = std::pow(10.,(G4double)(i+1))*keV; //-- Particle with kinetic energy filter. G4SDParticleWithEnergyFilter* pkinEFilter = new G4SDParticleWithEnergyFilter(fltName="gammaE filter",kmin,kmax); pkinEFilter->add("gamma"); // Accept only gamma. pkinEFilter->show(); // Show accepting condition to stdout. //-- Surface Current Scorer which scores number of tracks in unit area.

G4PSFlatSurfaceCurrent* scorer =   new G4PSFlatSurfaceCurrent(psgName,fCurrent_InOut); scorer->SetFilter(pkinEFilter); // Assign filter. MFDet->RegisterPrimitive(scorer); // Register it to MultiFunctionalDetector. } … snippet ….

See example “extended/runAndEvent/RE02

Page 12: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

12122006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Creating your own scorerCreating your own scorer

Though we provide most commonly-used scorers, you may want to create your own.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 If you believe your requirement is quite common, just let us know, so that we will add a new

scorer.scorer.

G4VPrimitiveScorer is the abstract base class.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();

};

Page 13: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

13132006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Creating your own SDFilterCreating your own SDFilter

G4VSDFilter is the abstract base class G4VSDFilter is the abstract base class

class G4VSDFilter { public: G4VSDFilter(G4String name); virtual ~G4VSDFilter(); public: virtual G4bool Accept(const G4Step*) const = 0;…

Page 14: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

14142006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Sensitive detector vs. primitive scorerSensitive detector vs. primitive scorer

Sensitive detectorSensitive detectorYou have to implement your own You have to implement your own detector and hit classes.detector and hit classes.One hit class can contain many One hit class can contain many quantities. A hit can be made for quantities. A hit can be made for each individual step, or each individual step, or accumulate quantities.accumulate quantities.Basically one hits collection is Basically one hits collection is made per one detector.made per one detector.Hits collection is relatively Hits collection is relatively compact. compact.

Primitive scorerPrimitive scorerMany scorers are provided by Many scorers are provided by Geant4. You can add your own.Geant4. You can add your own.Each scorer accumulates one Each scorer accumulates one quantity for an event. quantity for an event.

G4MultiFunctionalDetector G4MultiFunctionalDetector creates many collections (maps), creates many collections (maps), i.e. one collection per one i.e. one collection per one scorer.scorer.Keys of maps are redundant for Keys of maps are redundant for scorers of same volume.scorers of same volume.I would suggest to :I would suggest to :

Use primitive scorers Use primitive scorers if you are if you are notnot interested in recording each individual step interested in recording each individual step butbut accumulating accumulating

some physics quantities for an event for a run, andsome physics quantities for an event for a run, and if you do if you do notnot have to have too many scorers. have to have too many scorers.

Otherwise, consider implementing your own sensitive detector.Otherwise, consider implementing your own sensitive detector.

Page 15: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

2006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT 1515

Accumulating scores for a runAccumulating scores for a run

BeginOfRunAction

EndOfRunAction

BeginOfEventAction

EndOfEventAction

G4Run

G4Event Event Summary

Accumulate event dataRun Summary

Page 16: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

16162006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

A tip for scoringA tip for scoring

For scoring purposes, you need to accumulate a physical quantity (e.g. energy dFor scoring purposes, you need to accumulate a physical quantity (e.g. energy d

eposition of a step) for entire run of many events. In such a case, do eposition of a step) for entire run of many events. In such a case, do NOTNOT sum u sum u

p individual energy deposition of each step directly to a variable for entire run.p individual energy deposition of each step directly to a variable for entire run.

Compared to the total sum for entire run, each energy deposition of single stCompared to the total sum for entire run, each energy deposition of single st

ep is too tiny. Rounding error problem may easily happen.ep is too tiny. Rounding error problem may easily happen.

Total energy deposition of 1 million events of 1 GeV incident particle ends up to 1 Total energy deposition of 1 million events of 1 GeV incident particle ends up to 1

PeV (10PeV (1015 15 eV), while energy deposition of each single step is O(1 keV) or even smeV), while energy deposition of each single step is O(1 keV) or even sm

aller.aller.

Create your own Run class derived from Create your own Run class derived from G4RunG4Run, and implement , and implement RecordEvent(cRecordEvent(c

onst G4Event*)onst G4Event*) virtual method. Here you can get all output of the event so that y virtual method. Here you can get all output of the event so that y

ou can accumulate the sum of an event to a variable for entire run.ou can accumulate the sum of an event to a variable for entire run.

RecordEvent(const G4Event*)RecordEvent(const G4Event*) is automatically invoked by is automatically invoked by G4RunManagerG4RunManager..

Your run class object should be instantiated in Your run class object should be instantiated in GenerateRun()GenerateRun() method of you method of you

r r UserRunActionUserRunAction..

Page 17: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

17172006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Customized run classCustomized run class

#include “G4Run.hh”#include “G4Run.hh”#include “G4Event.hh”#include “G4Event.hh”#include “G4THitsMap.hh”#include “G4THitsMap.hh”Class MyRun : public G4RunClass MyRun : public G4Run{{ public: public: MyRun();MyRun(); virtual ~MyRun();virtual ~MyRun(); virtual void RecordEvent(const G4Event*);virtual void RecordEvent(const G4Event*); private:private: G4int nEvent;G4int nEvent; G4int totalSurfFluxID, protonSurfFluxID, totalDoseID;G4int totalSurfFluxID, protonSurfFluxID, totalDoseID; G4THitsMap<G4double> totalSurfFlux;G4THitsMap<G4double> totalSurfFlux; G4THitsMap<G4double> protonSurfFlux;G4THitsMap<G4double> protonSurfFlux; G4THitsMap<G4double> totalDose;G4THitsMap<G4double> totalDose;

G4THitsMap<G4double>* eventTotalSurfFlux;G4THitsMap<G4double>* eventTotalSurfFlux;

G4THitsMap<G4double>* eventProtonSurfFlux; G4THitsMap<G4double>* eventProtonSurfFlux;

G4THitsMap<G4double>* eventTotalDoseG4THitsMap<G4double>* eventTotalDose public:public: … … access methods …access methods …};};

Implement how you accumulate event data

Page 18: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

18182006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Customized run classCustomized run classMyRun::MyRun() : nEvent(0)MyRun::MyRun() : nEvent(0)

{{

G4SDManager* SDM = G4SDManager::GetSDMpointer();G4SDManager* SDM = G4SDManager::GetSDMpointer();

totalSurfFluxID = SDM->GetCollectionID("totalSurfFluxID = SDM->GetCollectionID("myCellScorer/myCellScorer/TotalSurfFlux");");

protonSurfFluxID = SDM->GetCollectionID("protonSurfFluxID = SDM->GetCollectionID("myCellScorer/ProtonmyCellScorer/ProtonSurfFlux");");

totalDoseID = SDM->GetCollectionID("totalDoseID = SDM->GetCollectionID("myCellScorer/myCellScorer/TotalDose");");

}}

void MyRun::RecordEvent(const G4Event* evt)void MyRun::RecordEvent(const G4Event* evt)

{{

nEvent++;nEvent++;

G4HCofThisEvent* HCE = evt->GetHCofThisEvent();G4HCofThisEvent* HCE = evt->GetHCofThisEvent();

eventTotalSurfFlux = (G4THitsMap<G4double>*)(HCE->GetHC(totalSurfFluxID));eventTotalSurfFlux = (G4THitsMap<G4double>*)(HCE->GetHC(totalSurfFluxID));

eventProtonSurfFlux = (G4THitsMap<G4double>*)(HCE->GetHC(protonSurfFluxID));eventProtonSurfFlux = (G4THitsMap<G4double>*)(HCE->GetHC(protonSurfFluxID));

eventTotalDose = (G4THitsMap<G4double>*)(HCE->GetHC(totalDose));eventTotalDose = (G4THitsMap<G4double>*)(HCE->GetHC(totalDose));

totalSurfFlux += *eventTotalSurfFlux;totalSurfFlux += *eventTotalSurfFlux;

protonSurfFlux += *eventProtonSurfFlux;protonSurfFlux += *eventProtonSurfFlux;

totalDose += *eventTotalDose;totalDose += *eventTotalDose;

}}

name of G4MultiFunctionalDetector object

name of G4VPrimitiveScorer object

No need of loops. += operator is provided !

Page 19: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

19192006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

RunAction with customized run RunAction with customized run

G4Run* MyRunAction::GenerateRun()G4Run* MyRunAction::GenerateRun()

{ { return (new MyRun());return (new MyRun()); } }

void MyRunAction::EndOfRunAction(const G4Run* aRun)void MyRunAction::EndOfRunAction(const G4Run* aRun)

{{

MyRun* theRun = (MyRun*)aRun;MyRun* theRun = (MyRun*)aRun;

// … analyze / record / print-out your run summary// … analyze / record / print-out your run summary

// MyRun object has everything you need …// MyRun object has everything you need …

}}

As you have seen, to accumulate event data, you do As you have seen, to accumulate event data, you do NOTNOT need need Event / tracking / stepping action classesEvent / tracking / stepping action classes

All you need are your All you need are your Run and RunActionRun and RunAction classes. classes.

With newly introducing concrete sensitivity classes, you do With newly introducing concrete sensitivity classes, you do NOTNOT even need even need Sensitive detector implementationSensitive detector implementation

Refer to exampleN07Refer to exampleN07

Page 20: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

20202006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Accessing to a hits map for Run/Event SummaryAccessing to a hits map for Run/Event Summary

G4THitsMap<G4double>G4THitsMap<G4double> is an STL map, mapping a key (G4int) to a is an STL map, mapping a key (G4int) to a pointerpointer to a to a double value, i.e. equivalent to double value, i.e. equivalent to std::map<G4int,G4double*>..

G4HCofThisEvent* HCE = evt->GetHCofThisEvent();G4HCofThisEvent* HCE = evt->GetHCofThisEvent();

G4THitsMap<G4double>* evtMap

= (G4THitsMap<G4double>*)(HCE->GetHC(colID));

To get number of entriesTo get number of entries

G4int n = evtMap->entries();

To access to each entry sequentiallyTo access to each entry sequentially

std::map<G4int,G4double*>::iterator itr

= evtMap->GetMap()->begin();

for( ; itr!=evtMap->GetMap()->end(); itr++ )

{ G4int key = (itr->first);

G4double val = *(itr->second); }

To access to a double value with a keyTo access to a double value with a key

G4double* pVal = (*evtMap)[key];

If(pVal) val = *pVal; Null pointer is returned if the key does not exist in the map.

Pointer is returned.

Page 21: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

21212006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

SummarySummary

Geant4 offers G4VSensitiveDetector scorer.Geant4 offers G4VSensitiveDetector scorer. There are two sort of choice for users,There are two sort of choice for users,

Base classes for user developmentsBase classes for user developmentsPrimitive scorer classes for rapid developmentsPrimitive scorer classes for rapid developments

A part of this development was supported by JST CREST.A part of this development was supported by JST CREST.

User can make a choice according to the needs,User can make a choice according to the needs,E.g. life cycle of application, developing skill, etc..E.g. life cycle of application, developing skill, etc..

Future worksFuture works We are still working to improve primitive scorers for more efficient We are still working to improve primitive scorers for more efficient

scoring.scoring. Requirements from users are very welcome. We will involve it to Requirements from users are very welcome. We will involve it to

future release.future release.

Page 22: 2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMT 1 Scorer and Sensitive Detector Filter Tsukasa Aso Toyama National College of Maritime Technology,

22222006/11/10 Pasadena2006/11/10 Pasadena GEANT4-SPENVIS, Tsukasa Aso, TNCMTGEANT4-SPENVIS, Tsukasa Aso, TNCMT

Keys of G4THitsMapKeys of G4THitsMapAll provided primitive scorer classes use All provided primitive scorer classes use G4THitsMap<G4double>G4THitsMap<G4double>..

By default, the copy number is taken from the physical volume to which G4MultiFunctionalBy default, the copy number is taken from the physical volume to which G4MultiFunctional

Detector is assigned.Detector is assigned.

If the physical volume is placed only once, but its (grand-)mother volume is rIf the physical volume is placed only once, but its (grand-)mother volume is r

eplicated, use the second argument of the constructor of the primitive scorer eplicated, use the second argument of the constructor of the primitive scorer

to indicate the level where the copy number should be taken.to indicate the level where the copy number should be taken.

e.g. G4PSCellFlux(G4Steing name, e.g. G4PSCellFlux(G4Steing name, G4int depth=0G4int depth=0))

See exaSee exa

mpleN07mpleN07

If your indexing scheme is more complicated (e.g. utilizing copy numbers of If your indexing scheme is more complicated (e.g. utilizing copy numbers of

more than one hierarchies), you can override the virtual method more than one hierarchies), you can override the virtual method GetIndex()GetIndex() p p

rovided for all the primitive scorers. rovided for all the primitive scorers. (v8.x example RE02 will show you.)(v8.x example RE02 will show you.)

CopyNo0

Copy No0

CopyNo0

Copy No0

CopyNo0

Copy No0

Copy No 0 Copy No 1 Copy No 2

Scorer A

Scorer B

Key should be taken from upper geometry hierarchy