71 #include "TRestPatternMask.h"
170 fCanvas =
new TCanvas(
"canv",
"This is the canvas title", 1200, 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 xO = 2.5 * (rnd->Rndm() - 0.5) *
fMaskRadius;
187 Double_t yO = 2.5 * (rnd->Rndm() - 0.5) *
fMaskRadius;
193 if (points.count(
id) == 0) {
194 std::vector<TVector2> a;
195 a.push_back(TVector2(xO, yO));
198 points[id].push_back(TVector2(xO, yO));
202 std::vector<TGraph*> gridGraphs;
204 for (
const auto& x : points) {
206 TGraph* gr =
new TGraph();
207 gr->SetName(grname.c_str());
209 for (
unsigned int n = 0; n < x.second.size(); n++) {
210 gr->SetPoint(gr->GetN(), x.second[n].X(), x.second[n].Y());
214 gr->SetLineColor(kBlack);
215 gr->SetMarkerColor(kBlack);
216 gr->SetMarkerSize(0.6);
219 gr->SetMarkerColor((nGraphs * 3) % 29 + 20);
220 gr->SetLineColor((nGraphs * 3) % 29 + 20);
221 gr->SetMarkerSize(0.6);
225 gr->SetMarkerStyle(20);
226 gridGraphs.push_back(gr);
231 gridGraphs[0]->GetHistogram()->SetMaximum(1.25 *
fMaskRadius);
232 gridGraphs[0]->GetHistogram()->SetMinimum(-1.25 *
fMaskRadius);
234 gridGraphs[0]->GetXaxis()->SetTitle(
"X [mm]");
235 gridGraphs[0]->GetXaxis()->SetTitleSize(0.04);
236 gridGraphs[0]->GetXaxis()->SetLabelSize(0.04);
237 gridGraphs[0]->GetYaxis()->SetTitle(
"Y[mm]");
238 gridGraphs[0]->GetYaxis()->SetTitleOffset(1.5);
239 gridGraphs[0]->GetYaxis()->SetTitleSize(0.04);
240 gridGraphs[0]->GetYaxis()->SetLabelSize(0.04);
242 gridGraphs[0]->Draw(
"AP");
243 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 (not the mask, mask is always centered)
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.