diff --git a/src/GlueXSensitiveDetectorCTOF.cc b/src/GlueXSensitiveDetectorCTOF.cc index 09eade6..7a47ac2 100644 --- a/src/GlueXSensitiveDetectorCTOF.cc +++ b/src/GlueXSensitiveDetectorCTOF.cc @@ -233,9 +233,11 @@ G4bool GlueXSensitiveDetectorCTOF::ProcessHits(G4Step* step, } if (merge_hit) { - // sum the charge, do energy weighting of the time - hiter->t_ns = (hiter->dE_GeV * hiter->t_ns + dEtop/GeV * ttop/ns) / - (hiter->dE_GeV += dEtop/GeV); + // Use the time from the earlier hit but add the charge + hiter->dE_GeV += dEtop/GeV; + if (hiter->t_ns*ns > ttop) { + hiter->t_ns = ttop/ns; + } } else { // create new hit @@ -264,10 +266,11 @@ G4bool GlueXSensitiveDetectorCTOF::ProcessHits(G4Step* step, } } if (merge_hit) { - // sum the charge, do energy weighting of the time - hiter->t_ns = (hiter->dE_GeV * hiter->t_ns + - dEbottom/GeV * tbottom/ns) / - (hiter->dE_GeV += dEbottom/GeV); + // Use the time from the earlier hit but add the charge + hiter->dE_GeV += dEbottom/GeV; + if (hiter->t_ns*ns > tbottom) { + hiter->t_ns = tbottom/ns; + } } else { // create new hit diff --git a/src/GlueXSensitiveDetectorFTOF.cc b/src/GlueXSensitiveDetectorFTOF.cc index 9c50478..238589a 100644 --- a/src/GlueXSensitiveDetectorFTOF.cc +++ b/src/GlueXSensitiveDetectorFTOF.cc @@ -262,10 +262,12 @@ G4bool GlueXSensitiveDetectorFTOF::ProcessHits(G4Step* step, } if (merge_hit) { - // sum the charge, do energy weighting of the time - hiter->t_ns = (hiter->dE_GeV * hiter->t_ns + - dEnorth/GeV * tnorth/ns) / - (hiter->dE_GeV += dEnorth/GeV); + // Use the time from the earlier hit but add the charge + hiter->dE_GeV += dEnorth/GeV; + if (hiter->t_ns*ns > tnorth) { + hiter->t_ns = tnorth/ns; + } + std::vector::reverse_iterator xiter; xiter = hiter->extra.rbegin(); if (trackID != xiter->track_ || fabs(tin/ns - xiter->t_ns) > 0.1) { @@ -326,10 +328,12 @@ G4bool GlueXSensitiveDetectorFTOF::ProcessHits(G4Step* step, } } if (merge_hit) { - // sum the charge, do energy weighting of the time - hiter->t_ns = (hiter->dE_GeV * hiter->t_ns + - dEsouth/GeV * tsouth/ns) / - (hiter->dE_GeV += dEsouth/GeV); + // Use the time from the earlier hit but add the charge + hiter->dE_GeV += dEsouth/GeV; + if (hiter->t_ns*ns > tsouth) { + hiter->t_ns = tsouth/ns; + } + std::vector::reverse_iterator xiter; xiter = hiter->extra.rbegin(); if (trackID != xiter->track_ || fabs(tin/ns - xiter->t_ns) > 0.1) { diff --git a/src/GlueXSensitiveDetectorPS.cc b/src/GlueXSensitiveDetectorPS.cc index 8b34c36..e231525 100644 --- a/src/GlueXSensitiveDetectorPS.cc +++ b/src/GlueXSensitiveDetectorPS.cc @@ -204,10 +204,11 @@ G4bool GlueXSensitiveDetectorPS::ProcessHits(G4Step* step, } } if (merge_hit) { - // Add the charge, do energy-weighted time averaging - hiter->t_ns = (hiter->t_ns * hiter->dE_GeV + t/ns * dEsum/GeV) / - (hiter->dE_GeV + dEsum/GeV); - hiter->dE_GeV += dEsum/GeV; + // Use the time from the earlier hit but add the charge + hiter->dE_GeV += dEsum/GeV; + if (hiter->t_ns*ns > t) { + hiter->t_ns = t/ns; + } } else { // create new hit diff --git a/src/GlueXSensitiveDetectorPSC.cc b/src/GlueXSensitiveDetectorPSC.cc index ffdbc85..2f4d47a 100644 --- a/src/GlueXSensitiveDetectorPSC.cc +++ b/src/GlueXSensitiveDetectorPSC.cc @@ -204,10 +204,11 @@ G4bool GlueXSensitiveDetectorPSC::ProcessHits(G4Step* step, } } if (merge_hit) { - // Add the charge, do energy-weighted time averaging - hiter->t_ns = (hiter->t_ns * hiter->dE_GeV + t/ns * dEsum/GeV) / - (hiter->dE_GeV + dEsum/GeV); - hiter->dE_GeV += dEsum/GeV; + // Use the time from the earlier hit but add the charge + hiter->dE_GeV += dEsum/GeV; + if (hiter->t_ns*ns > t) { + hiter->t_ns = t/ns; + } } else { // create new hit