15 const std::string&
group) :
23 ATH_MSG_INFO(
"Request to reinitialize not satisfied - tags have not changed");
37 ATH_MSG_ERROR(
" initialize_from_dict - cannot access MuonSpectrometer dictionary ");
51 if (atlasDict->
get_label_value(
"subdet",
"MuonSpectrometer", muonField)) {
52 ATH_MSG_ERROR(
"Could not get value for label 'MuonSpectrometer' of field 'subdet' in dictionary ");
58 region_id.add(muonField);
60 MultiRange muon_range =
m_dict->build_multirange(region_id, prefix,
"technology");
61 if (muon_range.
size()) {
62 ATH_MSG_INFO(
"MultiRange built successfully to Technology "
63 <<
"MultiRange size is " << muon_range.
size());
78 size_t begin = (context) ? context->
begin_index() : 0;
80 size_t end = (context) ? context->
end_index() : 0;
120 ATH_MSG_WARNING(
"MuonIdHelper::get_module_hash(): Could not determine hash for identifier " <<
id.get_compact());
139 ATH_MSG_WARNING(
"MuonIdHelper::get_detectorElement_hash(): Could not determine hash for identifier " <<
id.get_compact());
145 return get_hash(
id, hash_id, &context);
155 size_t begin = (context) ? context->
begin_index() : 0;
176 if (!
get_compact_id(old_id, compact_id, &context)) { new_id = compact_id; }
186 size_t begin = (context) ? context->
begin_index() : 0;
191 }
else if (0 == begin) {
195 if (
id.fields() != end+1)
result = 1;
211 compact_id = (Identifier::value_type)0;
214 for (
size_t i = 0; i <
id.fields(); i++) exp_id[i] =
id[i];
216 if (
m_dict &&
id.fields() > 0) {
217 size_t begin = (context) ? context->
begin_index() : 0;
218 size_t end = (context) ? context->
end_index() :
id.fields() - 1;
228 size_t begin = (context) ? context->
begin_index() : 0;
229 size_t end = (context) ? context->
end_index() : 0;
251 ATH_MSG_ERROR(
" initLevelsFromDict - dictionary NOT initialized ");
267 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find a muon station index: id, reg"
278 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'subdet' field ");
281 field =
m_dict->find_field(
"stationName");
287 for (
size_t i = 0; i < field->get_label_number(); i++) {
288 std::string name = field->get_label(i);
289 int index = (int)field->get_label_value(name);
295 if (
'B' == name[0]) {
300 if (
'G' == name[2] ||
'F' == name[2]) {
m_isSmall.insert(
index); }
301 }
else if (
'F' == name[2]) {
309 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'stationName' field ");
312 field =
m_dict->find_field(
"stationEta");
316 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'stationEta' field ");
319 field =
m_dict->find_field(
"stationPhi");
323 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'stationPhi' field ");
326 field =
m_dict->find_field(
"technology");
331 for (
size_t i = 0; i < field->get_label_number(); ++i) {
332 std::string name = field->get_label(i);
333 int index = (int)field->get_label_value(name);
341 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'technology' field ");
367 unsigned int nids = 0;
368 std::set<Identifier> ids;
372 for (
const auto & expId:rit) {
375 if (!(ids.insert(
id)).second) {
377 <<
" Error: duplicated id for module id. nid " << (
int)nids <<
" compact id " <<
id <<
" id ");
385 <<
" Error: set size NOT EQUAL to element hash max. size " << ids.size() <<
" hash max " <<
m_module_hash_max);
391 std::set<Identifier>::const_iterator first = ids.begin();
392 std::set<Identifier>::const_iterator last = ids.end();
393 for (; first != last && nids <
m_module_vec.size(); ++first) {
413 unsigned int nids = 0;
414 std::set<Identifier> ids;
418 for (
const auto & expId:rit) {
421 if (!(ids.insert(
id)).second) {
423 <<
" Error: duplicated id for channel id. nid " << nids <<
" compact id " <<
id <<
" id ");
437 std::set<Identifier>::const_iterator first = ids.begin();
438 std::set<Identifier>::const_iterator last = ids.end();
459 unsigned int nids = 0;
460 std::set<Identifier> ids;
464 for (
const auto & expId:rit) {
468 if (!(ids.insert(
id)).second) {
470 <<
" Error: duplicated id for channel id. nid " << nids <<
" compact id " <<
id <<
" id ");
479 <<
" Error: set size NOT EQUAL to hash max. size " << ids.size() <<
" hash max " <<
m_channel_hash_max);
489 unsigned short index = id;
499 unsigned short index = id;
509 unsigned short index = id;
519 unsigned short index = id;
545 for (
const auto &
id: rit) {
562 if (
get_hash(compact_id, hash_id, &wcontext)) {
563 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get hash, exp/compact "
564 <<
" " << std::hex << compact_id << std::dec <<
endmsg);
568 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get compact, exp/compact ");
573 unsigned short index = hash_id;
585 if (
get_hash(compact_id, hash_id, &wcontext)) {
586 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get previous phi hash, exp/compact "
587 <<
" " << std::hex << compact_id << std::dec);
591 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get previous phi compact, exp/compact ");
603 if (
get_hash(compact_id, hash_id, &wcontext)) {
604 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get next phi hash, exp/compact "
605 <<
" " << std::hex << compact_id << std::dec);
609 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get next phi compact, exp/compact ");
621 if (
get_hash(compact_id, hash_id, &wcontext)) {
622 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get previous eta hash, exp/compact "
623 <<
" " << std::hex << compact_id << std::dec);
627 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get previous eta compact, exp/compact ");
639 if (
get_hash(compact_id, hash_id, &wcontext)) {
640 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get next eta hash, exp/compact "
641 <<
" " << std::hex << compact_id << std::dec);
645 ATH_MSG_ERROR(
" MuonIdHelper::init_neighbors - unable to get next eta compact, exp/compact ");
662 for (; first != last; ++first, ++nids) {
666 ATH_MSG_ERROR(
"test_module_packing: Unable to get expanded id. Compact id " << compact);
671 ATH_MSG_ERROR(
"test_module_packing: Unable to get compact id. Expanded id " << std::string(
id));
674 if (compact != new_compact) {
675 ATH_MSG_ERROR(
"test_module_packing: new and old compacts not equal "
676 <<
"New/old/expanded ids " << new_compact <<
" " << compact <<
" " << std::string(
id));
681 ATH_MSG_INFO(
"test_module_packing: Successful tested " << nids <<
" ids. ");
683 ATH_MSG_ERROR(
"Unable to test module is packing - no dictionary has been defined. ");
691 ATH_MSG_ERROR(
"Unable to get expanded id. Compact id " << compact);
699 if (compact != new_compact) {
700 ATH_MSG_ERROR(
"new and old compacts not equal. New/old/expanded ids " << new_compact <<
" " << compact <<
" "
722 if (name.size() >= 2) {
723 if (
'I' == name[1] ||
'4' == name[1])
return 0;
724 if (
'E' == name[1] ||
'1' == name[1])
return 1;
725 if (
'M' == name[1] ||
'2' == name[1])
return 2;
726 if (
'O' == name[1] ||
'3' == name[1])
return 3;
728 if (name ==
"CSS" || name ==
"CSL")
return 0;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
static const Attributes_t empty
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
bool is_mdt(Identifier id) const
ExpandedIdentifier muon_exp(void) const
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
bool is_stgc(Identifier id) const
bool is_rpc(Identifier id) const
bool is_tgc(Identifier id) const
bool is_muon(Identifier id) const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
bool is_csc(Identifier id) const
Identifier muon(void) const
bool is_mm(Identifier id) const
const std::string & group() const
Group name for this helper.
AtlasDetectorID(const std::string &name, const std::string &group)
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
size_type begin_index() const
size_type end_index() const
const ExpandedIdentifier & prefix_id() const
Accessors.
int get_label_value(const std::string &field, const std::string &label, int &value) const
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
const IdDictFieldImplementation & implementation(size_t i) const
bool get_previous(element_type current, element_type &previous) const
Returns false if previous/next is at end of range, or not possible.
bool get_next(element_type current, element_type &next) const
This is a "hash" representation of an Identifier.
void clear()
Reset to invalid state.
value_type get_compact() const
Get the compact id.
A MultiRange combines several Ranges.
std::vector< Identifier >::const_iterator const_id_iterator
int stationNameIndex(const std::string &name) const
virtual int get_channel_hash(const Identifier &id, IdentifierHash &hash_id) const
int stationEta(const Identifier &id) const
std::set< int > m_isForward
const_id_iterator module_end() const
IdDictFieldImplementation m_phi_impl
const std::string & technologyString(const int &index) const
IdDictFieldImplementation m_tec_impl
int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
Create expanded id from compact id (return == 0 for OK)
const_id_iterator module_begin() const
Iterators over full set of ids.
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const
bool is_rpc(const Identifier &id) const
void test_id(const Identifier &id, const IdContext &context) const
int get_next_in_eta(const IdentifierHash &id, IdentifierHash &next) const
std::map< int, std::string > m_technologyIdxToNameMap
Mapping int -> string.
const MultiRange & multiRange() const
multirange
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK)
size_type m_CHANNEL_INDEX
virtual int get_hash_calc(const Identifier &compact_id, IdentifierHash &hash_id, const IdContext *context) const
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
void test_module_packing() const
Tests of packing.
hash_vec m_next_phi_module_vec
int technologyIndex(const std::string &name) const
size_type m_station_region_index
bool is_csc(const Identifier &id) const
IdDictFieldImplementation m_sta_impl
hash_vec m_prev_eta_module_vec
const_id_iterator channel_end() const
static const std::string BAD_NAME
std::map< int, std::string > m_stationIdxToNameMap
Mapping int -> string.
MultiRange m_full_module_range
bool is_muon(const Identifier &id) const
bool is_stgc(const Identifier &id) const
IdDictFieldImplementation m_eta_impl
bool validTechnology(int technology) const
void addStationID(Identifier &id, int stationName, int stationEta, int stationPhi, int technology) const
int get_compact_id(const ExpandedIdentifier &id, Identifier &compact_id, const IdContext *context) const
bool isEndcap(const Identifier &id) const
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const
size_type module_hash_max() const
the maximum hash value
const std::vector< Identifier > & idVector() const
the id's
bool isForward(const Identifier &id) const
MultiRange m_full_detectorElement_range
int get_next_in_phi(const IdentifierHash &id, IdentifierHash &next) const
const IdDictDictionary * m_dict
int nStationNames() const
bool is_tgc(const Identifier &id) const
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
IdContext module_context() const
id for module
int stationNameIndexMax() const
int stationRegion(const Identifier &id) const
IdContext technology_context() const
access to IdContext's which define which levels or fields are contained in the Muon id
int stationPhi(const Identifier &id) const
size_type m_DETECTORELEMENT_INDEX
int technology(const Identifier &id) const
int stationName(const Identifier &id) const
int init_channel_hashes()
size_type channel_hash_max() const
const_id_iterator channel_begin() const
Iterators over full set of ids.
size_type m_module_hash_max
bool isBarrel(const Identifier &id) const
bool isSmall(const Identifier &id) const
IdContext detectorElement_context() const
id for detector element
hash_vec m_next_eta_module_vec
id_vec m_detectorElement_vec
bool is_mm(const Identifier &id) const
virtual int init_detectorElement_hashes()
int technologyNameIndexMax() const
hash_vec m_prev_phi_module_vec
bool is_mdt(const Identifier &id) const
virtual bool isStNameInTech(const std::string &stationName) const =0
The valid element checks converted the identifier to a stationName string in order to assess whether ...
IdDictFieldImplementation m_muon_impl
std::set< int > m_isBarrel
bool validStation(int stationName, int technology) const
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const override
Create hash id from compact id (return == 0 for OK)
size_type m_detectorElement_hash_max
const_id_iterator detectorElement_end() const
static constexpr int NOT_VALID_HASH
Identifier::size_type size_type
std::map< std::string, int > m_stationNameToIdxMap
Mapping string -> int.
MultiRange m_full_channel_range
IdContext channel_context() const
id for channel
std::set< int > m_stationInTech
size_type m_channel_hash_max
std::set< int > m_isSmall
const std::string & stationNameString(const int &index) const
bool isInitialized() const
MuonIdHelper(const std::string &logName, const std::string &group)
id_vec::const_iterator id_vec_it
int get_expanded_id_calc(const Identifier &compact_id, ExpandedIdentifier &id, const IdContext *context) const
int get_prev_in_eta(const IdentifierHash &id, IdentifierHash &prev) const
size_type m_TECHNOLOGY_INDEX
int get_prev_in_phi(const IdentifierHash &id, IdentifierHash &prev) const
Access to hashes for neighbors in phi and eta (return == 0 for neighbor found)
std::map< std::string, int > m_technologyNameToIdxMap
Mapping string -> int.
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.