From ed470676c3264553d2a43149f6d6f1702d0535b3 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sat, 14 Oct 2023 16:36:09 -0500 Subject: [PATCH 01/14] add option to remove hits outside readout --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 1 + src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index ece71bcd..08e436eb 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -28,6 +28,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { TVector3 fFiducialPosition; Double_t fFiducialDiameter = 0; bool fRemoveZeroEnergyEvents = false; + bool fRemoveHitsOutsideReadout = false; TRestDetectorReadout* fReadout = nullptr; //! diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index 9ba22c46..a97a8a6b 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -20,7 +20,6 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in 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 @@ -31,8 +30,13 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto daqId = fReadout->GetDaqId(position, false); const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); + const bool isValidHit = channelType == fChannelType; - if (channelType != fChannelType) { + if (isValidHit || !fRemoveHitsOutsideReadout) { + fOutputHitsEvent->AddHit(position, energy, time, type); + } + if (!isValidHit) { + // this hit is either not on the readout or the channel is not of the type we want continue; } @@ -100,7 +104,7 @@ void TRestDetectorHitsReadoutAnalysisProcess::InitProcess() { exit(1); } - if (fChannelType == "") { + if (fChannelType.empty()) { cerr << "TRestDetectorHitsReadoutAnalysisProcess::InitProcess() : " << "Channel type not defined" << endl; exit(1); @@ -122,6 +126,7 @@ void TRestDetectorHitsReadoutAnalysisProcess::PrintMetadata() { void TRestDetectorHitsReadoutAnalysisProcess::InitFromConfigFile() { fRemoveZeroEnergyEvents = StringToBool(GetParameter("removeZeroEnergyEvents", "false")); + fRemoveHitsOutsideReadout = StringToBool(GetParameter("removeHitsOutsideReadout", "false")); fChannelType = GetParameter("channelType", fChannelType); fFiducialPosition = Get3DVectorParameterWithUnits("fiducialPosition", fFiducialPosition); fFiducialDiameter = GetDblParameterWithUnits("fiducialDiameter", fFiducialDiameter); From 421d77c1575065e1cc686dc469016070ff4f4afa Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sat, 14 Oct 2023 16:44:17 -0500 Subject: [PATCH 02/14] add check --- src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index a97a8a6b..57ccd65c 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -32,6 +32,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); const bool isValidHit = channelType == fChannelType; + const auto nHits = fOutputHitsEvent->GetNumberOfHits(); if (isValidHit || !fRemoveHitsOutsideReadout) { fOutputHitsEvent->AddHit(position, energy, time, type); } @@ -39,6 +40,12 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in // this hit is either not on the readout or the channel is not of the type we want continue; } + if (fOutputHitsEvent->GetNumberOfHits() != nHits + 1) { + // this should never happen + cerr << "TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent() : " + << "Error adding hit " << hitIndex << " to output event" << endl; + exit(1); + } hitPosition.push_back(position); hitEnergy.push_back(energy); From 55934e3418f57010609e745d0f07585c07e0f2da Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sat, 14 Oct 2023 17:12:12 -0500 Subject: [PATCH 03/14] compute additional observables in readout --- ...RestDetectorHitsReadoutAnalysisProcess.cxx | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index 57ccd65c..19675e5d 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -87,6 +87,26 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in positionSigma.SetY(sqrt(positionSigma.Y())); positionSigma.SetZ(sqrt(positionSigma.Z())); + const auto positionSigmaXY = + sqrt(positionSigma.X() * positionSigma.X() + positionSigma.Y() * positionSigma.Y()); + const auto positionSigmaXYBalance = + (positionSigma.X() - positionSigma.Y()) / (positionSigma.X() + positionSigma.Y()); + + TVector3 positionSkewness; + for (size_t i = 0; i < hitPosition.size(); i++) { + TVector3 diff3 = hitPosition[i] - positionAverage; + diff3.SetX(diff3.X() * diff3.X() * diff3.X()); + diff3.SetY(diff3.Y() * diff3.Y() * diff3.Y()); + diff3.SetZ(diff3.Z() * diff3.Z() * diff3.Z()); + positionSkewness += diff3 * hitEnergy[i]; + } + positionSkewness *= 1.0 / readoutEnergy; + const auto positionSkewnessXY = + (positionSkewness.X() + positionSkewness.Y()) / (positionSigmaXY * positionSigmaXY * positionSigmaXY); + positionSkewness.SetX(positionSkewness.X() / (positionSigma.X() * positionSigma.X() * positionSigma.X())); + positionSkewness.SetY(positionSkewness.Y() / (positionSigma.Y() * positionSigma.Y() * positionSigma.Y())); + positionSkewness.SetZ(positionSkewness.Z() / (positionSigma.Z() * positionSigma.Z() * positionSigma.Z())); + SetObservableValue("readoutEnergy", readoutEnergy); SetObservableValue("readoutNumberOfHits", hitEnergy.size()); @@ -97,6 +117,14 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in SetObservableValue("readoutSigmaPositionX", positionSigma.X()); SetObservableValue("readoutSigmaPositionY", positionSigma.Y()); SetObservableValue("readoutSigmaPositionZ", positionSigma.Z()); + SetObservableValue("readoutSigmaPositionXY", positionSigmaXY); + + SetObservableValue("readoutSigmaPositionXYBalance", positionSigmaXYBalance); + + SetObservableValue("readoutSkewnessPositionX", positionSkewness.X()); + SetObservableValue("readoutSkewnessPositionY", positionSkewness.Y()); + SetObservableValue("readoutSkewnessPositionZ", positionSkewness.Z()); + SetObservableValue("readoutSkewnessPositionXY", positionSkewnessXY); SetObservableValue("readoutEnergyInFiducial", energyInFiducial); From 1b530bd3d50c594173dd2c5ae7ab0e6a5acb68ec Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 17 Oct 2023 11:07:20 -0500 Subject: [PATCH 04/14] update class version --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 08e436eb..866a92e9 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -16,8 +16,8 @@ //! An analysis REST process to extract valuable information from Hits type of data. class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { private: - TRestDetectorHitsEvent* fInputHitsEvent; //! - TRestDetectorHitsEvent* fOutputHitsEvent; //! + TRestDetectorHitsEvent* fInputHitsEvent = nullptr; //! + TRestDetectorHitsEvent* fOutputHitsEvent = nullptr; //! void InitFromConfigFile() override; void Initialize() override; @@ -49,7 +49,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { ~TRestDetectorHitsReadoutAnalysisProcess() override = default; - ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2); + ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 3); }; #endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H From 20a5c2d1794ccc343032efa23ef574caa997cb71 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 6 May 2024 13:44:44 +0200 Subject: [PATCH 05/14] readout analysis working on veto --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 1 - src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 16 +++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 866a92e9..12408071 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -28,7 +28,6 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { TVector3 fFiducialPosition; Double_t fFiducialDiameter = 0; bool fRemoveZeroEnergyEvents = false; - bool fRemoveHitsOutsideReadout = false; TRestDetectorReadout* fReadout = nullptr; //! diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index 19675e5d..ed9099d3 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -15,7 +15,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in vector hitEnergy; double energyInFiducial = 0; - for (size_t hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) { + for (int hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) { const auto position = fInputHitsEvent->GetPosition(hitIndex); const auto energy = fInputHitsEvent->GetEnergy(hitIndex); const auto time = fInputHitsEvent->GetTime(hitIndex); @@ -32,20 +32,11 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); const bool isValidHit = channelType == fChannelType; - const auto nHits = fOutputHitsEvent->GetNumberOfHits(); - if (isValidHit || !fRemoveHitsOutsideReadout) { - fOutputHitsEvent->AddHit(position, energy, time, type); - } + fOutputHitsEvent->AddHit(position, energy, time, type); + if (!isValidHit) { - // this hit is either not on the readout or the channel is not of the type we want continue; } - if (fOutputHitsEvent->GetNumberOfHits() != nHits + 1) { - // this should never happen - cerr << "TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent() : " - << "Error adding hit " << hitIndex << " to output event" << endl; - exit(1); - } hitPosition.push_back(position); hitEnergy.push_back(energy); @@ -161,7 +152,6 @@ void TRestDetectorHitsReadoutAnalysisProcess::PrintMetadata() { void TRestDetectorHitsReadoutAnalysisProcess::InitFromConfigFile() { fRemoveZeroEnergyEvents = StringToBool(GetParameter("removeZeroEnergyEvents", "false")); - fRemoveHitsOutsideReadout = StringToBool(GetParameter("removeHitsOutsideReadout", "false")); fChannelType = GetParameter("channelType", fChannelType); fFiducialPosition = Get3DVectorParameterWithUnits("fiducialPosition", fFiducialPosition); fFiducialDiameter = GetDblParameterWithUnits("fiducialDiameter", fFiducialDiameter); From f8ecb7200de82cc8b182962fbbc059be9100fede Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 6 May 2024 13:51:11 +0200 Subject: [PATCH 06/14] class version --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 12408071..1aefdc55 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -48,7 +48,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { ~TRestDetectorHitsReadoutAnalysisProcess() override = default; - ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 3); + ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2); }; #endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H From cf36c2ce54e1ab86e2656a34d291294e68c58157 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sat, 14 Oct 2023 16:36:09 -0500 Subject: [PATCH 07/14] add option to remove hits outside readout --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 1 + src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index ece71bcd..08e436eb 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -28,6 +28,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { TVector3 fFiducialPosition; Double_t fFiducialDiameter = 0; bool fRemoveZeroEnergyEvents = false; + bool fRemoveHitsOutsideReadout = false; TRestDetectorReadout* fReadout = nullptr; //! diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index 9ba22c46..a97a8a6b 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -20,7 +20,6 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in 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 @@ -31,8 +30,13 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto daqId = fReadout->GetDaqId(position, false); const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); + const bool isValidHit = channelType == fChannelType; - if (channelType != fChannelType) { + if (isValidHit || !fRemoveHitsOutsideReadout) { + fOutputHitsEvent->AddHit(position, energy, time, type); + } + if (!isValidHit) { + // this hit is either not on the readout or the channel is not of the type we want continue; } @@ -100,7 +104,7 @@ void TRestDetectorHitsReadoutAnalysisProcess::InitProcess() { exit(1); } - if (fChannelType == "") { + if (fChannelType.empty()) { cerr << "TRestDetectorHitsReadoutAnalysisProcess::InitProcess() : " << "Channel type not defined" << endl; exit(1); @@ -122,6 +126,7 @@ void TRestDetectorHitsReadoutAnalysisProcess::PrintMetadata() { void TRestDetectorHitsReadoutAnalysisProcess::InitFromConfigFile() { fRemoveZeroEnergyEvents = StringToBool(GetParameter("removeZeroEnergyEvents", "false")); + fRemoveHitsOutsideReadout = StringToBool(GetParameter("removeHitsOutsideReadout", "false")); fChannelType = GetParameter("channelType", fChannelType); fFiducialPosition = Get3DVectorParameterWithUnits("fiducialPosition", fFiducialPosition); fFiducialDiameter = GetDblParameterWithUnits("fiducialDiameter", fFiducialDiameter); From 3c88ec3d812f9b3a57edbf344176969e6319f0e7 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sat, 14 Oct 2023 16:44:17 -0500 Subject: [PATCH 08/14] add check --- src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index a97a8a6b..57ccd65c 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -32,6 +32,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); const bool isValidHit = channelType == fChannelType; + const auto nHits = fOutputHitsEvent->GetNumberOfHits(); if (isValidHit || !fRemoveHitsOutsideReadout) { fOutputHitsEvent->AddHit(position, energy, time, type); } @@ -39,6 +40,12 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in // this hit is either not on the readout or the channel is not of the type we want continue; } + if (fOutputHitsEvent->GetNumberOfHits() != nHits + 1) { + // this should never happen + cerr << "TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent() : " + << "Error adding hit " << hitIndex << " to output event" << endl; + exit(1); + } hitPosition.push_back(position); hitEnergy.push_back(energy); From 62b50d9229b9017405dc3312e0600a78d0116379 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Sat, 14 Oct 2023 17:12:12 -0500 Subject: [PATCH 09/14] compute additional observables in readout --- ...RestDetectorHitsReadoutAnalysisProcess.cxx | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index 57ccd65c..19675e5d 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -87,6 +87,26 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in positionSigma.SetY(sqrt(positionSigma.Y())); positionSigma.SetZ(sqrt(positionSigma.Z())); + const auto positionSigmaXY = + sqrt(positionSigma.X() * positionSigma.X() + positionSigma.Y() * positionSigma.Y()); + const auto positionSigmaXYBalance = + (positionSigma.X() - positionSigma.Y()) / (positionSigma.X() + positionSigma.Y()); + + TVector3 positionSkewness; + for (size_t i = 0; i < hitPosition.size(); i++) { + TVector3 diff3 = hitPosition[i] - positionAverage; + diff3.SetX(diff3.X() * diff3.X() * diff3.X()); + diff3.SetY(diff3.Y() * diff3.Y() * diff3.Y()); + diff3.SetZ(diff3.Z() * diff3.Z() * diff3.Z()); + positionSkewness += diff3 * hitEnergy[i]; + } + positionSkewness *= 1.0 / readoutEnergy; + const auto positionSkewnessXY = + (positionSkewness.X() + positionSkewness.Y()) / (positionSigmaXY * positionSigmaXY * positionSigmaXY); + positionSkewness.SetX(positionSkewness.X() / (positionSigma.X() * positionSigma.X() * positionSigma.X())); + positionSkewness.SetY(positionSkewness.Y() / (positionSigma.Y() * positionSigma.Y() * positionSigma.Y())); + positionSkewness.SetZ(positionSkewness.Z() / (positionSigma.Z() * positionSigma.Z() * positionSigma.Z())); + SetObservableValue("readoutEnergy", readoutEnergy); SetObservableValue("readoutNumberOfHits", hitEnergy.size()); @@ -97,6 +117,14 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in SetObservableValue("readoutSigmaPositionX", positionSigma.X()); SetObservableValue("readoutSigmaPositionY", positionSigma.Y()); SetObservableValue("readoutSigmaPositionZ", positionSigma.Z()); + SetObservableValue("readoutSigmaPositionXY", positionSigmaXY); + + SetObservableValue("readoutSigmaPositionXYBalance", positionSigmaXYBalance); + + SetObservableValue("readoutSkewnessPositionX", positionSkewness.X()); + SetObservableValue("readoutSkewnessPositionY", positionSkewness.Y()); + SetObservableValue("readoutSkewnessPositionZ", positionSkewness.Z()); + SetObservableValue("readoutSkewnessPositionXY", positionSkewnessXY); SetObservableValue("readoutEnergyInFiducial", energyInFiducial); From 4264c41a0b80604e7c3a2e5859de61df02e9ecbe Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 17 Oct 2023 11:07:20 -0500 Subject: [PATCH 10/14] update class version --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 08e436eb..866a92e9 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -16,8 +16,8 @@ //! An analysis REST process to extract valuable information from Hits type of data. class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { private: - TRestDetectorHitsEvent* fInputHitsEvent; //! - TRestDetectorHitsEvent* fOutputHitsEvent; //! + TRestDetectorHitsEvent* fInputHitsEvent = nullptr; //! + TRestDetectorHitsEvent* fOutputHitsEvent = nullptr; //! void InitFromConfigFile() override; void Initialize() override; @@ -49,7 +49,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { ~TRestDetectorHitsReadoutAnalysisProcess() override = default; - ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2); + ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 3); }; #endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H From 0b49109252122d3ccd2975b3e44625f0083fbacc Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 6 May 2024 13:44:44 +0200 Subject: [PATCH 11/14] readout analysis working on veto --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 1 - src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 16 +++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 866a92e9..12408071 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -28,7 +28,6 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { TVector3 fFiducialPosition; Double_t fFiducialDiameter = 0; bool fRemoveZeroEnergyEvents = false; - bool fRemoveHitsOutsideReadout = false; TRestDetectorReadout* fReadout = nullptr; //! diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index 19675e5d..ed9099d3 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -15,7 +15,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in vector hitEnergy; double energyInFiducial = 0; - for (size_t hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) { + for (int hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) { const auto position = fInputHitsEvent->GetPosition(hitIndex); const auto energy = fInputHitsEvent->GetEnergy(hitIndex); const auto time = fInputHitsEvent->GetTime(hitIndex); @@ -32,20 +32,11 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); const bool isValidHit = channelType == fChannelType; - const auto nHits = fOutputHitsEvent->GetNumberOfHits(); - if (isValidHit || !fRemoveHitsOutsideReadout) { - fOutputHitsEvent->AddHit(position, energy, time, type); - } + fOutputHitsEvent->AddHit(position, energy, time, type); + if (!isValidHit) { - // this hit is either not on the readout or the channel is not of the type we want continue; } - if (fOutputHitsEvent->GetNumberOfHits() != nHits + 1) { - // this should never happen - cerr << "TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent() : " - << "Error adding hit " << hitIndex << " to output event" << endl; - exit(1); - } hitPosition.push_back(position); hitEnergy.push_back(energy); @@ -161,7 +152,6 @@ void TRestDetectorHitsReadoutAnalysisProcess::PrintMetadata() { void TRestDetectorHitsReadoutAnalysisProcess::InitFromConfigFile() { fRemoveZeroEnergyEvents = StringToBool(GetParameter("removeZeroEnergyEvents", "false")); - fRemoveHitsOutsideReadout = StringToBool(GetParameter("removeHitsOutsideReadout", "false")); fChannelType = GetParameter("channelType", fChannelType); fFiducialPosition = Get3DVectorParameterWithUnits("fiducialPosition", fFiducialPosition); fFiducialDiameter = GetDblParameterWithUnits("fiducialDiameter", fFiducialDiameter); From 93f42a3adf45490cd20f7770f4b84b9b57e07ef1 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 6 May 2024 13:51:11 +0200 Subject: [PATCH 12/14] class version --- inc/TRestDetectorHitsReadoutAnalysisProcess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/TRestDetectorHitsReadoutAnalysisProcess.h b/inc/TRestDetectorHitsReadoutAnalysisProcess.h index 12408071..1aefdc55 100644 --- a/inc/TRestDetectorHitsReadoutAnalysisProcess.h +++ b/inc/TRestDetectorHitsReadoutAnalysisProcess.h @@ -48,7 +48,7 @@ class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess { ~TRestDetectorHitsReadoutAnalysisProcess() override = default; - ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 3); + ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2); }; #endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H From 19cb9dd9b42085508c8a32fdd15a6d9a9d3f52bb Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 7 May 2024 10:19:00 +0200 Subject: [PATCH 13/14] add some comments --- src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index ed9099d3..fc0d065a 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -32,6 +32,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const auto channelType = fReadout->GetTypeForChannelDaqId(daqId); const bool isValidHit = channelType == fChannelType; + // we need to add all hits to preserve the input event fOutputHitsEvent->AddHit(position, energy, time, type); if (!isValidHit) { @@ -55,6 +56,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in const double readoutEnergy = accumulate(hitEnergy.begin(), hitEnergy.end(), 0.0); if (fRemoveZeroEnergyEvents && readoutEnergy <= 0) { + // events not depositing any energy in the readout are removed return nullptr; } From ab93f201fdefff23d75e766df56a57fc07edb5a4 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 7 May 2024 10:30:10 +0200 Subject: [PATCH 14/14] warning --- src/TRestDetectorHitsReadoutAnalysisProcess.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx index fc0d065a..37fdb49d 100644 --- a/src/TRestDetectorHitsReadoutAnalysisProcess.cxx +++ b/src/TRestDetectorHitsReadoutAnalysisProcess.cxx @@ -15,7 +15,7 @@ TRestEvent* TRestDetectorHitsReadoutAnalysisProcess::ProcessEvent(TRestEvent* in vector hitEnergy; double energyInFiducial = 0; - for (int hitIndex = 0; hitIndex < fInputHitsEvent->GetNumberOfHits(); hitIndex++) { + for (int hitIndex = 0; hitIndex < static_cast(fInputHitsEvent->GetNumberOfHits()); hitIndex++) { const auto position = fInputHitsEvent->GetPosition(hitIndex); const auto energy = fInputHitsEvent->GetEnergy(hitIndex); const auto time = fInputHitsEvent->GetTime(hitIndex);