14 #include "TRestDetectorHitsReductionProcess.h"
20 TRestDetectorHitsReductionProcess::TRestDetectorHitsReductionProcess() { Initialize(); }
22 TRestDetectorHitsReductionProcess::TRestDetectorHitsReductionProcess(
const char* configFilename) {
24 if (LoadConfigFromFile(configFilename) == -1) {
29 TRestDetectorHitsReductionProcess::~TRestDetectorHitsReductionProcess() {}
31 void TRestDetectorHitsReductionProcess::LoadDefaultConfig() {
32 SetName(
"hitsReductionProcess");
33 SetTitle(
"Default config");
35 fStartingDistance = 0.5;
37 fDistanceFactor = 1.5;
42 SetSectionName(this->ClassName());
43 SetLibraryVersion(LIBRARY_VERSION);
45 fInputHitsEvent =
nullptr;
46 fOutputHitsEvent =
nullptr;
49 void TRestDetectorHitsReductionProcess::LoadConfig(
const string& configFilename,
const string& name) {
50 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
57 fOutputHitsEvent = fInputHitsEvent;
59 Int_t initialHits = fOutputHitsEvent->GetNumberOfHits();
62 TRestHits* hits = fOutputHitsEvent->GetHits();
64 Double_t distance = fStartingDistance;
65 while (distance < fMinimumDistance || hits->GetNumberOfHits() > fMaxNodes) {
69 for (
unsigned int i = 0; i < hits->GetNumberOfHits(); i++) {
70 for (
unsigned int j = i + 1; j < hits->GetNumberOfHits(); j++) {
78 distance *= fDistanceFactor;
81 Int_t finalHits = fOutputHitsEvent->GetNumberOfHits();
84 cout <<
"TRestDetectorHitsReductionProcess : Initial number of hits : " << initialHits << endl;
85 cout <<
"TRestDetectorHitsReductionProcess : Final number of hits : " << finalHits << endl;
99 return fOutputHitsEvent;
105 fStartingDistance = GetDblParameterWithUnits(
"startingDistance");
106 fMinimumDistance = GetDblParameterWithUnits(
"minimumDistance");
107 fDistanceFactor =
StringToDouble(GetParameter(
"distanceStepFactor"));
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void Initialize() override
Making default settings.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void EndProcess() override
To be executed at the end of the run (outside event loop)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
A base class for any REST event.
It saves a 3-coordinate position and an energy for each punctual deposition.
virtual void MergeHits(int n, int m)
It merges hits n and m being the resulting hit placed at the weighted center and being its final ener...
Double_t GetDistance2(int n, int m) const
It returns the euclidian distance between hits n and m.
@ REST_Debug
+show the defined debug messages
Double_t StringToDouble(std::string in)
Gets a double from a string.