11 #include "TRestTrackDetachIsolatedNodesProcess.h"
19 TRestTrackDetachIsolatedNodesProcess::TRestTrackDetachIsolatedNodesProcess() { Initialize(); }
21 TRestTrackDetachIsolatedNodesProcess::TRestTrackDetachIsolatedNodesProcess(
const char* configFilename) {
24 if (LoadConfigFromFile(configFilename) == -1) LoadDefaultConfig();
28 TRestTrackDetachIsolatedNodesProcess::~TRestTrackDetachIsolatedNodesProcess() {
delete fOutputTrackEvent; }
30 void TRestTrackDetachIsolatedNodesProcess::LoadDefaultConfig() {
31 SetName(
"trackDetachIsolatedNodesProcess");
32 SetTitle(
"Default config");
36 SetSectionName(this->ClassName());
37 SetLibraryVersion(LIBRARY_VERSION);
39 fInputTrackEvent =
nullptr;
43 void TRestTrackDetachIsolatedNodesProcess::LoadConfig(
const string& configFilename,
const string& name) {
44 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
55 cout <<
"TRestTrackDetachIsolatedNodesProcess. Number of tracks : "
56 << fInputTrackEvent->GetNumberOfTracks() << endl;
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();
77 Int_t pId = fInputTrackEvent->GetTrack(tck)->GetParentID();
78 cout <<
"Track : " << tck <<
" TrackID : " << tckId <<
" ParentID : " << pId << endl;
79 cout <<
"-----------------" << endl;
81 cout <<
"-----------------" << endl;
89 connectedHits.AddHit(hits->
GetPosition(0), hits->GetEnergy(0), 0, hits->GetType(0),
92 for (
int n = 1; n < nHits - 1; n++) {
93 TVector3 x0, x1, pos0, pos1;
95 Double_t hitConnectivity = 0;
99 Double_t distance = 0;
100 for (
int m = n - 1; m < n + 1; m++) {
105 pos0 = fTubeLengthReduction * (x1 - x0) + x0;
106 pos1 = (1 - fTubeLengthReduction) * (x1 - x0) + x0;
108 distance += (x0 - x1).Mag();
113 cout <<
"Hit : " << n <<
" Connectivity : " << hitConnectivity
114 <<
" distance : " << distance / 2. << endl;
116 if (hitConnectivity <= fConnectivityThreshold && distance / 2 > fThresholdDistance) {
117 isolatedHit.AddHit(hits->
GetPosition(n), hits->GetEnergy(n), 0, hits->GetType(n),
121 isoTrack.SetTrackID(fOutputTrackEvent->GetNumberOfTracks() + 1);
123 isoTrack.SetParentID(tckId);
125 isoTrack.SetVolumeHits(isolatedHit);
127 fOutputTrackEvent->AddTrack(&isoTrack);
131 connectedHits.AddHit(hits->
GetPosition(n), hits->GetEnergy(n), 0, hits->GetType(n),
136 connectedHits.AddHit(hits->
GetPosition(nHits - 1), hits->GetEnergy(nHits - 1), 0,
137 hits->GetType(nHits - 1), hits->GetSigma(nHits - 1));
140 connectedTrack.SetTrackID(fOutputTrackEvent->GetNumberOfTracks() + 1);
142 connectedTrack.SetParentID(tckId);
144 connectedTrack.SetVolumeHits(connectedHits);
146 fOutputTrackEvent->AddTrack(&connectedTrack);
150 cout <<
"xxxx DetachIsolatedNodes trackEvent output xxxxx" << endl;
151 fOutputTrackEvent->PrintEvent();
152 cout <<
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << endl;
156 return fOutputTrackEvent;
162 fThresholdDistance =
StringToDouble(GetParameter(
"thDistance",
"8"));
163 fConnectivityThreshold =
StringToDouble(GetParameter(
"connectivityThreshold",
"0"));
165 fTubeLengthReduction =
StringToDouble(GetParameter(
"tubeLength",
"0.2"));
A base class for any REST event.
virtual void PrintEvent() const
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 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.