REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorReadoutPixel.h
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 
23 #ifndef RestCore_TRestDetectorReadoutPixel
24 #define RestCore_TRestDetectorReadoutPixel
25 
26 #include <TMath.h>
27 #include <TVector2.h>
28 
29 #include <iostream>
30 
33  private:
34  // TODO: refactor as TVector2 as with other readout classes (readouts will need to be regenerated)
35 
36  Double_t fPixelOriginX = 0;
37  Double_t fPixelOriginY = 0;
38 
39  Double_t fPixelSizeX = 0;
40  Double_t fPixelSizeY = 0;
41 
42  Double_t fRotation = 0;
44 
45  Bool_t fTriangle = false;
47 
49  Double_t fTolerance = 1.e-6;
50 
51  void Initialize();
52 
53  protected:
54  public:
56  Double_t GetOriginX() const { return fPixelOriginX; }
57 
59  Double_t GetOriginY() const { return fPixelOriginY; }
60 
62  TVector2 GetOrigin() const { return {fPixelOriginX, fPixelOriginY}; }
63 
65  Double_t GetRotation() const { return fRotation; }
66 
68  inline Double_t GetSizeX() const { return fPixelSizeX; }
69 
71  inline Double_t GetSizeY() const { return fPixelSizeY; }
72 
74  TVector2 GetSize() { return {fPixelSizeX, fPixelSizeY}; }
75 
77  Bool_t GetTriangle() const { return fTriangle; }
78 
79  TVector2 GetCenter() const;
80 
81  TVector2 GetVertex(int n) const;
82 
84  void SetOrigin(const TVector2& origin) {
85  fPixelOriginX = origin.X();
86  fPixelOriginY = origin.Y();
87  }
88 
90  void SetSize(const TVector2& size) {
91  fPixelSizeX = size.X();
92  fPixelSizeY = size.Y();
93  }
94 
96  void SetRotation(Double_t rot) { fRotation = rot; }
97 
99  void SetTriangle(Bool_t type) { fTriangle = type; }
100 
102  void SetTolerance(Double_t tol) { fTolerance = tol; }
103 
104  Bool_t IsInside(const TVector2& pos);
105 
106  TVector2 TransformToPixelCoordinates(const TVector2& pixel) const;
107 
108  void Print() const;
109 
110  // Constructor
112  // Destructor
113  virtual ~TRestDetectorReadoutPixel();
114 
115  ClassDef(TRestDetectorReadoutPixel, 5);
116 };
117 
118 #endif
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".
void SetOrigin(const TVector2 &origin)
Sets the origin of the pixel using a TVector2.
Double_t GetSizeX() const
Returns the pixel size in X.
Bool_t IsInside(const TVector2 &pos)
Determines if a given TVector2 pos coordinates are found inside the pixel. The coordinates are refere...
Bool_t GetTriangle() const
Returns true if the pixel is a triangle.
void SetSize(const TVector2 &size)
Sets the size of the pixel using a TVector2.
TVector2 GetOrigin() const
Returns a TVector2 with the pixel origin.
TVector2 GetSize()
Returns a TVector2 with the pixel size.
void SetTriangle(Bool_t type)
Sets the type of the pixel.
Double_t GetOriginY() const
Returns the y-coordinate pixel origin.
void SetRotation(Double_t rot)
Sets the rotation angle of the pixel in degrees.
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.
Double_t GetRotation() const
Returns the rotation angle in degrees.
void SetTolerance(Double_t tol)
Sets the value of the tolerance in mm. Used in IsInside method.
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.