Skip to content

Commit

Permalink
add option to not skip event if zero energy in readout
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Sep 21, 2023
1 parent 48dc3e2 commit e745984
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions inc/TRestDetectorHitsReadoutAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess {
std::string fChannelType;
TVector3 fFiducialPosition;
Double_t fFiducialDiameter = 0;
bool fRemoveZeroEnergyEvents = false;

TRestDetectorReadout* fReadout = nullptr; //!

Expand Down
15 changes: 8 additions & 7 deletions src/TRestDetectorHitsReadoutAnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in
vector<double> hitEnergy;
double energyInFiducial = 0;

for (size_t hit_index = 0; hit_index < fInputHitsEvent->GetNumberOfHits(); hit_index++) {
const auto position = fInputHitsEvent->GetPosition(hit_index);
const auto energy = fInputHitsEvent->GetEnergy(hit_index);
const auto time = fInputHitsEvent->GetTime(hit_index);
const auto type = fInputHitsEvent->GetType(hit_index);
for (size_t hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) {
const auto position = fInputHitsEvent->GetPosition(hitIndex);
const auto energy = fInputHitsEvent->GetEnergy(hitIndex);
const auto time = fInputHitsEvent->GetTime(hitIndex);
const auto type = fInputHitsEvent->GetType(hitIndex);
fOutputHitsEvent->AddHit(position, energy, time, type);

if (energy <= 0) {
// this should never happen
cerr << "TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent() : "
<< "Negative or zero energy found in hit " << hit_index << endl;
<< "Negative or zero energy found in hit " << hitIndex << endl;
exit(1);
}

Expand All @@ -52,7 +52,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in

const double readoutEnergy = accumulate(hitEnergy.begin(), hitEnergy.end(), 0.0);

if (readoutEnergy <= 0) {
if (fRemoveZeroEnergyEvents && readoutEnergy <= 0) {
return nullptr;
}

Expand Down Expand Up @@ -121,6 +121,7 @@ void TRestDetectorHitsReadoutAnalysisProcess::PrintMetadata() {
}

void TRestDetectorHitsReadoutAnalysisProcess::InitFromConfigFile() {
fRemoveZeroEnergyEvents = StringToBool(GetParameter("removeZeroEnergyEvents", "false"));
fChannelType = GetParameter("channelType", fChannelType);
fFiducialPosition = Get3DVectorParameterWithUnits("fiducialPosition", fFiducialPosition);
fFiducialDiameter = GetDblParameterWithUnits("fiducialDiameter", fFiducialDiameter);
Expand Down

0 comments on commit e745984

Please sign in to comment.