|
ATLAS Offline Software
|
Go to the documentation of this file.
23 if (::
getenv (
"IDDEBUG") != 0) {
38 for (
unsigned int i=0;
i<
str.size(); ++
i) {
39 if(!isdigit(
str[
i]))
return (
false);
41 if (0 ==
str.size())
return (
false);
71 static std::atomic<int>
i = 0;
82 m_resolved_references(false),
83 m_generated_implementation(false),
138 static const std::string
empty;
147 std::cout <<
"IdDictMgr::add_metadata> unable to add name/value " <<
name <<
"/" <<
value << std::endl;
165 dictionary_map::const_iterator
it;
171 return ((*it).second);
192 std::string
s = (*it).first;
195 std::cout <<
"IdDictMgr::add_dictionary> d[" <<
s <<
"]=" <<
d << std::endl;
224 std::cout <<
"IdDictMgr::generate_implementation>" << std::endl;
248 std::cout <<
"IdDictMgr::reset_implementation" << std::endl;
267 dictionary_map::const_iterator
it;
302 m_generated_implementation(false),
304 m_do_neighbours(true)
313 std::map <std::string, IdDictField*>::const_iterator
it;
330 return ((*it).second);
336 if (!idField)
return nullptr;
343 if (!idLabel || !idLabel->
m_valued)
return (1);
350 if (
field == 0)
return;
359 std::map <std::string, IdDictSubRegion*>::const_iterator
it;
365 return ((*it).second);
379 if ((region != 0) && (region_name == region->
m_name))
return (region);
398 if (subregion == 0)
return;
420 group->add_dictentry (region);
431 field->resolve_references (idd);
449 (*it)->resolve_references (idd, *
this,
index);
454 typedef std::vector <IdDictRegion*>
RV;
456 static void compute_bits (
const RV& regions,
size_t level,
const std::string&
group)
464 for (
k = 0;
k < regions.size (); ++
k) {
470 if (
k == 0) ored_field = thisField;
472 else ored_field |= thisField;
479 for (
k = 0;
k < regions.size (); ++
k) {
486 f.set_ored_field(ored_field);
490 static void get_bits (
const RV& regions,
size_t level,
const std::string&
group)
512 if (regions.size () == 0)
return;
514 if (regions.size () == 1) {
528 f.set_ored_field(
f.field());
558 overlapping.reserve(
mr.size());
559 orig.reserve(
mr.size());
560 temp.reserve(
mr.size());
563 if (
mr.size () == 0) {
566 overlapping.clear ();
570 for (
k = 0;
k <
mr.size (); ++
k) {
571 reference_region =
mr[
k];
574 overlapping.push_back (reference_region);
577 temp.push_back(reference_region);
584 if (reference_region == 0)
break;
586 if (overlapping.size () == 0) {
598 for (;
k <
mr.size (); ++
k) {
600 temp.push_back (region);
602 bool found_overlap =
false;
625 found_overlap =
false;
626 for (
size_t i = 0;
i < orig.size (); ++
i) {
629 bool overlap =
false;
636 if (
f1.range()->m_field_name ==
f.range()->m_field_name)
641 overlapping.push_back (region);
642 ored_field |= thisField;
643 found_overlap =
true;
645 temp.push_back (region);
648 }
while(found_overlap);
653 bool all_within_group =
true;
654 bool none_within_group =
true;
655 for (
size_t i = 0;
i < overlapping.size (); ++
i) {
658 none_within_group =
false;
660 all_within_group =
false;
664 if (all_within_group) temp.
clear();
670 if(!none_within_group) {
681 const std::string&
tag)
686 std::cout <<
"IdDictDictionary::generate_implementation>" << std::endl;
695 (*it)->generate_implementation (idd, *
this,
tag);
699 for (
it1 = regions.begin();
it1 != regions.end(); ++
it1) {
712 if (
"dummy" == (*it)->name())
continue;
724 (*itr)->find_neighbours(*
this);
737 (*it)->reset_implementation();
757 if (
range.match(
id) &&
range.fields() >=
id.fields()) {
785 if (
range.match(
id) &&
range.fields() >=
id.fields()) {
800 size_t bits_offset = 0;
803 impl.set_bits_offset(bits_offset);
804 bits_offset +=
impl.bits();
808 if ((not
field.isBounded()) || (0 !=
field.get_minimum()) ){
809 impl.set_decode_index(
true);
845 if (
mr.has_overlap ())
return (
false);
866 std::map< ExpandedIdentifier, IdDictDictEntry* > regions;
876 std::cout <<
"IdDictDictionary::sort - WARNING verify is FALSE - cannot sort "
935 for (
unsigned int i = 0;
i < group_mr.
size(); ++
i) {
963 const std::string& last_field)
const
968 if (
"" == last_field) {
975 if(
"dummy" == region.
m_name)
continue;
992 if(
"dummy" == region.
m_name)
continue;
1005 std::vector <IdDictFieldImplementation>::const_iterator
fit;
1012 new_range.
add(
impl.range()->build_range());
1014 if (last_field ==
impl.range()->m_field->m_name) {
1018 result.add(std::move(new_range));
1030 const std::string& last_field)
const
1035 if (
"" == last_field) {
1042 if(
"dummy" == region.
m_name)
continue;
1059 if(
"dummy" == region.
m_name)
continue;
1072 std::vector <IdDictFieldImplementation>::const_iterator
fit;
1079 new_range.
add(
impl.range()->build_range());
1081 if (last_field ==
impl.range()->m_field->m_name) {
1085 result.add(std::move(new_range));
1147 bool selected =
true;
1160 if (!
impl.field().match (
id[
i])) {
1182 if (0 == position &&
impl.bits() > 0) {
1186 position -=
impl.bits();
1187 packedId |= (
index << position);
1203 size_t region_index,
1205 size_t first_field_index)
const
1214 std::cout <<
"IdDictDictionary::pack32 - index2 < index1 - 1,2"
1221 std::cout <<
"IdDictDictionary::pack32 - region index incorrect - index,size"
1222 << region_index <<
" " <<
m_regions.size() << std::endl;
1233 std::cout <<
"IdDictDictionary::pack32 - region id empty" << std::endl;
1237 if(
index1 < first_field_index) {
1238 std::cout <<
"IdDictDictionary::pack32 - first_field_index > index1 "
1239 << first_field_index <<
" " <<
index1 << std::endl;
1246 if(!first_field_index) {
1248 position -=
impl.bits_offset();
1251 size_t field_index = 0;
1259 if (!
impl.ored_field().match(
fields[field_index])) {
1260 std::cout <<
"IdDictDictionary::pack32 - field does NOT match: value, allowed values "
1261 <<
fields[field_index] <<
" " << (std::string)
impl.ored_field()
1268 if (0 == position &&
impl.bits() > 0) {
1269 std::cout <<
"IdDictDictionary::pack32 - going past 0" << std::endl;
1275 if (
impl.decode_index()) {
1282 position -=
impl.bits();
1283 packedId |= (
index << position);
1296 size_t region_index,
1306 std::cout <<
"IdDictDictionary::pack32 - index2 < index1 - 1,2"
1313 std::cout <<
"IdDictDictionary::pack32 - region index incorrect - index,size"
1314 << region_index <<
" " <<
m_regions.size() << std::endl;
1325 std::cout <<
"IdDictDictionary::pack32 - region id empty" << std::endl;
1331 size_t field_index = 0;
1354 #if defined(FLATTEN) && defined(__GNUC__)
1370 unpackedId.
clear ();
1371 if (0 < localPrefix.
fields ()) unpackedId = localPrefix;
1383 bool selected =
false;
1394 if (
i >= localPrefix.
fields ())
1407 if (!
impl.field().match (localPrefix[
i]))
1428 if (
impl.bits() == 0)
continue;
1432 if (position <
impl.bits())
break;
1435 if (
index >=
impl.ored_field().get_indices ())
1469 position -=
impl.bits();
1478 if (selected)
break;
1494 const std::string&
sep,
1495 std::string& unpackedId)
const
1510 bool selected =
false;
1520 if (
i >= localPrefix.
fields ()) {
1532 if (!
impl.field().match (localPrefix[
i])) {
1552 if (
impl.bits() == 0)
continue;
1556 if (position <
impl.bits())
break;
1559 if (
index >=
impl.ored_field().get_indices ()) {
1582 std::string str_value(
"nil");
1594 switch (
range->m_specification) {
1597 str_value =
range->m_field->m_name +
' ';
1598 sprintf (temp,
"%d",
value);
1606 str_value +=
range->m_field->m_name +
' ';
1608 str_value +=
range->m_label;
1616 if (
label->m_valued) {
1617 str_value +=
range->m_label;
1633 if (index1 < range->m_labels.size()) {
1635 str_value +=
range->m_field->m_name +
' ';
1640 std::cout <<
"IdDictDictionary::unpack - Could not find value." << std::endl;
1641 std::cout <<
"value " <<
value << std::endl;
1642 std::cout <<
"field values " << std::endl;
1643 for (
unsigned int i=0;
i <
range->m_values.size(); ++
i) {
1644 std::cout <<
range->m_values[
i] <<
" ";
1646 std::cout << std::endl;
1652 std::cout <<
"unknown" << std::endl;
1659 unpackedId += str_value;
1662 position -=
impl.bits();
1670 if (selected)
break;
1688 size_t first_field_index,
1690 size_t region_index,
1699 std::cout <<
"IdDictDictionary::unpack - region index too large. Index, nregions "
1700 << region_index <<
" " <<
m_regions.size() << std::endl;
1711 std::cout <<
"IdDictDictionary::unpack - field index too large. Index, nfields "
1720 size_t prefix_offset = 0;
1725 if (first_field_index) {
1728 std::cout <<
"IdDictDictionary::unpack - first_field_index too large. Index, nfields "
1740 if (
impl.bits() == 0) {
1741 std::cout <<
"IdDictDictionary::unpack - no bits for this field. Region, field indexes "
1742 << region_index <<
" " << field_index << std::endl;
1747 if (
impl.bits() +
impl.bits_offset() - prefix_offset > position) {
1748 std::cout <<
"IdDictDictionary::unpack - bits + offset too large. Region, field indexes, bits, offset "
1749 << region_index <<
" " << field_index <<
" "
1750 <<
impl.bits() <<
" " <<
impl.bits_offset() <<
" " << prefix_offset
1759 size_t index =
id.extract(position -=
impl.bits() +
impl.bits_offset() - prefix_offset,
mask);
1779 size_t first_field_index,
1780 size_t begin_field_index,
1781 size_t end_field_index,
1782 size_t region_index,
1788 std::cout <<
"IdDictDictionary::copy - region index too large. Index, nregions "
1789 << region_index <<
" " <<
m_regions.size() << std::endl;
1798 std::cout <<
"IdDictDictionary::copy - field index too large. Indexes first, begin, end, nfields "
1799 << first_field_index <<
" "
1800 << begin_field_index <<
" "
1801 << end_field_index <<
" "
1807 size_t missing_offset = 0;
1808 if (first_field_index) {
1809 if (first_field_index > begin_field_index) {
1810 std::cout <<
"IdDictDictionary::copy - first_field_index > begin_field_index. Indexes "
1811 << first_field_index <<
" " << begin_field_index << std::endl;
1818 size_t prefix_offset = 0;
1819 if (begin_field_index) {
1820 if (begin_field_index > end_field_index) {
1821 std::cout <<
"IdDictDictionary::copy - begin_field_index > end_field_index. Indexes "
1822 << begin_field_index <<
" " << end_field_index << std::endl;
1830 size_t suffix_offset =
impl.bits() +
impl.bits_offset();
1834 if (position < prefix_offset - missing_offset) {
1835 std::cout <<
"IdDictDictionary::copy - position < prefix + missing. "
1836 << prefix_offset <<
" " << missing_offset << std::endl;
1841 if (position < suffix_offset + missing_offset) {
1842 std::cout <<
"IdDictDictionary::copy - position < suffix + missing. "
1843 << suffix_offset <<
" " << missing_offset << std::endl;
1856 mask -= prefix_mask + suffix_mask;
1896 const std::string& )
1941 }
catch (std::invalid_argument &
e){
1943 if (
label ==
nullptr)
continue;
1951 std::cerr <<
"Warning : label " <<
name <<
" not found" << std::endl;
1969 m_generated_implementation(false)
1976 m_generated_implementation(false)
1989 const std::vector<IdDictDictEntry*>&
1995 const std::vector<IdDictRegion*>&
2014 if(
"dummy" == region.
m_name)
continue;
2041 (*it)->set_index(
index);
2051 const std::string&
tag)
2055 std::cout <<
"IdDictGroup::generate_implementation>" << std::endl;
2079 std::cout <<
"IdDictGroup::generate_implementation - mismatch of sizes: regions/entries "
2096 (*it)->reset_implementation();
2122 std::map< ExpandedIdentifier, IdDictDictEntry* >
regions;
2132 auto last = itr.
end();
2133 if (
first != last) {
2136 std::cout <<
"IdDictDictionary::sort - WARNING empty region cannot sort "
2143 std::vector<IdDictRegion*>::size_type vecIt = 0;
2144 for (; mapIt !=
regions.end (); ++mapIt, ++vecIt) {
2149 std::cout <<
"IdDictGroup::sort - WARNING region map size is NOT the same as the vector size. Map size "
2187 m_selected_region(0)
2196 delete (*first).second;
2215 (*first).second->set_index (
index);
2229 (*first).second->resolve_references (idd,
dictionary);
2236 const std::string&
tag)
2241 std::cout <<
"IdDictAltRegions::generate_implementation could not find region for tag "
2242 <<
tag <<
" Keys in map " << std::endl;
2247 std::cout <<
" i " <<
i <<
" key " << (*first).first;
2249 std::cout << std::endl;
2278 (*first).second->clear();
2279 delete (*first).second;
2320 const std::string&
tag){
2323 std::cout <<
"IdDictRegion::generate_implementation>" << std::endl;
2390 entry->reset_implementation ();
2422 std::vector <IdDictRegionEntry*>::const_iterator
it;
2446 const std::string& )
2448 std::cout <<
"IdDictSubRegion::generate_implementation - SHOULD NEVER BE CALLED " << std::endl;
2456 const std::string&
tag)
2461 std::cout <<
"IdDictSubRegion::generate_implementation>" << std::endl;
2479 entry->reset_implementation ();
2544 std::cout <<
"IdDictRange::generate_implementation>" << std::endl;
2549 impl.set_range(
this);
2557 <<
" region #" << region.
m_index
2564 std::cout <<
"IdDictRange::generate_implementation: index >= impl size - "
2647 const std::string&
tag) {
2678 m_resolved_references(false)
2700 const std::string&
tag)
2705 std::cout <<
"IdDictReference::generate_implementation>" << std::endl;
2742 m_resolved_references(false),
2743 m_generated_implementation(false),
2744 m_propagated_information(false)
2769 const std::string&
tag)
2787 std::vector<IdDictRegionEntry*> prepend_entries;
2791 if(
this ==
entry)
break;
2796 prepend_entries.insert(prepend_entries.begin(),
entry);
2807 for (
it = prepend_entries.begin();
it != prepend_entries.end(); ++
it) {
2820 if (prepend_entries.size() > 0) {
2824 size_t region_number = region2.
m_index + 1;
2832 new_region->
m_name =
"dummy";
2833 new_region->
m_group =
"dummy";
2834 new_region->
m_index = region_number;
2845 if (
i >= prepend_entries.size())
continue;
2852 new_region->
m_entries.push_back(new_range);
2863 std::cout <<
"IdDictDictionaryRef::generate_implementation: - WARNING no dictionary found, cannot generate implementation "
JetConstituentVector::iterator iterator
IdDictRegion * find_region(const std::string ®ion_name) const
std::map< std::string, IdDictDictionary * > dictionary_map
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
virtual ~IdDictDictEntry()
std::vector< IdDictRegion * > m_next_samp
MultiRange build_multirange() const
Get MultiRange for full dictionary.
void resolve_references()
Construct dictionary after parsing.
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary)
static bool get_debug_state()
int unpack(const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, ExpandedIdentifier &unpackedId) const
Unpack the value_type id to an expanded Identifier, considering the provided prefix (result will incl...
const std::string & get_label(size_t index) const
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary)
int reset(size_t index1, size_t index2, size_t region_index, Identifier &packedId) const
Reset fields from index1 to index2.
bool do_neighbours(void) const
Neighbour initialization is performed by default One can switch or query this mode for any idHelper w...
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
void add_label(IdDictLabel *label)
std::vector< IdDictGroup * > m_groups
bool do_checks(void) const
Checks are performed by default in debug compilation and NOT in optimized compilation.
bool overlaps_with(const IdentifierField &other) const
Check whether two IdentifierFields overlap.
IdDictRegion * m_selected_region
IdDictLabel * find_label(const std::string &field, const std::string &label) const
std::vector< IdDictRegion * > m_regions
Range build_range() const
value_type mask_shift(value_type mask, size_type shift) const
extract field(s) by masking first, then shifting
bool m_resolved_references
void set_do_checks(bool do_checks)
IdDictRegion * m_prev_abs_eta
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion)
groups_type::const_iterator groups_const_it
void find_neighbours(const IdDictDictionary &dictionary)
void add(element_type value)
Append a value into a new field.
This iterator is able to generate all possible identifiers, from a fully bounded Range.
std::vector< IdDictRegion * > regions_type
const dictionary_map & get_dictionary_map() const
Access to all dictionaries.
IdDictSubRegion * m_subregion
IdDictLabel * find_label(const std::string &name) const
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
const std::string & find_metadata(const std::string &name) const
Access to meta data, name/value pairs.
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion, const std::string &tag="")
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
dictionary_map m_dictionaries
void reset_implementation()
specification_type m_specification
std::vector< IdDictRegion * > m_prev_samp
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion)
std::vector< IdDictRegion * > m_prev_subdet
int pack32(const ExpandedIdentifier &id, size_t index1, size_t index2, Identifier &packedId) const
Pack to 32bits the subset of id between (inclusive) index1 and index2 - this is generic,...
std::string m_DTD_version
IdDictField * find_field(const std::string &name) const
void reset_implementation()
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
std::vector< IdDictRegion * > m_next_subdet
void resolve_references(const IdDictMgr &idd)
bool verify() const
Here, we verify global constraints : (this must only be applied after the resolve_references and ge...
RangeIterator begin() const
std::string m_dictionary_name
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion, const std::string &tag="")
void reset_implementation()
std::vector< IdDictDictEntry * > m_entries
IdDictDictionary * m_parent_dict
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, size_t &index)
Identifier::size_type size_type
groups_type::iterator groups_it
IdDictRegion * m_next_abs_eta
void set_do_neighbours(bool do_neighbours)
std::map< std::string, IdDictField * > m_fields
IdDictGroup * find_group(const std::string &group_name) const
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Range build_range() const
void add_subdictionary_name(const std::string &name)
void reset_implementation()
size_t get_label_number() const
std::string group_name() const
std::vector< HWIdentifier >::iterator it1
map_type::iterator map_iterator
bool m_generated_implementation
MultiRange build_multirange() const
Get MultiRange for this group.
void add_entry(IdDictRegionEntry *entry)
std::vector< IdDictRegion * > m_regions
void add_dictentry(IdDictDictEntry *entry)
std::string group_name() const
bool m_propagated_information
void add_subdictionary_name(const std::string &name)
regions_type::iterator regions_it
bool m_resolved_references
std::string m_next_abs_eta_name
const std::vector< IdDictRegion * > & regions()
bool do_neighbours() const
Check whether or not to init neighbours.
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
ExpandedIdentifier::element_type get_label_value(const std::string &name) const
std::vector< element_type > element_vector
std::vector< IdDictRegionEntry * > m_entries
regions_type::const_iterator regions_const_it
void reset_implementation()
Reset of implementation.
std::vector< IdDictLabel * > m_labels
int get_label_value(const std::string &field, const std::string &label, int &value) const
void add_dictionary(IdDictDictionary *dictionary)
Fillers:
std::vector< std::string > m_prev_samp_names
A MultiRange combines several Ranges.
Range build_range() const
virtual bool verify() const
entries_type::iterator entries_it
void add_field(IdDictField *field)
std::vector< std::string > m_labels
Range build_range() const
virtual std::string group_name() const =0
void reset_implementation()
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
void set_index(size_t index)
std::vector< std::string > m_next_samp_names
continuation_mode m_continuation_mode
void add()
Add a wild card field.
IdDictSubRegion * find_subregion(const std::string &subregion_name) const
RangeIterator end() const
std::vector< std::string > m_prev_subdet_names
bool m_generated_implementation
const std::string & name()
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
void reset_implementation()
std::vector< std::string > m_subdictionary_names
Range build_range() const
void reset_implementation()
void reset_implementation()
std::string getenv(const std::string &variableName)
get an environment variable
std::map< std::string, IdDictSubRegion * > m_subregions
bool m_generated_implementation
void add_dictentry(IdDictDictEntry *entry)
virtual void reset_implementation()
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion)
bool m_resolved_references
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion, const std::string &tag="")
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
void set_DTD_version(const std::string &DTD_version)
void clear()
Erase all fields.
bool do_checks() const
Check whether or not to do checks for ids.
void set_index(size_t index)
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion, const std::string &tag="")
const std::string & DTD_version() const
DTD version.
unsigned long long value_type
bool isNumber(const std::string &s)
IdDictDictionary * m_dictionary
const std::vector< IdDictDictEntry * > & entries()
bool m_generated_implementation
bool m_resolved_references
void set_do_neighbours(bool do_neighbours)
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion ®ion)
void integrate_bits()
Set up integral of bits for efficient unpacking.
const std::string & tag() const
Version tag.
std::vector< IdDictFieldImplementation > m_implementation
void reset_implementation()
std::string m_subregion_name
bool m_generated_implementation
int copy(const Identifier &idin, size_t first_field_index, size_t begin_field_index, size_t end_field_index, size_t region_index, Identifier &idout) const
Copy a number of fields of the value_type id into another value_type id.
void add_subregion(IdDictSubRegion *subregion)
std::vector< IdDictRegion * > RV
void resolve_references(const IdDictMgr &idd)
std::set< std::string > m_subdictionary_names
Range build_range() const
std::vector< IdDictRegion * > m_all_regions
void add_metadata(const std::string &name, const std::string &value)
void generate_implementation(const std::string &tag="")
std::vector< std::string > m_next_subdet_names
std::vector< int > m_values
void set_do_checks(bool do_checks)