REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsNormalizationProcess.cxx
1
21
22#include "TRestDetectorHitsNormalizationProcess.h"
23
24using namespace std;
25
27
28TRestDetectorHitsNormalizationProcess::TRestDetectorHitsNormalizationProcess() { Initialize(); }
29
30TRestDetectorHitsNormalizationProcess::TRestDetectorHitsNormalizationProcess(const char* configFilename) {
31 Initialize();
32
33 if (LoadConfigFromFile(configFilename)) {
34 LoadDefaultConfig();
35 }
36
38}
39
40TRestDetectorHitsNormalizationProcess::~TRestDetectorHitsNormalizationProcess() {
41 delete fHitsOutputEvent;
42 // TRestDetectorHitsNormalizationProcess destructor
43}
44
45void TRestDetectorHitsNormalizationProcess::LoadDefaultConfig() {
46 SetTitle("Default config");
47
48 fFactor = 5.9;
49}
50
52 SetSectionName(this->ClassName());
53 SetLibraryVersion(LIBRARY_VERSION);
54
55 fFactor = 1.;
56
57 fHitsInputEvent = nullptr;
58 fHitsOutputEvent = new TRestDetectorHitsEvent();
59}
60
61void TRestDetectorHitsNormalizationProcess::LoadConfig(const string& configFilename, const string& name) {
62 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
63
65}
66
68 // Function to be executed once at the beginning of process
69 // (before starting the process of the events)
70
71 // Start by calling the InitProcess function of the abstract class.
72 // Comment this if you don't want it.
73 // TRestEventProcess::InitProcess();
74}
75
77 fHitsInputEvent = (TRestDetectorHitsEvent*)inputEvent;
78 fHitsOutputEvent->SetEventInfo(fHitsInputEvent);
79
80 for (unsigned int hit = 0; hit < fHitsInputEvent->GetNumberOfHits(); hit++)
81 fHitsOutputEvent->AddHit(fHitsInputEvent->GetX(hit), fHitsInputEvent->GetY(hit),
82 fHitsInputEvent->GetZ(hit), fHitsInputEvent->GetEnergy(hit) * fFactor,
83 fHitsInputEvent->GetTime(hit), fHitsInputEvent->GetType(hit));
84
86 cout << "TRestDetectorHitsNormalizationProcess. Hits added : " << fHitsOutputEvent->GetNumberOfHits()
87 << endl;
88 cout << "TRestDetectorHitsNormalizationProcess. Hits total energy : "
89 << fHitsOutputEvent->GetTotalEnergy() << endl;
90 }
91
92 return fHitsOutputEvent;
93}
94
96 // Function to be executed once at the end of the process
97 // (after all events have been processed)
98
99 // Start by calling the EndProcess function of the abstract class.
100 // Comment this if you don't want it.
101 // TRestEventProcess::EndProcess();
102}
103
105 fFactor = StringToDouble(GetParameter("normFactor", "1"));
106}
Double_t GetX(int n) const
Returns the X-coordinate of hit entry n in mm.
Double_t GetY(int n) const
Returns the Y-coordinate of hit entry n in mm.
Double_t GetZ(int n) const
Returns the Z-coordinate of hit entry n in mm.
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.
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 PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void Initialize() override
Making default settings.
A base class for any REST event.
Definition: TRestEvent.h:38
void SetEventInfo(TRestEvent *eve)
Definition: TRestEvent.cxx:137
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
Double_t StringToDouble(std::string in)
Gets a double from a string.