ATLAS Offline Software
Loading...
Searching...
No Matches
TrigFTF_GNN_Geometry Class Reference

#include <GNN_Geometry.h>

Collaboration diagram for TrigFTF_GNN_Geometry:

Public Member Functions

 TrigFTF_GNN_Geometry (const std::vector< TrigInDetSiLayer > &, const std::unique_ptr< GNN_FasTrackConnector > &)
 ~TrigFTF_GNN_Geometry ()
const TrigFTF_GNN_LayergetTrigFTF_GNN_LayerByKey (unsigned int) const
const TrigFTF_GNN_LayergetTrigFTF_GNN_LayerByIndex (int) const
unsigned int getTrigFTF_GNN_LayerKeyByIndex (int idx) const
int num_bins () const
unsigned int num_layers () const
const std::vector< std::pair< int, std::vector< int > > > & bin_groups () const

Protected Member Functions

const TrigFTF_GNN_LayeraddNewLayer (const TrigInDetSiLayer &, int)

Protected Attributes

float m_etaBinWidth
std::map< unsigned int, TrigFTF_GNN_Layer * > m_layMap
std::vector< TrigFTF_GNN_Layer * > m_layArray
std::vector< unsigned int > m_layerKeys
int m_nEtaBins
std::vector< std::pair< int, std::vector< int > > > m_binGroups

Detailed Description

Definition at line 48 of file GNN_Geometry.h.

Constructor & Destructor Documentation

◆ TrigFTF_GNN_Geometry()

TrigFTF_GNN_Geometry::TrigFTF_GNN_Geometry ( const std::vector< TrigInDetSiLayer > & layers,
const std::unique_ptr< GNN_FasTrackConnector > & conn )

Definition at line 300 of file GNN_Geometry.cxx.

300 : m_nEtaBins(0) {
301
302 const float min_z0 = -168.0;
303 const float max_z0 = 168.0;
304
305 m_etaBinWidth = conn->m_etaBin;
306
307 for(const auto& layer : layers) {
308 const TrigFTF_GNN_Layer* pL = addNewLayer(layer, m_nEtaBins);
309 m_nEtaBins += pL->num_bins();
310 }
311
312 //calculating bin tables in the connector...
313 //calculate bin pairs for graph edge building
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;//n2 : the new connectors
324 unsigned int dst = (*cIt)->m_dst;//n1
325
326 const TrigFTF_GNN_Layer* pL1 = getTrigFTF_GNN_LayerByKey(dst);
327 const TrigFTF_GNN_Layer* pL2 = getTrigFTF_GNN_LayerByKey(src);
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++) {//loop over bins in Layer 1
343 for(int b2=0;b2<nSrcBins;b2++) {//loop over bins in Layer 2
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) {//adding a new group
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 {//extend the last group
359 (*m_binGroups.rbegin()).second.push_back(bin2_idx);
360 }
361 }
362 }
363 }
364 }
365
366 // find stages of eta-bin pairs using the graph ablation algorithm
367
368 std::map<int, std::pair<std::list<int>, std::list<int> > > bin_map;
369
370 // 1. create a map of bin-to-bin connections
371
372 //initialize with empty links
373
374 for (const auto& bg : m_binGroups) {
375
376 int bin1 = bg.first;
377
378 if (bin_map.find(bin1) == bin_map.end()) {//add to the map
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()) {//add to the map
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);//incoming link bin1 <- bin2
395 bin2_links.first.push_back(bin1); //outgoing link bin2 -> bin1
396
397 }
398 }
399
400 std::map<int, std::pair<std::list<int>, std::list<int> > > current_map(bin_map);//copy bin map as the original will be modified
401
402 // 2. find stages starting from the last one (i.e. bin1 with no outgoing connections)
403
404 std::vector<std::vector<int> > stages;
405
406 stages.reserve(50);
407
408 while (!current_map.empty()) {
409
410 // 2a. find all bins with zero outgoing links
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 //2b. add a new stage: vector of bin1
423
424 stages.emplace_back(exit_bins);
425
426 //2c. remove links : graph ablation
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 //2d. finally, remove all exit bin1s from the map
442
443 for (auto bin1_key : exit_bins) {
444 current_map.erase(bin1_key);
445 }
446
447 }
448
449 //3. Refill binGroups with staged bin pair collections.
450
451 m_binGroups.clear();
452
453 for (auto iter = stages.rbegin(); iter != stages.rend(); ++iter) {//refill order is reverse to creation
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;//bins which are incoming to bin1
459
460 std::vector<int> v2(bin2_list.begin(), bin2_list.end());
461
462 m_binGroups.push_back(std::make_pair(bin1_idx, v2));//store the group
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
int num_bins() const
bool verifyBin(const TrigFTF_GNN_Layer *, int, int, float, float) const

◆ ~TrigFTF_GNN_Geometry()

TrigFTF_GNN_Geometry::~TrigFTF_GNN_Geometry ( )

Definition at line 469 of file GNN_Geometry.cxx.

469 {
470 for(std::vector<TrigFTF_GNN_Layer*>::iterator it = m_layArray.begin();it!=m_layArray.end();++it) {
471 delete (*it);
472 }
473 m_layMap.clear();m_layArray.clear();
474}
std::map< unsigned int, TrigFTF_GNN_Layer * > m_layMap
std::vector< TrigFTF_GNN_Layer * > m_layArray

Member Function Documentation

◆ addNewLayer()

const TrigFTF_GNN_Layer * TrigFTF_GNN_Geometry::addNewLayer ( const TrigInDetSiLayer & l,
int bin0 )
protected

Definition at line 490 of file GNN_Geometry.cxx.

490 {
491
492 unsigned int layerKey = l.m_subdet;
493
494 float ew = m_etaBinWidth;
495
496 TrigFTF_GNN_Layer* pHL = new TrigFTF_GNN_Layer(l, ew, bin0);
497
498 m_layMap.insert(std::pair<unsigned int, TrigFTF_GNN_Layer*>(layerKey, pHL));
499 m_layArray.push_back(pHL);
500 m_layerKeys.push_back(layerKey);
501 return pHL;
502}
std::vector< unsigned int > m_layerKeys
l
Printing final latex table to .tex output file.

◆ bin_groups()

const std::vector< std::pair< int, std::vector< int > > > & TrigFTF_GNN_Geometry::bin_groups ( ) const
inline

Definition at line 60 of file GNN_Geometry.h.

60{return m_binGroups;}

◆ getTrigFTF_GNN_LayerByIndex()

const TrigFTF_GNN_Layer * TrigFTF_GNN_Geometry::getTrigFTF_GNN_LayerByIndex ( int idx) const

Definition at line 484 of file GNN_Geometry.cxx.

484 {
485 return m_layArray.at(idx);
486}

◆ getTrigFTF_GNN_LayerByKey()

const TrigFTF_GNN_Layer * TrigFTF_GNN_Geometry::getTrigFTF_GNN_LayerByKey ( unsigned int key) const

Definition at line 476 of file GNN_Geometry.cxx.

476 {
477 std::map<unsigned int, TrigFTF_GNN_Layer*>::const_iterator it = m_layMap.find(key);
478 if(it == m_layMap.end()) {
479 return nullptr;
480 }
481 return (*it).second;
482}

◆ getTrigFTF_GNN_LayerKeyByIndex()

unsigned int TrigFTF_GNN_Geometry::getTrigFTF_GNN_LayerKeyByIndex ( int idx) const
inline

Definition at line 55 of file GNN_Geometry.h.

◆ num_bins()

int TrigFTF_GNN_Geometry::num_bins ( ) const
inline

Definition at line 58 of file GNN_Geometry.h.

58{return m_nEtaBins;}

◆ num_layers()

unsigned int TrigFTF_GNN_Geometry::num_layers ( ) const
inline

Definition at line 59 of file GNN_Geometry.h.

59{return m_layArray.size();}

Member Data Documentation

◆ m_binGroups

std::vector<std::pair<int, std::vector<int> > > TrigFTF_GNN_Geometry::m_binGroups
protected

Definition at line 73 of file GNN_Geometry.h.

◆ m_etaBinWidth

float TrigFTF_GNN_Geometry::m_etaBinWidth
protected

Definition at line 66 of file GNN_Geometry.h.

◆ m_layArray

std::vector<TrigFTF_GNN_Layer*> TrigFTF_GNN_Geometry::m_layArray
protected

Definition at line 69 of file GNN_Geometry.h.

◆ m_layerKeys

std::vector<unsigned int> TrigFTF_GNN_Geometry::m_layerKeys
protected

Definition at line 70 of file GNN_Geometry.h.

◆ m_layMap

std::map<unsigned int, TrigFTF_GNN_Layer*> TrigFTF_GNN_Geometry::m_layMap
protected

Definition at line 68 of file GNN_Geometry.h.

◆ m_nEtaBins

int TrigFTF_GNN_Geometry::m_nEtaBins
protected

Definition at line 71 of file GNN_Geometry.h.


The documentation for this class was generated from the following files: