-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating new TRestRadialStrippedMask #526
Merged
+317
−13
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8ca8f57
TRestSensitivity::ExportCurve is now renormalized by factor and power
jgalan e8895d0
Adding new radial stripped mask
jgalan 926f780
TRestRadialStrippedMask minor fixes
jgalan 5ffcbdf
Fixing issues when drawing the mask with an offset and/or rotation
jgalan cf4268c
Testing pipeline
jgalan 20fb609
TRestPatternMask::fOffset adding comment
jgalan 54cc9d5
TRestPatternMask. Solving drawing issue
jgalan ee4a6db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 43c1e26
Setting the spacers of the new NuSTAR like optics as an example
jovoy 9d0b5a7
TRestRadialStrippedMask. Adding an internal region
jgalan 4e4d07b
Adding example and new image
jgalan a59b044
Merge branch 'jgalan_radial_good' of github.com:rest-for-physics/fram…
jgalan 78ecdd1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3591991
Adding dimensions to the NuSTAR mask example
jovoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/************************************************************************* | ||
* This file is part of the REST software framework. * | ||
* * | ||
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * | ||
* For more information see https://gifna.unizar.es/trex * | ||
* * | ||
* REST is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* REST is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have a copy of the GNU General Public License along with * | ||
* REST in $REST_PATH/LICENSE. * | ||
* If not, see https://www.gnu.org/licenses/. * | ||
* For the list of contributors see $REST_PATH/CREDITS. * | ||
*************************************************************************/ | ||
|
||
#ifndef REST_TRestRadialStrippedMask | ||
#define REST_TRestRadialStrippedMask | ||
|
||
#include <TRestPatternMask.h> | ||
|
||
/// A class used to define a stripped mask pattern | ||
class TRestRadialStrippedMask : public TRestPatternMask { | ||
private: | ||
void Initialize() override; | ||
|
||
/// The periodity of the stripped structure in radians | ||
Double_t fStripsAngle = TMath::Pi() / 3; //< | ||
|
||
/// The width of the stripped structure in mm | ||
Double_t fStripsThickness = 0.5; //< | ||
|
||
/// The spacers structure will be effective from this radius, in mm. Default is from 20 mm. | ||
Double_t fInitialRadius = 20.; //< | ||
|
||
/// Radius of an internal circular region defined inside the fInitialRadius. If 0, there will be no region | ||
Double_t fInternalRegionRadius = 0.; //< | ||
|
||
/// It defines the maximum number of cells/regions in each axis | ||
Int_t fModulus = 10; | ||
|
||
public: | ||
virtual Int_t GetRegion(Double_t& x, Double_t& y) override; | ||
|
||
/// It returns the gap/periodicity of the strips in degrees | ||
Double_t GetStripsAngle() { return fStripsAngle * units("degrees"); } | ||
|
||
/// It returns the thickness of the strips in mm | ||
Double_t GetStripsThickness() { return fStripsThickness; } | ||
|
||
/// It returns the modulus used to define a finite set of ids | ||
Int_t GetModulus() { return fModulus; } | ||
|
||
void PrintMetadata() override; | ||
void PrintMaskMembers() override; | ||
void PrintMask() override; | ||
|
||
TRestRadialStrippedMask(); | ||
TRestRadialStrippedMask(const char* cfgFileName, std::string name = ""); | ||
~TRestRadialStrippedMask(); | ||
|
||
ClassDefOverride(TRestRadialStrippedMask, 1); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/************************************************************************* | ||
* This file is part of the REST software framework. * | ||
* * | ||
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * | ||
* For more information see https://gifna.unizar.es/trex * | ||
* * | ||
* REST is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* REST is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have a copy of the GNU General Public License along with * | ||
* REST in $REST_PATH/LICENSE. * | ||
* If not, see https://www.gnu.org/licenses/. * | ||
* For the list of contributors see $REST_PATH/CREDITS. * | ||
*************************************************************************/ | ||
|
||
///////////////////////////////////////////////////////////////////////// | ||
/// This class defines a stripped pattern. It defines a periodicity | ||
/// and a thickness for the strips. The method TRestRadialStrippedMask::GetRegion | ||
/// will return a unique id for each region in between strips. | ||
/// | ||
/// The stripped structure is centered in (0,0) and it can be shifted using | ||
/// the offset defined inside TRestPatternMask. The pattern will be only | ||
/// delimited by the limits imposed inside TRestPatternMask. | ||
/// | ||
/// ### Specific stripped metadata parameters | ||
/// | ||
/// * **stripsAngle**: This parameter defines the strips angular periodicity. | ||
/// * **stripsThickness**: The thickness of the strips. | ||
/// * **modulus**: A number that defines the range of ids used to identify | ||
/// the different regions inside the stripped pattern. If modulus is 10, | ||
/// then we will only be able to identify up to 10 unique regions. If a | ||
/// larger amount of regions is found, it will happen that two regions will | ||
/// be assigned the same id. | ||
/// | ||
/// ### Common pattern metadata parameters | ||
/// | ||
/// On top of the metadata class parameters, we may define common pattern | ||
/// parameters to induce an offset and rotation to the pattern. | ||
/// | ||
/// * **offset**: A parameter to shift the pattern window mask. | ||
/// * **rotationAngle**: An angle given in radians to rotate the pattern. | ||
/// * **maskRadius**: A radius defining the limits of the circular mask. | ||
/// | ||
/// ### Examples | ||
/// | ||
/// Mask pattern RML definitions can be found inside the file | ||
/// `REST_PATH/examples/masks.rml`. | ||
/// | ||
/// The following definition ilustrates a complete RML implementation of a | ||
/// TRestRadialStrippedMask. | ||
/// | ||
/// \code | ||
/// <TRestRadialStrippedMask name="strongback" verboseLevel="warning"> | ||
/// <parameter name="maskRadius" value="30cm" /> | ||
/// <parameter name="offset" value="(5,5)cm" /> | ||
/// <parameter name="rotationAngle" value="30degrees" /> | ||
/// | ||
/// <parameter name="stripsAngle" value="60degrees" /> | ||
/// <parameter name="stripsThickness" value="2.5cm" /> | ||
/// </TRestRadialStrippedMask> | ||
/// \endcode | ||
/// | ||
/// The basic use of this class is provided by the TRestRadialStrippedMask::GetRegion | ||
/// method. For example: | ||
/// | ||
/// \code | ||
/// TRestRadialStrippedMask mask("masks.rml", "radialStrips"); | ||
/// Int_t id = mask.GetRegion( 12.5, 4.3 ); | ||
/// std::cout << "Region id is : " << id << endl; | ||
/// \endcode | ||
/// | ||
/// The following figure may be generated using the TRestPatternMask::DrawMonteCarlo | ||
/// method. | ||
/// | ||
/// \code | ||
/// TRestRadialStrippedMask mask("masks.rml", "radialStrips"); | ||
/// TCanvas *c = mask.DrawMonteCarlo(30000); | ||
/// c->Draw(); | ||
/// c->Print("radialstrippedmask.png"); | ||
/// \endcode | ||
/// | ||
/// \htmlonly <style>div.image img[src="radialstrippedmask.png"]{width:500px;}</style> \endhtmlonly | ||
/// ![An illustration of the montecarlo mask test using DrawMonteCarlo](strippedmask.png) | ||
/// | ||
///---------------------------------------------------------------------- | ||
/// | ||
/// REST-for-Physics - Software for Rare Event Searches Toolkit | ||
/// | ||
/// History of developments: | ||
/// | ||
/// 2022-05: First implementation of TRestRadialStrippedMask | ||
/// Javier Galan | ||
/// | ||
/// \class TRestRadialStrippedMask | ||
/// \author: Javier Galan - javier.galan@unizar.es | ||
/// | ||
/// <hr> | ||
/// | ||
|
||
#include "TRestRadialStrippedMask.h" | ||
|
||
#include "TRandom3.h" | ||
|
||
ClassImp(TRestRadialStrippedMask); | ||
|
||
/////////////////////////////////////////////// | ||
/// \brief Default constructor | ||
/// | ||
TRestRadialStrippedMask::TRestRadialStrippedMask() : TRestPatternMask() { Initialize(); } | ||
|
||
///////////////////////////////////////////// | ||
/// \brief Constructor loading data from a config file | ||
/// | ||
/// If no configuration path is defined using TRestMetadata::SetConfigFilePath | ||
/// the path to the config file must be specified using full path, absolute or | ||
/// relative. | ||
/// | ||
/// The default behaviour is that the config file must be specified with | ||
/// full path, absolute or relative. | ||
/// | ||
/// \param cfgFileName A const char* giving the path to an RML file. | ||
/// \param name The name of the specific metadata. It will be used to find the | ||
/// corresponding TRestRadialStrippedMask section inside the RML. | ||
/// | ||
TRestRadialStrippedMask::TRestRadialStrippedMask(const char* cfgFileName, std::string name) | ||
: TRestPatternMask(cfgFileName) { | ||
Initialize(); | ||
|
||
LoadConfigFromFile(fConfigFileName, name); | ||
|
||
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) PrintMetadata(); | ||
} | ||
|
||
/////////////////////////////////////////////// | ||
/// \brief Default destructor | ||
/// | ||
TRestRadialStrippedMask::~TRestRadialStrippedMask() {} | ||
|
||
/////////////////////////////////////////////// | ||
/// \brief Function to initialize input/output event members and define | ||
/// the section name | ||
/// | ||
void TRestRadialStrippedMask::Initialize() { | ||
SetSectionName(this->ClassName()); | ||
SetType("RadialStripped"); | ||
} | ||
|
||
/////////////////////////////////////////////// | ||
/// \brief It returns a number identifying the region where the particle | ||
/// with coordinates (x,y) felt in. The method returns 0 if the particle | ||
/// hits the pattern. | ||
/// | ||
/// The particle will be counter-rotated to emulate the mask rotation | ||
/// using the method TRestPatternMask::ApplyCommonMaskTransformation | ||
/// | ||
Int_t TRestRadialStrippedMask::GetRegion(Double_t& x, Double_t& y) { | ||
if (TRestPatternMask::GetRegion(x, y)) return 0; | ||
|
||
Double_t d = TMath::Sqrt(x * x + y * y); | ||
|
||
if (d < fInitialRadius) { | ||
if (fInternalRegionRadius > 0 && d < fInternalRegionRadius) return 1; | ||
|
||
return 0; | ||
} | ||
|
||
TVector2 point(x, y); | ||
Double_t phi = point.Phi(); | ||
|
||
/// phi determines the region where the point is found | ||
Int_t region = (Int_t)(phi / fStripsAngle); | ||
region = 2 + region % fMaxRegions; | ||
|
||
Double_t angle = 0; | ||
/// Checking if we hit an arm | ||
while (angle < 2 * TMath::Pi()) { | ||
if (point.Y() < fStripsThickness / 2. && point.Y() > -fStripsThickness / 2. && point.X() >= 0) | ||
return 0; | ||
|
||
point = point.Rotate(fStripsAngle); | ||
angle += fStripsAngle; | ||
} | ||
|
||
return 1 + region % fModulus; | ||
} | ||
|
||
///////////////////////////////////////////// | ||
/// \brief Prints on screen the complete information about the metadata members from this class | ||
/// | ||
void TRestRadialStrippedMask::PrintMetadata() { | ||
TRestPatternMask::PrintMetadata(); | ||
|
||
PrintMaskMembers(); | ||
RESTMetadata << "++++" << RESTendl; | ||
} | ||
|
||
///////////////////////////////////////////// | ||
/// \brief Prints on screen the information about the metadata members of TRestRingsMask, | ||
/// including common pattern headers, but without common metadata headers. | ||
/// | ||
void TRestRadialStrippedMask::PrintMask() { | ||
PrintCommonPatternMembers(); | ||
RESTMetadata << "----" << RESTendl; | ||
PrintMaskMembers(); | ||
} | ||
|
||
///////////////////////////////////////////// | ||
/// \brief Prints on screen the information about the metadata members of TRestRingsMask, | ||
/// excluding common metadata headers. | ||
/// | ||
void TRestRadialStrippedMask::PrintMaskMembers() { | ||
RESTMetadata << " - Strips angle : " << fStripsAngle * units("degrees") << " degrees" << RESTendl; | ||
RESTMetadata << " - Strips thickness : " << fStripsThickness << " mm" << RESTendl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So one thing that we still need for this is the initialRadius like in the TRestSpiderMask. Does this mean that X-rays hitting inside the initialRadius are stopped? And then if you use internalRegionRadius they pass in that region? If I understood that correctly we would also need internalRegionRadius because some of the Spacers only start at the halfway mark of the radii.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have updated accordingly to follow the same logic as TRestSpiderMask. I updated the image on the documentation, and added also in the description of this PR. Watch out the
masks.rml
file.