71#include "TRestPatternMask.h"
170 fCanvas =
new TCanvas(
"canv",
"This is the canvas title", 1400, 1200);
173 TPad* pad1 =
new TPad(
"pad1",
"This is pad1", 0.01, 0.02, 0.99, 0.97);
178 fCanvas->SetBottomMargin(0.15);
181 std::map<int, std::vector<TVector2> > points;
183 TRandom3* rnd =
new TRandom3(0);
185 for (
int n = 0; n < nSamples; n++) {
186 Double_t x = 2.5 * (rnd->Rndm() - 0.5) *
fMaskRadius;
187 Double_t y = 2.5 * (rnd->Rndm() - 0.5) *
fMaskRadius;
191 if (points.count(
id) == 0) {
192 std::vector<TVector2> a;
193 a.push_back(TVector2(x, y));
196 points[id].push_back(TVector2(x, y));
200 std::vector<TGraph*> gridGraphs;
202 for (
const auto& x : points) {
204 TGraph* gr =
new TGraph();
205 gr->SetName(grname.c_str());
207 for (
unsigned int n = 0; n < x.second.size(); n++) {
208 gr->SetPoint(gr->GetN(), x.second[n].X(), x.second[n].Y());
212 gr->SetLineColor(kBlack);
213 gr->SetMarkerColor(kBlack);
214 gr->SetMarkerSize(0.6);
217 gr->SetMarkerColor((nGraphs * 3) % 29 + 20);
218 gr->SetLineColor((nGraphs * 3) % 29 + 20);
219 gr->SetMarkerSize(0.6);
223 gr->SetMarkerStyle(20);
224 gridGraphs.push_back(gr);
229 gridGraphs[0]->GetHistogram()->SetMaximum(1.25 *
fMaskRadius);
230 gridGraphs[0]->GetHistogram()->SetMinimum(-1.25 *
fMaskRadius);
232 gridGraphs[0]->GetXaxis()->SetTitle(
"X [mm]");
233 gridGraphs[0]->GetXaxis()->SetTitleSize(0.04);
234 gridGraphs[0]->GetXaxis()->SetLabelSize(0.04);
235 gridGraphs[0]->GetYaxis()->SetTitle(
"Y[mm]");
236 gridGraphs[0]->GetYaxis()->SetTitleOffset(1.5);
237 gridGraphs[0]->GetYaxis()->SetTitleSize(0.04);
238 gridGraphs[0]->GetYaxis()->SetLabelSize(0.04);
240 gridGraphs[0]->Draw(
"AP");
241 for (
int n = 1; n < nGraphs; n++) gridGraphs[n]->Draw(
"P");
An abstract class used to encapsulate different mask pattern class definitions.
TCanvas * DrawMonteCarlo(Int_t nSamples=10000)
It generates a Monte Carlo with positions and paints them the returned canvas. Each unique region is ...
TVector2 fOffset
It is used to introduce an offset on the pattern.
TRestPatternMask()
Default constructor.
TCanvas * fCanvas
A canvas for drawing.
Int_t fMaxRegions
The maximum number of regions allowed in each mask.
Bool_t HitsPattern(Double_t x, Double_t y)
Returns true if the pattern was hit. If (x,y) it is inside a region then, the pattern was not hit by ...
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestPatternMask.
Double_t fRotationAngle
An angle (in radians) used to introduce a rotation to the pattern.
Int_t ApplyCommonMaskTransformation(Double_t &x, Double_t &y)
It produces an effective mask rotation and translation for the point x,y.
virtual Int_t GetRegion(Double_t &x, Double_t &y)
To be implemented at the inherited class with the pattern and region identification logic.
~TRestPatternMask()
Default destructor.
Double_t fMaskRadius
The maximum mask radius in mm (if 0 it will be infinite)
std::string fPatternType
The pattern type (None/Stripped/Grid/Spider/Rings)
void PrintCommonPatternMembers()
Prints on screen the information about the metadata members without header.
@ REST_Info
+show most of the information for each steps
std::string IntegerToString(Int_t n, std::string format="%d")
Gets a string from an integer.