From 3218f449d4b7ce675ca322679061365702466fd1 Mon Sep 17 00:00:00 2001 From: clang runner Date: Sat, 29 Jan 2022 11:03:09 +0100 Subject: [PATCH] Now TRestReadoutPixel tolerance can be controled through the pixelTolerance parameter at TRestDetectorReadoutModule --- inc/TRestDetectorReadoutPixel.h | 7 +++++++ src/TRestDetectorReadout.cxx | 3 +++ src/TRestDetectorReadoutPixel.cxx | 14 ++++++-------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/inc/TRestDetectorReadoutPixel.h b/inc/TRestDetectorReadoutPixel.h index c7d7acfa0..c8011ef4e 100644 --- a/inc/TRestDetectorReadoutPixel.h +++ b/inc/TRestDetectorReadoutPixel.h @@ -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: @@ -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); diff --git a/src/TRestDetectorReadout.cxx b/src/TRestDetectorReadout.cxx index 72e2b35dc..24fc0d678 100644 --- a/src/TRestDetectorReadout.cxx +++ b/src/TRestDetectorReadout.cxx @@ -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 channelVector; @@ -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))); diff --git a/src/TRestDetectorReadoutPixel.cxx b/src/TRestDetectorReadoutPixel.cxx index 5cfcfc241..225d46910 100644 --- a/src/TRestDetectorReadoutPixel.cxx +++ b/src/TRestDetectorReadoutPixel.cxx @@ -41,8 +41,6 @@ ///
/// -double delta = 1.e-3; - #include "TRestDetectorReadoutPixel.h" using namespace std; @@ -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;