REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorFiducializationProcess.cxx
1
15
16#include "TRestDetectorFiducializationProcess.h"
17
18using namespace std;
19
21
22TRestDetectorFiducializationProcess::TRestDetectorFiducializationProcess() { Initialize(); }
23
24TRestDetectorFiducializationProcess::TRestDetectorFiducializationProcess(const char* configFilename) {
25 Initialize();
26 if (LoadConfigFromFile(configFilename)) {
27 LoadDefaultConfig();
28 }
29}
30
31TRestDetectorFiducializationProcess::~TRestDetectorFiducializationProcess() { delete fOutputHitsEvent; }
32
33void TRestDetectorFiducializationProcess::LoadDefaultConfig() { SetTitle("Default config"); }
34
36 SetSectionName(this->ClassName());
37 SetLibraryVersion(LIBRARY_VERSION);
38
39 fOutputHitsEvent = new TRestDetectorHitsEvent();
40 fInputHitsEvent = nullptr;
41
42 fReadout = nullptr;
43}
44
45void TRestDetectorFiducializationProcess::LoadConfig(const string& configFilename, const string& name) {
46 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
47}
48
50 fReadout = GetMetadata<TRestDetectorReadout>();
51 if (fReadout == nullptr) {
52 cout << "REST ERROR: Readout has not been initialized" << endl;
53 exit(-1);
54 }
55}
56
58 fInputHitsEvent = (TRestDetectorHitsEvent*)inputEvent;
59
60 Int_t nHits = fInputHitsEvent->GetNumberOfHits();
61 if (nHits <= 0) return nullptr;
62
63 TRestHits* hits = fInputHitsEvent->GetHits();
64 for (int n = 0; n < nHits; n++) {
65 Double_t eDep = hits->GetEnergy(n);
66
67 const Double_t x = hits->GetX(n);
68 const Double_t y = hits->GetY(n);
69 const Double_t z = hits->GetZ(n);
70
71 const Double_t t = hits->GetTime(n);
72 auto type = hits->GetType(n);
73
74 for (int p = 0; p < fReadout->GetNumberOfReadoutPlanes(); p++) {
75 TRestDetectorReadoutPlane* plane = fReadout->GetReadoutPlane(p);
76
77 if (plane->GetModuleIDFromPosition(TVector3(x, y, z)) >= 0) {
78 fOutputHitsEvent->AddHit(x, y, z, eDep, t, type);
79 }
80 }
81 }
82
83 if (fOutputHitsEvent->GetNumberOfHits() == 0) {
84 return nullptr;
85 }
86
88 cout << "TRestDetectorFiducializationProcess. Hits added : " << fOutputHitsEvent->GetNumberOfHits()
89 << endl;
90 cout << "TRestDetectorFiducializationProcess. Hits total energy : "
91 << fOutputHitsEvent->GetTotalEnergy() << endl;
92 }
93
94 return fOutputHitsEvent;
95}
96
98 // Function to be executed once at the end of the process
99 // (after all events have been processed)
100
101 // Start by calling the EndProcess function of the abstract class.
102 // Comment this if you don't want it.
103 // TRestEventProcess::EndProcess();
104}
105
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void Initialize() override
Making default settings.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
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)
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.
Int_t GetModuleIDFromPosition(const TVector3 &position) const
This method returns the module id where pos is found. The z-coordinate must be found in between the c...
TRestDetectorReadoutPlane * GetReadoutPlane(int p)
Returns a pointer to the readout plane by index.
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
@ REST_Debug
+show the defined debug messages