diff --git a/DDG4/include/DDG4/Geant4Data.h b/DDG4/include/DDG4/Geant4Data.h index d9daf2de3abc44fa20d41ac12e1978f593165b42..047da858773c2668f3dad26814a36c71fe235b31 100644 --- a/DDG4/include/DDG4/Geant4Data.h +++ b/DDG4/include/DDG4/Geant4Data.h @@ -211,7 +211,7 @@ namespace dd4hep { y = float(pos_y); z = float(pos_z); } - /// Access position + /// Access momentum Direction momentum() const { return Direction(px, py, pz); } diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 1ec2150fc9cb5157f31d1ab12065b51193d610b7..99de9b20da9d960845ee790f8dc5684c5c2d013e 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -86,8 +86,8 @@ namespace dd4hep { Position prePos = h.prePos(); Position postPos = h.postPos(); Position direction = postPos - prePos; - Position pos = mean_direction(prePos,postPos); - Direction mom = 0.5*( h. preMom() + h.postMom() ); + Position pos = mean_direction(prePos, postPos); + Direction mom = 0.5 * (h.preMom() + h.postMom()); double hit_len = direction.R(); // if (hit_len > 0) { diff --git a/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp b/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp index 674da9279d9282a3a899ad664007b819cd7dc23a..7c34c2752247b759c549ceb2256bbec82472769f 100644 --- a/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp +++ b/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp @@ -56,16 +56,17 @@ namespace dd4hep { /// Method for generating hit(s) using the information of G4Step object. template <> bool Geant4SensitiveAction<MyTrackerSD>::process(const G4Step* step,G4TouchableHistory* /*hist*/ ) { Geant4StepHandler h(step); - Position prePos = h.prePos(); - Position postPos = h.postPos(); - Position direction = postPos - prePos; - Position position = mean_direction(prePos,postPos); - double hit_len = direction.R(); - + Position prePos = h.prePos(); + Position postPos = h.postPos(); + Position direction = postPos - prePos; + Position pos = mean_direction(prePos,postPos); + Direction mom = 0.5 * (h.preMom() + h.postMom()); + double hit_len = direction.R(); + double depo = h.deposit(); + double tim = h.track->GetGlobalTime(); // Somehow extract here the physics you want - MyTrackerSD::Hit* hit = new MyTrackerSD::Hit(h.trkID(), h.trkPdgID(), h.deposit(), - h.track->GetGlobalTime(), hit_len, - position, 0.5*(h. preMom() + h.postMom())); + MyTrackerSD::Hit* hit = + new MyTrackerSD::Hit(h.trkID(), h.trkPdgID(), depo, tim, hit_len, pos, mom); Geant4HitData::MonteCarloContrib contrib = Geant4HitData::extractContribution(step); hit->cellID = cellID(step); hit->step_length = hit_len; @@ -74,14 +75,13 @@ namespace dd4hep { collection(m_collectionID)->add(hit); mark(h.track); if ( 0 == hit->cellID ) { - hit->cellID = volumeID(step); + hit->cellID = volumeID(step); except("+++ Invalid CELL ID for hit!"); } printP1("Hit with deposit:%f Pos:%f %f %f ID=%016X", - step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z(), - (void*)hit->cellID); + depo, pos.X(), pos.Y(), pos.Z(), (void*)hit->cellID); Geant4TouchableHandler handler(step); - print(" Geant4 path:%s",handler.path().c_str()); + print(" Geant4 path:%s", handler.path().c_str()); // Do something with my personal data (can be also something more clever ;-): m_userData.integratedDeposit += contrib.deposit;