REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTrackToDetectorHitsProcess.cxx
1 
11 #include "TRestTrackToDetectorHitsProcess.h"
12 
13 using namespace std;
14 
16 
17 TRestTrackToDetectorHitsProcess::TRestTrackToDetectorHitsProcess() { Initialize(); }
18 
19 TRestTrackToDetectorHitsProcess::TRestTrackToDetectorHitsProcess(const char* configFilename) {
20  Initialize();
21 
22  if (LoadConfigFromFile(configFilename) == -1) LoadDefaultConfig();
23 }
24 
25 TRestTrackToDetectorHitsProcess::~TRestTrackToDetectorHitsProcess() { delete fOutputHitsEvent; }
26 
27 void TRestTrackToDetectorHitsProcess::LoadDefaultConfig() {
28  SetName("trackToDetectorHitsProcess");
29  SetTitle("Default config");
30 
31  fTrackLevel = 0;
32 }
33 
35  SetSectionName(this->ClassName());
36  SetLibraryVersion(LIBRARY_VERSION);
37 
38  fInputTrackEvent = nullptr;
39  fOutputHitsEvent = new TRestDetectorHitsEvent();
40 }
41 
42 void TRestTrackToDetectorHitsProcess::LoadConfig(const string& configFilename, const string& name) {
43  if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
44 }
45 
47 
49  fInputTrackEvent = (TRestTrackEvent*)inputEvent;
50 
51  if (this->GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug)
52  fInputTrackEvent->PrintOnlyTracks();
53 
54  for (int n = 0; n < fInputTrackEvent->GetNumberOfTracks(); n++)
55  if (fInputTrackEvent->GetLevel(n) == fTrackLevel) {
56  TRestHits* hits = fInputTrackEvent->GetTrack(n)->GetHits();
57 
58  for (unsigned int h = 0; h < hits->GetNumberOfHits(); h++)
59  fOutputHitsEvent->AddHit(hits->GetX(h), hits->GetY(h), hits->GetZ(h), hits->GetEnergy(h),
60  hits->GetTime(h), hits->GetType(h));
61  }
62 
63  return fOutputHitsEvent;
64 }
65 
67 
69  fTrackLevel = StringToInteger(GetParameter("trackLevel", "1"));
70 }
A base class for any REST event.
Definition: TRestEvent.h:38
It saves a 3-coordinate position and an energy for each punctual deposition.
Definition: TRestHits.h:39
void AddHit(const TVector3 &position, Double_t energy, Double_t time=0, REST_HitType type=XYZ)
Adds a new hit to the list of hits using a TVector3.
Definition: TRestHits.cxx:345
@ REST_Debug
+show the defined debug messages
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 Initialize() override
Making default settings.
void EndProcess() override
To be executed at the end of the run (outside event loop)
Int_t StringToInteger(std::string in)
Gets an integer from a string.