diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 1aefdc55..2f994a6d 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -7,12 +7,13 @@ #include #include -#include -#include -#include -#include #include +#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: @@ -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; //! @@ -48,7 +52,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { ~TRestDetectorHitsReadoutAnalysisProcess() override = default; - ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2); + ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 3); }; #endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index b163bda8..ef371fab 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -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; @@ -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);