REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorHitsSpecularProcess.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
67#include "TRestDetectorHitsSpecularProcess.h"
68
69using namespace std;
70
72
73TRestDetectorHitsSpecularProcess::TRestDetectorHitsSpecularProcess() { Initialize(); }
74
87TRestDetectorHitsSpecularProcess::TRestDetectorHitsSpecularProcess(const char* configFilename) {
88 Initialize();
89 LoadConfigFromFile(configFilename);
90}
91
92TRestDetectorHitsSpecularProcess::~TRestDetectorHitsSpecularProcess() {}
93
95 SetSectionName(this->ClassName());
96 SetLibraryVersion(LIBRARY_VERSION);
97
98 fInputEvent = nullptr;
100}
101
103 fInputEvent = (TRestDetectorHitsEvent*)inputEvent;
105
106 for (unsigned int hit = 0; hit < fInputEvent->GetNumberOfHits(); hit++) {
107 TVector3 position(fInputEvent->GetX(hit), fInputEvent->GetY(hit), fInputEvent->GetZ(hit));
108 const auto type = fInputEvent->GetType(hit);
109 const auto energy = fInputEvent->GetEnergy(hit);
110 const auto time = fInputEvent->GetTime(hit);
111
112 if (type != XYZ) {
113 fOutputEvent->AddHit(position, energy, time, type);
114 continue;
115 }
116
117 const TVector3 relativePosition = position - fPosition;
118 const TVector3 reflectionVector = relativePosition - 2 * relativePosition.Dot(fNormal) * fNormal;
119
120 position = fPosition + reflectionVector;
121
122 fOutputEvent->AddHit(position, energy, time, type);
123 }
124 return fOutputEvent;
125}
126
129
130 fNormal = Get3DVectorParameterWithUnits("normal", {0, 0, 1});
131 fNormal = fNormal.Unit();
132 fPosition = Get3DVectorParameterWithUnits("position", {0, 0, 1});
133}
134
137
138 RESTMetadata << " - Plane normal : ( " << fNormal.X() << ", " << fNormal.Y() << ", " << fNormal.Z()
139 << ") mm" << RESTendl;
140 RESTMetadata << " - Plane position : ( " << fPosition.X() << ", " << fPosition.Y() << ", "
141 << fPosition.Z() << ")" << RESTendl;
142
143 EndPrintProcess();
144}
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 create specular hit images using a plane definition.
TRestDetectorHitsEvent * fOutputEvent
A pointer to the process output event.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
TVector3 fNormal
Defines the normal to the plane we use to generate the specular image.
TRestDetectorHitsEvent * fInputEvent
A pointer to the process input event.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
TVector3 fPosition
Defines the position of the plane. A point inside the plane.
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