ATLAS Offline Software
Loading...
Searching...
No Matches
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
27
28public:
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
58
59 virtual void ROBIDList( const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const = 0;
60
61
63
68
69 virtual void ROBIDList( long layer, const IRoiDescriptor& roi, std::vector<uint32_t>& roblist ) const = 0;
70
71 virtual ~IRegSelLUT(){};
72
73
74protected:
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
std::vector< size_t > vec
virtual void ROBIDList(const IRoiDescriptor &roi, std::vector< uint32_t > &roblist) const =0
Rob identifier methods methods.
void IDList_layer(long layer, const IRoiDescriptor &roi, std::vector< T > &idlist, handler_layer< C, T > lister) const
Definition IRegSelLUT.h:106
static void removeDuplicates(std::vector< T > &vec)
useful for removing duplicates if required ...
Definition IRegSelLUT.h:78
virtual ~IRegSelLUT()
Definition IRegSelLUT.h:71
void(C::*)(const IRoiDescriptor &, std::vector< T > &) const handler
Definition IRegSelLUT.h:85
virtual void HashIDList(long layer, const IRoiDescriptor &roi, std::vector< IdentifierHash > &idlist) const =0
HashIDList interface declaration. return list of non-repeated IdentifierHash.
void IDList(const IRoiDescriptor &roi, std::vector< T > &idlist, handler< C, T > lister) const
Definition IRegSelLUT.h:88
virtual void HashIDList(const IRoiDescriptor &roi, std::vector< IdentifierHash > &idlist) const =0
IdentifierHash methods.
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....
void(C::*)(long layer, const IRoiDescriptor &, std::vector< T > &) const handler_layer
Definition IRegSelLUT.h:103
Describes the API of the Region of Ineterest geometry.
virtual const IRoiDescriptor * at(int i) const =0
find an RoiDescriptor constituent
virtual unsigned size() const =0
number of constituents
virtual bool composite() const =0
Super RoI access methods.
struct color C
DataModel_detail::iterator< DVL > unique(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of unique for DataVector/List.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.