 |
ATLAS Offline Software
|
Go to the documentation of this file.
24 #include "GaudiKernel/MsgStream.h"
35 const std::string&
group,
38 , m_slar (supercell ? 1 : 0)
39 , m_hec_region_index(0)
43 , m_SAMPLING_INDEX(999)
72 int eta,
int phi_sector )
const
74 int phi = (
region == 0 ? sector*2 + phi_sector : sector );
86 if (
range.match(expId)) {
88 if (not eta_field.
empty()) {
112 if (
range.match(expId)) {
114 if (not eta_field.
empty()) {
133 if (
range.match(expId)) {
135 if (not phi_field.
empty()) {
159 if (
range.match(expId)) {
161 if (not phi_field.
empty()) {
178 std::string strg =
"initialize_base_from_dictionary";
183 log <<
MSG::DEBUG <<
"Request to reinitialize not satisfied - tags have not changed" <<
endmsg;
200 strg =
" initialize_base_from_dict - cannot initialize HEC part of LArCalorimeter dictionary ";
205 std::cout << strg << std::endl;
213 if (atlasDict->
get_label_value(
"subdet",
"LArCalorimeter", larField)) {
214 std::stringstream strm ;
215 strm << atlasDict->
name();
216 strg =
"Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
222 std::cout << strg << std::endl;
228 int larHecField = -1;
229 if (
dict()->get_label_value(
"part",
"LArHEC", larHecField)) {
230 std::stringstream strm ;
231 strm << atlasDict->
name();
232 strg =
"Could not get value for label 'LArHEC' of field 'part' in dictionary "
238 std::cout << strg << std::endl;
245 exp_region_id.
add(larField);
246 exp_region_id.
add(larHecField);
252 std::string strg0 =
"initialize_from_dict : " ;
261 std::cout << strg0 << std::endl;
262 std::cout << strg1 << std::endl;
263 std::cout << strg2 << std::endl;
325 std::string strg =
"setting etamin to 0 because actual value not found for regId "
331 std::cout << strg << std::endl;
336 if(phimin < 0 || phimax < 0) {
338 std::string strg =
"setting phimin/phimax to 0 because actual value not found for regId "
344 std::cout << strg << std::endl;
352 hc.
m_nphi = phimax-phimin+1 ;
356 std::stringstream strm ;
359 std::string strg =
"min > 15 "
365 std::cout << strg << std::endl;
374 std::stringstream strm ;
377 std::string strg =
"channel ranges, id, hash, i = "
383 std::cout << strg << std::endl;
408 std::string errorMessage =
"LArHEC_Base_ID::region_id() result is not OK: ID, range = "
425 std::string errorMessage =
"LArHEC_Base_ID::channel_id() result is not OK: ID, range = "
441 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID = "
449 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID, range = "
481 std::string strg =
"initLevelsFromDict - dictionary NOT initialized ";
486 std::cout << strg << std::endl;
505 std::stringstream strm ;
507 std::string strg =
"initLevelsFromDict - unable to find hec region index: id, reg "
508 + (std::string)expId + strm.str();
513 std::cout << strg << std::endl;
523 std::string strg =
"initLevelsFromDict - unable to find 'subdet' field ";
528 std::cout << strg << std::endl;
538 std::string strg =
"initLevelsFromDict - unable to find 'part' field ";
543 std::cout << strg << std::endl;
553 std::string strg =
"initLevelsFromDict - unable to find 'barrel-endcap' field ";
558 std::cout << strg << std::endl;
568 std::string strg =
"initLevelsFromDict - unable to find 'sampling' field ";
573 std::cout << strg << std::endl;
583 std::string strg =
"initLevelsFromDict - unable to find 'region' field ";
588 std::cout << strg << std::endl;
598 std::string strg =
"initLevelsFromDict - unable to find 'eta' field ";
603 std::cout << strg << std::endl;
613 std::string strg =
"initLevelsFromDict - unable to find 'phi' field ";
618 std::cout << strg << std::endl;
629 log << MSG::ERROR <<
"initLevelsFromDict - unable to find 'is-slar-hec' field "
633 std::cout <<
"LArEM_Base_ID::initLevelsFromDict - unable to find 'is-slar-hec' field "
679 std::cout <<
"decode index and bit fields for each level: " << std::endl;
712 neighbourList.clear();
717 log << MSG::WARNING <<
"neighbours not initialized !!! returning empty list" <<
endmsg;
720 std::cout <<
" LArHEC_Base_ID: neighbours not initialized !!! returning empty list " << std::endl;
728 log << MSG::WARNING <<
"neighbours requested for non-existing channel -- id/max " <<
id <<
"/"
732 std::cout <<
" neighbours requested for non-existing channel -- id/max " <<
id <<
"/"
738 const short int maxNeighb=20;
740 int neighbourIndex = 0;
754 unsigned int minHash = hecRegion->
hashMin();
755 unsigned int maxHash = hecRegion->
hashMax();
766 prevNeighbInPhi=neighbList[neighbourIndex-1];
780 nextNeighbInPhi=neighbList[neighbourIndex-1];
808 unsigned int index1=prevNeighbInPhi;
809 int oldNeighbourIndex = neighbourIndex;
815 if ( neighbourIndex > oldNeighbourIndex+1 ) {
816 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
817 neighbourIndex = oldNeighbourIndex+1;
819 oldNeighbourIndex = neighbourIndex;
821 if ( neighbourIndex > oldNeighbourIndex+1 ) {
822 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
823 neighbourIndex = oldNeighbourIndex+1;
828 unsigned int index2=nextNeighbInPhi;
829 int oldNeighbourIndex = neighbourIndex;
835 if ( neighbourIndex > oldNeighbourIndex+1 ) {
836 neighbourIndex = oldNeighbourIndex+1;
838 oldNeighbourIndex = neighbourIndex;
840 if ( neighbourIndex > oldNeighbourIndex+1 ) {
841 neighbourIndex = oldNeighbourIndex+1;
868 neighbourList.resize(neighbourIndex);
869 if (neighbourIndex <= maxNeighb) {
870 std::copy (&neighbList[0], &neighbList[neighbourIndex], neighbourList.begin());
873 std::stringstream strm ;
874 strm << neighbourIndex ;
875 std::string strg =
"more than 20 neighbours for this cell, NONE will be retained "
882 std::cout <<
"WARNING: " << strg << std::endl;
894 unsigned int nIndex =
index-1;
897 neighbList[neighbourIndex] = nHash;
909 unsigned int nIndex =
index+1;
912 neighbList[neighbourIndex] = nHash;
920 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
923 unsigned int nIndex = 0;
936 short int nPhiMinus = prevHecRegion->
phiN();
938 unsigned int maxHashMinus = prevHecRegion->
hashMax();
939 float phiMargin = 0.25*
std::min(gPhi,gPhiMinus);
940 float rPhi = (
index-minHash)*gPhi+hecRegion->
phiMin();
941 int nPhiMinusFirst =
int(std::floor((rPhi -prevHecRegion->
phiMin())
942 /gPhiMinus+phiMargin))
943 +maxHashMinus-nPhiMinus;
944 int nPhiMinusNext =
int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
945 /gPhiMinus+phiMargin))
946 +maxHashMinus-nPhiMinus;
947 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
949 for(
int i=nPhiMinusFirst;
i<nPhiMinusNext;
i++){
951 if(nIndex != nBiggerCell) {
953 neighbList[neighbourIndex] = nHash;
958 if(gPhi < gPhiMinus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
966 neighbList[neighbourIndex] = nHash;
974 const unsigned int& maxHash,
975 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
978 unsigned int nIndex = 0;
992 unsigned int minHashPlus = nextHecRegion->
hashMin();
993 float phiMargin = 0.25*
std::min(gPhi,gPhiPlus);
995 int nPhiPlusFirst =
int(std::floor((rPhi -nextHecRegion->
phiMin())
996 /gPhiPlus+phiMargin))+minHashPlus;
997 int nPhiPlusNext =
int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
998 /gPhiPlus+phiMargin))+minHashPlus;
999 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1001 for(
int i=nPhiPlusFirst;
i<nPhiPlusNext;
i++){
1003 if(nIndex != nBiggerCell) {
1005 neighbList[neighbourIndex] = nHash;
1010 if(gPhi < gPhiPlus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
1018 neighbList[neighbourIndex] = nHash;
1031 unsigned int nIndex=0;
1037 int nPrevSampReg = prevSampRegion.size();
1038 if(nPrevSampReg > 0) {
1041 for(
int ireg=0; ireg<nPrevSampReg; ireg++) {
1043 float minEtaMinus = prevHecRegion->
etaMin();
1044 float maxEtaMinus = prevHecRegion->
etaMax();
1047 float margin = 0.25*
std::min(gEta,granEtaMinus);
1048 if((minEtaMinus <
absEta+gEta-margin) && (
absEta+margin < maxEtaMinus)) {
1055 short int nPhiMinus = prevHecRegion->
phiN();
1057 unsigned int minHashMinus = prevHecRegion->
hashMin();
1059 float phiMargin = 0.25*
std::min(gPhi,gPhiMinus);
1062 int nPhiMinusFirst =
int(std::floor((rPhi -prevHecRegion->
phiMin())
1063 /gPhiMinus+phiMargin));
1064 int nPhiMinusNext =
int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
1065 /gPhiMinus+phiMargin));
1066 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
1068 double fEtaMinus = (
absEta-minEtaMinus) / granEtaMinus + margin;
1069 short int nEtaMinus =
int(fEtaMinus) ;
1070 for(
int i=nPhiMinusFirst;
i<nPhiMinusNext;
i++){
1071 nIndex = minHashMinus + nEtaMinus * nPhiMinus +
i;
1072 if( (nIndex >= prevHecRegion->
hashMin()) && (nIndex < prevHecRegion->hashMax()) ) {
1074 neighbList[neighbourIndex] = nHash;
1091 unsigned int nIndex=0;
1096 int nNextSampReg = nextSampRegion.size();
1097 if(nNextSampReg > 0) {
1100 for(
int ireg=0; ireg<nNextSampReg; ireg++) {
1103 float minEtaPlus = nextHecRegion->
etaMin();
1104 float maxEtaPlus = nextHecRegion->
etaMax();
1105 float margin = 0.25*
std::min(gEta,granEtaPlus);
1106 if((minEtaPlus <
absEta+gEta-margin) && (
absEta+margin < maxEtaPlus)) {
1112 short int nPhiPlus = nextHecRegion->
phiN();
1113 unsigned int minHashPlus = nextHecRegion->
hashMin();
1115 float phiMargin = 0.25*
std::min(gPhi,gPhiPlus);
1118 int nPhiPlusFirst =
int(std::floor((rPhi -nextHecRegion->
phiMin())
1119 /gPhiPlus+phiMargin));
1120 int nPhiPlusNext =
int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
1121 /gPhiPlus+phiMargin));
1122 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1124 double fEtaPlus = (
absEta-minEtaPlus) / granEtaPlus + margin ;
1125 int nEtaPlus =
int(fEtaPlus) ;
1126 for(
int i=nPhiPlusFirst;
i<nPhiPlusNext;
i++){
1127 nIndex = minHashPlus + nEtaPlus * nPhiPlus +
i;
1128 if( (nIndex >= nextHecRegion->
hashMin()) && (nIndex < nextHecRegion->hashMax()) ) {
1130 neighbList[neighbourIndex] = nHash;
1146 const std::vector<const IdDictRegion*>& vecOfDictRegions =
dictRegions();
1153 std::cout <<
" LArHEC_Base_ID::init_neighbors " << std::endl;
1161 std::vector<Identifier>::const_iterator debut=
reg_begin() ;
1162 std::vector<Identifier>::const_iterator
fin =
reg_end() ;
1164 for (; debut !=
fin; ++debut)
1175 if(
etaMin >= 0 && phiMin >= 0)
1182 log << MSG::ERROR <<
" LArId exception "
1183 << (std::string)except
1188 <<
" LArId exception "
1189 << (std::string)except
1199 log << MSG::WARNING <<
" could not find non negative etaMin and phiMin for region "
1204 std::cout <<
"WARNING !! could not find non negative etaMin and phiMin for region "
1224 unsigned int ireg0=0;
1241 const IdDictRegion* prevEtaDicReg = vecOfDictRegions[reg]->prev_abs_eta();
1243 const IdDictRegion* nextEtaDicReg = vecOfDictRegions[reg]->next_abs_eta();
1244 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1245 if(vecOfDictRegions[ireg] == prevEtaDicReg) regForPrevEta = ireg;
1246 if(vecOfDictRegions[ireg] == nextEtaDicReg) regForNextEta = ireg;
1253 std::vector<short int> regForPrevSamp;
1254 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->prev_samp()) {
1255 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1256 if(vecOfDictRegions[ireg] == dictreg) regForPrevSamp.push_back(ireg);
1260 std::vector<short int> regForNextSamp;
1261 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->next_samp()) {
1262 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1263 if(vecOfDictRegions[ireg] == dictreg) regForNextSamp.push_back(ireg);
1272 regForPrevEta,regForNextEta,
1273 regForPrevSamp,regForNextSamp);
1287 for (; debut !=
fin; ++debut) {
1290 if(regId != lastRegId) reg++;
1295 if ((
short int)hashReg != reg) {
1297 log << MSG::ERROR <<
" init_neighbors: problem reg, hashReg = " << reg <<
" " << hashReg
1301 std::cout <<
" init_neighbors: problem reg, hashReg = " << reg <<
" " << hashReg
JetConstituentVector::iterator iterator
IdDictFieldImplementation m_sampling_impl
bool isPhiMax(const unsigned int &index) const
is the considered cell in the last phi bin of the region ?
unsigned int hashMin() const
hash Id of the first cell of the region
MultiRange build_multirange() const
Get MultiRange for full dictionary.
IdDictFieldImplementation m_pn_reg_impl
IdDictFieldImplementation m_hec_impl
id_iterator hec_begin() const
begin iterator over full set of Hec Identifiers for channels
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
Scalar phi() const
phi method
std::vector< short int > m_vecOfCellInfo
void region_id_checks(int pos_neg, int sampling, int region) const
Factor out code common between LArHEC_ID and LArHEC_SuperCell_ID.
std::string show_to_string(void) const
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
float etaMax() const
end eta
Scalar eta() const
pseudorapidity method
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
const IdDictRegion & region(size_t i) const
Region at index i.
int fill_vec_of_dict_regions(const std::string &group_name="")
Initialize the list of detector regions.
const std::vector< short int > & nextSamplingRegion() const
region number of the next region in sampling
element_type get_minimum() const
Query the values.
IdDictFieldImplementation m_phi_impl
int initLevelsFromDict(const std::string &group_name)
size_type end_index() const
IdContext region_context() const
Return the context for regions.
void add(element_type value)
Append a value into a new field.
IMessageSvc * m_msgSvc
pointer to the message service
bool isPhiMin(const unsigned int &index) const
is the considered cell in the first phi bin of the region ?
element_type get_maximum() const
bool m_do_checks
Flag for subclasses to know whether or not to perform checks.
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
const std::string & name() const
Dictionary name.
int lar_field_value() const
small class holding the starting hash value, the min eta and the number of phi bins of each region
int unpack(Identifier id) const
Identifier manipulation methods.
bool isEtaMax(const unsigned int &index) const
is the considered cell in the last eta bin of the region ?
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
int lar_hec_field_value() 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)
constexpr int nPhi
Default bin number of phi for vertex map.
IdDictField * find_field(const std::string &name) const
float etaMin() const
starting eta
const HashGroup & regions() const
Return the HashGroup for regions.
virtual std::string dictionaryVersion(void) const override
float phiGranularity() const
phi granularity
bool m_do_neighbours
Flag for subclasses to know whether or not to perform neighbour initialization.
std::vector< short int > m_vecOfPhiMin
static int get_prevInPhi(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IdentifierHash channel_hash_binary_search(Identifier channelId) const
create hash id from channel id – method NOT optimised, please use channel_hash() above
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
size_type region_hash_max() const
One more than the largest region hash code.
size_type m_hec_region_index
This class provides an interface to deal with regions in the neighbours finding
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
float etaGranularity(const IdentifierHash regHash) const
Return the eta granularity of a region, or NOT_VALID.
bool isEtaMin(const unsigned int &index) const
is the considered cell in the first eta bin of the region ?
void set_bits(size_type bits, size_type bits_offset)
const IdDictDictionary * dict() const
Return the dictionary for this subdetector.
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,...
Base class to factor out code common among Calo ID helpers.
id_iterator hec_end() const
end iterator over full set of Hec Identifiers for channels
const std::vector< short int > & prevSamplingRegion() const
region number of the prev region in sampling
id_iterator reg_end() const
end iterator over set of region Identifiers
IdDictFieldImplementation m_pn_impl
IdDictFieldImplementation m_region_impl
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &group_name)
initialization from the identifier dictionary
size_type bits_offset() const
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
float phiMin() const
starting phi
bool twoSymSides() const
True if the + and - sides of the calorimeter are identical (true layout).
float etaGranularity() const
eta granularity
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
int phi_min_init(const Identifier regId) const
ExpandedIdentifier lar_hec_exp(void) const
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
void channel_id_checks(int pos_neg, int sampling, int region, int eta, int phi) const
short int phiN() const
number of phi bins
IdDictFieldImplementation m_slar_impl
bool m_quiet
If true, suppress DEBUG/INFO messages.
IdDictFieldImplementation m_lar_impl
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &dict_name)
Do basic initialization of the helper.
Tell the compiler to optimize assuming that FP may trap.
int get_label_value(const std::string &field, const std::string &label, int &value) const
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
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
float eta0(const IdentifierHash regHash) const
Return the minimum eta of region, or NOT_VALID.
std::vector< HashCalc > m_hash_calcs
MultiRange m_full_region_range
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
size_type m_SAMPLING_INDEX
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
short int nextEtaRegion() const
region number of the next region in eta
def init(v_theApp, v_rootStream=None)
static int get_nextInPhi(const LArHEC_region *hecRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
const HashGroup & channels() const
Return the HashGroup for channels (cells).
LArHEC_Base_ID(const std::string &name, const std::string &group, bool supercell)
Constructor.
int match(const ExpandedIdentifier &id) const
Match an identifier.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
float phi0(const IdentifierHash regHash) const
Return the minimum phi of region, or NOT_VALID.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
const std::vector< const IdDictRegion * > & dictRegions() const
Return the vector of IdDictRegion, accessed via region hash.
unsigned int hashMax() const
hash Id of the last cell of the region +1
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
bool absEta(const xAOD::TauJet &tau, float &out)
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
void clear()
Erase all fields.
MultiRange m_full_channel_range
std::vector< LArHEC_region * > m_vecOfRegions
float phiGranularity(const IdentifierHash regHash) const
Return the phi granularity of a region, or NOT_VALID.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
constexpr int nEta
Default bin number of eta for vertex map.
id_iterator reg_begin() const
begin iterator over set of region Identifiers
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
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
int region(const Identifier id) const
return region [0,1]
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
IdDictFieldImplementation m_eta_impl
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
Exception class for LAr Identifiers.
short int prevEtaRegion() const
region number of the previous region in eta
Identifier::size_type size_type
int phi(const Identifier id) const
return phi[0,63] outer part [0,31] inner part