18#define MAX_BUFFER_LEN 1024
22 const std::string&
group,
43 if (range.match(expId)) {
45 if (not eta_field.
empty()) {
69 if (range.match(expId)) {
71 if (not eta_field.
empty()) {
90 if (range.match(expId)) {
92 if (not phi_field.
empty()) {
116 if (range.match(expId)) {
118 if (not phi_field.
empty()) {
136 const std::string& group_name)
143 ATH_MSG_DEBUG(
"Request to reinitialize not satisfied - tags have not changed");
163 if (atlasDict->
get_label_value(
"subdet",
"LArCalorimeter", larField)) {
164 ATH_MSG_ERROR(
"Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary " << atlasDict->
name());
170 int larFcalField = -1;
171 if (
dict()->get_label_value(
"part",
"LArFCAL", larFcalField)) {
172 ATH_MSG_ERROR(
"Could not get value for label 'LArFCAL' of field 'part' in dictionary " << atlasDict->
name());
221 std::string errorMessage =
"LArFCAL_Base_ID::module_id() result is not OK: ID, range = "
236 std::string errorMessage =
"LArFCAL_Base_ID::channel_id() result is not OK: ID, range = "
251 std::string errorMessage =
"LArFCAL_Base_ID::channel_id(modId) result is not OK: ID = "
259 std::string errorMessage =
"LArFCAL_Base_ID::channel_id(modId) result is not OK: ID, range = "
288 ATH_MSG_ERROR(
"initLevelsFromDict - dictionary NOT initialized ");
315 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'subdet' field ");
324 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'part' field ");
333 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'barrel-endcap' field ");
343 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'module' field ");
353 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'eta' field ");
362 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'phi' field ");
371 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'is-slar-fcal' field");
396 ATH_MSG_DEBUG(
"decode index and bit fields for each level:");
410 if (
channels().init (*
this,
"channels",
415 if (
regions().init (*
this,
"regions",
425 std::vector<IdentifierHash>& neighbourList)
const
429 neighbourList.clear();
432 ATH_MSG_WARNING(
"neighbours not initialized !!! returning empty list");
445 neighbourList.insert(neighbourList.end(),
453 neighbourList.insert(neighbourList.end(),
461 neighbourList.insert(neighbourList.end(),
481 fin.open(
file.c_str());
500 bool isComment =
true;
507 fin.getline(aLine,
sizeof(aLine)-1);
508 sLine = std::string(aLine);
509 }
while (sLine.empty() && !fin.eof());
510 isComment = ( sLine.find(
'#') != std::string::npos );
513 unsigned int ic, inext;
515 while ( sLine.empty() && !fin.eof()) {
516 fin.getline(aLine,
sizeof(aLine)-1);
517 sLine = std::string(aLine);
519 std::istringstream es( sLine.c_str() );
521 if ( es >> AorC >> isamp >>
dot >> iphi >>
dot >> ieta ) {
522 thisCell =
channel_id((AorC==
'A'||AorC==
'S'?2:-2),isamp,ieta,iphi);
524 while ( es >> AorC >> isamp >>
dot >> iphi >>
dot >> ieta ) {
525 nextCell =
channel_id((AorC==
'A'||AorC==
'S'?2:-2),isamp,ieta,iphi);
527 vec[ic].insert(
vec[ic].end(),inext);
531 }
while (!fin.eof()) ;
544 std::string f2d,f3dnext,f3dprev;
547 f2d =
"FCalSuperCells2DNeighborsNew-April2014.txt";
548 f3dnext =
"FCalSuperCells3DNeighborsNextNew-April2014.txt";
549 f3dprev =
"FCalSuperCells3DNeighborsPrevNew-April2014.txt";
556 if (f2d.empty() || f3dnext.empty() || f3dprev.empty()) {
557 ATH_MSG_ERROR(
"init_neighbours: cannot find neighbours files: f2d: " << f2d <<
" f3dnext: " << f3dnext <<
" f3dprev: " << f3dprev);
558 throw std::runtime_error(
"LArFCAL_Base_ID::init_neighbours: Cannot find the FCAL Neighbour file names");
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
static const Attributes_t empty
virtual std::string dictionaryVersion(void) const override
bool m_do_neighbours
Flag for subclasses to know whether or not to perform neighbour initialization.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int lar_fcal_field_value() const
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
ExpandedIdentifier lar_fcal_exp(void) const
int lar_field_value() const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
const std::string & group() const
Group name for this helper.
size_type hash_max() const
Return one more than the largest hash code.
const HashGroup & regions() const
Return the HashGroup for regions.
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &dict_name)
Do basic initialization of the helper.
IdContext region_context() const
Return the context for regions.
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
CaloIDHelper(const std::string &name, const std::string &group)
Constructor.
Identifier region_id(IdentifierHash hashId) const
Return the region Identifier for a given hash code (no checking).
int fill_vec_of_dict_regions(const std::string &group_name="")
Initialize the list of detector regions.
const IdDictDictionary * dict() const
Return the dictionary for this subdetector.
const std::string & name() const
Return the name for this helper.
const HashGroup & channels() const
Return the HashGroup for channels (cells).
void clear()
Erase all fields.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
size_type end_index() const
MultiRange build_multirange() const
Get MultiRange for full dictionary.
int get_label_value(const std::string &field, const std::string &label, int &value) const
const std::string & name() const
Dictionary name.
const IdDictField * find_field(const std::string &name) const
const IdDictRegion & region(size_t i) const
Region at index i.
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
const std::string & find_metadata(const std::string &name) const
Access to meta data, name/value pairs.
const IdDictFieldImplementation & implementation(size_t i) const
element_type get_minimum() const
Query the values.
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
element_type get_maximum() const
This is a "hash" representation of an Identifier.
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
IdDictFieldImplementation m_slar_impl
int phi_min_init(const Identifier regId) const
int init_neighbours_3d_prev(const std::string &filename)
IdDictFieldImplementation m_pn_impl
int init_neighbours_3d_next(const std::string &filename)
int eta(const Identifier id) const
eta [0,63] module 1 ; [0,31] module 2 ; [0,15] module 3
Identifier module_id(const ExpandedIdentifier &exp_id) const
module identifier for a channel from ExpandedIdentifier
IdDictFieldImplementation m_fcal_impl
int init_neighbours_from_file(const std::string &filename, std::vector< std::set< IdentifierHash > > &vec)
IdDictFieldImplementation m_eta_impl
IdDictFieldImplementation m_module_impl
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
virtual int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &group_name)
initialization from the identifier dictionary
int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = all2D,...
std::vector< std::set< IdentifierHash > > m_neighbours_3d_next_vec
int init_neighbours(const IdDictMgr &dict_mgr)
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
int phi(const Identifier id) const
phi [0,15]
int init_neighbours_2d(const std::string &filename)
void module_id_checks(int pos_neg, int module) const
std::vector< std::set< IdentifierHash > > m_neighbours_3d_prev_vec
std::vector< short int > m_vecOfPhiMin
IdDictFieldImplementation m_phi_impl
IdContext module_context() const
context for modules – method kept for backward compatibility.
int initLevelsFromDict(const std::string &group_name)
size_type m_fcal_region_index
std::vector< std::set< IdentifierHash > > m_neighbours_2d_vec
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
int pos_neg(const Identifier id) const
pos_neg : +/- 2 (A/C side)
void channel_id_checks(int pos_neg, int module, int eta, int phi) const
MultiRange m_full_module_range
MultiRange m_full_channel_range
IdDictFieldImplementation m_lar_impl
LArFCAL_Base_ID(const std::string &name, const std::string &group, bool supercell)
virtual int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
Exception class for LAr Identifiers.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs