REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsTranslationProcess.cxx
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
59#include "TRestDetectorHitsTranslationProcess.h"
60
61using namespace std;
62
64
65TRestDetectorHitsTranslationProcess::TRestDetectorHitsTranslationProcess() { Initialize(); }
66
79TRestDetectorHitsTranslationProcess::TRestDetectorHitsTranslationProcess(const char* configFilename) {
80 Initialize();
81 LoadConfigFromFile(configFilename);
82}
83
84TRestDetectorHitsTranslationProcess::~TRestDetectorHitsTranslationProcess() {}
85
87 SetSectionName(this->ClassName());
88 SetLibraryVersion(LIBRARY_VERSION);
89
90 fInputEvent = nullptr;
92}
93
97
98 for (unsigned int hit = 0; hit < fInputEvent->GetNumberOfHits(); hit++) {
99 TVector3 position(fInputEvent->GetX(hit), fInputEvent->GetY(hit), fInputEvent->GetZ(hit));
100 const auto type = fInputEvent->GetType(hit);
101 const auto energy = fInputEvent->GetEnergy(hit);
102 const auto time = fInputEvent->GetTime(hit);
103
104 if (type != XYZ) {
105 fOutputEvent->AddHit(position, energy, time, type);
106 continue;
107 }
108
109 position += fTranslation;
110 fOutputEvent->AddHit(position, energy, time, type);
111 }
112 return fOutputEvent;
113}
114
117
118 fTranslation = Get3DVectorParameterWithUnits("translation", {0, 0, 1});
119}
120
123
124 RESTMetadata << " - Translation vector : ( " << fTranslation.X() << ", " << fTranslation.Y() << ", "
125 << fTranslation.Z() << ") mm" << RESTendl;
126
127 EndPrintProcess();
128}
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.
A process to translate hits by a given user amount.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
TRestDetectorHitsEvent * fInputEvent
A pointer to the process input event.
TVector3 fTranslation
The amount to be translated every hit.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
TRestDetectorHitsEvent * fOutputEvent
A pointer to the process output event.
void Initialize() override
Making default settings.
virtual void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void BeginPrintProcess()
[name, cut range]
A base class for any REST event.
Definition: TRestEvent.h:38
void SetEventInfo(TRestEvent *eve)
Definition: TRestEvent.cxx:137
endl_t RESTendl
Termination flag object for TRestStringOutput.
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.
void SetSectionName(std::string sName)
set the section name, clear the section content