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 ResponseG4int myDigiCollID = fDM->GetDigiCollectionID( "digi_collection_name" );Then, you can get the pointer to your concrete G4THitsCollection object or G4TDigiCollection object of thecurrently processing event.MyHitsCollection * HC = fDM->GetHitsCollection( myHitsCollID );MyDigiCollection * DC = fDM->GetDigiCollection( myDigiCollID );In case you want to access to the hits or digits collection of previous events, add the second argument.MyHitsCollection * HC = fDM->GetHitsCollection( myHitsCollID, n );MyDigiCollection * DC = fDM->GetDigiCollection( myDigiCollID, n );where, n indicates the hits or digits collection of the n th previous event.4.6. Object Persistency4.6.1. Persistency in <strong>Geant4</strong>Object persistency is provided by <strong>Geant4</strong> as an optional category, so that the user may run <strong>Geant4</strong> with or withoutan object database management system (ODBMS).When a usual (transient) object is created in C++, the object is placed onto the application heap and it ceases toexist when the application terminates. Persistent objects, on the other hand, live beyond the termination of theapplication process and may then be accessed by other processes (in some cases, by processes on other machines).Figure 4.9. Persistent object.C++ does not have, as an intrinsic part of the language, the ability to store and retrieve persistent objects. <strong>Geant4</strong>provides an abstract framework <strong>for</strong> persistency of hits, digits and events.Two examples demonstrating an implementation of object persistency using one of the tools accessible throughthe available interface, is provided in examples/extended/persistency.4.6.2. Using Reflex <strong>for</strong> persistency of <strong>Geant4</strong> objectsObject persistency of <strong>Geant4</strong> objects is also possible by the mean of the Reflex library. Reflex provides, in anon-intrusive way, reflection capabilities to C++ classes by generating "dictionary in<strong>for</strong>mation" <strong>for</strong> them. Thosedictionaries can then be loaded in memory allowing direct persistency of the given objects without any instrumentationof the code. The Reflex library is also part of ROOT (since release v5.08).The basic steps that one needs to do in order to use Reflex with ROOT I/O <strong>for</strong> arbitrary C++ classes is:1. Generate the dictionary <strong>for</strong> the given classes using the genreflex tool from ROOT (this usually is done byadding the appropriate command to the makefile)2. Add initialization of ROOT I/O and loading of the generated dictionary <strong>for</strong> the given classes in the appropriatepart of the code137

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

Saved successfully!

Ooh no, something went wrong!