301
302 const float min_z0 = -168.0;
303 const float max_z0 = 168.0;
304
306
307 for(const auto& layer : layers) {
310 }
311
312
313
314
315 int lastBin1 = -1;
316
317 for(std::map<
int, std::vector<GNN_FASTRACK_CONNECTION*> >::const_iterator it =
conn->m_connMap.begin();it!=
conn->m_connMap.end();++it) {
318
319 const std::vector<GNN_FASTRACK_CONNECTION*>& vConn = (*it).second;
320
321 for(std::vector<GNN_FASTRACK_CONNECTION*>::const_iterator cIt=vConn.begin();cIt!=vConn.end();++cIt) {
322
323 unsigned int src = (*cIt)->m_src;
324 unsigned int dst = (*cIt)->m_dst;
325
328
329 if (pL1==nullptr) {
330 std::cout << " skipping invalid dst layer " << dst << std::endl;
331 continue;
332 }
333 if (pL2==nullptr) {
334 std::cout <<
" skipping invalid src layer " <<
src << std::endl;
335 continue;
336 }
337 int nSrcBins = pL2->
m_bins.size();
338 int nDstBins = pL1->
m_bins.size();
339
340 (*cIt)->m_binTable.resize(nSrcBins*nDstBins, 0);
341
342 for(int b1=0;b1<nDstBins;b1++) {
343 for(int b2=0;b2<nSrcBins;b2++) {
344 if(!pL1->
verifyBin(pL2, b1, b2, min_z0, max_z0))
continue;
345 int address = b1 + b2*nDstBins;
346 (*cIt)->m_binTable.at(address) = 1;
347
348 int bin1_idx = pL1->
m_bins.at(b1);
349 int bin2_idx = pL2->
m_bins.at(b2);
350
351 if(bin1_idx != lastBin1) {
352
353 std::vector<int>
v2(1, bin2_idx);
354 m_binGroups.push_back(std::make_pair(bin1_idx, v2));
355 lastBin1 = bin1_idx;
356
357 }
358 else {
359 (*
m_binGroups.rbegin()).second.push_back(bin2_idx);
360 }
361 }
362 }
363 }
364 }
365
366
367
368 std::map<int, std::pair<std::list<int>, std::list<int> > > bin_map;
369
370
371
372
373
375
377
378 if (bin_map.find(bin1) == bin_map.end()) {
379 std::pair<std::list<int>, std::list<int> > empty_links;
380 bin_map.insert(std::make_pair(bin1, empty_links));
381 }
382
383 std::pair<std::list<int>, std::list<int> >& bin1_links = (*bin_map.find(bin1)).second;
384
385 for (
auto bin2 :
bg.second) {
386
387 if (bin_map.find(bin2) == bin_map.end()) {
388 std::pair<std::list<int>, std::list<int> > empty_links;
389 bin_map.insert(std::make_pair(bin2, empty_links));
390 }
391
392 std::pair<std::list<int>, std::list<int> >& bin2_links = (*bin_map.find(bin2)).second;
393
394 bin1_links.second.push_back(bin2);
395 bin2_links.first.push_back(bin1);
396
397 }
398 }
399
400 std::map<int, std::pair<std::list<int>, std::list<int> > > current_map(bin_map);
401
402
403
404 std::vector<std::vector<int> > stages;
405
406 stages.reserve(50);
407
408 while (!current_map.empty()) {
409
410
411
412 std::vector<int> exit_bins;
413
414 for(const auto& bl : current_map) {
415
416 if(!bl.second.first.empty()) continue;
417
418 exit_bins.push_back(bl.first);
419
420 }
421
422
423
424 stages.emplace_back(exit_bins);
425
426
427
428 for (auto bin1_key : exit_bins) {
429 auto p1 = current_map.find(bin1_key);
430 if (p1 == current_map.end()) continue;
431 auto& bin1_links = (*p1).second;
432
433 for(auto bin2_key : bin1_links.second) {
434 auto p2 = current_map.find(bin2_key);
435 if (p2 == current_map.end()) continue;
436 std::list<int>&
links = (*p2).second.first;
437 links.remove(bin1_key);
438 }
439 }
440
441
442
443 for (auto bin1_key : exit_bins) {
444 current_map.erase(bin1_key);
445 }
446
447 }
448
449
450
452
453 for (auto iter = stages.rbegin(); iter != stages.rend(); ++iter) {
454
455 for (auto bin1_idx : (*iter)) {
456 const auto p = bin_map.find(bin1_idx);
457 if (p == bin_map.end()) continue;
458 const std::list<int>& bin2_list = (*p).second.second;
459
460 std::vector<int>
v2(bin2_list.begin(), bin2_list.end());
461
462 m_binGroups.push_back(std::make_pair(bin1_idx, v2));
463
464 }
465 }
466}
const TrigFTF_GNN_Layer * addNewLayer(const TrigInDetSiLayer &, int)
const TrigFTF_GNN_Layer * getTrigFTF_GNN_LayerByKey(unsigned int) const
std::vector< std::pair< int, std::vector< int > > > m_binGroups
std::vector< int > m_bins
bool verifyBin(const TrigFTF_GNN_Layer *, int, int, float, float) const