ATLAS Offline Software
IRegSelLUT.h
Go to the documentation of this file.
1 // emacs: this is -*- c++ -*-
2 //
3 // @file IRegSelTool.h
4 //
5 // Generic lookup table interface class for all teh different types
6 // of Region Selector lookup tables
7 // NB: it would make sense for the IRegSelTool interface to inherit
8 // from this also, so that we guarantee the same interface
9 // for the tables and corresponding tools
10 //
11 // @author Mark Sutton
12 //
13 // Copyright (C) 2012-2020 CERN for the benefit of the ATLAS collaboration
14 
15 
16 #ifndef IREGIONSELECTOR_IREGSELLUT_H
17 #define IREGIONSELECTOR_IREGSELLUT_H
18 
20 #include <vector>
21 #include <algorithm>
22 #include <stdint.h>
23 
25 
26 class IRegSelLUT {
27 
28 public:
29 
31 
32 
34 
39  virtual void HashIDList( const IRoiDescriptor& roi, std::vector<IdentifierHash>& idlist ) const = 0;
40 
41 
43 
48  virtual void HashIDList( long layer, const IRoiDescriptor& roi, std::vector<IdentifierHash>& idlist ) const = 0;
49 
50 
52 
54 
59  virtual void ROBIDList( const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const = 0;
60 
61 
63 
69  virtual void ROBIDList( long layer, const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const = 0;
70 
71  virtual ~IRegSelLUT(){};
72 
73 
74 protected:
75 
77  template<typename T>
78  static void removeDuplicates(std::vector<T>& vec) {
79  std::sort(vec.begin(), vec.end());
80  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
81  }
82 
83 
84  template<typename C, typename T>
85  using handler = void (C::*)(const IRoiDescriptor& , std::vector<T>& ) const;
86 
87  template<typename C, typename T>
88  void IDList( const IRoiDescriptor& roi, std::vector<T>& idlist, handler<C,T> lister ) const {
89 
90  if ( roi.composite() ) {
91  idlist.clear();
92  for ( unsigned iroi=roi.size() ; iroi-- ; ) IDList<C>( *(roi.at(iroi)), idlist, lister );
93  if ( roi.size()>1 ) IRegSelLUT::removeDuplicates( idlist );
94  return;
95  }
96 
97  (dynamic_cast<const C*>(this)->*lister)( roi, idlist );
98 
99  }
100 
101 
102  template<typename C, typename T>
103  using handler_layer = void (C::*)(long layer, const IRoiDescriptor& , std::vector<T>& ) const;
104 
105  template<typename C, typename T>
106  void IDList_layer( long layer, const IRoiDescriptor& roi, std::vector<T>& idlist, handler_layer<C,T> lister ) const {
107 
108  if ( roi.composite() ) {
109  idlist.clear();
110  for ( unsigned iroi=roi.size() ; iroi-- ; ) IDList_layer<C>( layer, *(roi.at(iroi)), idlist, lister );
111  if ( roi.size()>1 ) IRegSelLUT::removeDuplicates( idlist );
112  return;
113  }
114 
115  (dynamic_cast<const C*>(this)->*lister)( layer, roi, idlist );
116 
117  }
118 
119 
120 
121 };
122 
123 
124 
125 #endif // IREGIONSELECTOR_IREGSELLUT_H
DMTest::C
C_v1 C
Definition: C.h:26
IRegSelLUT::~IRegSelLUT
virtual ~IRegSelLUT()
Definition: IRegSelLUT.h:71
IRoiDescriptor::size
virtual unsigned size() const =0
number of constituents
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
IRegSelLUT::HashIDList
virtual void HashIDList(long layer, const IRoiDescriptor &roi, std::vector< IdentifierHash > &idlist) const =0
HashIDList interface declaration. return list of non-repeated IdentifierHash.
IRegSelLUT::IDList
void IDList(const IRoiDescriptor &roi, std::vector< T > &idlist, handler< C, T > lister) const
Definition: IRegSelLUT.h:88
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
IRegSelLUT::handler_layer
void(C::*)(long layer, const IRoiDescriptor &, std::vector< T > &) const handler_layer
Definition: IRegSelLUT.h:103
IRegSelLUT
Definition: IRegSelLUT.h:26
IdentifierHash.h
IRegSelLUT::handler
void(C::*)(const IRoiDescriptor &, std::vector< T > &) const handler
Definition: IRegSelLUT.h:85
IRegSelLUT::IDList_layer
void IDList_layer(long layer, const IRoiDescriptor &roi, std::vector< T > &idlist, handler_layer< C, T > lister) const
Definition: IRegSelLUT.h:106
IRegSelLUT::HashIDList
virtual void HashIDList(const IRoiDescriptor &roi, std::vector< IdentifierHash > &idlist) const =0
IdentifierHash methods.
IRoiDescriptor.h
IRegSelLUT::ROBIDList
virtual void ROBIDList(const IRoiDescriptor &roi, std::vector< uint32_t > &roblist) const =0
Rob identifier methods methods.
IRoiDescriptor::at
virtual const IRoiDescriptor * at(int i) const =0
find an RoiDescriptor constituent
IRegSelLUT::removeDuplicates
static void removeDuplicates(std::vector< T > &vec)
useful for removing duplicates if required ...
Definition: IRegSelLUT.h:78
IRoiDescriptor::composite
virtual bool composite() const =0
Super RoI access methods.
IRegSelLUT::ROBIDList
virtual void ROBIDList(long layer, const IRoiDescriptor &roi, std::vector< uint32_t > &roblist) const =0
ROBIDList interface declaration. This interface can be used by the ID subdetectors....