REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsNormalizationProcess.cxx
1 
22 #include "TRestDetectorHitsNormalizationProcess.h"
23 
24 using namespace std;
25 
27 
28 TRestDetectorHitsNormalizationProcess::TRestDetectorHitsNormalizationProcess() { Initialize(); }
29 
30 TRestDetectorHitsNormalizationProcess::TRestDetectorHitsNormalizationProcess(const char* configFilename) {
31  Initialize();
32 
33  if (LoadConfigFromFile(configFilename)) {
34  LoadDefaultConfig();
35  }
36 
37  PrintMetadata();
38 }
39 
40 TRestDetectorHitsNormalizationProcess::~TRestDetectorHitsNormalizationProcess() {
41  delete fHitsOutputEvent;
42  // TRestDetectorHitsNormalizationProcess destructor
43 }
44 
45 void 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 
61 void TRestDetectorHitsNormalizationProcess::LoadConfig(const string& configFilename, const string& name) {
62  if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
63 
64  PrintMetadata();
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 
85  if (this->GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) {
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 }
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 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
@ REST_Debug
+show the defined debug messages
Double_t StringToDouble(std::string in)
Gets a double from a string.