Skip to content

Commit

Permalink
Merge pull request #219 from JeffersonLab/tof_first_hit
Browse files Browse the repository at this point in the history
Leading edge time for TOF, CTOF, PS and PSC
  • Loading branch information
rjones30 authored Mar 21, 2024
2 parents 7ece149 + a78ca55 commit d2f88e9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
17 changes: 10 additions & 7 deletions src/GlueXSensitiveDetectorCTOF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions src/GlueXSensitiveDetectorFTOF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<GlueXHitFTOFbar::hitextra_t>::reverse_iterator xiter;
xiter = hiter->extra.rbegin();
if (trackID != xiter->track_ || fabs(tin/ns - xiter->t_ns) > 0.1) {
Expand Down Expand Up @@ -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<GlueXHitFTOFbar::hitextra_t>::reverse_iterator xiter;
xiter = hiter->extra.rbegin();
if (trackID != xiter->track_ || fabs(tin/ns - xiter->t_ns) > 0.1) {
Expand Down
9 changes: 5 additions & 4 deletions src/GlueXSensitiveDetectorPS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/GlueXSensitiveDetectorPSC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2f88e9

Please sign in to comment.