Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small changes necessary for https://github.com/rest-for-physics/geant4lib/pull/41 #10

Merged
merged 4 commits into from
Apr 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/TRestGeant4ToDetectorHitsProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,28 @@ TRestEvent* TRestGeant4ToDetectorHitsProcess::ProcessEvent(TRestEvent* evInput)
Double_t x, y, z, E;

for (i = 0; i < fG4Event->GetNumberOfTracks(); i++) {
for (j = 0; j < fG4Event->GetTrack(i)->GetNumberOfHits(); j++) {
const auto& track = fG4Event->GetTrack(i);
const auto& hits = track.GetHits();
for (j = 0; j < track.GetNumberOfHits(); j++) {
// read x,y,z and E of every hit in the G4 event
x = fG4Event->GetTrack(i)->GetHits()->fX[j];
y = fG4Event->GetTrack(i)->GetHits()->fY[j];
z = fG4Event->GetTrack(i)->GetHits()->fZ[j];
E = fG4Event->GetTrack(i)->GetHits()->fEnergy[j];
x = hits.GetX(j);
y = hits.GetX(j);
z = hits.GetX(j);
E = hits.GetEnergy(j);
juanangp marked this conversation as resolved.
Show resolved Hide resolved
lobis marked this conversation as resolved.
Show resolved Hide resolved

Bool_t addHit = true;
Copy link
Member

@juanangp juanangp Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we change the behaviour, by default addHit = true unless the number of volume hits is higher than zero

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we change the behaviour, by default addHit = true unless the number of volume hits is higher than zero

I am not sure if this refers to the current code (77c74c1), I think the behaviour right now is the same, right?

Copy link
Member

@juanangp juanangp Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not the same, before we had addHit = true if fVolumeId.size() == 0 now we just check hits.GetVolumeId(j) == volumeID). So, in case fVolumeId.size() == 0 (which I would suggest fVolumeId.empty()) we assume addHit = false. Therefore, the logic has been changed.

Bug was indroduced in 4a29a1b

Copy link
Member

@jgalan jgalan Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, however if fVolumeId.size() == 0, then we would have no hits inside the event. In normal conditions, the loop will always go inside, setting addHit=false. Because, if there are hits it means that there was at least one activeVolume and fVolumeId should contain at least 1 volume id.

Except that fVolumeId behaviour would have been changed in restG4.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 53d73ec restores previous logic, perhaps now pipeline passes 🤞🏻

if (fVolumeId.size() > 0) {
addHit = false;
for (unsigned int n = 0; n < fVolumeId.size(); n++)
if (fG4Event->GetTrack(i)->GetHits()->GetVolumeId(j) == fVolumeId[n]) addHit = true;
if (hits.GetVolumeId(j) == fVolumeId[n]) {
juanangp marked this conversation as resolved.
Show resolved Hide resolved
addHit = true;
}
}

// and write them in the output hits event:
if (addHit && E > 0) fHitsEvent->AddHit(x, y, z, E);
if (addHit && E > 0) {
fHitsEvent->AddHit(x, y, z, E);
}
}
}

Expand Down