11#include "TRestTrackDetachIsolatedNodesProcess.h"
19TRestTrackDetachIsolatedNodesProcess::TRestTrackDetachIsolatedNodesProcess() {
Initialize(); }
21TRestTrackDetachIsolatedNodesProcess::TRestTrackDetachIsolatedNodesProcess(
const char* configFilename) {
28TRestTrackDetachIsolatedNodesProcess::~TRestTrackDetachIsolatedNodesProcess() {
delete fOutputTrackEvent; }
30void TRestTrackDetachIsolatedNodesProcess::LoadDefaultConfig() {
31 SetName(
"trackDetachIsolatedNodesProcess");
32 SetTitle(
"Default config");
39 fInputTrackEvent =
nullptr;
43void TRestTrackDetachIsolatedNodesProcess::LoadConfig(
const string& configFilename,
const string& name) {
55 cout <<
"TRestTrackDetachIsolatedNodesProcess. Number of tracks : "
56 << fInputTrackEvent->GetNumberOfTracks() << endl;
59 fInputTrackEvent->PrintEvent();
62 for (
int tck = 0; tck < fInputTrackEvent->GetNumberOfTracks(); tck++)
63 fOutputTrackEvent->AddTrack(fInputTrackEvent->GetTrack(tck));
65 for (
int tck = 0; tck < fInputTrackEvent->GetNumberOfTracks(); tck++) {
66 if (!fInputTrackEvent->isTopLevel(tck))
continue;
67 Int_t tckId = fInputTrackEvent->GetTrack(tck)->GetTrackID();
69 TRestVolumeHits* hits = fInputTrackEvent->GetTrack(tck)->GetVolumeHits();
70 TRestVolumeHits* originHits = fInputTrackEvent->GetOriginTrackById(tckId)->GetVolumeHits();
72 Int_t nHits = hits->GetNumberOfHits();
75 Int_t pId = fInputTrackEvent->GetTrack(tck)->GetParentID();
76 cout <<
"Track : " << tck <<
" TrackID : " << tckId <<
" ParentID : " << pId << endl;
77 cout <<
"-----------------" << endl;
79 cout <<
"-----------------" << endl;
86 connectedHits.AddHit(hits->
GetPosition(0), hits->GetEnergy(0), 0, hits->GetType(0),
89 for (
int n = 1; n < nHits - 1; n++) {
90 TVector3 x0, x1, pos0, pos1;
92 Double_t hitConnectivity = 0;
96 Double_t distance = 0;
97 for (
int m = n - 1; m < n + 1; m++) {
102 pos0 = fTubeLengthReduction * (x1 - x0) + x0;
103 pos1 = (1 - fTubeLengthReduction) * (x1 - x0) + x0;
105 distance += (x0 - x1).Mag();
110 cout <<
"Hit : " << n <<
" Connectivity : " << hitConnectivity
111 <<
" distance : " << distance / 2. << endl;
113 if (hitConnectivity <= fConnectivityThreshold && distance / 2 > fThresholdDistance) {
114 isolatedHit.AddHit(hits->
GetPosition(n), hits->GetEnergy(n), 0, hits->GetType(n),
118 isoTrack.SetTrackID(fOutputTrackEvent->GetNumberOfTracks() + 1);
120 isoTrack.SetParentID(tckId);
122 isoTrack.SetVolumeHits(isolatedHit);
124 fOutputTrackEvent->AddTrack(&isoTrack);
128 connectedHits.AddHit(hits->
GetPosition(n), hits->GetEnergy(n), 0, hits->GetType(n),
133 connectedHits.AddHit(hits->
GetPosition(nHits - 1), hits->GetEnergy(nHits - 1), 0,
134 hits->GetType(nHits - 1), hits->GetSigma(nHits - 1));
137 connectedTrack.SetTrackID(fOutputTrackEvent->GetNumberOfTracks() + 1);
139 connectedTrack.SetParentID(tckId);
141 connectedTrack.SetVolumeHits(connectedHits);
143 fOutputTrackEvent->AddTrack(&connectedTrack);
147 cout <<
"xxxx DetachIsolatedNodes trackEvent output xxxxx" << endl;
148 fOutputTrackEvent->PrintEvent();
149 cout <<
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << endl;
153 return fOutputTrackEvent;
A base class for any REST event.
Double_t GetEnergyInCylinder(const TVector3 &x0, const TVector3 &x1, Double_t radius) const
It determines the total energy contained inside a cylinder with a given radius and delimited between ...
TVector3 GetPosition(int n) const
It returns the position of hit number n.
@ REST_Debug
+show the defined debug messages
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void Initialize() override
Making default settings.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void EndProcess() override
To be executed at the end of the run (outside event loop)
void RemoveHits()
It removes all hits inside the class.
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
Double_t StringToDouble(std::string in)
Gets a double from a string.