ATLAS Offline Software
Loading...
Searching...
No Matches
runStripDesignDump.cxx File Reference
#include <MuonReadoutGeometryR4/StripDesign.h>
#include <MuonReadoutGeometryR4/WireGroupDesign.h>
#include <MuonReadoutGeometryR4/RadialStripDesign.h>
#include <GaudiKernel/SystemOfUnits.h>
#include <TGraph.h>
#include <TFile.h>
#include <TH2I.h>
#include <TRandom3.h>
Include dependency graph for runStripDesignDump.cxx:

Go to the source code of this file.

Functions

void addPoint (TGraph &graph, const Amg::Vector2D &point)
void createGraph (const StripDesign &design, TFile &outFile, const std::string &graphName)
double edgePoint (const StripDesign &design, unsigned int idx, bool min)
void testChannelNumber (const StripDesign &design, TFile &outFile, const std::string &histoName)
void testBoundaries (const StripDesign &design, TFile &outFile, const std::string &histoName)
bool testChamberBackForthMapping (const MuonGMR4::RadialStripDesign &design)
bool testChamberBackForthMapping (const MuonGMR4::StripDesign &design)
bool testChamberBackForthMapping (const MuonGMR4::WireGroupDesign &design)
int main (int argc, char **argv)

Function Documentation

◆ addPoint()

void addPoint ( TGraph & graph,
const Amg::Vector2D & point )

Definition at line 17 of file runStripDesignDump.cxx.

17 {
18 graph.SetPoint(graph.GetN(), point.x(), point.y());
19}

◆ createGraph()

void createGraph ( const StripDesign & design,
TFile & outFile,
const std::string & graphName )

Definition at line 20 of file runStripDesignDump.cxx.

20 {
21 std::unique_ptr<TGraph> graph = std::make_unique<TGraph>();
22 Eigen::Rotation2D rot{design.stereoAngle()};
23 addPoint(*graph, design.cornerBotLeft());
24 addPoint(*graph, design.cornerBotRight());
25 addPoint(*graph, design.cornerTopRight());
26 addPoint(*graph, design.cornerTopLeft());
27 addPoint(*graph, design.cornerBotLeft());
28 for (int strip = design.firstStripNumber(); strip <= design.numStrips(); ++strip) {
29 addPoint(*graph, rot * design.leftEdge(strip).value_or(Amg::Vector2D::Zero()));
30 addPoint(*graph, rot * design.center(strip).value_or(Amg::Vector2D::Zero()));
31 addPoint(*graph, rot * design.rightEdge(strip).value_or(Amg::Vector2D::Zero()));
32 addPoint(*graph, rot * design.leftEdge(strip).value_or(Amg::Vector2D::Zero()));
33 }
34 std::cout<<"################################################################"<<std::endl;
35 std::cout<<design<<std::endl;
36 std::cout<<"################################################################"<<std::endl;
37 outFile.WriteObject(graph.get(), graphName.c_str());
38}
double stereoAngle() const
Returns the value of the stereo angle.
const Amg::Vector2D & cornerTopLeft() const
Returns the top left corner of the trapezoid.
int firstStripNumber() const
Returns the number of the first strip.
CheckVector2D center(int stripNumb) const
Returns the bisector of the strip (Global numbering scheme)
const Amg::Vector2D & cornerTopRight() const
Returns the top right corner of the trapezoid.
CheckVector2D leftEdge(int stripNumb) const
Returns the left edge of the strip (Global numbering scheme)
CheckVector2D rightEdge(int stripNumb) const
Returns the right edge of the strip (Global numbering scheme)
const Amg::Vector2D & cornerBotRight() const
Returns the bottom right corner of the trapezoid.
const Amg::Vector2D & cornerBotLeft() const
Returns the bottom left corner of the trapezoid.
virtual int numStrips() const
Number of strips on the panel.
outFile
Comment Out Those You do not wish to run.
void addPoint(TGraph &graph, const Amg::Vector2D &point)

◆ edgePoint()

double edgePoint ( const StripDesign & design,
unsigned int idx,
bool min )

Definition at line 39 of file runStripDesignDump.cxx.

39 {
40 if (min) {
41 double minLeft = std::min(design.cornerBotLeft()[idx], design.cornerBotRight()[idx]);
42 double minRight = std::min(design.cornerTopLeft()[idx], design.cornerTopRight()[idx]);
43 return std::min(minLeft, minRight) - 25.*Gaudi::Units::mm;
44 }
45 double maxLeft = std::max(design.cornerBotLeft()[idx], design.cornerBotRight()[idx]);
46 double maxRight = std::max(design.cornerTopLeft()[idx], design.cornerTopRight()[idx]);
47 return std::max(maxLeft, maxRight) + 25.*Gaudi::Units::mm;
48}
#define min(a, b)
Definition cfImp.cxx:40

◆ main()

int main ( int argc,
char ** argv )

Flip the strip design

Definition at line 243 of file runStripDesignDump.cxx.

243 {
244 constexpr double halfHeight = 200. * Gaudi::Units::mm;
245 constexpr double shortEdge = 150. * Gaudi::Units::mm;
246 constexpr double longEdge = 300. * Gaudi::Units::mm;
247
248 constexpr double stripPitch = 5 * Gaudi::Units::mm;
249 constexpr double stripWidth = stripPitch / 3;
250 constexpr double stereoAngle = 20. * Gaudi::Units::deg;
251 constexpr unsigned int numStrips = 2.*halfHeight / stripPitch -1;
252 std::string outFile{"./Strip.root"};
253 if (argc > 1) outFile = argv[1];
254
255
256 std::unique_ptr<TFile> file = std::make_unique<TFile>(outFile.c_str(), "RECREATE");
257
258 StripDesign nominalDesign{};
259 nominalDesign.defineTrapezoid(shortEdge, longEdge, halfHeight);
260 nominalDesign.defineStripLayout(Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
261 stripPitch, stripWidth, numStrips, 1);
263 createGraph(nominalDesign, *file, "NominalDesign");
264 testChannelNumber(nominalDesign, *file, "NominalNumbers");
265 testBoundaries(nominalDesign, *file, "NominalBoundaries");
266 if (!testChamberBackForthMapping(nominalDesign)) {
267 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Nominal design channel mapping failed "<<std::endl;
268 return EXIT_FAILURE;
269 }
270
272 StripDesign flippedDesign{};
273 flippedDesign.defineTrapezoid(shortEdge, longEdge, halfHeight);
274 flippedDesign.flipTrapezoid();
275 constexpr unsigned numStripsRot = 2*longEdge / stripPitch -1;
276 flippedDesign.defineStripLayout(Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
277 stripPitch, stripWidth, numStripsRot, 1);
278
279 createGraph(flippedDesign,*file, "FlippedDesign");
280 testChannelNumber(flippedDesign, *file, "FlippedNumbers");
281 testBoundaries(flippedDesign, *file, "FlippedBoundaries");
282 if (!testChamberBackForthMapping(flippedDesign)) {
283 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Flipped design channel mapping failed "<<std::endl;
284 return EXIT_FAILURE;
285 }
286
287 StripDesign rotatedDesign{};
288 rotatedDesign.defineTrapezoid(shortEdge, longEdge, halfHeight, stereoAngle);
289 rotatedDesign.defineStripLayout(Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
290 stripPitch, stripWidth, numStrips, 0);
292 createGraph(rotatedDesign, *file, "StereoDesign");
293 testChannelNumber(rotatedDesign, *file, "StereoNumbers");
294 testBoundaries(rotatedDesign, *file, "StereoBoundaries");
295 if (!testChamberBackForthMapping(rotatedDesign)) {
296 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Stereo Rotated design channel mapping failed "<<std::endl;
297 return EXIT_FAILURE;
298 }
299
300 StripDesign rotatedDesignNeg{};
301 rotatedDesignNeg.defineTrapezoid(shortEdge, longEdge, halfHeight, -stereoAngle);
302 rotatedDesignNeg.defineStripLayout(Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
303 stripPitch, stripWidth, numStrips, 1);
305 createGraph(rotatedDesignNeg, *file, "NegStereoDesign");
306 testChannelNumber(rotatedDesignNeg, *file, "NegStereoDesignNumbers");
307 if (!testChamberBackForthMapping(rotatedDesignNeg)) {
308 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Rotated design VolII channel mapping failed "<<std::endl;
309 return EXIT_FAILURE;
310 }
311
312
313 StripDesign flippedRotated{};
314 flippedRotated.defineTrapezoid(shortEdge, longEdge, halfHeight, stereoAngle);
315 flippedRotated.defineStripLayout(Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
316 stripPitch, stripWidth, numStrips, 1);
317 flippedRotated.flipTrapezoid();
319 createGraph(flippedRotated, *file, "StereoFlipped");
320 testChannelNumber(rotatedDesign, *file, "StereoFlippedNumbers");
321 if (!testChamberBackForthMapping(rotatedDesignNeg)) {
322 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Rotated flipped design channel mapping failed "<<std::endl;
323 return EXIT_FAILURE;
324 }
325
326 StripDesign diamondDesign{};
327 diamondDesign.defineDiamond(shortEdge, longEdge, halfHeight, halfHeight);
328 diamondDesign.defineStripLayout(Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
329 stripPitch, stripWidth, numStrips+ 25, 1);
330
331 createGraph(diamondDesign, *file, "Diamond");
332 testChannelNumber(diamondDesign, *file, "DiamondNumbers");
333 testBoundaries(diamondDesign, *file, "DiamondBoundaries");
334
335
336 StripDesign flippedDiamond{};
337 flippedDiamond.defineDiamond(shortEdge, longEdge, halfHeight, halfHeight);
338 flippedDiamond.defineStripLayout(Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
339 stripPitch, stripWidth, numStrips, 1);
340 flippedDiamond.flipTrapezoid();
341 createGraph(flippedDiamond, *file, "FlippedDiamond");
342 testChannelNumber(flippedDiamond, *file, "FlippedDiamondNumbers");
343 testBoundaries(flippedDiamond, *file, "FlippedDiamondBoundaries");
344
345 if (!testChamberBackForthMapping(diamondDesign)) {
346 std::cerr<<"runStripDesignDump() "<<__LINE__<<" --- Diamond design forth and back mapping failed."<<std::endl;
347 return EXIT_FAILURE;
348 }
349
350 WireGroupDesign groupDesign{};
351 groupDesign.defineTrapezoid(shortEdge, longEdge, halfHeight);
352 {
353
354
355 unsigned int wireCounter{1}, totWires{0}, nCycles{0};
356 int sign{1};
357 while(totWires< numStrips) {
358 groupDesign.declareGroup(wireCounter);
359 totWires+=wireCounter;
360 if (wireCounter == 1) sign = 1;
361 else if (wireCounter == 5) sign = -1;
362 wireCounter+=sign;
363 ++nCycles;
364 }
365 groupDesign.defineStripLayout(Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
366 stripPitch, stripWidth, nCycles, 1);
367
368
369 }
370 createGraph(groupDesign, *file, "WireGroups");
371 testChannelNumber(groupDesign, *file, "WireNumbers");
372 if (!testChamberBackForthMapping(groupDesign)) {
373 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- WireGroupDesign back & forth mapping of channels failed "<<std::endl;
374 return EXIT_FAILURE;
375 }
376
377 WireGroupDesign flipedWireGroups{};
378 flipedWireGroups.defineTrapezoid(shortEdge, longEdge, halfHeight);
379 flipedWireGroups.flipTrapezoid();
380 {
381
382
383 unsigned int wireCounter{1}, totWires{0}, nCycles{0};
384 int sign{1};
385 while(totWires< numStrips) {
386 flipedWireGroups.declareGroup(wireCounter);
387 totWires+=wireCounter;
388 if (wireCounter == 1) sign = 1;
389 else if (wireCounter == 5) sign = -1;
390 wireCounter+=sign;
391 ++nCycles;
392 }
393 flipedWireGroups.defineStripLayout(Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
394 stripPitch, stripWidth, nCycles, 1);
395
396 }
397 createGraph(flipedWireGroups, *file, "FlippedWireGroups");
398 testChannelNumber(flipedWireGroups, *file, "FlippedWireNumbers");
399
400 if (!testChamberBackForthMapping(flipedWireGroups)) {
401 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Flipped WireGroupDesign back & forth mapping of channels failed "<<std::endl;
402 return EXIT_FAILURE;
403 }
404
405 RadialStripDesign flippedRadialDesign{};
406 flippedRadialDesign.defineTrapezoid(shortEdge, longEdge, halfHeight);
407 flippedRadialDesign.flipTrapezoid();
408 {
409 TRandom3 rand{};
410 std::array<double, 25> bottomMountings{}, topMountings{};
411 for (size_t i = 0 ; i < bottomMountings.size(); ++i){
412 bottomMountings[i] = rand.Uniform(-shortEdge, shortEdge);
413 topMountings[i] = rand.Uniform(-longEdge, longEdge);
414 }
415 std::sort(bottomMountings.begin(), bottomMountings.end());
416 std::sort(topMountings.begin(), topMountings.end());
417
418
419 for (size_t i =0; i < bottomMountings.size(); ++i) {
420 flippedRadialDesign.addStrip(bottomMountings[i], topMountings[i]);
421 }
422 }
423 createGraph(flippedRadialDesign, *file, "FlippedRadialDesign");
424 testChannelNumber(flippedRadialDesign, *file, "FlippedRadialNumbers");
425
426 if (!testChamberBackForthMapping(flippedRadialDesign)) {
427 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Flipped Radial design mapping failed channel mapping failed "<<std::endl;
428 return EXIT_FAILURE;
429 }
430 RadialStripDesign RadialDesign{};
431 RadialDesign.defineTrapezoid(shortEdge, longEdge, halfHeight);
432 {
433 const double edgeLength = 0.5* std::hypot(shortEdge - longEdge, 2* halfHeight);
434 std::array<double, 15> mountings{-0.95 * edgeLength, -0.76 * edgeLength, -0.63 *edgeLength,
435 -0.57 * edgeLength, -0.41 * edgeLength, -0.21 *edgeLength,
436 0, 0.16 * edgeLength, 0.34 *edgeLength,
437 0.42 * edgeLength, 0.53 * edgeLength, 0.66 *edgeLength,
438 0.75 * edgeLength, 0.86 * edgeLength, 0.99 *edgeLength};
439
440 for (size_t i =0; i < mountings.size(); ++i) {
441 RadialDesign.addStrip(mountings[i], -mountings[mountings.size()- 1 - i]);
442 }
443 }
444 createGraph(RadialDesign, *file, "RadialDesign");
445 testChannelNumber(RadialDesign, *file, "RadialNumbers");
446 if (!testChamberBackForthMapping(RadialDesign)) {
447 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Radial design mapping failed channel mapping failed "<<std::endl;
448 return EXIT_FAILURE;
449 }
450 return EXIT_SUCCESS;
451}
int sign(int a)
void addStrip(const double posOnBottom, const double posOnTop)
: Defines a new radial strip.
void defineDiamond(double HalfShortY, double HalfLongY, double HalfHeight, double yCutout)
Defines the edges of the sTGC diamond L3 sector.
void defineStripLayout(Amg::Vector2D &&posFirst, const double stripPitch, const double stripWidth, const int numStrips, const int numFirst=1)
Defines the layout of the strip detector by specifing the position of the first strip w....
void defineTrapezoid(double HalfShortY, double HalfLongY, double HalfHeight)
Defines the edges of the trapezoid.
void flipTrapezoid()
Flips the edges of the trapezoid boundaries by 90 degrees clockwise.
void declareGroup(const unsigned int x)
Adds a new group of wires to the design.
Eigen::Matrix< double, 2, 1 > Vector2D
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void testChannelNumber(const StripDesign &design, TFile &outFile, const std::string &histoName)
void testBoundaries(const StripDesign &design, TFile &outFile, const std::string &histoName)
void createGraph(const StripDesign &design, TFile &outFile, const std::string &graphName)
bool testChamberBackForthMapping(const MuonGMR4::RadialStripDesign &design)
TFile * file

◆ testBoundaries()

void testBoundaries ( const StripDesign & design,
TFile & outFile,
const std::string & histoName )

Definition at line 72 of file runStripDesignDump.cxx.

72 {
73 const double lowX = edgePoint(design, Amg::x, true);
74 const double highX = edgePoint(design, Amg::x, false);
75 const double lowY = edgePoint(design, Amg::y, true);
76 const double highY = edgePoint(design, Amg::y, false);
77 const unsigned nBinX = (highX -lowX) / 0.25*Gaudi::Units::mm;
78 const unsigned nBinY = (highY -lowY) / 0.25*Gaudi::Units::mm;
79
80 std::unique_ptr<TH2I> histo = std::make_unique<TH2I>(histoName.c_str(),
81 "boundaries;x[mm];y[mm];isInside",
82 nBinX, lowX, highX,
83 nBinY, lowY, highY);
84 Eigen::Rotation2D stereoRot{design.stereoAngle()};
85 for (unsigned binX = 1; binX < nBinX; ++ binX) {
86 for (unsigned binY = 1; binY < nBinY; ++binY) {
87 const Amg::Vector2D pos{histo->GetXaxis()->GetBinCenter(binX),
88 histo->GetYaxis()->GetBinCenter(binY)};
89 histo->SetBinContent(binX, binY, design.insideTrapezoid(stereoRot*pos));
90 }
91 }
92 outFile.WriteObject(histo.get(), histo->GetName());
93}
bool insideTrapezoid(const Amg::Vector2D &extPos) const
Checks whether an external point is inside the trapezoidal area.
@ binX
Definition BinningType.h:47
@ binY
Definition BinningType.h:48
double edgePoint(const StripDesign &design, unsigned int idx, bool min)

◆ testChamberBackForthMapping() [1/3]

bool testChamberBackForthMapping ( const MuonGMR4::RadialStripDesign & design)

Throw 1000 points onto the strip and check whether they're all assigned to the same strip number

Definition at line 95 of file runStripDesignDump.cxx.

95 {
96 std::cout<<"##################################################################################"<<std::endl;
97 std::cout<<"runStripDesignDump() -- Check strip back and forth mapping of "<<std::endl<<design<<std::endl;
98 std::cout<<"##################################################################################"<<std::endl;
100 const int numStrips = design.numStrips();
101 TRandom3 pointGenerator{};
102 for (int ch = 1; ch <= numStrips; ++ch) {
103 const CheckVector2D stripCent = design.center(ch);
104 if (!stripCent) {
105 std::cout<<"runStripDesignDump() "<<__LINE__<<" -- Strip "<<ch<< " is not fetchable"<<std::endl;
106 continue;
107 }
108 const Amg::Vector2D& stripCentVal{(*stripCent)};
109 int backChNum = design.stripNumber(stripCentVal);
110 if (backChNum != ch) {
111 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Back & forth mapping of strip "<<ch
112 <<" "<<Amg::toString(stripCentVal)<<" gave different results "<<ch<<" vs. "<<backChNum<<std::endl;
113 return false;
114 }
115 const Amg::Vector2D leftBot = design.stripLeftBottom(ch);
116 const Amg::Vector2D leftTop = design.stripLeftTop(ch);
117 const Amg::Vector2D rightBot = design.stripRightBottom(ch);
118 const Amg::Vector2D rightTop = design.stripRightTop(ch);
119
120 const double widthTop{(leftTop- rightTop).mag()}, widthBot{(leftBot - rightBot).mag()};
122 for (int p = 0; p < 1000; ++p) {
123 const double horStep = pointGenerator.Uniform();
124 const Amg::Vector2D pBot = leftBot + horStep *widthBot * design.edgeDirBottom();
125 const Amg::Vector2D pTop = leftTop + horStep *widthTop * design.edgeDirTop();
126
127 const Amg::Vector2D pToTest = pBot + pointGenerator.Uniform()*(pTop - pBot);
128 const int testCh = design.stripNumber(pToTest);
129 if (testCh != ch) {
130 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- The point "<<Amg::toString(pToTest)<<" should be associated "
131 <<" with channel "<<ch<<" but the design associated it with "<<testCh<<std::endl;
132 return false;
133 }
134 }
135 }
136 return true;
137}
Scalar mag() const
mag method
Amg::Vector2D stripLeftTop(int stripNumber) const
: Returns the intersection of the left strip edge at the top panel's edge
Amg::Vector2D stripRightTop(int stripNumber) const
: Returns the intersecetion fo the right strip edge at the top panel's edge
Amg::Vector2D stripRightBottom(int stripNumber) const
: Returns the intersecton of the strip right edge at the bottom panel's edge
int numStrips() const override
Returns the number of defined strips.
int stripNumber(const Amg::Vector2D &extPos) const override final
Returns the associated channel number of an external vector.
Amg::Vector2D stripLeftBottom(int stripNumber) const
: Returns the intersection of the left strip edge at the bottom panel's edge
const Amg::Vector2D & edgeDirTop() const
Returns the unit vector pointing from the top left -> top right corner.
std::optional< Amg::Vector2D > CheckVector2D
Definition StripDesign.h:82
const Amg::Vector2D & edgeDirBottom() const
Returns the unit vector pointing from the bottom left -> bottom right corner.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.

◆ testChamberBackForthMapping() [2/3]

bool testChamberBackForthMapping ( const MuonGMR4::StripDesign & design)

Probably we're either at 1 or nChannels

Place the vector shortly before the nominal boundary crossing

Ensure that it's actually inside the boundary

Definition at line 139 of file runStripDesignDump.cxx.

139 {
140 std::cout<<"##################################################################################"<<std::endl;
141 std::cout<<"runStripDesignDump() -- Check strip back and forth mapping of "<<std::endl<<design<<std::endl;
142 std::cout<<"##################################################################################"<<std::endl;
143 using CheckVector2D = MuonGMR4::CheckVector2D;
144 const int numStrips = design.numStrips();
145 const AmgSymMatrix(2) restRot{Eigen::Rotation2D{design.stereoAngle()}};
146 for (int ch = 1; ch <= numStrips; ++ch) {
147 const CheckVector2D stripCent = design.center(ch);
148 if (!stripCent) {
149 std::cout<<"runStripDesignDump() "<<__LINE__<<" -- Strip "<<ch<< " is not fetchable"<<std::endl;
150 continue;
151 }
152 const Amg::Vector2D& stripCentVal{(*stripCent)};
153 const int backChNum = design.stripNumber(stripCentVal);
154 if (backChNum != ch) {
155 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Back & forth mapping of strip "<<ch
156 <<" "<<Amg::toString(stripCentVal)<<" gave different results "<<ch<<" vs. "<<backChNum<<std::endl;
157 return false;
158 }
159 const Amg::Vector2D upperEdge = stripCentVal + 0.499 * design.stripLength(ch) * Amg::Vector2D::UnitY();
160 if (design.stripNumber(upperEdge) != ch){
161 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Traveling along channel "<<ch<<" results in a different number"
162 <<design.stripNumber(upperEdge)<<std::endl;
163 }
164
165 const Amg::Vector2D lowerEdge = stripCentVal - 0.499 * design.stripLength(ch) * Amg::Vector2D::UnitY();
166 if (design.stripNumber(lowerEdge) != ch){
167 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Traveling against channel "<<ch<<" results in a different number"
168 <<design.stripNumber(lowerEdge)<<std::endl;
169 }
170
171 auto testAdjacent = [&](const int adjacentCh) -> bool {
172 const CheckVector2D adjacentStrip = design.center(adjacentCh);
174 if (!adjacentCh || !adjacentStrip) {
175 return true;
176 }
177 const Amg::Vector2D& adjacentVal{*adjacentStrip};
179 const Amg::Vector2D adjacentShift = stripCentVal + 0.49*(adjacentVal - stripCentVal);
181 if (!design.insideTrapezoid(restRot * adjacentShift)) {
182 return true;
183 }
184 const int backAdjacent = design.stripNumber(adjacentShift);
185 if (backAdjacent != ch) {
186 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- the point "<<Amg::toString(adjacentShift)
187 <<" should be assigned to "<<ch<<". Ref strip: "<<Amg::toString(stripCentVal)
188 <<", adjacent: "<<Amg::toString(adjacentVal)
189 <<" but the design decided that it's gonna be "<<backAdjacent<<std::endl;
190 return false;
191 }
192 return true;
193 };
194 if (!testAdjacent(ch -1)){
195 std::cerr<<"runStripDesignDump() "<<__LINE__<<" Previous strip assignment of "<<ch<<" failed. "<<std::endl;
196 return false;
197 }
198 if (!testAdjacent(ch +1)){
199 std::cerr<<"runStripDesignDump() "<<__LINE__<<" Following strip assignment of "<<ch<<" failed. "<<std::endl;
200 return false;
201 }
202 }
203 return true;
204}
#define AmgSymMatrix(dim)
virtual double stripLength(int stripNumb) const
Returns length of the strip.
virtual int stripNumber(const Amg::Vector2D &pos) const
Calculates the number of the strip whose center is closest to the given point.

◆ testChamberBackForthMapping() [3/3]

bool testChamberBackForthMapping ( const MuonGMR4::WireGroupDesign & design)

Definition at line 205 of file runStripDesignDump.cxx.

205 {
206 std::cout<<"##################################################################################"<<std::endl;
207 std::cout<<"runStripDesignDump() -- Check strip back and forth mapping of "<<std::endl<<design<<std::endl;
208 std::cout<<"##################################################################################"<<std::endl;
209 using CheckVector2D = MuonGMR4::CheckVector2D;
210 const int numStrips = design.numStrips();
211 const AmgSymMatrix(2) restRot{Eigen::Rotation2D{design.stereoAngle()}};
212 for (int ch = 1; ch <= numStrips; ++ch) {
213 const CheckVector2D stripCent = design.center(ch);
214 if (!stripCent) {
215 std::cout<<"runStripDesignDump() "<<__LINE__<<" -- Strip "<<ch<< " is not fetchable"<<std::endl;
216 continue;
217 }
218 const Amg::Vector2D& stripCentVal{(*stripCent)};
219 const int backChNum = design.stripNumber(stripCentVal);
220 if (backChNum != ch) {
221 std::cerr<<"runStripDesignDump() "<<__LINE__<<" -- Back & forth mapping of strip "<<ch
222 <<" "<<Amg::toString(stripCentVal)<<" gave different results "<<ch<<" vs. "<<backChNum
223 <<" "<<Amg::toString(design.center(backChNum).value_or(Amg::Vector2D::Zero()))<<std::endl;
224 return false;
225 }
226 const int nWires = design.numWiresInGroup(ch);
227 for (int wire = 1; wire <= nWires ; ++ wire) {
228 CheckVector2D wireVec = design.wirePosition(ch, wire);
229 if (!wireVec || !design.insideTrapezoid(*wireVec)) {
230 continue;
231 }
232 auto [backWireGrp, backWire] = design.wireNumber(*wireVec);
233 if (backWireGrp != ch && wire != backWire) {
234 std::cout<<"runStripDesignDump() "<<__LINE__<<" -- The wire ("<<ch<<"/"<<wire<<") is backmapped to "
235 <<"("<<backWireGrp<<"/"<<backWire<<"). "<<std::endl;
236 return false;
237 }
238 }
239 }
240 return true;
241}
int stripNumber(const Amg::Vector2D &pos) const override
Calculates the number of the strip whose center is closest to the given point.
unsigned int numWiresInGroup(unsigned int groupNum) const
Returns the number of wires in a given group.
CheckVector2D wirePosition(unsigned int groupNum, unsigned int wireNum) const
Returns the positition of the i-th wire in the g-th group groupNum [1; numStrips() wire number [1; nu...
std::pair< int, int > wireNumber(const Amg::Vector2D &extPos) const
Returns a pair where the first component indicate the wire group number and the second one returns th...

◆ testChannelNumber()

void testChannelNumber ( const StripDesign & design,
TFile & outFile,
const std::string & histoName )

Definition at line 49 of file runStripDesignDump.cxx.

49 {
50
51 const double lowX = edgePoint(design, Amg::x, true);
52 const double highX = edgePoint(design, Amg::x, false);
53 const double lowY = edgePoint(design, Amg::y, true);
54 const double highY = edgePoint(design, Amg::y, false);
55 const unsigned nBinX = (highX -lowX) / 0.5*Gaudi::Units::mm;
56 const unsigned nBinY = (highY -lowY) / 0.5*Gaudi::Units::mm;
57
58 std::unique_ptr<TH2I> histo = std::make_unique<TH2I>(histoName.c_str(),
59 "channels:x[mm];y[mm];channelNumber",
60 nBinX, lowX, highX,
61 nBinY, lowY, highY);
62 Eigen::Rotation2D stereoRot{design.stereoAngle()};
63 for (unsigned binX = 1; binX < nBinX; ++ binX) {
64 for (unsigned binY = 1; binY < nBinY; ++binY) {
65 const Amg::Vector2D pos{histo->GetXaxis()->GetBinCenter(binX),
66 histo->GetYaxis()->GetBinCenter(binY)};
67 histo->SetBinContent(binX, binY, design.stripNumber(stereoRot*pos));
68 }
69 }
70 outFile.WriteObject(histo.get(), histo->GetName());
71}