12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Detector Definition and Responseand G4VPrimitiveScorer connected with a slush ("/"). G4THitsMap has a [] operator taking the key value as anargument and returning the pointer of the value. Please note that the [] operator returns the pointer of the value.If you get zero from the [] operator, it does not mean the value is zero, but that the provided key does not exist.The value itself is accessible with an astarisk ("*"). It is advised to check the validity of the returned pointerbe<strong>for</strong>e accessing the value. G4THitsMap also has a += operator in order to accumulate event data into run data.Example 4.16 shows the use of G4THitsMap.Example 4.16. An example of accessing to G4THitsMap objects.#include "ExN07Run.hh"#include "G4Event.hh"#include "G4HCofThisEvent.hh"#include "G4SDManager.hh"ExN07Run::ExN07Run(){G4String detName[6] = {"Calor-A_abs","Calor-A_gap","Calor-B_abs","Calor-B_gap","Calor-C_abs","Calor-C_gap"};G4String primNameSum[6] = {"eDep","nGamma","nElectron","nPositron","trackLength","nStep"};G4String primNameMin[3] = {"minEkinGamma","minEkinElectron","minEkinPositron"};G4SDManager* SDMan = G4SDManager::GetSDMpointer();G4String fullName;<strong>for</strong>(size_t i=0;iGetHCofThisEvent();if(!HCE) return;numberOfEvent++;<strong>for</strong>(size_t i=0;iGetMap()->begin();<strong>for</strong>(; itr != evtMap->GetMap()->end(); itr++){G4int key = (itr->first);G4double val = *(itr->second);G4double* mapP = mapMin[i][k][key];if( mapP && (val>*mapP) ) continue;mapMin[i][k].set(key,val);}}}}4.4.6. Concrete classes of G4VPrimitiveScorerWith <strong>Geant4</strong> version 8.0, several concrete primitive scorer classes are provided, all of which are derived from theG4VPrimitiveScorer abstract base class and which are to be registered to G4MultiFunctionalDetector. Each ofthem contains one G4THitsMap object and scores a simple double value <strong>for</strong> each key.132

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!