|
ATLAS Offline Software
|
Go to the documentation of this file.
20 #include "GaudiKernel/MsgStream.h"
32 , m_slar (supercell ? 1 : 0)
33 , m_hec_region_index(0)
37 , m_SAMPLING_INDEX(999)
66 int eta,
int phi_sector )
const
68 int phi = (
region == 0 ? sector*2 + phi_sector : sector );
80 if (
range.match(expId)) {
106 if (
range.match(expId)) {
127 if (
range.match(expId)) {
153 if (
range.match(expId)) {
172 std::string strg =
"initialize_base_from_dictionary";
177 log <<
MSG::DEBUG <<
"Request to reinitialize not satisfied - tags have not changed" <<
endmsg;
194 strg =
" initialize_base_from_dict - cannot initialize HEC part of LArCalorimeter dictionary ";
199 std::cout << strg << std::endl;
207 if (atlasDict->
get_label_value(
"subdet",
"LArCalorimeter", larField)) {
208 std::stringstream strm ;
209 strm << atlasDict->
m_name ;
210 strg =
"Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
216 std::cout << strg << std::endl;
222 int larHecField = -1;
223 if (
dict()->get_label_value(
"part",
"LArHEC", larHecField)) {
224 std::stringstream strm ;
225 strm << atlasDict->
m_name ;
226 strg =
"Could not get value for label 'LArHEC' of field 'part' in dictionary "
232 std::cout << strg << std::endl;
239 exp_region_id.
add(larField);
240 exp_region_id.
add(larHecField);
246 std::string strg0 =
"initialize_from_dict : " ;
255 std::cout << strg0 << std::endl;
256 std::cout << strg1 << std::endl;
257 std::cout << strg2 << std::endl;
319 std::string strg =
"setting etamin to 0 because actual value not found for regId "
325 std::cout << strg << std::endl;
331 std::string strg =
"setting phimin to 0 because actual value not found for regId "
337 std::cout << strg << std::endl;
349 std::stringstream strm ;
352 std::string strg =
"min > 15 "
358 std::cout << strg << std::endl;
367 std::stringstream strm ;
370 std::string strg =
"channel ranges, id, hash, i = "
376 std::cout << strg << std::endl;
401 std::string errorMessage =
"LArHEC_Base_ID::region_id() result is not OK: ID, range = "
418 std::string errorMessage =
"LArHEC_Base_ID::channel_id() result is not OK: ID, range = "
434 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID = "
442 std::string errorMessage =
"LArHEC_Base_ID::channel_id(regId) result is not OK: ID, range = "
474 std::string strg =
"initLevelsFromDict - dictionary NOT initialized ";
479 std::cout << strg << std::endl;
498 std::stringstream strm ;
500 std::string strg =
"initLevelsFromDict - unable to find hec region index: id, reg "
501 + (std::string)expId + strm.str();
506 std::cout << strg << std::endl;
516 std::string strg =
"initLevelsFromDict - unable to find 'subdet' field ";
521 std::cout << strg << std::endl;
531 std::string strg =
"initLevelsFromDict - unable to find 'part' field ";
536 std::cout << strg << std::endl;
546 std::string strg =
"initLevelsFromDict - unable to find 'barrel-endcap' field ";
551 std::cout << strg << std::endl;
561 std::string strg =
"initLevelsFromDict - unable to find 'sampling' field ";
566 std::cout << strg << std::endl;
576 std::string strg =
"initLevelsFromDict - unable to find 'region' field ";
581 std::cout << strg << std::endl;
591 std::string strg =
"initLevelsFromDict - unable to find 'eta' field ";
596 std::cout << strg << std::endl;
606 std::string strg =
"initLevelsFromDict - unable to find 'phi' field ";
611 std::cout << strg << std::endl;
622 log << MSG::ERROR <<
"initLevelsFromDict - unable to find 'is-slar-hec' field "
626 std::cout <<
"LArEM_Base_ID::initLevelsFromDict - unable to find 'is-slar-hec' field "
672 std::cout <<
"decode index and bit fields for each level: " << std::endl;
705 neighbourList.clear();
710 log << MSG::WARNING <<
"neighbours not initialized !!! returning empty list" <<
endmsg;
713 std::cout <<
" LArHEC_Base_ID: neighbours not initialized !!! returning empty list " << std::endl;
721 log << MSG::WARNING <<
"neighbours requested for non-existing channel -- id/max " <<
id <<
"/"
725 std::cout <<
" neighbours requested for non-existing channel -- id/max " <<
id <<
"/"
731 const short int maxNeighb=20;
733 int neighbourIndex = 0;
747 unsigned int minHash = hecRegion->
hashMin();
748 unsigned int maxHash = hecRegion->
hashMax();
759 prevNeighbInPhi=neighbList[neighbourIndex-1];
773 nextNeighbInPhi=neighbList[neighbourIndex-1];
801 unsigned int index1=prevNeighbInPhi;
802 int oldNeighbourIndex = neighbourIndex;
808 if ( neighbourIndex > oldNeighbourIndex+1 ) {
809 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
810 neighbourIndex = oldNeighbourIndex+1;
812 oldNeighbourIndex = neighbourIndex;
814 if ( neighbourIndex > oldNeighbourIndex+1 ) {
815 neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
816 neighbourIndex = oldNeighbourIndex+1;
821 unsigned int index2=nextNeighbInPhi;
822 int oldNeighbourIndex = neighbourIndex;
828 if ( neighbourIndex > oldNeighbourIndex+1 ) {
829 neighbourIndex = oldNeighbourIndex+1;
831 oldNeighbourIndex = neighbourIndex;
833 if ( neighbourIndex > oldNeighbourIndex+1 ) {
834 neighbourIndex = oldNeighbourIndex+1;
861 neighbourList.resize(neighbourIndex);
862 if (neighbourIndex <= maxNeighb) {
863 std::copy (&neighbList[0], &neighbList[neighbourIndex], neighbourList.begin());
866 std::stringstream strm ;
867 strm << neighbourIndex ;
868 std::string strg =
"more than 20 neighbours for this cell, NONE will be retained "
875 std::cout <<
"WARNING: " << strg << std::endl;
887 unsigned int nIndex =
index-1;
890 neighbList[neighbourIndex] = nHash;
902 unsigned int nIndex =
index+1;
905 neighbList[neighbourIndex] = nHash;
913 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
916 unsigned int nIndex = 0;
929 short int nPhiMinus = prevHecRegion->
phiN();
931 unsigned int maxHashMinus = prevHecRegion->
hashMax();
932 float phiMargin = 0.25*
std::min(gPhi,gPhiMinus);
933 float rPhi = (
index-minHash)*gPhi+hecRegion->
phiMin();
934 int nPhiMinusFirst =
int(std::floor((rPhi -prevHecRegion->
phiMin())
935 /gPhiMinus+phiMargin))
936 +maxHashMinus-nPhiMinus;
937 int nPhiMinusNext =
int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
938 /gPhiMinus+phiMargin))
939 +maxHashMinus-nPhiMinus;
940 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
942 for(
int i=nPhiMinusFirst;
i<nPhiMinusNext;
i++){
944 if(nIndex != nBiggerCell) {
946 neighbList[neighbourIndex] = nHash;
951 if(gPhi < gPhiMinus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
959 neighbList[neighbourIndex] = nHash;
967 const unsigned int& maxHash,
968 int& neighbourIndex,
IdentifierHash* neighbList,
unsigned int& nBiggerCell)
const
971 unsigned int nIndex = 0;
985 unsigned int minHashPlus = nextHecRegion->
hashMin();
986 float phiMargin = 0.25*
std::min(gPhi,gPhiPlus);
988 int nPhiPlusFirst =
int(std::floor((rPhi -nextHecRegion->
phiMin())
989 /gPhiPlus+phiMargin))+minHashPlus;
990 int nPhiPlusNext =
int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
991 /gPhiPlus+phiMargin))+minHashPlus;
992 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
994 for(
int i=nPhiPlusFirst;
i<nPhiPlusNext;
i++){
996 if(nIndex != nBiggerCell) {
998 neighbList[neighbourIndex] = nHash;
1003 if(gPhi < gPhiPlus && nBiggerCell ==
NOT_VALID_HASH) nBiggerCell=nIndex;
1011 neighbList[neighbourIndex] = nHash;
1024 unsigned int nIndex=0;
1030 int nPrevSampReg = prevSampRegion.size();
1031 if(nPrevSampReg > 0) {
1034 for(
int ireg=0; ireg<nPrevSampReg; ireg++) {
1036 float minEtaMinus = prevHecRegion->
etaMin();
1037 float maxEtaMinus = prevHecRegion->
etaMax();
1040 float margin = 0.25*
std::min(gEta,granEtaMinus);
1041 if((minEtaMinus <
absEta+gEta-margin) && (
absEta+margin < maxEtaMinus)) {
1048 short int nPhiMinus = prevHecRegion->
phiN();
1050 unsigned int minHashMinus = prevHecRegion->
hashMin();
1052 float phiMargin = 0.25*
std::min(gPhi,gPhiMinus);
1055 int nPhiMinusFirst =
int(std::floor((rPhi -prevHecRegion->
phiMin())
1056 /gPhiMinus+phiMargin));
1057 int nPhiMinusNext =
int(std::floor((rPhi+gPhi-prevHecRegion->
phiMin())
1058 /gPhiMinus+phiMargin));
1059 if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
1061 double fEtaMinus = (
absEta-minEtaMinus) / granEtaMinus + margin;
1062 short int nEtaMinus =
int(fEtaMinus) ;
1063 for(
int i=nPhiMinusFirst;
i<nPhiMinusNext;
i++){
1064 nIndex = minHashMinus + nEtaMinus * nPhiMinus +
i;
1065 if( (nIndex >= prevHecRegion->
hashMin()) && (nIndex < prevHecRegion->hashMax()) ) {
1067 neighbList[neighbourIndex] = nHash;
1084 unsigned int nIndex=0;
1089 int nNextSampReg = nextSampRegion.size();
1090 if(nNextSampReg > 0) {
1093 for(
int ireg=0; ireg<nNextSampReg; ireg++) {
1096 float minEtaPlus = nextHecRegion->
etaMin();
1097 float maxEtaPlus = nextHecRegion->
etaMax();
1098 float margin = 0.25*
std::min(gEta,granEtaPlus);
1099 if((minEtaPlus <
absEta+gEta-margin) && (
absEta+margin < maxEtaPlus)) {
1105 short int nPhiPlus = nextHecRegion->
phiN();
1106 unsigned int minHashPlus = nextHecRegion->
hashMin();
1108 float phiMargin = 0.25*
std::min(gPhi,gPhiPlus);
1111 int nPhiPlusFirst =
int(std::floor((rPhi -nextHecRegion->
phiMin())
1112 /gPhiPlus+phiMargin));
1113 int nPhiPlusNext =
int(std::floor((rPhi+gPhi-nextHecRegion->
phiMin())
1114 /gPhiPlus+phiMargin));
1115 if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1117 double fEtaPlus = (
absEta-minEtaPlus) / granEtaPlus + margin ;
1118 int nEtaPlus =
int(fEtaPlus) ;
1119 for(
int i=nPhiPlusFirst;
i<nPhiPlusNext;
i++){
1120 nIndex = minHashPlus + nEtaPlus * nPhiPlus +
i;
1121 if( (nIndex >= nextHecRegion->
hashMin()) && (nIndex < nextHecRegion->hashMax()) ) {
1123 neighbList[neighbourIndex] = nHash;
1139 const std::vector<const IdDictRegion*>& vecOfDictRegions =
dictRegions();
1146 std::cout <<
" LArHEC_Base_ID::init_neighbors " << std::endl;
1154 std::vector<Identifier>::const_iterator debut=
reg_begin() ;
1155 std::vector<Identifier>::const_iterator
fin =
reg_end() ;
1157 for (; debut !=
fin; ++debut)
1168 if(
etaMin >= 0 && phiMin >= 0)
1175 log << MSG::ERROR <<
" LArId exception "
1176 << (std::string)except
1181 <<
" LArId exception "
1182 << (std::string)except
1192 log << MSG::WARNING <<
" could not find non negative etaMin and phiMin for region "
1197 std::cout <<
"WARNING !! could not find non negative etaMin and phiMin for region "
1217 unsigned int ireg0=0;
1237 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1238 if(vecOfDictRegions[ireg] == prevEtaDicReg) regForPrevEta = ireg;
1239 if(vecOfDictRegions[ireg] == nextEtaDicReg) regForNextEta = ireg;
1246 std::vector<short int> regForPrevSamp;
1247 std::vector<IdDictRegion*> prevSampDicReg = vecOfDictRegions[
reg]->m_prev_samp;
1248 for(
unsigned int isam=0;isam<prevSampDicReg.size();isam++){
1249 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1250 if(vecOfDictRegions[ireg] == prevSampDicReg[isam]) regForPrevSamp.push_back(ireg);
1254 std::vector<short int> regForNextSamp;
1255 std::vector<IdDictRegion*> nextSampDicReg = vecOfDictRegions[
reg]->m_next_samp;
1256 for(
unsigned int isam=0;isam<nextSampDicReg.size();isam++){
1257 for(
unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1258 if(vecOfDictRegions[ireg] == nextSampDicReg[isam]) regForNextSamp.push_back(ireg);
1267 regForPrevEta,regForNextEta,
1268 regForPrevSamp,regForNextSamp);
1282 for (; debut !=
fin; ++debut) {
1285 if(regId != lastRegId)
reg++;
1290 if ((
short int)hashReg !=
reg) {
1292 log << MSG::ERROR <<
" init_neighbors: problem reg, hashReg = " <<
reg <<
" " << hashReg
1296 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
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
Scalar phi() const
phi method
id_iterator reg_begin(void) const
begin iterator over set of region Identifiers
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
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
IdDictFieldImplementation m_phi_impl
int initLevelsFromDict(const std::string &group_name)
IdContext region_context() const
Return the context for regions.
void add(element_type value)
id_iterator reg_end(void) const
end iterator over set of region Identifiers
size_type end_index(void) const
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 ?
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)
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.
reg
globals -----------------------------------------------------------------—
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
id_iterator hec_end(void) const
end iterator over full set of Hec Identifiers for channels
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 .
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.
const std::vector< short int > & prevSamplingRegion() const
region number of the prev region in sampling
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)
std::vector< IdDictRegion * > m_regions
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
element_type get_minimum() const
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
LArHEC_Base_ID(const std::string &name, bool supercell)
Constructor.
MultiRange m_full_region_range
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
id_iterator hec_begin(void) const
begin iterator over full set of Hec Identifiers for channels
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)
element_type get_maximum() const
const HashGroup & channels() const
Return the HashGroup for channels (cells).
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, double &out)
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
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 the individual specification for the range of one ExpandedIdentifier field.
constexpr int nEta
Default bin number of eta for vertex map.
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]
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