29 const std::string&
group,
32 ,
m_slar (supercell ? 1 : 0)
48 std::vector<LArHEC_region*>::iterator first =
m_vecOfRegions.begin();
50 for (; first != last; ++first)
delete (*first);
66 int eta,
int phi_sector )
const
68 int phi = (
region == 0 ? sector*2 + phi_sector : sector );
80 if (range.match(expId)) {
82 if (not eta_field.
empty()) {
88 if (etamin < result) result = etamin;
106 if (range.match(expId)) {
108 if (not eta_field.
empty()) {
110 if (result < etamax) result = etamax;
127 if (range.match(expId)) {
129 if (not phi_field.
empty()) {
131 if (-999 == result) {
135 if (phimin < result) result = phimin;
153 if (range.match(expId)) {
155 if (not phi_field.
empty()) {
157 if (result < phimax) result = phimax;
167 const std::string& group_name)
174 ATH_MSG_DEBUG(
"Request to reinitialize not satisfied - tags have not changed");
182 if(CaloIDHelper::initialize_base_from_dictionary(dict_mgr,
191 ATH_MSG_WARNING(
" initialize_base_from_dict - cannot initialize HEC part of LArCalorimeter dictionary ");
198 if (atlasDict->
get_label_value(
"subdet",
"LArCalorimeter", larField)) {
199 ATH_MSG_ERROR(
"Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary " << atlasDict->
name());
204 int larHecField = -1;
205 if (dict()->get_label_value(
"part",
"LArHEC", larHecField)) {
206 ATH_MSG_ERROR(
"Could not get value for label 'LArHEC' of field 'part' in dictionary " << atlasDict->
name());
212 exp_region_id.
add(larField);
213 exp_region_id.
add(larHecField);
216 m_full_region_range = dict()->build_multirange(exp_region_id, group_name, prefix,
"region");
283 if(phimin < 0 || phimax < 0) {
292 hc.
m_nphi = phimax-phimin+1 ;
328 std::string errorMessage =
"LArHEC_Base_ID::region_id() result is not OK: ID, range = "
345 std::string errorMessage =
"LArHEC_Base_ID::channel_id() result is not OK: ID, range = "
361 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID = "
369 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID, range = "
384 if(context && context->end_index() >=
m_ETA_INDEX) {
399 ATH_MSG_ERROR(
"initLevelsFromDict - dictionary NOT initialized");
421 const IdDictField* field = dict()->find_field(
"subdet") ;
426 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'subdet' field");
430 field = dict()->find_field(
"part") ;
435 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'part' field");
439 field = dict()->find_field(
"barrel-endcap") ;
444 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'barrel-endcap' field");
448 field = dict()->find_field(
"sampling") ;
453 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'sampling' field");
457 field = dict()->find_field(
"region") ;
462 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'region' field");
466 field = dict()->find_field(
"eta") ;
471 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'eta' field");
475 field = dict()->find_field(
"phi") ;
480 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'phi' field");
484 field = dict()->find_field(
"is-slar-hec") ;
489 ATH_MSG_ERROR(
"initLevelsFromDict - unable to find 'is-slar-hec' field");
507 ATH_MSG_DEBUG(
"decode index and bit fields for each level: ");
522 if (
channels().init (*
this,
"channels",
526 if (
regions().init (*
this,
"regions",
538 neighbourList.clear();
541 ATH_MSG_WARNING(
"neighbours not initialized !!! returning empty list");
550 const short int maxNeighb=20;
552 int neighbourIndex = 0;
555 unsigned int index=id;
564 short int nPhi = hecRegion->
phiN();
566 unsigned int minHash = hecRegion->
hashMin();
567 unsigned int maxHash = hecRegion->
hashMax();
578 prevNeighbInPhi=neighbList[neighbourIndex-1];
592 nextNeighbInPhi=neighbList[neighbourIndex-1];
604 get_prevInEta(hecRegion,
index, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
612 get_nextInEta(hecRegion,
index, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
620 unsigned int index1=prevNeighbInPhi;
621 int oldNeighbourIndex = neighbourIndex;
626 get_prevInEta(hecRegion, index1, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
627 if ( neighbourIndex > oldNeighbourIndex+1 ) {
628 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
629 neighbourIndex = oldNeighbourIndex+1;
631 oldNeighbourIndex = neighbourIndex;
632 get_nextInEta(hecRegion, index1, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
633 if ( neighbourIndex > oldNeighbourIndex+1 ) {
634 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
635 neighbourIndex = oldNeighbourIndex+1;
640 unsigned int index2=nextNeighbInPhi;
641 int oldNeighbourIndex = neighbourIndex;
646 get_prevInEta(hecRegion, index2, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
647 if ( neighbourIndex > oldNeighbourIndex+1 ) {
648 neighbourIndex = oldNeighbourIndex+1;
650 oldNeighbourIndex = neighbourIndex;
651 get_nextInEta(hecRegion, index2, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
652 if ( neighbourIndex > oldNeighbourIndex+1 ) {
653 neighbourIndex = oldNeighbourIndex+1;
666 int nEta = int( (
index-minHash) / nPhi);
667 double absEta = hecRegion->
etaMin() + nEta*granEta;
680 neighbourList.resize(neighbourIndex);
681 if (neighbourIndex <= maxNeighb) {
682 std::copy (&neighbList[0], &neighbList[neighbourIndex], neighbourList.begin());
685 ATH_MSG_WARNING(
"more than 20 neighbours for this cell, NONE will be retained " << neighbourIndex);
696 unsigned int nIndex =
index-1;
697 if( ((
index-minHash)%(nPhi)) == 0 ) nIndex=
index+nPhi-1;
699 neighbList[neighbourIndex] = nHash;
711 unsigned int nIndex =
index+1;
712 if( ((
index-minHash+1)%(nPhi)) == 0 ) nIndex=
index-nPhi+1;
714 neighbList[neighbourIndex] = nHash;
722 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
725 unsigned int nIndex = 0;
738 short int nPhiMinus = prevHecRegion->
phiN();
740 unsigned int maxHashMinus = prevHecRegion->
hashMax();
741 float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
742 float rPhi = (
index-minHash)*gPhi+hecRegion->
phiMin();
743 int nPhiMinusFirst = int(std::floor((rPhi -prevHecRegion->
phiMin())
744 /gPhiMinus+phiMargin))
745 +maxHashMinus-nPhiMinus;
746 int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
747 /gPhiMinus+phiMargin))
748 +maxHashMinus-nPhiMinus;
749 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
751 for(
int i=nPhiMinusFirst; i<nPhiMinusNext; i++){
753 if(nIndex != nBiggerCell) {
755 neighbList[neighbourIndex] = nHash;
760 if(gPhi < gPhiMinus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
766 nIndex =
index - nPhi;
768 neighbList[neighbourIndex] = nHash;
776 const unsigned int& maxHash,
777 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
780 unsigned int nIndex = 0;
794 unsigned int minHashPlus = nextHecRegion->
hashMin();
795 float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
796 float rPhi = (
index+nPhi-maxHash)*gPhi+hecRegion->
phiMin();
797 int nPhiPlusFirst = int(std::floor((rPhi -nextHecRegion->
phiMin())
798 /gPhiPlus+phiMargin))+minHashPlus;
799 int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
800 /gPhiPlus+phiMargin))+minHashPlus;
801 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
803 for(
int i=nPhiPlusFirst; i<nPhiPlusNext; i++){
805 if(nIndex != nBiggerCell) {
807 neighbList[neighbourIndex] = nHash;
812 if(gPhi < gPhiPlus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
818 nIndex =
index + nPhi;
820 neighbList[neighbourIndex] = nHash;
828 const double& absEta,
833 unsigned int nIndex=0;
839 int nPrevSampReg = prevSampRegion.size();
840 if(nPrevSampReg > 0) {
843 for(
int ireg=0; ireg<nPrevSampReg; ireg++) {
845 float minEtaMinus = prevHecRegion->
etaMin();
846 float maxEtaMinus = prevHecRegion->
etaMax();
849 float margin = 0.25*std::min(gEta,granEtaMinus);
850 if((minEtaMinus < absEta+gEta-margin) && (absEta+margin < maxEtaMinus)) {
857 short int nPhiMinus = prevHecRegion->
phiN();
859 unsigned int minHashMinus = prevHecRegion->
hashMin();
861 float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
863 float rPhi = ((
index-minHash)%nPhi)*gPhi+hecRegion->
phiMin();
864 int nPhiMinusFirst = int(std::floor((rPhi -prevHecRegion->
phiMin())
865 /gPhiMinus+phiMargin));
866 int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
867 /gPhiMinus+phiMargin));
868 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
870 double fEtaMinus = (absEta-minEtaMinus) / granEtaMinus + margin;
871 short int nEtaMinus = int(fEtaMinus) ;
872 for(
int i=nPhiMinusFirst; i<nPhiMinusNext; i++){
873 nIndex = minHashMinus + nEtaMinus * nPhiMinus + i;
874 if( (nIndex >= prevHecRegion->
hashMin()) && (nIndex < prevHecRegion->hashMax()) ) {
876 neighbList[neighbourIndex] = nHash;
888 const double& absEta,
893 unsigned int nIndex=0;
898 int nNextSampReg = nextSampRegion.size();
899 if(nNextSampReg > 0) {
902 for(
int ireg=0; ireg<nNextSampReg; ireg++) {
905 float minEtaPlus = nextHecRegion->
etaMin();
906 float maxEtaPlus = nextHecRegion->
etaMax();
907 float margin = 0.25*std::min(gEta,granEtaPlus);
908 if((minEtaPlus < absEta+gEta-margin) && (absEta+margin < maxEtaPlus)) {
914 short int nPhiPlus = nextHecRegion->
phiN();
915 unsigned int minHashPlus = nextHecRegion->
hashMin();
917 float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
919 float rPhi = ((
index-minHash)%nPhi)*gPhi+hecRegion->
phiMin();
920 int nPhiPlusFirst = int(std::floor((rPhi -nextHecRegion->
phiMin())
921 /gPhiPlus+phiMargin));
922 int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
923 /gPhiPlus+phiMargin));
924 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
926 double fEtaPlus = (absEta-minEtaPlus) / granEtaPlus + margin ;
927 int nEtaPlus = int(fEtaPlus) ;
928 for(
int i=nPhiPlusFirst; i<nPhiPlusNext; i++){
929 nIndex = minHashPlus + nEtaPlus * nPhiPlus + i;
930 if( (nIndex >= nextHecRegion->
hashMin()) && (nIndex < nextHecRegion->hashMax()) ) {
932 neighbList[neighbourIndex] = nHash;
946 const std::vector<const IdDictRegion*>& vecOfDictRegions =
dictRegions();
954 std::vector<Identifier>::const_iterator debut=
reg_begin() ;
955 std::vector<Identifier>::const_iterator fin =
reg_end() ;
957 for (; debut != fin; ++debut)
968 if(etaMin >= 0 && phiMin >= 0)
998 unsigned int ireg0=0;
1015 const IdDictRegion* prevEtaDicReg = vecOfDictRegions[reg]->prev_abs_eta();
1017 const IdDictRegion* nextEtaDicReg = vecOfDictRegions[reg]->next_abs_eta();
1018 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1019 if(vecOfDictRegions[ireg] == prevEtaDicReg) regForPrevEta = ireg;
1020 if(vecOfDictRegions[ireg] == nextEtaDicReg) regForNextEta = ireg;
1027 std::vector<short int> regForPrevSamp;
1028 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->prev_samp()) {
1029 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1030 if(vecOfDictRegions[ireg] == dictreg) regForPrevSamp.push_back(ireg);
1034 std::vector<short int> regForNextSamp;
1035 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->next_samp()) {
1036 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1037 if(vecOfDictRegions[ireg] == dictreg) regForNextSamp.push_back(ireg);
1046 regForPrevEta,regForNextEta,
1047 regForPrevSamp,regForNextSamp);
1061 for (; debut != fin; ++debut) {
1064 if(regId != lastRegId) reg++;
1069 if ((
short int)hashReg != reg) {
1070 ATH_MSG_ERROR(
" init_neighbors: problem reg, hashReg = " << reg <<
" " << hashReg);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#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.
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="")
Do basic initialization of the helper.
float phiGranularity(const IdentifierHash regHash) const
Return the phi granularity of a region, or NOT_VALID.
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...
int get_label_value(const std::string &field, const std::string &label, int &value) const
const std::string & name() const
Dictionary name.
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.
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP