ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::ModuleIdentifierMatchUtil Namespace Reference

Namespaces

namespace  detail

Concepts

concept  HasColumns
concept  HasCells
concept  ModuleDesignConcept

Typedefs

using ModuleData_t = std::array< int, ModuleIdentifierMatchUtil::kAllRows/2 >

Enumerations

enum  EModulePatternPart {
  kBarrelEndcapSelectRange =0 , kLayerRange =2 , kEtaRange =4 , kPhiRange =6 ,
  kColumnStripRange =8 , kLength =10 , kSideRange =12 , kAllRows =14 ,
  kNParts =15
}
 The identifier parts used for identifier matching kAllRows denotes the element which contains a flag (0, 1), to specify whether a pattern should match all modules which are connected to the same side of a physical sensor. More...

Functions

template<ModuleDesignConcept T_ModuleDesign>
int getColumnsOrCells (const T_ModuleDesign &moduleDesign)
template<bool test_order, typename T>
bool verifyElementCountAndOrder (const std::vector< std::vector< T > > &arr, std::size_t n_expected, std::size_t test_n=0)
 Test whether the given 2D vector has the expected number of elements, and correct ordering.
bool verifyModulePatternList (const std::vector< std::vector< int > > &arr)
 Verify whether a list of module identifier patterns is consistent.
template<typename T>
bool verifyElementCount (const std::vector< std::vector< T > > &arr, std::size_t n_expected)
 test whether the 2D vector arr has the expected number of elements.
void setModuleData (EModulePatternPart part, int value, std::array< int, kAllRows/2 > &dest)
 Convenience function to set the specified element in the given array.
template<class T_ID, class T_ModuleDesign>
void setModuleData (const T_ID &id_helper, const Identifier &identifier, const T_ModuleDesign &module_design, ModuleData_t &module_data)
 Convenience function to extract various identifier parts and set the given array.
void moduleMatches (const std::vector< std::vector< int > > &module_pattern, const ModuleData_t &module_data, std::vector< unsigned int > &module_pattern_idx)
 Test whether an identifier, which is split into various parts, matches some of the given patterns.
bool matchesBothSides (const std::vector< int > &a_module_pattern)
 Test whether the given pattern matches identifiers which refer to either side of a sensor.
bool isSideMatching (const std::vector< int > &a_module_pattern, int side)
 Test whether the given pattern matches the given side.
bool matchesAllModuleRowsOfSensor (const std::vector< int > &a_module_pattern)
 Test whether a pattern matches all module rows of a sensor or just a single row.

Typedef Documentation

◆ ModuleData_t

Enumeration Type Documentation

◆ EModulePatternPart

The identifier parts used for identifier matching kAllRows denotes the element which contains a flag (0, 1), to specify whether a pattern should match all modules which are connected to the same side of a physical sensor.

Enumerator
kBarrelEndcapSelectRange 
kLayerRange 
kEtaRange 
kPhiRange 
kColumnStripRange 
kLength 
kSideRange 
kAllRows 
kNParts 

Definition at line 55 of file ModuleIdentifierMatchUtil.h.

Function Documentation

◆ getColumnsOrCells()

template<ModuleDesignConcept T_ModuleDesign>
int InDet::ModuleIdentifierMatchUtil::getColumnsOrCells ( const T_ModuleDesign & moduleDesign)

Definition at line 40 of file ModuleIdentifierMatchUtil.h.

40 {
41 if constexpr(HasColumns<T_ModuleDesign>) {
42 return moduleDesign.columns();
43 }
44 else {
45 return moduleDesign.cells();
46 }
47 }

◆ isSideMatching()

bool InDet::ModuleIdentifierMatchUtil::isSideMatching ( const std::vector< int > & a_module_pattern,
int side )
inline

Test whether the given pattern matches the given side.

Definition at line 193 of file ModuleIdentifierMatchUtil.h.

193 {
194 assert( ModuleIdentifierMatchUtil::kSideRange+1 < a_module_pattern.size() );
195 return side >= a_module_pattern[ModuleIdentifierMatchUtil::kSideRange]
196 && side <= a_module_pattern[ModuleIdentifierMatchUtil::kSideRange+1];
197 }

◆ matchesAllModuleRowsOfSensor()

bool InDet::ModuleIdentifierMatchUtil::matchesAllModuleRowsOfSensor ( const std::vector< int > & a_module_pattern)
inline

Test whether a pattern matches all module rows of a sensor or just a single row.

Parameters
a_module_patterna module identifier pattern
Returns
true if the pattern matches all module rows connected to a physical sensor. A sensor might be connected to multiple modules where the modules might be connected to the same sensor side in multiple rows. If the given pattern matches all rows, this function returns true.

Definition at line 206 of file ModuleIdentifierMatchUtil.h.

206 {
207 assert(ModuleIdentifierMatchUtil::kAllRows < a_module_pattern.size());
208 return a_module_pattern[ModuleIdentifierMatchUtil::kAllRows] != 0;
209 }

◆ matchesBothSides()

bool InDet::ModuleIdentifierMatchUtil::matchesBothSides ( const std::vector< int > & a_module_pattern)
inline

Test whether the given pattern matches identifiers which refer to either side of a sensor.

Parameters
a_module_patterna module identifier pattern
Returns
true if the side range only contains one element A sensor might be connected to multiple modules where the modules might be located on different sides of a sensor. The side range may contain one side only or both sides. In the latter case this function returns true.

Definition at line 186 of file ModuleIdentifierMatchUtil.h.

186 {
187 assert( ModuleIdentifierMatchUtil::kSideRange+1 < a_module_pattern.size() );
188 return a_module_pattern[ModuleIdentifierMatchUtil::kSideRange]
189 != a_module_pattern[ModuleIdentifierMatchUtil::kSideRange+1];
190 }

◆ moduleMatches()

void InDet::ModuleIdentifierMatchUtil::moduleMatches ( const std::vector< std::vector< int > > & module_pattern,
const ModuleData_t & module_data,
std::vector< unsigned int > & module_pattern_idx )
inline

Test whether an identifier, which is split into various parts, matches some of the given patterns.

Parameters
module_patternan array which contains ranges for various identifier parts
module_dataan array which contains various parts of an identifier
module_pattern_idxan output vector which will be filled with the indices of matching patterns Will test all "patterns" in module pattern whether they match the given identifier parts. The patterns contain ranges of identifier parts (start and end of the range are inclusive). For a pattern to match, all identifier parts have to be within the allowed range of a pattern.

Definition at line 154 of file ModuleIdentifierMatchUtil.h.

156 {
157 module_pattern_idx.clear();
158 for (unsigned int pattern_i=0u; pattern_i<module_pattern.size(); ++pattern_i) {
159 const std::vector<int> &pattern = module_pattern[pattern_i];
160 unsigned int range_i=0;
161 bool match=true;
162 for (int module_value : module_data) {
163 assert( range_i+1 < pattern.size());
164 if (module_value<pattern[range_i] || module_value>pattern[range_i+1]) {
165 // test if even/odd filter and continue if it is and that filter passes
166 if (pattern[range_i+1]>=pattern[range_i] || pattern[range_i+1]!=-2 || (module_value & 1) != (pattern[range_i] & 1)) {
167 match=false;
168 break;
169 }
170 }
171 range_i+=2;
172 }
173 if (match) {
174 module_pattern_idx.push_back(pattern_i);
175 }
176 }
177 }
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357

◆ setModuleData() [1/2]

template<class T_ID, class T_ModuleDesign>
void InDet::ModuleIdentifierMatchUtil::setModuleData ( const T_ID & id_helper,
const Identifier & identifier,
const T_ModuleDesign & module_design,
ModuleData_t & module_data )
inline

Convenience function to extract various identifier parts and set the given array.

Parameters
id_helperthe ID helper e.g. PixelID, SCT_ID to extract various parts from the given identifier
identifierthe identifier from which the various parts are extracted
n_columns_or_stripseither the number of columns (e.g. for pixel) or strips
module_datathe array which will be filled with the identifier parts Fill an array with identifier parts which can be used to match module identifiers.

Definition at line 133 of file ModuleIdentifierMatchUtil.h.

136 {
137 setModuleData(kBarrelEndcapSelectRange, id_helper.barrel_ec(identifier), module_data);
138 setModuleData(kLayerRange, id_helper.layer_disk(identifier), module_data);
139 setModuleData(kEtaRange, id_helper.eta_module(identifier), module_data);
140 setModuleData(kPhiRange, id_helper.phi_module(identifier), module_data);
141 setModuleData(kColumnStripRange, getColumnsOrCells(module_design), module_data);
142 setModuleData(kLength, static_cast<int>(module_design.length()*1e3), module_data);
143 setModuleData(kSideRange, detail::getZeroOrSide(id_helper,identifier),module_data);
144 }
int getZeroOrSide(const T_ID &id_helper, const Identifier &id)
int getColumnsOrCells(const T_ModuleDesign &moduleDesign)
void setModuleData(EModulePatternPart part, int value, std::array< int, kAllRows/2 > &dest)
Convenience function to set the specified element in the given array.

◆ setModuleData() [2/2]

void InDet::ModuleIdentifierMatchUtil::setModuleData ( EModulePatternPart part,
int value,
std::array< int, kAllRows/2 > & dest )
inline

Convenience function to set the specified element in the given array.

Parameters
partspecifies the element to set
valuethe value to copy to the array
destthe array to which the value is copied

Definition at line 120 of file ModuleIdentifierMatchUtil.h.

120 {
121 assert( part%2==0 && static_cast<unsigned int>(part/2)<dest.size());
122 dest[part/2] = value;
123 }

◆ verifyElementCount()

template<typename T>
bool InDet::ModuleIdentifierMatchUtil::verifyElementCount ( const std::vector< std::vector< T > > & arr,
std::size_t n_expected )
inline

test whether the 2D vector arr has the expected number of elements.

See verifyElementCountAndOrder

Definition at line 111 of file ModuleIdentifierMatchUtil.h.

111 {
112 return verifyElementCountAndOrder<false,T>(arr,n_expected, 0);
113 }
bool verifyElementCountAndOrder(const std::vector< std::vector< T > > &arr, std::size_t n_expected, std::size_t test_n=0)
Test whether the given 2D vector has the expected number of elements, and correct ordering.

◆ verifyElementCountAndOrder()

template<bool test_order, typename T>
bool InDet::ModuleIdentifierMatchUtil::verifyElementCountAndOrder ( const std::vector< std::vector< T > > & arr,
std::size_t n_expected,
std::size_t test_n = 0 )
inline

Test whether the given 2D vector has the expected number of elements, and correct ordering.

Template Parameters
test_orderif true test element order otherwise only test element count
Telement type
Parameters
arr2D array to be tested
n_expectednumber of elements of in each element vector of the top-level vector
test_nnumber of elements (not pairs) to test when verifying the correct order of element pairs
Returns
true if arr passes the tests Test whether each element vector of arr, which is a vector, contains the same number of elements n_expected. if test_order is true also test whether the first test_n/2 element pairs of each element vector of arr are in ascending order i.e. arr[..][2*i] < arr[..][2*i+1] for all i..n_test/2

Definition at line 81 of file ModuleIdentifierMatchUtil.h.

81 {
82 for (const auto &sub_arr : arr) {
83 if (sub_arr.size() != n_expected) return false;
84 if (test_n%2 != 0 || test_n>=n_expected) return false;
85 if constexpr(test_order) {
86 for (unsigned int i=0; i<test_n; i+=2) {
87 if (sub_arr.at(i)>sub_arr.at(i+1)) {
88 if (sub_arr.at(i+1)!=-2 || (sub_arr.at(i)!=0 && sub_arr.at(i)!=1)) {
89 return false;
90 }
91 }
92 }
93 }
94 }
95 return true;
96 }

◆ verifyModulePatternList()

bool InDet::ModuleIdentifierMatchUtil::verifyModulePatternList ( const std::vector< std::vector< int > > & arr)
inline

Verify whether a list of module identifier patterns is consistent.

The function tests whether the given 2D vector has the correct number of elements and whether the element pairs which represent ranges have the expected ascending order. See verifyElementCountAndOrder

Definition at line 103 of file ModuleIdentifierMatchUtil.h.

103 {
105 }