Closed MarkusFrankATcernch closed 3 months ago
All "generic" examples invoking Geant4 now use the Geant4HitData. The issue was that Geant4 expects in the G4VHitsCollection instances of G4VHit. G4VHit is of no use anymore once Geant4 terminated and hence at writing always a copy was necessary to extract the relevant data to some persistent class. The Geant4HitData are embedded in some small wrapper of the G4VHit (concrete class Geant4HitWrapper in Geant4HitCollection.h). In particular to output objects to ROOT is exteremely simple because the data are unlinked from the wrapper and directly give to ROOT for output.
In practice: 1) Only one type of hits in one Geant4HitCollection. Mixed collections are not allowed. It also does not make sense that the very same subdetector produces different hit types. 2) To initialize a hit collection with a specific type call the constructor like this: auto coll = new Geant4HitCollection(det, coll, sd, (TYPE) 0); See: checkout/DDG4/include/DDG4/Geant4SensDetAction.h 3) Adding hits should be straight forward: TYPE* ht = ..... coll->add(hit); See: DDG4/plugins/Geant4SDActions.cpp 4) If you have custom data writer classes (Other than plain ROOT, EDM4HEP or LCIO) or custom data types You need to properly convert to/from the custom data classes.
If you need to use custom hit classes, please hava a look in examples/DDG4_MySensDet. This example demonstrates the usage of this mechanism is described using a custom hit class.
Issue was added for documentation purpose and history. Close it now.
Till v01-20 there was a Geant4Hits.h (DDG4) where the class Geant4Hit upon G4VHit then Tracker and Calo hits where defined.
But since v01-25, I noticed the Geant4Hits stuff has been indeed deprecated ( removed ) ...
Now I am trying to work with G4Hit (for SensitaveDets ) on the top of Geant4HitData (Geant4Data) and G4VHitsCollection ( Geant4HitCollection ) by wrapping my hit with the Geant4HitWrapper. ( I.e. trying my derived Hit from Geant4HitData while its container from G4VHitsCollection ... )
Unfortunately it became non-trivial to me ( not an expert for programming ), it's even hard for me to initialize the ComponentCast ( of the HitManipulator ) from my physics inputs like CellID, energy-deposit, position ... .
In this email, I wonder, is there some ( working ) example somewhere so that I can follow ? Or I have to choose only single ( e.g. Geant4HitData but not HitCollection ) from DDG4, for the time being ? Would you please have a look and give (any) suggestions ?