16 #include "DDG4/Geant4SensDetAction.inl"
17 #include "DDG4/Factories.h"
37 using namespace npdet;
51 template <>
void Geant4SensitiveAction<PhotoMultiplierSD>::defineCollections() {
53 m_collectionID = declareReadoutFilteredCollection<PhotoMultiplierSD::Hit>();
57 template <>
bool Geant4SensitiveAction<PhotoMultiplierSD>::process(G4Step* step,G4TouchableHistory* ) {
58 Geant4StepHandler h(step);
59 Position prePos = h.prePos();
60 Position postPos = h.postPos();
61 Position direction = postPos - prePos;
62 Position position = mean_direction(prePos,postPos);
63 double hit_len = direction.R();
67 Geant4HitData::MonteCarloContrib contrib = Geant4HitData::extractContribution(step);
68 hit->cellID = cellID(step);
69 hit->
energy = contrib.deposit;
71 hit->
momentum = 0.5*(h. preMom() + h.postMom());
73 collection(m_collectionID)->add(hit);
75 if ( 0 == hit->cellID ) {
76 hit->cellID = volumeID(step);
77 except(
"+++ Invalid CELL ID for hit!");
79 printP1(
"Hit with deposit:%f Pos:%f %f %f ID=%016X",
80 step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z(),
82 Geant4TouchableHandler handler(step);
83 print(
" Geant4 path:%s",handler.path().c_str());
86 m_userData.averageEnergy += contrib.deposit;
87 ++m_userData.nPhotons;
95 namespace dd4hep {
namespace sim {