32 int m_connector_id = 0;
42 mec8_channel_id(
int cable_id,
int connector_id,
int channel_id ):
43 m_cable_id( cable_id ),
44 m_connector_id( connector_id ),
45 m_channel_id( channel_id )
51 inline bool operator < (
const mec8_channel_id&
lhs,
const mec8_channel_id&
rhs )
53 if( lhs.m_cable_id != rhs.m_cable_id )
return lhs.m_cable_id < rhs.m_cable_id;
54 if( lhs.m_connector_id != rhs.m_connector_id )
return lhs.m_connector_id < rhs.m_connector_id;
55 return lhs.m_channel_id < rhs.m_channel_id;
59 [[maybe_unused]]
void print_mapping(
const std::string&
name,
const std::array<int, MicromegasDefs::m_nchannels_fee>&
array )
62 std::cout <<
"int " << name <<
"[" << array.size() <<
"] = {" << std::endl <<
" ";
63 for(
size_t i =0;
i < array.size(); ++
i )
65 if(
i > 0 ) std::cout <<
", ";
68 std::cout << std::endl <<
" ";
71 std::cout << array[
i];
75 std::cout << std::endl <<
"};" << std::endl;
108 std::cout <<
"MicromegasMapping::MicromegasMapping." << std::endl;
111 std::sort( m_detectors.begin(), m_detectors.end(), [](
const DetectorId&
lhs,
const DetectorId&
rhs )
118 for(
const auto& detector_id:m_detectors )
119 { m_detector_map.emplace( detector_id.m_fee_id, detector_id ); }
128 std::vector<int>
out;
139 std::cout <<
"MicromegasMapping::get_hitsetkey - invalid fee_id: " << fee_id << std::endl;
141 }
else return iter->second.m_hitsetkey;
150 std::cout <<
"MicromegasMapping::get_detname_saclay - invalid fee_id: " << fee_id << std::endl;
152 }
else return iter->second.m_detname_saclay;
161 std::cout <<
"MicromegasMapping::get_detname_sphenix - invalid fee_id: " << fee_id << std::endl;
163 }
else return iter->second.m_detname_sphenix;
172 std::cout <<
"MicromegasMapping::get_physical_strip - invalid channel: " << channel_id << std::endl;
179 switch (segmentation_type)
198 std::cout <<
"MicromegasMapping::get_detname_saclay_from_hitsetkey - invalid key: " << key << std::endl;
200 }
else return iter->m_detname_saclay;
209 std::cout <<
"MicromegasMapping::get_detname_sphenix_from_hitsetkey - invalid key: " << key << std::endl;
211 }
else return iter->m_detname_sphenix;
227 std::array<mec8_channel_id, MicromegasDefs::m_nchannels_fee> fee_to_mec8_mapping =
229 {0,0,34}, {0,0,33}, {0,0,32}, {0,0,31}, {0,0,30}, {0,0,29}, {0,0,28}, {0,0,27},
230 {0,0,26}, {0,0,25}, {0,0,24}, {0,0,23}, {0,0,22}, {0,0,21}, {0,0,20}, {0,0,19},
231 {0,0,18}, {0,0,17}, {0,0,16}, {0,0,15}, {0,0,14}, {0,0,13}, {0,0,12}, {0,0,11},
232 {0,0,10}, {0,0,9}, {0,0,8}, {0,0,7}, {0,0,6}, {0,0,5}, {0,0,4}, {0,0,3},
234 {0,0,68}, {0,0,67}, {0,0,66}, {0,0,65}, {0,0,64}, {0,0,63}, {0,0,62}, {0,0,61},
235 {0,0,60}, {0,0,59}, {0,0,58}, {0,0,57}, {0,0,56}, {0,0,55}, {0,0,54}, {0,0,53},
236 {0,0,52}, {0,0,51}, {0,0,50}, {0,0,49}, {0,0,48}, {0,0,47}, {0,0,46}, {0,0,45},
237 {0,0,44}, {0,0,43}, {0,0,42}, {0,0,41}, {0,0,40}, {0,0,39}, {0,0,38}, {0,0,37},
239 {0,1,34}, {0,1,33}, {0,1,32}, {0,1,31}, {0,1,30}, {0,1,29}, {0,1,28}, {0,1,27},
240 {0,1,26}, {0,1,25}, {0,1,24}, {0,1,23}, {0,1,22}, {0,1,21}, {0,1,20}, {0,1,19},
241 {0,1,18}, {0,1,17}, {0,1,16}, {0,1,15}, {0,1,14}, {0,1,13}, {0,1,12}, {0,1,11},
242 {0,1,10}, {0,1,9}, {0,1,8}, {0,1,7}, {0,1,6}, {0,1,5}, {0,1,4}, {0,1,3},
244 {0,1,68}, {0,1,67}, {0,1,66}, {0,1,65}, {0,1,64}, {0,1,63}, {0,1,62}, {0,1,61},
245 {0,1,60}, {0,1,59}, {0,1,58}, {0,1,57}, {0,1,56}, {0,1,55}, {0,1,54}, {0,1,53},
246 {0,1,52}, {0,1,51}, {0,1,50}, {0,1,49}, {0,1,48}, {0,1,47}, {0,1,46}, {0,1,45},
247 {0,1,44}, {0,1,43}, {0,1,42}, {0,1,41}, {0,1,40}, {0,1,39}, {0,1,38}, {0,1,37},
249 {1,0,34}, {1,0,33}, {1,0,32}, {1,0,31}, {1,0,30}, {1,0,29}, {1,0,28}, {1,0,27},
250 {1,0,26}, {1,0,25}, {1,0,24}, {1,0,23}, {1,0,22}, {1,0,21}, {1,0,20}, {1,0,19},
251 {1,0,18}, {1,0,17}, {1,0,16}, {1,0,15}, {1,0,14}, {1,0,13}, {1,0,12}, {1,0,11},
252 {1,0,10}, {1,0,9}, {1,0,8}, {1,0,7}, {1,0,6}, {1,0,5}, {1,0,4}, {1,0,3},
254 {1,0,68}, {1,0,67}, {1,0,66}, {1,0,65}, {1,0,64}, {1,0,63}, {1,0,62}, {1,0,61},
255 {1,0,60}, {1,0,59}, {1,0,58}, {1,0,57}, {1,0,56}, {1,0,55}, {1,0,54}, {1,0,53},
256 {1,0,52}, {1,0,51}, {1,0,50}, {1,0,49}, {1,0,48}, {1,0,47}, {1,0,46}, {1,0,45},
257 {1,0,44}, {1,0,43}, {1,0,42}, {1,0,41}, {1,0,40}, {1,0,39}, {1,0,38}, {1,0,37},
259 {1,1,34}, {1,1,33}, {1,1,32}, {1,1,31}, {1,1,30}, {1,1,29}, {1,1,28}, {1,1,27},
260 {1,1,26}, {1,1,25}, {1,1,24}, {1,1,23}, {1,1,22}, {1,1,21}, {1,1,20}, {1,1,19},
261 {1,1,18}, {1,1,17}, {1,1,16}, {1,1,15}, {1,1,14}, {1,1,13}, {1,1,12}, {1,1,11},
262 {1,1,10}, {1,1,9}, {1,1,8}, {1,1,7}, {1,1,6}, {1,1,5}, {1,1,4}, {1,1,3},
264 {1,1,68}, {1,1,67}, {1,1,66}, {1,1,65}, {1,1,64}, {1,1,63}, {1,1,62}, {1,1,61},
265 {1,1,60}, {1,1,59}, {1,1,58}, {1,1,57}, {1,1,56}, {1,1,55}, {1,1,54}, {1,1,53},
266 {1,1,52}, {1,1,51}, {1,1,50}, {1,1,49}, {1,1,48}, {1,1,47}, {1,1,46}, {1,1,45},
267 {1,1,44}, {1,1,43}, {1,1,42}, {1,1,41}, {1,1,40}, {1,1,39}, {1,1,38}, {1,1,37}
277 std::map<int,int> mec8_to_signal_mapping_z = {
280 {3,1}, {5,2}, {7,3}, {9,4}, {11,5}, {13,6}, {15,7}, {17,8},
281 {19,9}, {21,10}, {23,11}, {25,12}, {27,13}, {29,14}, {31,15}, {33,16},
283 {37,17}, {39,18}, {41,19}, {43,20}, {45,21}, {47,22}, {49,23}, {51,24},
284 {53,25}, {55,26}, {57,27}, {59,28}, {61,29}, {63,30}, {65,31}, {67,32},
288 {4,33}, {6,34}, {8,35}, {10,36}, {12,37}, {14,38}, {16,39}, {18,40},
289 {20,41}, {22,42}, {24,43}, {26,44}, {28,45}, {30,46}, {32,47}, {34,48},
291 {38,49}, {40,50}, {42,51}, {44,52}, {46,53}, {48,54}, {50,55}, {52,56},
292 {54,57}, {56,58}, {58,59}, {60,60}, {62,61}, {64,62}, {66,63}, {68,64},
301 std::map<mec8_channel_id,int> mec8_to_signal_mapping_z_all;
302 for(
const auto& [mec8_channel,signal_id]:mec8_to_signal_mapping_z )
306 if( signal_id == -1 )
continue;
309 mec8_to_signal_mapping_z_all.insert(std::pair<mec8_channel_id,int>({0,0,mec8_channel}, signal_id));
312 mec8_to_signal_mapping_z_all.insert(std::pair<mec8_channel_id,int>({0,1,mec8_channel}, signal_id+64));
315 mec8_to_signal_mapping_z_all.insert(std::pair<mec8_channel_id,int>({1,0,mec8_channel}, signal_id+128));
318 mec8_to_signal_mapping_z_all.insert(std::pair<mec8_channel_id,int>({1,1,mec8_channel}, signal_id+192));
323 std::map<int,int> strip_to_signal_id_mapping_all =
325 {1,1}, {2,33}, {3,2}, {4,34}, {5,3}, {6,35}, {7,4}, {8,36},
326 {9,5}, {10,37}, {11,6}, {12,38}, {13,7}, {14,39}, {15,8}, {16,40},
327 {17,9}, {18,41}, {19,10}, {20,42}, {21,11}, {22,43}, {23,12}, {24,44},
328 {25,13}, {26,45}, {27,14}, {28,46}, {29,15}, {30,47}, {31,16}, {32,48},
329 {33,17}, {34,49}, {35,18}, {36,50}, {37,19}, {38,51}, {39,20}, {40,52},
330 {41,21}, {42,53}, {43,22}, {44,54}, {45,23}, {46,55}, {47,24}, {48,56},
331 {49,25}, {50,57}, {51,26}, {52,58}, {53,27}, {54,59}, {55,28}, {56,60},
332 {57,29}, {58,61}, {59,30}, {60,62}, {61,31}, {62,63}, {63,32}, {64,64},
334 {65,65}, {66,97}, {67,66}, {68,98}, {69,67}, {70,99}, {71,68}, {72,100},
335 {73,69}, {74,101}, {75,70}, {76,102}, {77,71}, {78,103}, {79,72}, {80,104},
336 {81,73}, {82,105}, {83,74}, {84,106}, {85,75}, {86,107}, {87,76}, {88,108},
337 {89,77}, {90,109}, {91,78}, {92,110}, {93,79}, {94,111}, {95,80}, {96,112},
338 {97,81}, {98,113}, {99,82}, {100,114}, {101,83}, {102,115}, {103,84}, {104,116},
339 {105,85}, {106,117}, {107,86}, {108,118}, {109,87}, {110,119}, {111,88}, {112,120},
340 {113,89}, {114,121}, {115,90}, {116,122}, {117,91}, {118,123}, {119,92}, {120,124},
341 {121,93}, {122,125}, {123,94}, {124,126}, {125,95}, {126,127}, {127,96}, {128,128},
343 {129,129}, {130,161}, {131,130}, {132,162}, {133,131}, {134,163}, {135,132}, {136,164},
344 {137,133}, {138,165}, {139,134}, {140,166}, {141,135}, {142,167}, {143,136}, {144,168},
345 {145,137}, {146,169}, {147,138}, {148,170}, {149,139}, {150,171}, {151,140}, {152,172},
346 {153,141}, {154,173}, {155,142}, {156,174}, {157,143}, {158,175}, {159,144}, {160,176},
347 {161,145}, {162,177}, {163,146}, {164,178}, {165,147}, {166,179}, {167,148}, {168,180},
348 {169,149}, {170,181}, {171,150}, {172,182}, {173,151}, {174,183}, {175,152}, {176,184},
349 {177,153}, {178,185}, {179,154}, {180,186}, {181,155}, {182,187}, {183,156}, {184,188},
350 {185,157}, {186,189}, {187,158}, {188,190}, {189,159}, {190,191}, {191,160}, {192,192},
352 {193,193}, {194,225}, {195,194}, {196,226}, {197,195}, {198,227}, {199,196}, {200,228},
353 {201,197}, {202,229}, {203,198}, {204,230}, {205,199}, {206,231}, {207,200}, {208,232},
354 {209,201}, {210,233}, {211,202}, {212,234}, {213,203}, {214,235}, {215,204}, {216,236},
355 {217,205}, {218,237}, {219,206}, {220,238}, {221,207}, {222,239}, {223,208}, {224,240},
356 {225,209}, {226,241}, {227,210}, {228,242}, {229,211}, {230,243}, {231,212}, {232,244},
357 {233,213}, {234,245}, {235,214}, {236,246}, {237,215}, {238,247}, {239,216}, {240,248},
358 {241,217}, {242,249}, {243,218}, {244,250}, {245,219}, {246,251}, {247,220}, {248,252},
359 {249,221}, {250,253}, {251,222}, {252,254}, {253,223}, {254,255}, {255,224}, {256,256}
363 auto get_strip_geant_z = [](
int strip_audrey )
381 auto mec8_channel_id = fee_to_mec8_mapping[channel_id];
384 int mec8_signal_id = mec8_to_signal_mapping_z_all.at(mec8_channel_id);
387 const auto iter = std::find_if( strip_to_signal_id_mapping_all.begin(), strip_to_signal_id_mapping_all.end(), [mec8_signal_id](
const std::pair<int,int>& pair ) {
return pair.second == mec8_signal_id; } );
388 assert( iter != strip_to_signal_id_mapping_all.end() );
389 const int strip_audrey = iter->first;
392 const int strip_geant = get_strip_geant_z( strip_audrey );
407 std::map<int,int> mec8_to_signal_mapping_phi = {
410 {3,64}, {5,63}, {7,62}, {9,61}, {11,60}, {13,59}, {15,58}, {17,57},
411 {19,56}, {21,55}, {23,54}, {25,53}, {27,52}, {29,51}, {31,50}, {33,49},
413 {37,48}, {39,47}, {41,46}, {43,45}, {45,44}, {47,43}, {49,42}, {51,41},
414 {53,40}, {55,39}, {57,38}, {59,37}, {61,36}, {63,35}, {65,34}, {67,33},
418 {4,32}, {6,31}, {8,30}, {10,29}, {12,28}, {14,27}, {16,26}, {18,25},
419 {20,24}, {22,23}, {24,22}, {26,21}, {28,20}, {30,19}, {32,18}, {34,17},
421 {38,16}, {40,15}, {42,14}, {44,13}, {46,12}, {48,11}, {50,10}, {52,9},
422 {54,8}, {56,7}, {58,6}, {60,5}, {62,4}, {64,3}, {66,2}, {68,1},
431 std::map<mec8_channel_id,int> mec8_to_signal_mapping_phi_all;
432 for(
const auto& [mec8_channel,signal_id]:mec8_to_signal_mapping_phi )
436 if( signal_id == -1 )
continue;
439 mec8_to_signal_mapping_phi_all.insert(std::pair<mec8_channel_id,int>({0,0,mec8_channel}, signal_id+192));
442 mec8_to_signal_mapping_phi_all.insert(std::pair<mec8_channel_id,int>({0,1,mec8_channel}, signal_id+128));
445 mec8_to_signal_mapping_phi_all.insert(std::pair<mec8_channel_id,int>({1,0,mec8_channel}, signal_id+64));
448 mec8_to_signal_mapping_phi_all.insert(std::pair<mec8_channel_id,int>({1,1,mec8_channel}, signal_id));
452 auto get_strip_geant_phi = [](
int strip_audrey )
458 return MicromegasDefs::m_nchannels_fee-strip_audrey;
470 auto mec8_channel_id = fee_to_mec8_mapping[channel_id];
473 int mec8_signal_id = mec8_to_signal_mapping_phi_all.at(mec8_channel_id);
476 const auto iter = std::find_if( strip_to_signal_id_mapping_all.begin(), strip_to_signal_id_mapping_all.end(), [mec8_signal_id](
const std::pair<int,int>& pair ) {
return pair.second == mec8_signal_id; } );
477 assert( iter != strip_to_signal_id_mapping_all.end() );
478 const int strip_audrey = iter->first;
481 const int strip_geant = get_strip_geant_phi( strip_audrey );