Skip to content

Commit

Permalink
Check energiesX (#50)
Browse files Browse the repository at this point in the history
* Check energiesX

* Correct MaxTrackOK observables

* Debug
  • Loading branch information
JPorron authored Nov 13, 2024
1 parent 68283f4 commit 7808b06
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/TRestTrack2DAnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,13 @@ TRestEvent* TRestTrack2DAnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {

// --- Max track observables --- //

// Copy the MaxTrack keys immediately after checking the vector
// Check if the maximum (final) energy value in energiesX and Y is non-zero
bool hasNonZeroEnergyX = !energiesX.empty() && energiesX[0].second != 0;
bool hasNonZeroEnergyY = !energiesY.empty() && energiesY[0].second != 0;

SetObservableValue("MaxTrack_XZ_OK", !energiesX.empty());
SetObservableValue("MaxTrack_XZ_OK", hasNonZeroEnergyX);

if (!energiesX.empty()) {
if (hasNonZeroEnergyX) {
int energiesX0FirstKey =
energiesX[0].first; // Declare Keys outside to avoid error when accessing "energiesX[0].first"...

Expand Down Expand Up @@ -454,9 +456,9 @@ TRestEvent* TRestTrack2DAnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
SetObservableValue("MaxTrack_XZ_SkewZ", 0.);
}

SetObservableValue("MaxTrack_YZ_OK", !energiesY.empty());
SetObservableValue("MaxTrack_YZ_OK", hasNonZeroEnergyY);

if (!energiesY.empty()) {
if (hasNonZeroEnergyY) {
int energiesY0FirstKey = energiesY[0].first;

SetObservableValue("MaxTrack_YZ_NHitsY", YZ_NHitsY[energiesY0FirstKey]);
Expand Down Expand Up @@ -484,7 +486,7 @@ TRestEvent* TRestTrack2DAnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
SetObservableValue("MaxTrack_YZ_SkewZ", 0.);
}

SetObservableValue("MaxTrack_XZ_YZ_OK", !energiesY.empty() && !energiesX.empty());
SetObservableValue("MaxTrack_XZ_YZ_OK", hasNonZeroEnergyX && hasNonZeroEnergyY);

if (!energiesX.empty() && !energiesY.empty()) {
Double_t energiesX0SecondKey = energiesX[0].second;
Expand All @@ -508,10 +510,15 @@ TRestEvent* TRestTrack2DAnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
SetObservableValue("MaxTrack_XZ_YZ_GaussSigmaZBalance", XZ_YZ_GaussSigmaZBalance[0]);

// --- Second max track observables --- //
SetObservableValue("SecondMaxTrack_XZ_OK", energiesX.size() > 1);

// Check if the second maximum energy value in energiesX and Y is non-zero
bool hasNonZeroSecondMaxEnergyX = energiesX.size() > 1 && energiesX[1].second != 0;
bool hasNonZeroSecondMaxEnergyY = energiesY.size() > 1 && energiesY[1].second != 0;

SetObservableValue("SecondMaxTrack_XZ_OK", hasNonZeroSecondMaxEnergyX);

// Copy the SecondTrack keys immediately after checking the vector
if (energiesX.size() > 1) {
if (hasNonZeroSecondMaxEnergyX) {
int energiesX1FirstKey =
energiesX[1].first; // Declare Keys outside to avoid error when accessing "energiesX[1].first"...

Expand Down Expand Up @@ -540,9 +547,9 @@ TRestEvent* TRestTrack2DAnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
SetObservableValue("SecondMaxTrack_XZ_SkewZ", 0.);
}

SetObservableValue("SecondMaxTrack_YZ_OK", energiesY.size() > 1);
SetObservableValue("SecondMaxTrack_YZ_OK", hasNonZeroSecondMaxEnergyY);

if (!energiesY.empty()) {
if (hasNonZeroSecondMaxEnergyY) {
int energiesY1FirstKey = energiesY[1].first;

SetObservableValue("SecondMaxTrack_YZ_NHitsY", YZ_NHitsY[energiesY1FirstKey]);
Expand Down Expand Up @@ -575,7 +582,7 @@ TRestEvent* TRestTrack2DAnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
SetObservableValue("SecondMaxTrack_XZ_YZ_GaussSigmaXYBalance", XZ_YZ_GaussSigmaXYBalance[1]);
SetObservableValue("SecondMaxTrack_XZ_YZ_GaussSigmaZBalance", XZ_YZ_GaussSigmaZBalance[1]);

SetObservableValue("SecondMaxTrack_XZ_YZ_OK", energiesY.size() > 1 && energiesX.size() > 1);
SetObservableValue("SecondMaxTrack_XZ_YZ_OK", hasNonZeroSecondMaxEnergyX && hasNonZeroSecondMaxEnergyY);

if (energiesY.size() > 1 && energiesX.size() > 1) {
Double_t energiesX1SecondKey = energiesX[1].second;
Expand Down

0 comments on commit 7808b06

Please sign in to comment.