REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorReadoutPixel.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
43
44#include "TRestDetectorReadoutPixel.h"
45
46#include <TRestMetadata.h>
47
48using namespace std;
49
55
60
65
70 TVector2 center(0, 0);
71 TVector2 origin(fPixelOriginX, fPixelOriginY);
72 TVector2 oppositeVertex = GetVertex(2);
73
74 if (fTriangle)
75 center = (oppositeVertex - origin) / 4. + origin;
76 else
77 center = (origin + oppositeVertex) / 2.;
78
79 return center;
80}
81
88 TVector2 vertex(0, 0);
89 TVector2 origin(fPixelOriginX, fPixelOriginY);
90
91 if (n % 4 == 0)
92 return origin;
93 else if (n % 4 == 1) {
94 vertex.Set(fPixelSizeX, 0);
95 vertex = vertex.Rotate(fRotation * TMath::Pi() / 180.);
96
97 vertex = vertex + origin;
98 } else if (n % 4 == 2) {
99 vertex.Set(fPixelSizeX, fPixelSizeY);
100 vertex = vertex.Rotate(fRotation * TMath::Pi() / 180.);
101
102 vertex = vertex + origin;
103 } else if (n % 4 == 3) {
104 vertex.Set(0, fPixelSizeY);
105 vertex = vertex.Rotate(fRotation * TMath::Pi() / 180.);
106
107 vertex = vertex + origin;
108 }
109 return vertex;
110}
111
116Bool_t TRestDetectorReadoutPixel::isInside(Double_t x, Double_t y) {
117 TVector2 pos(x, y);
118 return isInside(pos);
119}
120
127 Double_t const x = pos.X();
128 if (pos.X() >= -fTolerance && pos.X() <= fPixelSizeX + fTolerance) // Condition on X untouched
129 {
130 if (fTriangle && pos.Y() >= -fTolerance &&
131 pos.Y() <= fPixelSizeY + fTolerance -
132 x * (fPixelSizeY / fPixelSizeX)) // if triangle, third condition depends on x
133 return true;
134 if (!fTriangle && pos.Y() >= -fTolerance &&
135 pos.Y() <= fPixelSizeY + fTolerance) // for a normal rectangular pixel, same
136 // simple conditions
137 return true;
138 }
139 return false;
140}
141
147TVector2 TRestDetectorReadoutPixel::TransformToPixelCoordinates(const TVector2& pixel) const {
148 TVector2 pos(pixel.X() - fPixelOriginX, pixel.Y() - fPixelOriginY);
149 pos = pos.Rotate(-fRotation * TMath::Pi() / 180.);
150 return pos;
151}
152
157 std::cout << " ## Pixel position : (" << GetOriginX() << "," << GetOriginY() << ") mm size : ("
158 << GetSizeX() << "," << GetSizeY() << ") mm" << std::endl;
159 std::cout << " rotation : " << fRotation << " degrees"
160 << " type : ";
161 if (fTriangle)
162 std::cout << "triangle" << std::endl;
163 else
164 std::cout << "rectangle" << std::endl;
165}
A class to store the readout pixel definition used in TRestDetectorReadoutChannel.
TVector2 GetCenter() const
Returns the center TVector2 position of the pixel.
Double_t fPixelSizeY
The pixel y size.
Double_t fPixelOriginX
The pixel x-origin position, left-bottom corner.
Double_t GetOriginX() const
Returns the x-coordinate pixel origin.
Double_t fTolerance
It will be initialized with the module parameter "pixelTolerance".
Double_t GetSizeX() const
Returns the pixel size in X.
Double_t GetOriginY() const
Returns the y-coordinate pixel origin.
Bool_t isInside(TVector2 pos)
Determines if a given TVector2 pos coordinates are found inside the pixel. The coordinates are refere...
void Initialize()
Initializes the pixel members.
void Print() const
Prints on screen the pixel details, origin, size, rotation.
TVector2 GetVertex(int n) const
Returns the specified pixel vertex position.
TVector2 TransformToPixelCoordinates(const TVector2 &pixel) const
Transforms the coordinates given in a TVector2 to the internal pixel coordinate system....
virtual ~TRestDetectorReadoutPixel()
TRestDetectorReadoutPixel default destructor.
TRestDetectorReadoutPixel()
TRestDetectorReadoutPixel default constructor.
Double_t fPixelSizeX
The pixel x size.
Double_t fPixelOriginY
The pixel y-origin position, left-bottom corner.
Double_t GetSizeY() const
Returns the pixel size in Y.