14 #include "TRestDetectorHitsToTrackFastProcess.h"
18 #include <TRestMesh.h>
22 TRestDetectorHitsToTrackFastProcess::TRestDetectorHitsToTrackFastProcess() { Initialize(); }
24 TRestDetectorHitsToTrackFastProcess::TRestDetectorHitsToTrackFastProcess(
const char* configFilename) {
27 if (LoadConfigFromFile(configFilename) == -1) LoadDefaultConfig();
30 TRestDetectorHitsToTrackFastProcess::~TRestDetectorHitsToTrackFastProcess() {
35 void TRestDetectorHitsToTrackFastProcess::LoadDefaultConfig() {
36 SetName(
"fastHitsToTrackProcess");
37 SetTitle(
"Default config");
39 fCellResolution = 10.;
41 fNetOrigin = TVector3(-500, -500, -500);
42 fNodes = (Int_t)(fNetSize / fCellResolution);
46 SetSectionName(this->ClassName());
47 SetLibraryVersion(LIBRARY_VERSION);
49 fCellResolution = 10.;
51 fNetOrigin = TVector3(-500, -500, -500);
52 fNodes = (Int_t)(fNetSize / fCellResolution);
58 void TRestDetectorHitsToTrackFastProcess::LoadConfig(
const string& configFilename,
const string& name) {
59 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
77 fTrackEvent->SetID(fHitsEvent->GetID());
78 fTrackEvent->SetSubID(fHitsEvent->GetSubID());
79 fTrackEvent->SetTimeStamp(fHitsEvent->GetTimeStamp());
80 fTrackEvent->SetSubEventTag(fHitsEvent->GetSubEventTag());
93 TRestHits* xzHits = fHitsEvent->GetXZHits();
95 Int_t xTracks = FindTracks(xzHits);
97 fTrackEvent->SetNumberOfXTracks(xTracks);
99 TRestHits* yzHits = fHitsEvent->GetYZHits();
101 Int_t yTracks = FindTracks(yzHits);
103 fTrackEvent->SetNumberOfYTracks(yTracks);
105 TRestHits* xyzHits = fHitsEvent->GetXYZHits();
123 if (fTrackEvent->GetNumberOfTracks() == 0)
return nullptr;
125 fTrackEvent->SetLevels();
130 Int_t TRestDetectorHitsToTrackFastProcess::FindTracks(
TRestHits* hits) {
138 vector<TRestTrack> track(nTracksFound);
139 vector<TRestVolumeHits> volHit(nTracksFound);
141 double nan = numeric_limits<double>::quiet_NaN();
142 for (
unsigned int h = 0; h < hits->GetNumberOfHits(); h++) {
143 Double_t x = hits->GetX(h);
144 Double_t y = hits->GetY(h);
145 Double_t z = hits->GetZ(h);
146 Double_t time = hits->GetTime(h);
147 REST_HitType type = hits->GetType(h);
148 Double_t en = hits->GetEnergy(h);
150 TVector3 pos(x, y, z);
151 TVector3 sigma(0, 0, 0);
153 Int_t gId = mesh->
GetGroupId(type == YZ ? nan : hits->GetX(h), type == XZ ? nan : hits->GetY(h),
155 volHit[gId].AddHit(pos, en, time, type, sigma);
158 for (
int tckID = 0; tckID < nTracksFound; tckID++) {
159 track[tckID].SetParentID(0);
160 track[tckID].SetTrackID(fTrackEvent->GetNumberOfTracks() + 1);
161 track[tckID].SetVolumeHits(volHit[tckID]);
162 fTrackEvent->AddTrack(&track[tckID]);
180 fCellResolution = GetDblParameterWithUnits(
"cellResolution");
181 fNetSize = GetDblParameterWithUnits(
"netSize");
182 fNetOrigin = Get3DVectorParameterWithUnits(
"netOrigin");
183 fNodes = (Int_t)(fNetSize / fCellResolution);
void Initialize() override
Making default settings.
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 InitProcess() override
To be executed at the beginning of the run (outside event loop)
A base class for any REST event.
It saves a 3-coordinate position and an energy for each punctual deposition.
A basic class inheriting from TObject to help creating a node grid definition.
void SetOrigin(Double_t oX, Double_t oY, Double_t oZ)
Sets the origin of the bounding-box and initializes the nodes vector to zero.
void SetNodesFromHits(TRestHits *hits)
It initializes the nodes using the hit coordinates found inside a TRestHits structure.
Int_t GetGroupId(Double_t x, Double_t y, Double_t z)
Returns the group id corresponding to the x,y,z coordinate. If the coordinate falls at a non-initiali...
Int_t GetNumberOfGroups() const
Returns the total number of groups identified.