|
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;
804 impl.set_bits_offset(bits_offset);
805 bits_offset +=
impl.bits();
810 0 !=
field.get_minimum())
812 impl.set_decode_index(
true);
848 if (
mr.has_overlap ())
return (
false);
869 std::map< ExpandedIdentifier, IdDictDictEntry* > regions;
879 std::cout <<
"IdDictDictionary::sort - WARNING verify is FALSE - cannot sort "
938 for (
unsigned int i = 0;
i < group_mr.
size(); ++
i) {
966 const std::string& last_field)
const
971 if (
"" == last_field) {
978 if(
"dummy" == region.
m_name)
continue;
995 if(
"dummy" == region.
m_name)
continue;
1008 std::vector <IdDictFieldImplementation>::const_iterator
fit;
1015 new_range.
add(
impl.range()->build_range());
1017 if (last_field ==
impl.range()->m_field->m_name) {
1021 result.add(std::move(new_range));
1033 const std::string& last_field)
const
1038 if (
"" == last_field) {
1045 if(
"dummy" == region.
m_name)
continue;
1062 if(
"dummy" == region.
m_name)
continue;
1075 std::vector <IdDictFieldImplementation>::const_iterator
fit;
1082 new_range.
add(
impl.range()->build_range());
1084 if (last_field ==
impl.range()->m_field->m_name) {
1088 result.add(std::move(new_range));
1150 bool selected =
true;
1163 if (!
impl.field().match (
id[
i])) {
1185 if (0 == position &&
impl.bits() > 0) {
1189 position -=
impl.bits();
1190 packedId |= (
index << position);
1206 size_t region_index,
1208 size_t first_field_index)
const
1217 std::cout <<
"IdDictDictionary::pack32 - index2 < index1 - 1,2"
1224 std::cout <<
"IdDictDictionary::pack32 - region index incorrect - index,size"
1225 << region_index <<
" " <<
m_regions.size() << std::endl;
1236 std::cout <<
"IdDictDictionary::pack32 - region id empty" << std::endl;
1240 if(
index1 < first_field_index) {
1241 std::cout <<
"IdDictDictionary::pack32 - first_field_index > index1 "
1242 << first_field_index <<
" " <<
index1 << std::endl;
1249 if(!first_field_index) {
1251 position -=
impl.bits_offset();
1254 size_t field_index = 0;
1262 if (!
impl.ored_field().match(
fields[field_index])) {
1263 std::cout <<
"IdDictDictionary::pack32 - field does NOT match: value, allowed values "
1264 <<
fields[field_index] <<
" " << (std::string)
impl.ored_field()
1271 if (0 == position &&
impl.bits() > 0) {
1272 std::cout <<
"IdDictDictionary::pack32 - going past 0" << std::endl;
1278 if (
impl.decode_index()) {
1285 position -=
impl.bits();
1286 packedId |= (
index << position);
1299 size_t region_index,
1309 std::cout <<
"IdDictDictionary::pack32 - index2 < index1 - 1,2"
1316 std::cout <<
"IdDictDictionary::pack32 - region index incorrect - index,size"
1317 << region_index <<
" " <<
m_regions.size() << std::endl;
1328 std::cout <<
"IdDictDictionary::pack32 - region id empty" << std::endl;
1334 size_t field_index = 0;
1357 #if defined(FLATTEN) && defined(__GNUC__)
1373 unpackedId.
clear ();
1374 if (0 < localPrefix.
fields ()) unpackedId = localPrefix;
1386 bool selected =
false;
1397 if (
i >= localPrefix.
fields ())
1410 if (!
impl.field().match (localPrefix[
i]))
1431 if (
impl.bits() == 0)
continue;
1435 if (position <
impl.bits())
break;
1438 if (
index >=
impl.ored_field().get_indices ())
1472 position -=
impl.bits();
1481 if (selected)
break;
1497 const std::string&
sep,
1498 std::string& unpackedId)
const
1513 bool selected =
false;
1523 if (
i >= localPrefix.
fields ()) {
1535 if (!
impl.field().match (localPrefix[
i])) {
1555 if (
impl.bits() == 0)
continue;
1559 if (position <
impl.bits())
break;
1562 if (
index >=
impl.ored_field().get_indices ()) {
1585 std::string str_value(
"nil");
1597 switch (
range->m_specification) {
1602 str_value =
range->m_field->m_name +
' ';
1603 sprintf (temp,
"%d",
value);
1611 str_value +=
range->m_field->m_name +
' ';
1613 str_value +=
range->m_label;
1621 if (
label->m_valued) {
1622 str_value +=
range->m_label;
1638 if (index1 < range->m_labels.size()) {
1640 str_value +=
range->m_field->m_name +
' ';
1645 std::cout <<
"IdDictDictionary::unpack - Could not find value." << std::endl;
1646 std::cout <<
"value " <<
value << std::endl;
1647 std::cout <<
"field values " << std::endl;
1648 for (
unsigned int i=0;
i <
range->m_values.size(); ++
i) {
1649 std::cout <<
range->m_values[
i] <<
" ";
1651 std::cout << std::endl;
1657 std::cout <<
"unknown" << std::endl;
1664 unpackedId += str_value;
1667 position -=
impl.bits();
1675 if (selected)
break;
1693 size_t first_field_index,
1695 size_t region_index,
1704 std::cout <<
"IdDictDictionary::unpack - region index too large. Index, nregions "
1705 << region_index <<
" " <<
m_regions.size() << std::endl;
1716 std::cout <<
"IdDictDictionary::unpack - field index too large. Index, nfields "
1725 size_t prefix_offset = 0;
1730 if (first_field_index) {
1733 std::cout <<
"IdDictDictionary::unpack - first_field_index too large. Index, nfields "
1745 if (
impl.bits() == 0) {
1746 std::cout <<
"IdDictDictionary::unpack - no bits for this field. Region, field indexes "
1747 << region_index <<
" " << field_index << std::endl;
1752 if (
impl.bits() +
impl.bits_offset() - prefix_offset > position) {
1753 std::cout <<
"IdDictDictionary::unpack - bits + offset too large. Region, field indexes, bits, offset "
1754 << region_index <<
" " << field_index <<
" "
1755 <<
impl.bits() <<
" " <<
impl.bits_offset() <<
" " << prefix_offset
1764 size_t index =
id.extract(position -=
impl.bits() +
impl.bits_offset() - prefix_offset,
mask);
1784 size_t first_field_index,
1785 size_t begin_field_index,
1786 size_t end_field_index,
1787 size_t region_index,
1793 std::cout <<
"IdDictDictionary::copy - region index too large. Index, nregions "
1794 << region_index <<
" " <<
m_regions.size() << std::endl;
1803 std::cout <<
"IdDictDictionary::copy - field index too large. Indexes first, begin, end, nfields "
1804 << first_field_index <<
" "
1805 << begin_field_index <<
" "
1806 << end_field_index <<
" "
1812 size_t missing_offset = 0;
1813 if (first_field_index) {
1814 if (first_field_index > begin_field_index) {
1815 std::cout <<
"IdDictDictionary::copy - first_field_index > begin_field_index. Indexes "
1816 << first_field_index <<
" " << begin_field_index << std::endl;
1823 size_t prefix_offset = 0;
1824 if (begin_field_index) {
1825 if (begin_field_index > end_field_index) {
1826 std::cout <<
"IdDictDictionary::copy - begin_field_index > end_field_index. Indexes "
1827 << begin_field_index <<
" " << end_field_index << std::endl;
1835 size_t suffix_offset =
impl.bits() +
impl.bits_offset();
1839 if (position < prefix_offset - missing_offset) {
1840 std::cout <<
"IdDictDictionary::copy - position < prefix + missing. "
1841 << prefix_offset <<
" " << missing_offset << std::endl;
1846 if (position < suffix_offset + missing_offset) {
1847 std::cout <<
"IdDictDictionary::copy - position < suffix + missing. "
1848 << suffix_offset <<
" " << missing_offset << std::endl;
1861 mask -= prefix_mask + suffix_mask;
1901 const std::string& )
1946 }
catch (std::invalid_argument &
e){
1948 if (
label ==
nullptr)
continue;
1956 std::cerr <<
"Warning : label " <<
name <<
" not found" << std::endl;
1974 m_generated_implementation(false)
1981 m_generated_implementation(false)
1994 const std::vector<IdDictDictEntry*>&
2000 const std::vector<IdDictRegion*>&
2019 if(
"dummy" == region.
m_name)
continue;
2046 (*it)->set_index(
index);
2056 const std::string&
tag)
2060 std::cout <<
"IdDictGroup::generate_implementation>" << std::endl;
2084 std::cout <<
"IdDictGroup::generate_implementation - mismatch of sizes: regions/entries "
2101 (*it)->reset_implementation();
2127 std::map< ExpandedIdentifier, IdDictDictEntry* >
regions;
2137 auto last = itr.
end();
2138 if (
first != last) {
2141 std::cout <<
"IdDictDictionary::sort - WARNING empty region cannot sort "
2148 std::vector<IdDictRegion*>::size_type vecIt = 0;
2149 for (; mapIt !=
regions.end (); ++mapIt, ++vecIt) {
2154 std::cout <<
"IdDictGroup::sort - WARNING region map size is NOT the same as the vector size. Map size "
2192 m_selected_region(0)
2201 delete (*first).second;
2220 (*first).second->set_index (
index);
2234 (*first).second->resolve_references (idd,
dictionary);
2241 const std::string&
tag)
2246 std::cout <<
"IdDictAltRegions::generate_implementation could not find region for tag "
2247 <<
tag <<
" Keys in map " << std::endl;
2252 std::cout <<
" i " <<
i <<
" key " << (*first).first;
2254 std::cout << std::endl;
2283 (*first).second->clear();
2284 delete (*first).second;
2325 const std::string&
tag){
2328 std::cout <<
"IdDictRegion::generate_implementation>" << std::endl;
2395 entry->reset_implementation ();
2427 std::vector <IdDictRegionEntry*>::const_iterator
it;
2451 const std::string& )
2453 std::cout <<
"IdDictSubRegion::generate_implementation - SHOULD NEVER BE CALLED " << std::endl;
2461 const std::string&
tag)
2466 std::cout <<
"IdDictSubRegion::generate_implementation>" << std::endl;
2484 entry->reset_implementation ();
2549 std::cout <<
"IdDictRange::generate_implementation>" << std::endl;
2554 impl.set_range(
this);
2562 <<
" region #" << region.
m_index
2569 std::cout <<
"IdDictRange::generate_implementation: index >= impl size - "
2668 const std::string&
tag) {
2699 m_resolved_references(false)
2721 const std::string&
tag)
2726 std::cout <<
"IdDictReference::generate_implementation>" << std::endl;
2763 m_resolved_references(false),
2764 m_generated_implementation(false),
2765 m_propagated_information(false)
2790 const std::string&
tag)
2808 std::vector<IdDictRegionEntry*> prepend_entries;
2812 if(
this ==
entry)
break;
2817 prepend_entries.insert(prepend_entries.begin(),
entry);
2828 for (
it = prepend_entries.begin();
it != prepend_entries.end(); ++
it) {
2841 if (prepend_entries.size() > 0) {
2845 size_t region_number = region2.
m_index + 1;
2853 new_region->
m_name =
"dummy";
2854 new_region->
m_group =
"dummy";
2855 new_region->
m_index = region_number;
2866 if (
i >= prepend_entries.size())
continue;
2873 new_region->
m_entries.push_back(new_range);
2884 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)