32 const std::string&
group,
35 ,
m_slar (supercell ? 1 : 0)
51 std::vector<LArHEC_region*>::iterator first =
m_vecOfRegions.begin();
53 for (; first != last; ++first)
delete (*first);
69 int eta,
int phi_sector )
const
71 int phi = (
region == 0 ? sector*2 + phi_sector : sector );
83 if (range.match(expId)) {
85 if (not eta_field.
empty()) {
109 if (range.match(expId)) {
111 if (not eta_field.
empty()) {
130 if (range.match(expId)) {
132 if (not phi_field.
empty()) {
156 if (range.match(expId)) {
158 if (not phi_field.
empty()) {
170 const std::string& group_name)
177 ATH_MSG_DEBUG(
"Request to reinitialize not satisfied - tags have not changed");
194 ATH_MSG_WARNING(
" initialize_base_from_dict - cannot initialize HEC part of LArCalorimeter dictionary ");
201 if (atlasDict->
get_label_value(
"subdet",
"LArCalorimeter", larField)) {
202 ATH_MSG_ERROR(
"Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary " << atlasDict->
name());
207 int larHecField = -1;
208 if (
dict()->get_label_value(
"part",
"LArHEC", larHecField)) {
209 ATH_MSG_ERROR(
"Could not get value for label 'LArHEC' of field 'part' in dictionary " << atlasDict->
name());
215 exp_region_id.
add(larField);
216 exp_region_id.
add(larHecField);
286 if(phimin < 0 || phimax < 0) {
295 hc.
m_nphi = phimax-phimin+1 ;
331 std::string errorMessage =
"LArHEC_Base_ID::region_id() result is not OK: ID, range = "
348 std::string errorMessage =
"LArHEC_Base_ID::channel_id() result is not OK: ID, range = "
364 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID = "
372 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID, range = "
402 ATH_MSG_ERROR(
"initLevelsFromDict - dictionary NOT initialized");
429 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'subdet' field");
438 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'part' field");
447 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'barrel-endcap' field");
456 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'sampling' field");
465 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'region' field");
474 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'eta' field");
483 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'phi' field");
492 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'is-slar-hec' field");
510 ATH_MSG_DEBUG(
"decode index and bit fields for each level: ");
525 if (
channels().init (*
this,
"channels",
529 if (
regions().init (*
this,
"regions",
541 neighbourList.clear();
544 ATH_MSG_WARNING(
"neighbours not initialized !!! returning empty list");
553 const short int maxNeighb=20;
555 int neighbourIndex = 0;
558 unsigned int index=id;
567 short int nPhi = hecRegion->
phiN();
569 unsigned int minHash = hecRegion->
hashMin();
570 unsigned int maxHash = hecRegion->
hashMax();
581 prevNeighbInPhi=neighbList[neighbourIndex-1];
595 nextNeighbInPhi=neighbList[neighbourIndex-1];
607 get_prevInEta(hecRegion,
index, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
615 get_nextInEta(hecRegion,
index, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
623 unsigned int index1=prevNeighbInPhi;
624 int oldNeighbourIndex = neighbourIndex;
629 get_prevInEta(hecRegion, index1, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
630 if ( neighbourIndex > oldNeighbourIndex+1 ) {
631 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
632 neighbourIndex = oldNeighbourIndex+1;
634 oldNeighbourIndex = neighbourIndex;
635 get_nextInEta(hecRegion, index1, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
636 if ( neighbourIndex > oldNeighbourIndex+1 ) {
637 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
638 neighbourIndex = oldNeighbourIndex+1;
643 unsigned int index2=nextNeighbInPhi;
644 int oldNeighbourIndex = neighbourIndex;
649 get_prevInEta(hecRegion, index2, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
650 if ( neighbourIndex > oldNeighbourIndex+1 ) {
651 neighbourIndex = oldNeighbourIndex+1;
653 oldNeighbourIndex = neighbourIndex;
654 get_nextInEta(hecRegion, index2, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
655 if ( neighbourIndex > oldNeighbourIndex+1 ) {
656 neighbourIndex = oldNeighbourIndex+1;
669 int nEta = int( (
index-minHash) / nPhi);
670 double absEta = hecRegion->
etaMin() + nEta*granEta;
683 neighbourList.resize(neighbourIndex);
684 if (neighbourIndex <= maxNeighb) {
685 std::copy (&neighbList[0], &neighbList[neighbourIndex], neighbourList.begin());
688 ATH_MSG_WARNING(
"more than 20 neighbours for this cell, NONE will be retained " << neighbourIndex);
699 unsigned int nIndex =
index-1;
700 if( ((
index-minHash)%(nPhi)) == 0 ) nIndex=
index+nPhi-1;
702 neighbList[neighbourIndex] = nHash;
714 unsigned int nIndex =
index+1;
715 if( ((
index-minHash+1)%(nPhi)) == 0 ) nIndex=
index-nPhi+1;
717 neighbList[neighbourIndex] = nHash;
725 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
728 unsigned int nIndex = 0;
741 short int nPhiMinus = prevHecRegion->
phiN();
743 unsigned int maxHashMinus = prevHecRegion->
hashMax();
744 float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
745 float rPhi = (
index-minHash)*gPhi+hecRegion->
phiMin();
746 int nPhiMinusFirst = int(std::floor((rPhi -prevHecRegion->
phiMin())
747 /gPhiMinus+phiMargin))
748 +maxHashMinus-nPhiMinus;
749 int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
750 /gPhiMinus+phiMargin))
751 +maxHashMinus-nPhiMinus;
752 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
754 for(
int i=nPhiMinusFirst; i<nPhiMinusNext; i++){
756 if(nIndex != nBiggerCell) {
758 neighbList[neighbourIndex] = nHash;
763 if(gPhi < gPhiMinus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
769 nIndex =
index - nPhi;
771 neighbList[neighbourIndex] = nHash;
779 const unsigned int& maxHash,
780 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
783 unsigned int nIndex = 0;
797 unsigned int minHashPlus = nextHecRegion->
hashMin();
798 float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
799 float rPhi = (
index+nPhi-maxHash)*gPhi+hecRegion->
phiMin();
800 int nPhiPlusFirst = int(std::floor((rPhi -nextHecRegion->
phiMin())
801 /gPhiPlus+phiMargin))+minHashPlus;
802 int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
803 /gPhiPlus+phiMargin))+minHashPlus;
804 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
806 for(
int i=nPhiPlusFirst; i<nPhiPlusNext; i++){
808 if(nIndex != nBiggerCell) {
810 neighbList[neighbourIndex] = nHash;
815 if(gPhi < gPhiPlus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
821 nIndex =
index + nPhi;
823 neighbList[neighbourIndex] = nHash;
831 const double& absEta,
836 unsigned int nIndex=0;
842 int nPrevSampReg = prevSampRegion.size();
843 if(nPrevSampReg > 0) {
846 for(
int ireg=0; ireg<nPrevSampReg; ireg++) {
848 float minEtaMinus = prevHecRegion->
etaMin();
849 float maxEtaMinus = prevHecRegion->
etaMax();
852 float margin = 0.25*std::min(gEta,granEtaMinus);
853 if((minEtaMinus < absEta+gEta-margin) && (absEta+margin < maxEtaMinus)) {
860 short int nPhiMinus = prevHecRegion->
phiN();
862 unsigned int minHashMinus = prevHecRegion->
hashMin();
864 float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
866 float rPhi = ((
index-minHash)%nPhi)*gPhi+hecRegion->
phiMin();
867 int nPhiMinusFirst = int(std::floor((rPhi -prevHecRegion->
phiMin())
868 /gPhiMinus+phiMargin));
869 int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
870 /gPhiMinus+phiMargin));
871 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
873 double fEtaMinus = (absEta-minEtaMinus) / granEtaMinus + margin;
874 short int nEtaMinus = int(fEtaMinus) ;
875 for(
int i=nPhiMinusFirst; i<nPhiMinusNext; i++){
876 nIndex = minHashMinus + nEtaMinus * nPhiMinus + i;
877 if( (nIndex >= prevHecRegion->
hashMin()) && (nIndex < prevHecRegion->hashMax()) ) {
879 neighbList[neighbourIndex] = nHash;
891 const double& absEta,
896 unsigned int nIndex=0;
901 int nNextSampReg = nextSampRegion.size();
902 if(nNextSampReg > 0) {
905 for(
int ireg=0; ireg<nNextSampReg; ireg++) {
908 float minEtaPlus = nextHecRegion->
etaMin();
909 float maxEtaPlus = nextHecRegion->
etaMax();
910 float margin = 0.25*std::min(gEta,granEtaPlus);
911 if((minEtaPlus < absEta+gEta-margin) && (absEta+margin < maxEtaPlus)) {
917 short int nPhiPlus = nextHecRegion->
phiN();
918 unsigned int minHashPlus = nextHecRegion->
hashMin();
920 float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
922 float rPhi = ((
index-minHash)%nPhi)*gPhi+hecRegion->
phiMin();
923 int nPhiPlusFirst = int(std::floor((rPhi -nextHecRegion->
phiMin())
924 /gPhiPlus+phiMargin));
925 int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
926 /gPhiPlus+phiMargin));
927 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
929 double fEtaPlus = (absEta-minEtaPlus) / granEtaPlus + margin ;
930 int nEtaPlus = int(fEtaPlus) ;
931 for(
int i=nPhiPlusFirst; i<nPhiPlusNext; i++){
932 nIndex = minHashPlus + nEtaPlus * nPhiPlus + i;
933 if( (nIndex >= nextHecRegion->
hashMin()) && (nIndex < nextHecRegion->hashMax()) ) {
935 neighbList[neighbourIndex] = nHash;
949 const std::vector<const IdDictRegion*>& vecOfDictRegions =
dictRegions();
957 std::vector<Identifier>::const_iterator debut=
reg_begin() ;
958 std::vector<Identifier>::const_iterator fin =
reg_end() ;
960 for (; debut != fin; ++debut)
971 if(etaMin >= 0 && phiMin >= 0)
1001 unsigned int ireg0=0;
1018 const IdDictRegion* prevEtaDicReg = vecOfDictRegions[reg]->prev_abs_eta();
1020 const IdDictRegion* nextEtaDicReg = vecOfDictRegions[reg]->next_abs_eta();
1021 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1022 if(vecOfDictRegions[ireg] == prevEtaDicReg) regForPrevEta = ireg;
1023 if(vecOfDictRegions[ireg] == nextEtaDicReg) regForNextEta = ireg;
1030 std::vector<short int> regForPrevSamp;
1031 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->prev_samp()) {
1032 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1033 if(vecOfDictRegions[ireg] == dictreg) regForPrevSamp.push_back(ireg);
1037 std::vector<short int> regForNextSamp;
1038 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->next_samp()) {
1039 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1040 if(vecOfDictRegions[ireg] == dictreg) regForNextSamp.push_back(ireg);
1049 regForPrevEta,regForNextEta,
1050 regForPrevSamp,regForNextSamp);
1064 for (; debut != fin; ++debut) {
1067 if(regId != lastRegId) reg++;
1072 if ((
short int)hashReg != reg) {
1073 ATH_MSG_ERROR(
" init_neighbors: problem reg, hashReg = " << reg <<
" " << hashReg);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Factor out code common between LArHEC_ID and LArHEC_SuperCell_ID.
virtual std::string dictionaryVersion(void) const override
bool m_do_checks
Flag for subclasses to know whether or not to perform checks.
bool m_do_neighbours
Flag for subclasses to know whether or not to perform neighbour initialization.
int lar_hec_field_value() const
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
ExpandedIdentifier lar_hec_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.
float phi0(const IdentifierHash regHash) const
Return the minimum phi of region, or NOT_VALID.
const HashGroup & regions() const
Return the HashGroup for regions.
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
float eta0(const IdentifierHash regHash) const
Return the minimum eta of region, or NOT_VALID.
const std::vector< const IdDictRegion * > & dictRegions() const
Return the vector of IdDictRegion, accessed via region hash.
float etaGranularity(const IdentifierHash regHash) const
Return the eta granularity of a region, or NOT_VALID.
size_type region_hash_max() const
One more than the largest region hash code.
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.
int fill_vec_of_dict_regions(const std::string &group_name="")
Initialize the list of detector regions.
float phiGranularity(const IdentifierHash regHash) const
Return the phi granularity of a region, or NOT_VALID.
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 add(element_type value)
Append a value into a new field.
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.
Identifier::size_type size_type
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
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.
small class holding the starting hash value, the min eta and the number of phi bins of each region
IdDictFieldImplementation m_region_impl
id_iterator hec_end() const
end iterator over full set of Hec Identifiers for channels
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 = prevInPhi,...
IdDictFieldImplementation m_phi_impl
int initLevelsFromDict(const std::string &group_name)
int region(const Identifier id) const
return region [0,1]
LArHEC_Base_ID(const std::string &name, const std::string &group, bool supercell)
Constructor.
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
size_type m_SAMPLING_INDEX
id_iterator reg_begin() const
begin iterator over set of region Identifiers
static int get_prevInPhi(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &group_name)
initialization from the identifier dictionary
bool twoSymSides() const
True if the + and - sides of the calorimeter are identical (true layout).
int phi_min_init(const Identifier regId) const
void channel_id_checks(int pos_neg, int sampling, int region, int eta, int phi) const
static int get_nextInPhi(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
void region_id_checks(int pos_neg, int sampling, int region) const
IdDictFieldImplementation m_hec_impl
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
IdDictFieldImplementation m_slar_impl
IdDictFieldImplementation m_sampling_impl
std::vector< HashCalc > m_hash_calcs
int get_nextInSamp(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
MultiRange m_full_channel_range
std::vector< short int > m_vecOfPhiMin
int phi(const Identifier id) const
return phi[0,63] outer part [0,31] inner part
IdDictFieldImplementation m_pn_impl
size_type m_hec_region_index
int get_prevInEta(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
int get_prevInSamp(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
IdDictFieldImplementation m_pn_reg_impl
id_iterator hec_begin() const
begin iterator over full set of Hec Identifiers for channels
MultiRange m_full_region_range
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
int get_nextInEta(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &maxHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
virtual int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
std::vector< short int > m_vecOfCellInfo
IdDictFieldImplementation m_lar_impl
std::vector< LArHEC_region * > m_vecOfRegions
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
IdDictFieldImplementation m_eta_impl
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
id_iterator reg_end() const
end iterator over set of region Identifiers
IdentifierHash channel_hash_binary_search(Identifier channelId) const
create hash id from channel id – method NOT optimised, please use channel_hash() above
This class provides an interface to deal with regions in the neighbours finding.
bool isEtaMax(const unsigned int &index) const
is the considered cell in the last eta bin of the region ?
float etaGranularity() const
eta granularity
bool isPhiMax(const unsigned int &index) const
is the considered cell in the last phi bin of the region ?
const std::vector< short int > & prevSamplingRegion() const
region number of the prev region in sampling
float etaMax() const
end eta
const std::vector< short int > & nextSamplingRegion() const
region number of the next region in sampling
short int nextEtaRegion() const
region number of the next region in eta
unsigned int hashMax() const
hash Id of the last cell of the region +1
unsigned int hashMin() const
hash Id of the first cell of the region
float phiMin() const
starting phi
short int prevEtaRegion() const
region number of the previous region in eta
float phiGranularity() const
phi granularity
short int phiN() const
number of phi bins
float etaMin() const
starting eta
bool isPhiMin(const unsigned int &index) const
is the considered cell in the first phi bin of the region ?
bool isEtaMin(const unsigned int &index) const
is the considered cell in the first eta bin of the region ?
Exception class for LAr Identifiers.
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
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP