 |
ATLAS Offline Software
|
Go to the documentation of this file.
20 #include "GaudiKernel/MsgStream.h"
31 const std::string&
group,
34 , m_slar (supercell ? 1 : 0)
35 , m_hec_region_index(0)
39 , m_SAMPLING_INDEX(999)
68 int eta,
int phi_sector )
const
70 int phi = (
region == 0 ? sector*2 + phi_sector : sector );
82 if (
range.match(expId)) {
84 if (not eta_field.
empty()) {
108 if (
range.match(expId)) {
110 if (not eta_field.
empty()) {
129 if (
range.match(expId)) {
131 if (not phi_field.
empty()) {
155 if (
range.match(expId)) {
157 if (not phi_field.
empty()) {
174 std::string strg =
"initialize_base_from_dictionary";
179 log <<
MSG::DEBUG <<
"Request to reinitialize not satisfied - tags have not changed" <<
endmsg;
196 strg =
" initialize_base_from_dict - cannot initialize HEC part of LArCalorimeter dictionary ";
201 std::cout << strg << std::endl;
209 if (atlasDict->
get_label_value(
"subdet",
"LArCalorimeter", larField)) {
210 std::stringstream strm ;
211 strm << atlasDict->
name();
212 strg =
"Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
218 std::cout << strg << std::endl;
224 int larHecField = -1;
225 if (
dict()->get_label_value(
"part",
"LArHEC", larHecField)) {
226 std::stringstream strm ;
227 strm << atlasDict->
name();
228 strg =
"Could not get value for label 'LArHEC' of field 'part' in dictionary "
234 std::cout << strg << std::endl;
241 exp_region_id.
add(larField);
242 exp_region_id.
add(larHecField);
248 std::string strg0 =
"initialize_from_dict : " ;
257 std::cout << strg0 << std::endl;
258 std::cout << strg1 << std::endl;
259 std::cout << strg2 << std::endl;
321 std::string strg =
"setting etamin to 0 because actual value not found for regId "
327 std::cout << strg << std::endl;
332 if(phimin < 0 || phimax < 0) {
334 std::string strg =
"setting phimin/phimax to 0 because actual value not found for regId "
340 std::cout << strg << std::endl;
348 hc.
m_nphi = phimax-phimin+1 ;
352 std::stringstream strm ;
355 std::string strg =
"min > 15 "
361 std::cout << strg << std::endl;
370 std::stringstream strm ;
373 std::string strg =
"channel ranges, id, hash, i = "
379 std::cout << strg << std::endl;
404 std::string errorMessage =
"LArHEC_Base_ID::region_id() result is not OK: ID, range = "
421 std::string errorMessage =
"LArHEC_Base_ID::channel_id() result is not OK: ID, range = "
437 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID = "
445 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID, range = "
477 std::string strg =
"initLevelsFromDict - dictionary NOT initialized ";
482 std::cout << strg << std::endl;
501 std::stringstream strm ;
503 std::string strg =
"initLevelsFromDict - unable to find hec region index: id, reg "
504 + (std::string)expId + strm.str();
509 std::cout << strg << std::endl;
519 std::string strg =
"initLevelsFromDict - unable to find 'subdet' field ";
524 std::cout << strg << std::endl;
534 std::string strg =
"initLevelsFromDict - unable to find 'part' field ";
539 std::cout << strg << std::endl;
549 std::string strg =
"initLevelsFromDict - unable to find 'barrel-endcap' field ";
554 std::cout << strg << std::endl;
564 std::string strg =
"initLevelsFromDict - unable to find 'sampling' field ";
569 std::cout << strg << std::endl;
579 std::string strg =
"initLevelsFromDict - unable to find 'region' field ";
584 std::cout << strg << std::endl;
594 std::string strg =
"initLevelsFromDict - unable to find 'eta' field ";
599 std::cout << strg << std::endl;
609 std::string strg =
"initLevelsFromDict - unable to find 'phi' field ";
614 std::cout << strg << std::endl;
625 log << MSG::ERROR <<
"initLevelsFromDict - unable to find 'is-slar-hec' field "
629 std::cout <<
"LArEM_Base_ID::initLevelsFromDict - unable to find 'is-slar-hec' field "
675 std::cout <<
"decode index and bit fields for each level: " << std::endl;
708 neighbourList.clear();
713 log << MSG::WARNING <<
"neighbours not initialized !!! returning empty list" <<
endmsg;
716 std::cout <<
" LArHEC_Base_ID: neighbours not initialized !!! returning empty list " << std::endl;
724 log << MSG::WARNING <<
"neighbours requested for non-existing channel -- id/max " <<
id <<
"/"
728 std::cout <<
" neighbours requested for non-existing channel -- id/max " <<
id <<
"/"
734 const short int maxNeighb=20;
736 int neighbourIndex = 0;
750 unsigned int minHash = hecRegion->
hashMin();
751 unsigned int maxHash = hecRegion->
hashMax();
762 prevNeighbInPhi=neighbList[neighbourIndex-1];
776 nextNeighbInPhi=neighbList[neighbourIndex-1];
804 unsigned int index1=prevNeighbInPhi;
805 int oldNeighbourIndex = neighbourIndex;
811 if ( neighbourIndex > oldNeighbourIndex+1 ) {
812 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
813 neighbourIndex = oldNeighbourIndex+1;
815 oldNeighbourIndex = neighbourIndex;
817 if ( neighbourIndex > oldNeighbourIndex+1 ) {
818 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
819 neighbourIndex = oldNeighbourIndex+1;
824 unsigned int index2=nextNeighbInPhi;
825 int oldNeighbourIndex = neighbourIndex;
831 if ( neighbourIndex > oldNeighbourIndex+1 ) {
832 neighbourIndex = oldNeighbourIndex+1;
834 oldNeighbourIndex = neighbourIndex;
836 if ( neighbourIndex > oldNeighbourIndex+1 ) {
837 neighbourIndex = oldNeighbourIndex+1;
864 neighbourList.resize(neighbourIndex);
865 if (neighbourIndex <= maxNeighb) {
866 std::copy (&neighbList[0], &neighbList[neighbourIndex], neighbourList.begin());
869 std::stringstream strm ;
870 strm << neighbourIndex ;
871 std::string strg =
"more than 20 neighbours for this cell, NONE will be retained "
878 std::cout <<
"WARNING: " << strg << std::endl;
890 unsigned int nIndex =
index-1;
893 neighbList[neighbourIndex] = nHash;
905 unsigned int nIndex =
index+1;
908 neighbList[neighbourIndex] = nHash;
916 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
919 unsigned int nIndex = 0;
932 short int nPhiMinus = prevHecRegion->
phiN();
934 unsigned int maxHashMinus = prevHecRegion->
hashMax();
935 float phiMargin = 0.25*
std::min(gPhi,gPhiMinus);
936 float rPhi = (
index-minHash)*gPhi+hecRegion->
phiMin();
937 int nPhiMinusFirst =
int(std::floor((rPhi -prevHecRegion->
phiMin())
938 /gPhiMinus+phiMargin))
939 +maxHashMinus-nPhiMinus;
940 int nPhiMinusNext =
int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
941 /gPhiMinus+phiMargin))
942 +maxHashMinus-nPhiMinus;
943 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
945 for(
int i=nPhiMinusFirst;
i<nPhiMinusNext;
i++){
947 if(nIndex != nBiggerCell) {
949 neighbList[neighbourIndex] = nHash;
954 if(gPhi < gPhiMinus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
962 neighbList[neighbourIndex] = nHash;
970 const unsigned int& maxHash,
971 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
974 unsigned int nIndex = 0;
988 unsigned int minHashPlus = nextHecRegion->
hashMin();
989 float phiMargin = 0.25*
std::min(gPhi,gPhiPlus);
991 int nPhiPlusFirst =
int(std::floor((rPhi -nextHecRegion->
phiMin())
992 /gPhiPlus+phiMargin))+minHashPlus;
993 int nPhiPlusNext =
int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
994 /gPhiPlus+phiMargin))+minHashPlus;
995 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
997 for(
int i=nPhiPlusFirst;
i<nPhiPlusNext;
i++){
999 if(nIndex != nBiggerCell) {
1001 neighbList[neighbourIndex] = nHash;
1006 if(gPhi < gPhiPlus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
1014 neighbList[neighbourIndex] = nHash;
1027 unsigned int nIndex=0;
1033 int nPrevSampReg = prevSampRegion.size();
1034 if(nPrevSampReg > 0) {
1037 for(
int ireg=0; ireg<nPrevSampReg; ireg++) {
1039 float minEtaMinus = prevHecRegion->
etaMin();
1040 float maxEtaMinus = prevHecRegion->
etaMax();
1043 float margin = 0.25*
std::min(gEta,granEtaMinus);
1044 if((minEtaMinus <
absEta+gEta-margin) && (
absEta+margin < maxEtaMinus)) {
1051 short int nPhiMinus = prevHecRegion->
phiN();
1053 unsigned int minHashMinus = prevHecRegion->
hashMin();
1055 float phiMargin = 0.25*
std::min(gPhi,gPhiMinus);
1058 int nPhiMinusFirst =
int(std::floor((rPhi -prevHecRegion->
phiMin())
1059 /gPhiMinus+phiMargin));
1060 int nPhiMinusNext =
int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
1061 /gPhiMinus+phiMargin));
1062 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
1064 double fEtaMinus = (
absEta-minEtaMinus) / granEtaMinus + margin;
1065 short int nEtaMinus =
int(fEtaMinus) ;
1066 for(
int i=nPhiMinusFirst;
i<nPhiMinusNext;
i++){
1067 nIndex = minHashMinus + nEtaMinus * nPhiMinus +
i;
1068 if( (nIndex >= prevHecRegion->
hashMin()) && (nIndex < prevHecRegion->hashMax()) ) {
1070 neighbList[neighbourIndex] = nHash;
1087 unsigned int nIndex=0;
1092 int nNextSampReg = nextSampRegion.size();
1093 if(nNextSampReg > 0) {
1096 for(
int ireg=0; ireg<nNextSampReg; ireg++) {
1099 float minEtaPlus = nextHecRegion->
etaMin();
1100 float maxEtaPlus = nextHecRegion->
etaMax();
1101 float margin = 0.25*
std::min(gEta,granEtaPlus);
1102 if((minEtaPlus <
absEta+gEta-margin) && (
absEta+margin < maxEtaPlus)) {
1108 short int nPhiPlus = nextHecRegion->
phiN();
1109 unsigned int minHashPlus = nextHecRegion->
hashMin();
1111 float phiMargin = 0.25*
std::min(gPhi,gPhiPlus);
1114 int nPhiPlusFirst =
int(std::floor((rPhi -nextHecRegion->
phiMin())
1115 /gPhiPlus+phiMargin));
1116 int nPhiPlusNext =
int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
1117 /gPhiPlus+phiMargin));
1118 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1120 double fEtaPlus = (
absEta-minEtaPlus) / granEtaPlus + margin ;
1121 int nEtaPlus =
int(fEtaPlus) ;
1122 for(
int i=nPhiPlusFirst;
i<nPhiPlusNext;
i++){
1123 nIndex = minHashPlus + nEtaPlus * nPhiPlus +
i;
1124 if( (nIndex >= nextHecRegion->
hashMin()) && (nIndex < nextHecRegion->hashMax()) ) {
1126 neighbList[neighbourIndex] = nHash;
1142 const std::vector<const IdDictRegion*>& vecOfDictRegions =
dictRegions();
1149 std::cout <<
" LArHEC_Base_ID::init_neighbors " << std::endl;
1157 std::vector<Identifier>::const_iterator debut=
reg_begin() ;
1158 std::vector<Identifier>::const_iterator
fin =
reg_end() ;
1160 for (; debut !=
fin; ++debut)
1171 if(
etaMin >= 0 && phiMin >= 0)
1178 log << MSG::ERROR <<
" LArId exception "
1179 << (std::string)except
1184 <<
" LArId exception "
1185 << (std::string)except
1195 log << MSG::WARNING <<
" could not find non negative etaMin and phiMin for region "
1200 std::cout <<
"WARNING !! could not find non negative etaMin and phiMin for region "
1220 unsigned int ireg0=0;
1237 const IdDictRegion* prevEtaDicReg = vecOfDictRegions[reg]->prev_abs_eta();
1239 const IdDictRegion* nextEtaDicReg = vecOfDictRegions[reg]->next_abs_eta();
1240 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1241 if(vecOfDictRegions[ireg] == prevEtaDicReg) regForPrevEta = ireg;
1242 if(vecOfDictRegions[ireg] == nextEtaDicReg) regForNextEta = ireg;
1249 std::vector<short int> regForPrevSamp;
1250 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->prev_samp()) {
1251 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1252 if(vecOfDictRegions[ireg] == dictreg) regForPrevSamp.push_back(ireg);
1256 std::vector<short int> regForNextSamp;
1257 for (
const IdDictRegion* dictreg : vecOfDictRegions[reg]->next_samp()) {
1258 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1259 if(vecOfDictRegions[ireg] == dictreg) regForNextSamp.push_back(ireg);
1268 regForPrevEta,regForNextEta,
1269 regForPrevSamp,regForNextSamp);
1283 for (; debut !=
fin; ++debut) {
1286 if(regId != lastRegId) reg++;
1291 if ((
short int)hashReg != reg) {
1293 log << MSG::ERROR <<
" init_neighbors: problem reg, hashReg = " << reg <<
" " << hashReg
1297 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 ?
#define CXXUTILS_TRAPPING_FP
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
bool absEta(const xAOD::TauJet &tau, float &out)
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)
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