85 #include "TRestDetectorHitsToTrackProcess.h"
108 SetSectionName(this->ClassName());
109 SetLibraryVersion(LIBRARY_VERSION);
111 fClusterDistance = 1.;
113 fHitsEvent =
nullptr;
129 cout <<
"TResDetectorHitsToTrackProcess : nHits " << fHitsEvent->GetNumberOfHits() << endl;
131 TRestHits* xzHits = fHitsEvent->GetXZHits();
134 cout <<
"TRestDetectorHitsToTrackProcess : Number of xzHits : " << xzHits->GetNumberOfHits() << endl;
135 Int_t xTracks = FindTracks(xzHits);
137 fTrackEvent->SetNumberOfXTracks(xTracks);
139 TRestHits* yzHits = fHitsEvent->GetYZHits();
141 cout <<
"TRestDetectorHitsToTrackProcess : Number of yzHits : " << yzHits->GetNumberOfHits() << endl;
142 Int_t yTracks = FindTracks(yzHits);
144 fTrackEvent->SetNumberOfYTracks(yTracks);
146 TRestHits* xyzHits = fHitsEvent->GetXYZHits();
148 cout <<
"TRestDetectorHitsToTrackProcess : Number of xyzHits : " << xyzHits->GetNumberOfHits()
154 cout <<
"TRestDetectorHitsToTrackProcess. X tracks : " << xTracks <<
" Y tracks : " << yTracks
156 cout <<
"TRestDetectorHitsToTrackProcess. Total number of tracks : "
157 << fTrackEvent->GetNumberOfTracks() << endl;
160 if (fTrackEvent->GetNumberOfTracks() == 0)
return nullptr;
163 fTrackEvent->PrintOnlyTracks();
165 fTrackEvent->SetLevels();
178 Int_t nTracksFound = 0;
182 bool isProcessed =
false;
188 Float_t fClusterDistance2 = (Float_t)(fClusterDistance * fClusterDistance);
191 while (hits->GetNumberOfHits() > 0) {
195 for (
unsigned int q = 0; q < Q.size(); q++) {
197 for (
unsigned int j = 0; j < hits->GetNumberOfHits(); j++) {
198 if ((
int)j != Q[q]) {
199 if (hits->
GetDistance2(Q[q], j) < fClusterDistance2) P.push_back(j);
206 for (
unsigned int i = 0; i < P.size(); i++) {
209 for (
int j = 0; j < qsize; j++) {
218 if (isProcessed ==
false) {
227 std::sort(Q.begin(), Q.end());
229 std::reverse(Q.begin(), Q.end());
233 for (
unsigned int nhit = 0; nhit < Q.size(); nhit++) {
234 const Double_t x = hits->GetX(Q[nhit]);
235 const Double_t y = hits->GetY(Q[nhit]);
236 const Double_t z = hits->GetZ(Q[nhit]);
237 const Double_t en = hits->GetEnergy(Q[nhit]);
239 TVector3 pos(x, y, z);
240 TVector3 sigma(0., 0., 0.);
242 volHit.AddHit(pos, en, 0, hits->GetType(Q[nhit]), sigma);
247 track->SetParentID(0);
248 track->SetTrackID(fTrackEvent->GetNumberOfTracks() + 1);
249 track->SetVolumeHits(volHit);
252 RESTDebug <<
"Adding track : id=" << track->GetTrackID() <<
" parent : " << track->GetParentID()
254 fTrackEvent->AddTrack(track);
A process to convert a TRestDetectorHitsEvent into a TRestTrackEvent.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
~TRestDetectorHitsToTrackProcess()
Default destructor.
TRestDetectorHitsToTrackProcess()
Default constructor.
void Initialize() override
Function to initialize input/output event members and define the section name.
Int_t FindTracks(TRestHits *hits)
The main algorithm. It idetifies the hits that belong to each track and adds them already to the outp...
A base class for any REST event.
void SetEventInfo(TRestEvent *eve)
It saves a 3-coordinate position and an energy for each punctual deposition.
virtual void RemoveHit(int n)
It removes the hit at position n from the list.
Double_t GetDistance2(int n, int m) const
It returns the euclidian distance between hits n and m.
virtual void PrintHits(Int_t nHits=-1) const
It prints on screen the first nHits from the list.
@ REST_Extreme
show everything
@ REST_Debug
+show the defined debug messages
void RemoveHits()
It removes all hits inside the class.