diff --git a/DDG4/include/DDG4/DDG4Dict.h b/DDG4/include/DDG4/DDG4Dict.h index 4d21721403c92b5ec366984b50fa9b435a45ab02..3598ccca6e3e7cf4fe9a73b3eb38c9e4b0f730a2 100644 --- a/DDG4/include/DDG4/DDG4Dict.h +++ b/DDG4/include/DDG4/DDG4Dict.h @@ -142,7 +142,7 @@ namespace dd4hep { /// Default constructor inline Geant4Tracker::Hit::Hit() : length(0), energyDeposit(0e0) { } /// Initializing constructor - inline Geant4Tracker::Hit::Hit(int, int, double, double) {} + //inline Geant4Tracker::Hit::Hit(int, int, double, double) {} /// Default destructor inline Geant4Tracker::Hit::~Hit() { } /// Explicit assignment operation diff --git a/DDG4/include/DDG4/Geant4Data.h b/DDG4/include/DDG4/Geant4Data.h index 7e88e7aac384b22a6d9aeac94f42122b8aecf7c4..d9daf2de3abc44fa20d41ac12e1978f593165b42 100644 --- a/DDG4/include/DDG4/Geant4Data.h +++ b/DDG4/include/DDG4/Geant4Data.h @@ -15,8 +15,8 @@ #define DDG4_GEANT4DATA_H // Framework include files -#include "DD4hep/Memory.h" -#include "Math/Vector3D.h" +#include <DD4hep/Memory.h> +#include <Math/Vector3D.h> // C/C++ include files #include <set> @@ -138,60 +138,60 @@ namespace dd4hep { class MonteCarloContrib { public: /// Geant 4 Track identifier - int trackID; + int trackID = -1; /// Particle ID from the PDG table - int pdgID; + int pdgID = -1; /// Total energy deposit in this hit - double deposit; + double deposit = 0.0; /// Timestamp when this energy was deposited double time; /// Length of this step double length = 0.0; /// Proper position of the hit contribution - float x,y,z; + float x = 0.0, y = 0.0, z = 0.0; + /// Proper particle momentum when generating the hit of the contributing particle + float px = 0.0, py = 0.0, pz = 0.0; /// Default constructor - MonteCarloContrib() - : trackID(-1), pdgID(-1), deposit(0.0), time(0.0), x(0), y(0), z(0) { - } + MonteCarloContrib() = default; + /// Copy constructor + MonteCarloContrib(const MonteCarloContrib& c) = default; + /// Move constructor + MonteCarloContrib(MonteCarloContrib&& c) = default; +#if 0 /// Initializing constructor MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len) - : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len), x(0), y(0), z(0) { + : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len) { } +#endif /// Initializing constructor - MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, float* pos) + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, float* pos, float* mom) : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len), - x(pos[0]), y(pos[1]), z(pos[2]) + x(pos[0]), y(pos[1]), z(pos[2]), px(mom[0]), py(mom[1]), pz(mom[2]) { } /// Initializing constructor - MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, double* pos) + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, double* pos, double* mom) : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len), - x(pos[0]), y(pos[1]), z(pos[2]) + x(float(pos[0])), y(float(pos[1])), z(float(pos[2])), + px(float(mom[0])), py(float(mom[1])), pz(float(mom[2])) { } - /// Copy constructor - MonteCarloContrib(const MonteCarloContrib& c) - : trackID(c.trackID), pdgID(c.pdgID), deposit(c.deposit), time(c.time), length(c.length), - x(c.x), y(c.y), z(c.z) { - } - /// Assignment operator - MonteCarloContrib& operator=(const MonteCarloContrib& c) { - if ( this != &c ) { - trackID = c.trackID; - pdgID = c.pdgID; - deposit = c.deposit; - time = c.time; - length = c.length; - x = c.x; - y = c.y; - z = c.z; - } - return *this; + /// Initializing constructor + MonteCarloContrib(int track_id, int pdg, double dep, double time_stamp, double len, const Position& pos, const Direction& mom) + : trackID(track_id), pdgID(pdg), deposit(dep), time(time_stamp), length(len), + x(float(pos.x())), y(float(pos.y())), z(float(pos.z())), + px(float(mom.x())), py(float(mom.y())), pz(float(mom.z())) + { } + /// Assignment operator (move) + MonteCarloContrib& operator=(MonteCarloContrib&& c) = default; + /// Assignment operator (copy) + MonteCarloContrib& operator=(const MonteCarloContrib& c) = default; /// Clear data content void clear() { x = y = z = 0.0; + px = py = pz = 0.0; time = deposit = length = 0.0; pdgID = trackID = -1; } @@ -199,6 +199,34 @@ namespace dd4hep { Position position() const { return Position(x, y, z); } + /// Set position of the contribution + void setPosition(const Position& pos) { + x = pos.x(); + y = pos.y(); + z = pos.z(); + } + /// Set position of the contribution + void setPosition(double pos_x, double pos_y, double pos_z) { + x = float(pos_x); + y = float(pos_y); + z = float(pos_z); + } + /// Access position + Direction momentum() const { + return Direction(px, py, pz); + } + /// Set memonetum of the contribution + void setMomentum(const Direction& dir) { + px = dir.x(); + py = dir.y(); + pz = dir.z(); + } + /// Set memonetum of the contribution + void setMomentum(double mom_x, double mom_y, double mom_z) { + px = float(mom_x); + py = float(mom_y); + pz = float(mom_z); + } }; typedef MonteCarloContrib Contribution; typedef std::vector<MonteCarloContrib> Contributions; @@ -254,7 +282,7 @@ namespace dd4hep { /// copy constructor Hit(const Hit& c) = delete; /// Initializing constructor - Hit(int track_id, int pdg_id, double deposit, double time_stamp); + Hit(int track_id, int pdg_id, double deposit, double time_stamp, double len, const Position& p, const Direction& d); /// Default destructor virtual ~Hit(); /// Move assignment operator diff --git a/DDG4/plugins/Geant4EscapeCounter.cpp b/DDG4/plugins/Geant4EscapeCounter.cpp index 80bc3e78fb178c050755d724286de08d1d067516..13b573ac1e8e8132fc32ed7668bb7b8c71a22036 100644 --- a/DDG4/plugins/Geant4EscapeCounter.cpp +++ b/DDG4/plugins/Geant4EscapeCounter.cpp @@ -102,13 +102,25 @@ bool Geant4EscapeCounter::process(const G4Step* step, G4TouchableHistory* /* his Geant4TouchableHandler handler(step); string hdlr_path = handler.path(); Position prePos = h.prePos(); + Position postPos = h.postPos(); Geant4HitCollection* coll = collection(m_collectionID); - SimpleTracker::Hit* hit = new SimpleTracker::Hit(th.id(),th.pdgID(),h.deposit(),th.time()); + SimpleTracker::Hit* hit = new SimpleTracker::Hit(); + hit->g4ID = th.id(); + hit->energyDeposit = h.deposit(); hit->cellID = volumeID(step); hit->energyDeposit = th.energy(); hit->position = prePos; hit->momentum = h.trkMom(); - hit->length = 0; + hit->length = (postPos-prePos).R(); + hit->truth.trackID = th.id(); + hit->truth.deposit = h.deposit(); + hit->truth.pdgID = th.pdgID(); + hit->truth.deposit = h.deposit(); + hit->truth.time = th.time(); + hit->truth.length = hit->length; + hit->truth.x = hit->position.x(); + hit->truth.y = hit->position.y(); + hit->truth.z = hit->position.z(); coll->add(hit); mark(h.track); diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index ffb5036c00300ce50e541f53f199dbc3a2106a4f..1ec2150fc9cb5157f31d1ab12065b51193d610b7 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -83,33 +83,28 @@ namespace dd4hep { Geant4SensitiveAction<Geant4Tracker>::process(const G4Step* step,G4TouchableHistory* /* hist */) { typedef Geant4Tracker::Hit Hit; 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(); // if (hit_len > 0) { // double new_len = mean_length(h.preMom(),h.postMom())/hit_len; // direction *= new_len/hit_len; // } - - Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime()); - HitContribution contrib = Hit::extractContribution(step); - hit->cellID = cellID(step); - hit->energyDeposit = contrib.deposit; - hit->position = position; - hit->momentum = 0.5*( h. preMom() + h.postMom() ) ; - hit->length = hit_len; + Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime(), hit_len, pos, mom); + hit->truth = Hit::extractContribution(step); + hit->cellID = cellID(step); 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!"); } print("Hit with deposit:%f Pos:%f %f %f ID=%016X", - step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z(), - (void*)hit->cellID); + step->GetTotalEnergyDeposit(), pos.X(), pos.Y(), pos.Z(), (void*)hit->cellID); Geant4TouchableHandler handler(step); print(" Geant4 path:%s",handler.path().c_str()); return true; @@ -122,16 +117,13 @@ namespace dd4hep { { typedef Geant4Tracker::Hit Hit; Geant4FastSimHandler h(spot); - Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime()); + Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime(), + 0e0, h.avgPosition(), h.momentum()); hit->cellID = cellID(h.touchable(), h.avgPositionG4()); - hit->energyDeposit = h.deposit(); - hit->position = h.avgPosition(); - hit->momentum = h.momentum(); - hit->length = 0e0; collection(m_collectionID)->add(hit); mark(h.track); if ( 0 == hit->cellID ) { - hit->cellID = volumeID(h.touchable()); + hit->cellID = volumeID(h.touchable()); except("+++ Invalid CELL ID for hit!"); } print("Hit with deposit:%f Pos:%f %f %f ID=%016X", @@ -170,19 +162,16 @@ namespace dd4hep { G4Track * track = step->GetTrack(); typedef Geant4Tracker::Hit Hit; 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(); - - Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime()); - HitContribution contrib = Hit::extractContribution(step); - hit->cellID = cellID(step); - hit->energyDeposit = contrib.deposit; - hit->position = position; - hit->momentum = 0.5*( h. preMom() + h.postMom() ) ; - hit->length = hit_len; + 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 tim = h.track->GetGlobalTime(); + double hit_len = direction.R(); + + Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), tim, hit_len, pos, mom); + hit->cellID = cellID(step); if (track->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition()) { track->SetTrackStatus(fStopAndKill); } @@ -193,8 +182,7 @@ namespace dd4hep { except("+++ Invalid CELL ID for hit!"); } print("Hit with deposit:%f Pos:%f %f %f ID=%016X", - step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z(), - (void*)hit->cellID); + step->GetTotalEnergyDeposit(), pos.X(),pos.Y(), pos.Z(), (void*)hit->cellID); Geant4TouchableHandler handler(step); print(" Geant4 path:%s",handler.path().c_str()); return true; @@ -207,12 +195,9 @@ namespace dd4hep { { typedef Geant4Tracker::Hit Hit; Geant4FastSimHandler h(spot); - Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime()); + Hit* hit = new Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime(), + 0e0, h.avgPosition(), h.momentum()); hit->cellID = cellID(h.touchable(), h.avgPositionG4()); - hit->energyDeposit = h.deposit(); - hit->position = h.avgPosition(); - hit->momentum = h.momentum(); - hit->length = 0e0; collection(m_collectionID)->add(hit); mark(h.track); if ( 0 == hit->cellID ) { @@ -655,17 +640,13 @@ namespace dd4hep { if ( current == -1 ) { return; } - double deposit = pre.truth.deposit; - double time = deposit != 0 ? mean_time / deposit : mean_time; - Position pos = deposit != 0 ? mean_pos / deposit : mean_pos; - Momentum mom = 0.5 * (pre.momentum + post.momentum); - double path_len = (post.position - pre.position).R(); - Geant4Tracker::Hit* hit = new Geant4Tracker::Hit(pre.truth.trackID, - pre.truth.pdgID, - deposit,time); - hit->position = pos; - hit->momentum = mom; - hit->length = path_len; + double depo = pre.truth.deposit; + double time = depo != 0 ? mean_time / depo : mean_time; + Position pos = depo != 0 ? mean_pos / depo : mean_pos; + Momentum mom = 0.5 * (pre.momentum + post.momentum); + double path_len = (post.position - pre.position).R(); + Geant4Tracker::Hit* hit = new Geant4Tracker::Hit(pre.truth.trackID, pre.truth.pdgID, + depo, time, path_len, pos, mom); hit->cellID = cell; collection->add(hit); sensitive->printM2("+++ TrackID:%6d [%s] CREATE hit combination with %2d deposit(s):" diff --git a/DDG4/plugins/Geant4TrackerWeightedSD.cpp b/DDG4/plugins/Geant4TrackerWeightedSD.cpp index 058dc097df187ee11e52fd800b2193389952bd6c..f69af314203898c1ac682ac5e9e4f91f4755add5 100644 --- a/DDG4/plugins/Geant4TrackerWeightedSD.cpp +++ b/DDG4/plugins/Geant4TrackerWeightedSD.cpp @@ -233,11 +233,9 @@ namespace dd4hep { Geant4Tracker::Hit* hit = new Geant4Tracker::Hit(pre.truth.trackID, pre.truth.pdgID, - deposit,time); + deposit,time, step_length, + pos, mom); hit->flag = hit_flag; - hit->position = pos; - hit->momentum = mom; - hit->length = step_length; hit->cellID = cell; hit->g4ID = g4ID; diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index 0760c94e569e27af84ea621d8b092dac2e0cdb27..c9d1456ff536a620ced161213d4b452ed5799c2b 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -55,8 +55,7 @@ DataExtension::~DataExtension() { } /// Default constructor -Geant4HitData::Geant4HitData() - : cellID(0), flag(0), g4ID(0), extension() { +Geant4HitData::Geant4HitData() { InstanceCount::increment(this); } @@ -70,12 +69,13 @@ Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* ste Geant4StepHandler h(step); double deposit = (h.trackDef() == G4OpticalPhoton::OpticalPhotonDefinition()) ? h.trkEnergy() : h.totalEnergy(); - const G4ThreeVector& pre = h.prePosG4(); - const G4ThreeVector& post = h.postPosG4(); - double length = (post-pre).mag() ; - float pos[] = {float((pre.x()+post.x())/2.0),float((pre.y()+post.y())/2.0),float((pre.z()+post.z())/2.0) }; - Contribution contrib(h.trkID(),h.trkPdgID(),deposit,h.trkTime(),length,pos); - return contrib; + const G4ThreeVector& pre = h.prePosG4(); + const G4ThreeVector& post = h.postPosG4(); + G4ThreeVector m = h.track->GetMomentum(); + double len = (post-pre).mag() ; + double pos[] = { (pre.x()+post.x())/2.0,(pre.y()+post.y())/2.0,(pre.z()+post.z())/2.0 }; + double mom[] = { m.x(), m.y(), m.z() }; + return Contribution(h.trkID(), h.trkPdgID(), deposit, h.trkTime(), len, pos, mom); } /// Extract the MC contribution for a given hit from the step information with BirksLaw effect option @@ -86,18 +86,22 @@ Geant4HitData::Contribution Geant4HitData::extractContribution(const G4Step* ste (h.trackDef() == G4OpticalPhoton::OpticalPhotonDefinition()) ? h.trkEnergy() : h.totalEnergy(); const G4ThreeVector& pre = h.prePosG4(); const G4ThreeVector& post = h.postPosG4(); + G4ThreeVector m = h.track->GetMomentum(); double length = (post-pre).mag() ; - float pos[] = {float((pre.x()+post.x())/2.0),float((pre.y()+post.y())/2.0),float((pre.z()+post.z())/2.0) }; - Contribution contrib(h.trkID(),h.trkPdgID(),deposit,h.trkTime(),length,pos); - return contrib; + double mom[] = { m.x(), m.y(), m.z() }; + double pos[] = { (pre.x()+post.x())/2.0,(pre.y()+post.y())/2.0,(pre.z()+post.z())/2.0 }; + return Contribution(h.trkID(), h.trkPdgID(), deposit, h.trkTime(), length, pos, mom); } /// Extract the MC contribution for a given hit from the fast simulation spot information Geant4HitData::Contribution Geant4HitData::extractContribution(const Geant4FastSimSpot* spot) { Geant4FastSimHandler h(spot); + const G4Track* t = spot->primary; + G4ThreeVector m = t->GetMomentum(); G4ThreeVector p = h.avgPositionG4(); - double position[3] = {p.x(), p.y(), p.z()}; - return Contribution(h.trkID(),h.trkPdgID(),h.energy(),h.trkTime(),0e0,position); + double pos[] = { p.x(), p.y(), p.z() }; + double mom[] = { m.x(), m.y(), m.z() }; + return Contribution( h.trkID(), h.trkPdgID(), h.energy(), h. trkTime(), 0e0, pos, mom); } /// Default constructor @@ -108,8 +112,13 @@ Geant4Tracker::Hit::Hit() } /// Standard initializing constructor -Geant4Tracker::Hit::Hit(int track_id, int pdg_id, double deposit, double time_stamp) - : Geant4HitData(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp, 0.), energyDeposit(deposit) { +Geant4Tracker::Hit::Hit(int track_id, int pdg_id, double deposit, double time_stamp, + double len, const Position& pos, const Direction& mom) + : Geant4HitData(), position(pos), momentum(mom), length(len), + truth(track_id, pdg_id, deposit, time_stamp, len, pos, mom), + energyDeposit(deposit) +{ + g4ID = track_id; InstanceCount::increment(this); } @@ -139,14 +148,20 @@ Geant4Tracker::Hit& Geant4Tracker::Hit::clear() { /// Store Geant4 point and step information into tracker hit structure. Geant4Tracker::Hit& Geant4Tracker::Hit::storePoint(const G4Step* step, const G4StepPoint* pnt) { - G4Track* trk = step->GetTrack(); + G4Track* trk = step->GetTrack(); + G4ThreeVector trm = trk->GetMomentum(); G4ThreeVector pos = pnt->GetPosition(); G4ThreeVector mom = pnt->GetMomentum(); - + double dep = step->GetTotalEnergyDeposit(); + + truth.deposit = dep; truth.trackID = trk->GetTrackID(); truth.pdgID = trk->GetDefinition()->GetPDGEncoding(); - truth.deposit = step->GetTotalEnergyDeposit(); truth.time = trk->GetGlobalTime(); + truth.setPosition(pos.x(), pos.y(), pos.z()); + truth.setMomentum(trm.x(), trm.y(), trm.z()); + + energyDeposit = dep; position.SetXYZ(pos.x(), pos.y(), pos.z()); momentum.SetXYZ(mom.x(), mom.y(), mom.z()); length = 0; @@ -156,16 +171,21 @@ Geant4Tracker::Hit& Geant4Tracker::Hit::storePoint(const G4Step* step, const G4S /// Store Geant4 spot information into tracker hit structure. Geant4Tracker::Hit& Geant4Tracker::Hit::storePoint(const Geant4FastSimSpot* spot) { const G4Track* trk = spot->primary; - G4ThreeVector pos = spot->hitPosition(); - G4ThreeVector mom = trk->GetMomentum().unit(); double dep = spot->hit->GetEnergy(); + G4ThreeVector trm = trk->GetMomentum(); + G4ThreeVector pos = spot->hitPosition(); + G4ThreeVector mom = trk->GetMomentum().unit() * dep; + this->truth.deposit = dep; this->truth.trackID = trk->GetTrackID(); this->truth.time = trk->GetGlobalTime(); this->truth.pdgID = trk->GetDefinition()->GetPDGEncoding(); + this->truth.setPosition(pos.x(), pos.y(), pos.z()); + this->truth.setMomentum(trm.x(), trm.y(), trm.z()); + this->energyDeposit = dep; this->position.SetXYZ(pos.x(), pos.y(), pos.z()); - this->momentum.SetXYZ(mom.x()*dep, mom.y()*dep, mom.z()*dep); + this->momentum.SetXYZ(mom.x(), mom.y(), mom.z()); this->length = 0; return *this; } diff --git a/examples/DDG4_MySensDet/src/MyTrackerHit.h b/examples/DDG4_MySensDet/src/MyTrackerHit.h index b7374b93d22a9a814d7ed1203abc3838b5bb3b92..23d397077bfa155929bc35a2a82fe3b9034ceb2e 100644 --- a/examples/DDG4_MySensDet/src/MyTrackerHit.h +++ b/examples/DDG4_MySensDet/src/MyTrackerHit.h @@ -47,8 +47,9 @@ namespace SomeExperiment { /// Default constructor MyTrackerHit() = default; /// Initializing constructor - MyTrackerHit(int track_id, int pdg_id, double deposit, double time_stamp) - : dd4hep::sim::Geant4Tracker::Hit(track_id,pdg_id,deposit,time_stamp) {} + MyTrackerHit(int track_id, int pdg_id, double deposit, double time_stamp, double len, + const dd4hep::Position& pos, const dd4hep::Direction& mom) + : dd4hep::sim::Geant4Tracker::Hit(track_id,pdg_id,deposit,time_stamp, len, pos, mom) {} /// Default destructor virtual ~MyTrackerHit() = default; /// Assignment operator diff --git a/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp b/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp index f4b0624ac9a0691e877f221150809c0eca782a94..674da9279d9282a3a899ad664007b819cd7dc23a 100644 --- a/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp +++ b/examples/DDG4_MySensDet/src/MyTrackerSDAction.cpp @@ -63,13 +63,11 @@ namespace dd4hep { double hit_len = direction.R(); // Somehow extract here the physics you want - MyTrackerSD::Hit* hit = new MyTrackerSD::Hit(h.trkID(), h.trkPdgID(), h.deposit(), h.track->GetGlobalTime()); + MyTrackerSD::Hit* hit = new MyTrackerSD::Hit(h.trkID(), h.trkPdgID(), h.deposit(), + h.track->GetGlobalTime(), hit_len, + position, 0.5*(h. preMom() + h.postMom())); Geant4HitData::MonteCarloContrib contrib = Geant4HitData::extractContribution(step); hit->cellID = cellID(step); - hit->energyDeposit = contrib.deposit; - hit->position = position; - hit->momentum = 0.5*(h. preMom() + h.postMom()); - hit->length = hit_len; hit->step_length = hit_len; hit->prePos = prePos; hit->postPos = postPos;