9 #include <GaudiKernel/SystemOfUnits.h>
18 graph.SetPoint(graph.GetN(), point.x(), point.y());
21 std::unique_ptr<TGraph> graph = std::make_unique<TGraph>();
34 std::cout<<
"################################################################"<<std::endl;
35 std::cout<<design<<std::endl;
36 std::cout<<
"################################################################"<<std::endl;
37 outFile.WriteObject(graph.get(), graphName.c_str());
58 std::unique_ptr<TH2I>
histo = std::make_unique<TH2I>(histoName.c_str(),
59 "channels:x[mm];y[mm];channelNumber",
80 std::unique_ptr<TH2I>
histo = std::make_unique<TH2I>(histoName.c_str(),
81 "boundaries;x[mm];y[mm];isInside",
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);
105 std::cout<<
"runStripDesignDump() "<<__LINE__<<
" -- Strip "<<
ch<<
" is not fetchable"<<std::endl;
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;
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();
127 const Amg::Vector2D pToTest = pBot + pointGenerator.Uniform()*(pTop - pBot);
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;
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();
146 for (
int ch = 1;
ch <= numStrips; ++
ch) {
147 const CheckVector2D stripCent = design.
center(
ch);
149 std::cout<<
"runStripDesignDump() "<<__LINE__<<
" -- Strip "<<
ch<<
" is not fetchable"<<std::endl;
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;
161 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Traveling along channel "<<
ch<<
" results in a different number"
167 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Traveling against channel "<<
ch<<
" results in a different number"
171 auto testAdjacent = [&](
const int adjacentCh) ->
bool {
172 const CheckVector2D adjacentStrip = design.
center(adjacentCh);
174 if (!adjacentCh || !adjacentStrip) {
179 const Amg::Vector2D adjacentShift = stripCentVal + 0.49*(adjacentVal - stripCentVal);
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)
189 <<
" but the design decided that it's gonna be "<<backAdjacent<<std::endl;
194 if (!testAdjacent(
ch -1)){
195 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" Previous strip assignment of "<<
ch<<
" failed. "<<std::endl;
198 if (!testAdjacent(
ch +1)){
199 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" Following strip assignment of "<<
ch<<
" failed. "<<std::endl;
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();
212 for (
int ch = 1;
ch <= numStrips; ++
ch) {
213 const CheckVector2D stripCent = design.
center(
ch);
215 std::cout<<
"runStripDesignDump() "<<__LINE__<<
" -- Strip "<<
ch<<
" is not fetchable"<<std::endl;
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
227 for (
int wire = 1; wire <= nWires ; ++ wire) {
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;
249 constexpr
double stripWidth = stripPitch / 3;
251 constexpr
unsigned int numStrips = 2.*halfHeight / stripPitch -1;
252 std::string
outFile{
"./Strip.root"};
256 std::unique_ptr<TFile>
file = std::make_unique<TFile>(
outFile.c_str(),
"RECREATE");
260 nominalDesign.defineStripLayout(
Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
261 stripPitch, stripWidth, numStrips, 1);
267 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Nominal design channel mapping failed "<<std::endl;
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);
283 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Flipped design channel mapping failed "<<std::endl;
288 rotatedDesign.
defineTrapezoid(shortEdge, longEdge, halfHeight, stereoAngle);
289 rotatedDesign.defineStripLayout(
Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
290 stripPitch, stripWidth, numStrips, 0);
296 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Stereo Rotated design channel mapping failed "<<std::endl;
301 rotatedDesignNeg.
defineTrapezoid(shortEdge, longEdge, halfHeight, -stereoAngle);
302 rotatedDesignNeg.defineStripLayout(
Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
303 stripPitch, stripWidth, numStrips, 1);
308 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Rotated design VolII channel mapping failed "<<std::endl;
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();
322 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Rotated flipped design channel mapping failed "<<std::endl;
327 diamondDesign.
defineDiamond(shortEdge, longEdge, halfHeight, halfHeight);
328 diamondDesign.defineStripLayout(
Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
329 stripPitch, stripWidth, numStrips+ 25, 1);
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();
346 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" --- Diamond design forth and back mapping failed."<<std::endl;
355 unsigned int wireCounter{1}, totWires{0}, nCycles{0};
357 while(totWires< numStrips) {
358 groupDesign.declareGroup(wireCounter);
359 totWires+=wireCounter;
360 if (wireCounter == 1)
sign = 1;
361 else if (wireCounter == 5)
sign = -1;
365 groupDesign.defineStripLayout(
Amg::Vector2D{-halfHeight + 0.5*stripPitch,0},
366 stripPitch, stripWidth, nCycles, 1);
373 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- WireGroupDesign back & forth mapping of channels failed "<<std::endl;
379 flipedWireGroups.flipTrapezoid();
383 unsigned int wireCounter{1}, totWires{0}, nCycles{0};
385 while(totWires< numStrips) {
386 flipedWireGroups.declareGroup(wireCounter);
387 totWires+=wireCounter;
388 if (wireCounter == 1)
sign = 1;
389 else if (wireCounter == 5)
sign = -1;
393 flipedWireGroups.defineStripLayout(
Amg::Vector2D{-longEdge + 0.5*stripPitch,0},
394 stripPitch, stripWidth, nCycles, 1);
401 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Flipped WireGroupDesign back & forth mapping of channels failed "<<std::endl;
407 flippedRadialDesign.flipTrapezoid();
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);
415 std::sort(bottomMountings.begin(), bottomMountings.end());
416 std::sort(topMountings.begin(), topMountings.end());
419 for (
size_t i =0;
i < bottomMountings.size(); ++
i) {
420 flippedRadialDesign.addStrip(bottomMountings[
i], topMountings[
i]);
427 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Flipped Radial design mapping failed channel mapping failed "<<std::endl;
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};
440 for (
size_t i =0;
i < mountings.size(); ++
i) {
441 RadialDesign.addStrip(mountings[
i], -mountings[mountings.size()- 1 -
i]);
447 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Radial design mapping failed channel mapping failed "<<std::endl;