90 #include "TRestDetectorHitmapAnalysisProcess.h"
120 LoadConfigFromFile(configFilename);
127 SetSectionName(this->ClassName());
128 SetLibraryVersion(LIBRARY_VERSION);
130 fHitsEvent =
nullptr;
139 TVector3 hitMean = fHitsEvent->GetMeanPosition();
141 TVector3 transformedMean = hitMean;
143 for (
const auto& t : fTransformations) {
145 tr = GetTransformation(t);
147 if (tr.
type ==
"specular") transformedMean = Specular(transformedMean, tr);
148 if (tr.
type ==
"rotation") transformedMean = Rotation(transformedMean, tr);
149 if (tr.
type ==
"translation") transformedMean = Translation(transformedMean, tr);
152 SetObservableValue(
"xMean", transformedMean.X());
153 SetObservableValue(
"yMean", transformedMean.Y());
154 SetObservableValue(
"zMean", transformedMean.Z());
164 if (tr.
type !=
"specular")
return {0, 0, 0};
167 Double_t vByN = V.Dot(tr.
vector);
168 TVector3 reflectionVector = V - 2 * vByN * tr.
vector;
169 return tr.
position + reflectionVector;
177 if (tr.
type !=
"rotation")
return {0, 0, 0};
179 TVector3 position = pos - tr.
position;
191 if (tr.
type !=
"translation")
return {0, 0, 0};
193 TVector3 position = pos + tr.
vector;
201 for (
const auto& t : fTransDefinitions) {
202 if (t.name == name)
return t;
215 auto specularDef = GetElement(
"specular");
216 while (specularDef) {
218 trans.
type =
"specular";
220 string name = GetFieldValue(
"name", specularDef);
221 if (name ==
"Not defined") {
222 RESTError <<
"The `name` field was not found in specular definition!" << RESTendl;
227 TVector3 position = Get3DVectorParameterWithUnits(
"position", specularDef);
228 if (position == TVector3(-1, -1, -1)) {
229 RESTError <<
"The `position` field was not found in specular definition!" << RESTendl;
234 TVector3 vect = Get3DVectorParameterWithUnits(
"vector", specularDef);
235 if (vect == TVector3(-1, -1, -1)) {
236 RESTError <<
"The `vector` field was not found in specular definition!" << RESTendl;
241 fTransDefinitions.push_back(trans);
242 specularDef = GetNextElement(specularDef);
245 auto rotationDef = GetElement(
"rotation");
246 while (rotationDef) {
248 trans.
type =
"rotation";
250 string name = GetFieldValue(
"name", rotationDef);
251 if (name ==
"Not defined") {
252 RESTError <<
"The `name` field was not found in rotation definition!" << RESTendl;
257 TVector3 position = Get3DVectorParameterWithUnits(
"position", rotationDef);
258 if (position == TVector3(-1, -1, -1)) {
259 RESTError <<
"The `position` field was not found in rotation definition!" << RESTendl;
264 TVector3 vect = Get3DVectorParameterWithUnits(
"vector", rotationDef);
265 if (vect == TVector3(-1, -1, -1)) {
266 RESTError <<
"The `vector` field was not found in rotation definition!" << RESTendl;
271 Double_t angle = GetDblParameterWithUnits(
"angle", rotationDef);
272 if (angle == PARAMETER_NOT_FOUND_DBL) {
273 RESTError <<
"The `angle` field was not found in rotation definition!" << RESTendl;
278 fTransDefinitions.push_back(trans);
279 rotationDef = GetNextElement(rotationDef);
282 auto translationDef = GetElement(
"translation");
283 while (translationDef) {
285 trans.
type =
"translation";
287 string name = GetFieldValue(
"name", translationDef);
288 if (name ==
"Not defined") {
289 RESTError <<
"The `name` field was not found in translation definition!" << RESTendl;
294 TVector3 vect = Get3DVectorParameterWithUnits(
"vector", translationDef);
295 if (vect == TVector3(-1, -1, -1)) {
296 RESTError <<
"The `vector` field was not found in translation definition!" << RESTendl;
301 fTransDefinitions.push_back(trans);
302 translationDef = GetNextElement(translationDef);
312 if (!fTransDefinitions.empty()) {
313 RESTMetadata <<
" List of transformation definitions: " << RESTendl;
314 RESTMetadata <<
" ----------------------------------- " << RESTendl;
315 RESTMetadata <<
" " << RESTendl;
317 RESTMetadata <<
" No transformations found! " << RESTendl;
319 for (
const auto& t : fTransDefinitions) {
320 if (t.type ==
"specular") {
321 RESTMetadata <<
" - Specular transformation: " << RESTendl;
322 RESTMetadata <<
" + Plane position : (" << t.position.X() <<
", " << t.position.Y() <<
", "
323 << t.position.Z() <<
") mm" << RESTendl;
324 RESTMetadata <<
" + Plane normal : (" << t.vector.X() <<
", " << t.vector.Y() <<
", "
325 << t.vector.Z() <<
")" << RESTendl;
326 RESTMetadata <<
" " << RESTendl;
329 if (t.type ==
"rotation") {
330 RESTMetadata <<
" - Rotation transformation: " << RESTendl;
331 RESTMetadata <<
" + Rotation center : (" << t.position.X() <<
", " << t.position.Y() <<
", "
332 << t.position.Z() <<
") mm" << RESTendl;
333 RESTMetadata <<
" + Rotation axis : (" << t.vector.X() <<
", " << t.vector.Y() <<
", "
334 << t.vector.Z() <<
")" << RESTendl;
335 RESTMetadata <<
" + Rotation angle : " << t.angle *
units(
"degrees") <<
" degrees" << RESTendl;
336 RESTMetadata <<
" " << RESTendl;
339 if (t.type ==
"translation") {
340 RESTMetadata <<
" - Translation transformation: " << RESTendl;
341 RESTMetadata <<
" + Translation vector : (" << t.vector.X() <<
", " << t.vector.Y() <<
", "
342 << t.vector.Z() <<
") mm" << RESTendl;
343 RESTMetadata <<
" " << RESTendl;
347 RESTMetadata <<
" Order of transformations: " << RESTendl;
348 RESTMetadata <<
" ------------------------- " << RESTendl;
349 RESTMetadata <<
" " << RESTendl;
352 for (
const auto& t : fTransformations) {
354 RESTMetadata << n <<
". " << t << RESTendl;
An analysis process to apply rotation/translation/specular to mean hit positions.
TVector3 Specular(const TVector3 &pos, const HitTransformation &tr)
It performs a specular transformation of the given pos in the argument and the transformation propert...
TRestDetectorHitmapAnalysisProcess()
Default constructor.
HitTransformation GetTransformation(const std::string &name)
It returns the transformation with a given name.
void Initialize() override
Function to initialize input/output event members and define the section name.
~TRestDetectorHitmapAnalysisProcess()
Default destructor.
TVector3 Translation(const TVector3 &pos, const HitTransformation &tr)
It performs a translation of the given pos in the argument and the transformation properties stored i...
TVector3 Rotation(const TVector3 &pos, const HitTransformation &tr)
It performs a rotation of the given pos in the argument and the transformation properties stored in t...
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void PrintMetadata() override
Prints out the metadata member values.
void InitFromConfigFile() override
A custom initalization from a config file.
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.