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 
61 using namespace std;
62 
64 
65 TRestDetectorHitsTranslationProcess::TRestDetectorHitsTranslationProcess() { Initialize(); }
66 
79 TRestDetectorHitsTranslationProcess::TRestDetectorHitsTranslationProcess(const char* configFilename) {
80  Initialize();
81  LoadConfigFromFile(configFilename);
82 }
83 
84 TRestDetectorHitsTranslationProcess::~TRestDetectorHitsTranslationProcess() {}
85 
87  SetSectionName(this->ClassName());
88  SetLibraryVersion(LIBRARY_VERSION);
89 
90  fInputEvent = nullptr;
91  fOutputEvent = new TRestDetectorHitsEvent();
92 }
93 
95  fInputEvent = (TRestDetectorHitsEvent*)inputEvent;
96  fOutputEvent->SetEventInfo(fInputEvent);
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 
122  BeginPrintProcess();
123 
124  RESTMetadata << " - Translation vector : ( " << fTranslation.X() << ", " << fTranslation.Y() << ", "
125  << fTranslation.Z() << ") mm" << RESTendl;
126 
127  EndPrintProcess();
128 }
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.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
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.
A base class for any REST event.
Definition: TRestEvent.h:38
void SetEventInfo(TRestEvent *eve)
Definition: TRestEvent.cxx:137