Skip to content

Commit

Permalink
Merge pull request #118 from rest-for-physics/readout-analysis-z
Browse files Browse the repository at this point in the history
Add option to ignore z in `TRestDetectorHitsReadoutAnalysisProcess`
  • Loading branch information
lobis authored May 17, 2024
2 parents 5d4427f + 1689935 commit e47e9a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 9 additions & 5 deletions inc/TRestDetectorHitsReadoutAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

#include <TCanvas.h>
#include <TH1D.h>
#include <TRestDetectorGas.h>
#include <TRestDetectorHitsEvent.h>
#include <TRestDetectorReadout.h>
#include <TRestDetectorSignalEvent.h>
#include <TRestEventProcess.h>

#include "TRestDetectorGas.h"
#include "TRestDetectorHitsEvent.h"
#include "TRestDetectorReadout.h"
#include "TRestDetectorSignalEvent.h"

//! An analysis REST process to extract valuable information from Hits type of data.
class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess {
private:
Expand All @@ -28,6 +29,9 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess {
TVector3 fFiducialPosition;
Double_t fFiducialDiameter = 0;
bool fRemoveZeroEnergyEvents = false;
/// \brief If true, the Z coordinate will be ignored when checking if a position is inside the readout.
/// This is required if processing experimental data where only relative z is available.
bool fIgnoreZ = false;

TRestDetectorReadout* fReadout = nullptr; //!

Expand All @@ -48,7 +52,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess {

~TRestDetectorHitsReadoutAnalysisProcess() override = default;

ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2);
ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 3);
};

#endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H
8 changes: 6 additions & 2 deletions src/TRestDetectorHitsReadoutAnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in
<< "Negative energy found in hit " << hitIndex << endl;
exit(1);
}

const auto daqId = fReadout->GetDaqId(position, false);
// when working with hits derived from experimental data, only relative z is available, so it cannot
// be used to check if a position is inside the readout. We use z=0 in this case which in most cases
// is inside.
const auto daqId =
fReadout->GetDaqId({position.X(), position.Y(), fIgnoreZ ? 0 : position.Z()}, false);
const auto channelType = fReadout->GetTypeForChannelDaqId(daqId);
const bool isValidHit = channelType == fChannelType;

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

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

0 comments on commit e47e9a5

Please sign in to comment.