REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTrackToDetectorHitsProcess.cxx
1
10
11#include "TRestTrackToDetectorHitsProcess.h"
12
13using namespace std;
14
16
17TRestTrackToDetectorHitsProcess::TRestTrackToDetectorHitsProcess() { Initialize(); }
18
19TRestTrackToDetectorHitsProcess::TRestTrackToDetectorHitsProcess(const char* configFilename) {
20 Initialize();
21
22 if (LoadConfigFromFile(configFilename) == -1) LoadDefaultConfig();
23}
24
25TRestTrackToDetectorHitsProcess::~TRestTrackToDetectorHitsProcess() { delete fOutputHitsEvent; }
26
27void 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
42void TRestTrackToDetectorHitsProcess::LoadConfig(const string& configFilename, const string& name) {
43 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
44}
45
47
49 fInputTrackEvent = (TRestTrackEvent*)inputEvent;
50
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}
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t=0, REST_HitType type=XYZ)
Adds a new hit to this event.
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
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
TRestStringOutput::REST_Verbose_Level GetVerboseLevel()
returns the verboselevel in type of REST_Verbose_Level enumerator
void SetSectionName(std::string sName)
set the section name, clear the section content
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.
@ 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.