Skip to content

Commit

Permalink
Now TRestReadoutPixel tolerance can be controled through the pixelTol…
Browse files Browse the repository at this point in the history
…erance parameter at TRestDetectorReadoutModule
  • Loading branch information
jgalan committed Jan 29, 2022
1 parent ccd8f5f commit 3218f44
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions inc/TRestDetectorReadoutPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class TRestDetectorReadoutPixel : public TObject {

Bool_t fTriangle; ///< The type of the pixel : false is rectangular, true is
///< triangle

/// It will be initialized with the module parameter "pixelTolerance"
Double_t fTolerance = 1.e-6; //!

void Initialize();

protected:
Expand Down Expand Up @@ -106,6 +110,9 @@ class TRestDetectorReadoutPixel : public TObject {
/// Sets the type of the pixel
void SetTriangle(Bool_t type) { fTriangle = type; }

/// Sets the value of the tolerance in mm. Used in IsInside method.
void SetTolerance(Double_t tol) { fTolerance = tol; }

Bool_t isInside(TVector2 pos);
Bool_t isInside(Double_t x, Double_t y);

Expand Down
3 changes: 3 additions & 0 deletions src/TRestDetectorReadout.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ TRestDetectorReadoutModule* TRestDetectorReadout::ParseModuleDefinition(TiXmlEle
module.SetName(GetFieldValue("name", moduleDefinition));
module.SetSize(StringTo2DVector(GetFieldValue("size", moduleDefinition)));
module.SetTolerance(StringToDouble(GetFieldValue("tolerance", moduleDefinition)));
Double_t pixelTolerance = StringToDouble(GetFieldValue("pixelTolerance", moduleDefinition));
if (pixelTolerance == -1) pixelTolerance = 1.e-6;

#pragma region addChannel
vector<TRestDetectorReadoutChannel> channelVector;
Expand All @@ -634,6 +636,7 @@ TRestDetectorReadoutModule* TRestDetectorReadout::ParseModuleDefinition(TiXmlEle
pixel.SetSize(StringTo2DVector(GetFieldValue("size", pixelDefinition)));
pixel.SetRotation(StringToDouble(GetFieldValue("rotation", pixelDefinition)));
pixel.SetTriangle(StringToBool(GetFieldValue("triangle", pixelDefinition)));
pixel.SetTolerance(pixelTolerance);

if (StringToInteger(GetFieldValue("id", pixelDefinition)) != -1)
pixelIDVector.push_back(StringToInteger(GetFieldValue("id", pixelDefinition)));
Expand Down
14 changes: 6 additions & 8 deletions src/TRestDetectorReadoutPixel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
/// <hr>
///

double delta = 1.e-3;

#include "TRestDetectorReadoutPixel.h"
using namespace std;

Expand Down Expand Up @@ -125,15 +123,15 @@ Bool_t TRestDetectorReadoutPixel::isInside(Double_t x, Double_t y) {
Bool_t TRestDetectorReadoutPixel::isInside(TVector2 pos) {
pos = TransformToPixelCoordinates(pos);
Double_t const x = pos.X();
if (pos.X() >= -delta && pos.X() <= fPixelSizeX + delta) // Condition on X untouched
if (pos.X() >= -fTolerance && pos.X() <= fPixelSizeX + fTolerance) // Condition on X untouched
{
if (fTriangle && pos.Y() >= -delta &&
pos.Y() <= fPixelSizeY + delta -
if (fTriangle && pos.Y() >= -fTolerance &&
pos.Y() <= fPixelSizeY + fTolerance -
x * (fPixelSizeY / fPixelSizeX)) // if triangle, third condition depends on x
return true;
if (!fTriangle && pos.Y() >= -delta &&
pos.Y() <= fPixelSizeY + delta) // for a normal rectangular pixel, same
// simple conditions
if (!fTriangle && pos.Y() >= -fTolerance &&
pos.Y() <= fPixelSizeY + fTolerance) // for a normal rectangular pixel, same
// simple conditions
return true;
}
return false;
Expand Down

0 comments on commit 3218f44

Please sign in to comment.