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;
243int main(
int argc,
char** argv) {
244 constexpr double halfHeight = 200. * Gaudi::Units::mm;
245 constexpr double shortEdge = 150. * Gaudi::Units::mm;
246 constexpr double longEdge = 300. * Gaudi::Units::mm;
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];
256 std::unique_ptr<TFile>
file = std::make_unique<TFile>(outFile.c_str(),
"RECREATE");
261 stripPitch, stripWidth, numStrips, 1);
267 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Nominal design channel mapping failed "<<std::endl;
275 constexpr unsigned numStripsRot = 2*longEdge / stripPitch -1;
277 stripPitch, stripWidth, numStripsRot, 1);
283 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Flipped design channel mapping failed "<<std::endl;
288 rotatedDesign.
defineTrapezoid(shortEdge, longEdge, halfHeight, stereoAngle);
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);
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);
316 stripPitch, stripWidth, numStrips, 1);
322 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Rotated flipped design channel mapping failed "<<std::endl;
327 diamondDesign.
defineDiamond(shortEdge, longEdge, halfHeight, halfHeight);
329 stripPitch, stripWidth, numStrips+ 25, 1);
337 flippedDiamond.
defineDiamond(shortEdge, longEdge, halfHeight, halfHeight);
339 stripPitch, stripWidth, numStrips, 1);
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) {
359 totWires+=wireCounter;
360 if (wireCounter == 1)
sign = 1;
361 else if (wireCounter == 5)
sign = -1;
366 stripPitch, stripWidth, nCycles, 1);
373 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- WireGroupDesign back & forth mapping of channels failed "<<std::endl;
383 unsigned int wireCounter{1}, totWires{0}, nCycles{0};
385 while(totWires< numStrips) {
387 totWires+=wireCounter;
388 if (wireCounter == 1)
sign = 1;
389 else if (wireCounter == 5)
sign = -1;
394 stripPitch, stripWidth, nCycles, 1);
401 std::cerr<<
"runStripDesignDump() "<<__LINE__<<
" -- Flipped WireGroupDesign back & forth mapping of channels failed "<<std::endl;
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;