diff --git a/inc/TRestTrackLinearizationProcess.h b/inc/TRestTrackLinearizationProcess.h index e6e6fe8..e097ce2 100644 --- a/inc/TRestTrackLinearizationProcess.h +++ b/inc/TRestTrackLinearizationProcess.h @@ -23,9 +23,9 @@ #ifndef RestCore_TRestTrackLinearizationProcess #define RestCore_TRestTrackLinearizationProcess -#include +#include -#include "TRestTrackEvent.h" +#include "TRestEventProcess.h" //! A process to perform track linearization class TRestTrackLinearizationProcess : public TRestEventProcess { @@ -38,6 +38,7 @@ class TRestTrackLinearizationProcess : public TRestEventProcess { protected: // A parameter which defines the maximum number of nodes for the track linearization Int_t fMaxNodes = 6; + Bool_t fFixBoundaries = false; public: RESTValue GetInputEvent() const override { return fTrackEvent; } @@ -50,6 +51,7 @@ class TRestTrackLinearizationProcess : public TRestEventProcess { void PrintMetadata() override { BeginPrintProcess(); RESTMetadata << "Max nodes: " << fMaxNodes << RESTendl; + RESTMetadata << "Fix boundaries: " << (fFixBoundaries ? "true" : "false") << RESTendl; EndPrintProcess(); } @@ -65,6 +67,6 @@ class TRestTrackLinearizationProcess : public TRestEventProcess { // ROOT class definition helper. Increase the number in it every time // you add/rename/remove the process parameters - ClassDefOverride(TRestTrackLinearizationProcess, 1); + ClassDefOverride(TRestTrackLinearizationProcess, 2); }; #endif diff --git a/src/TRestTrackLinearizationProcess.cxx b/src/TRestTrackLinearizationProcess.cxx index 5f0d923..c68d7d4 100644 --- a/src/TRestTrackLinearizationProcess.cxx +++ b/src/TRestTrackLinearizationProcess.cxx @@ -36,6 +36,11 @@ /// /// ### Parameters /// * fMaxNodes : Maximum number of nodes (hits) to reduce the hits to a line +/// * fFixBoundaries : Fix the boundaries of the track, i.e. the first and last nodes. It +/// is recommended to add 2 more nodes to fMaxNodes when setting this parameter to true. This +/// avoids the first and last nodes being pulled into the center of the track by the +/// kMeansClustering algorithm. This is useful when you need an accurate measurement of the +/// track length, but it is less precise (worse length resolution). Default is false. /// /// ### Examples /// \code @@ -63,7 +68,6 @@ #include "TRestTrackLinearizationProcess.h" #include "TRestTrackReductionProcess.h" - using namespace std; ClassImp(TRestTrackLinearizationProcess); @@ -167,7 +171,7 @@ void TRestTrackLinearizationProcess::GetHitsProjection(TRestVolumeHits* hits, co return; } - TRestVolumeHits::kMeansClustering(hits, vHits, 1); + TRestVolumeHits::kMeansClustering(hits, vHits, 1, fFixBoundaries); if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) for (unsigned int i = 0; i < vHits.GetNumberOfHits(); i++)