ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CaloNeighbourRegion Class Reference

#include <CaloNeighbours.h>

Collaboration diagram for CaloNeighbourRegion:

Public Types

enum  {
  SIDE = 2, SAMPL = 3, REGION = 4, ETA = 5,
  PHI = 6, TILESECTION = 1, TILEPHI = 3, TILEETA = 4,
  TILESAMPL = 5, FCALETA = 4, FCALPHI = 5
}
 

Public Member Functions

 CaloNeighbourRegion (const std::string &name, const CaloCell_Base_ID *theCaloId)
 
virtual ~CaloNeighbourRegion ()
 
void setType (const NEIGHBOURTYPE type)
 
void setSourceRange (const Range &theRange)
 
void setTargetRange (const Range &theRange)
 
void setSide (const int side1, const int side2)
 
void setPhi (const int phi1, const int phi2)
 
int setNeighbours (ExpandedIdentifier &id1, std::vector< ExpandedIdentifier > &id2, std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &neighbourMapPlus, std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &neighbourMapMinus)
 
void initializeVectors (std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &neighbourMapPlus, std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &neighbourMapMinus)
 
int getNeighbours (const IdentifierHash caloHash, std::vector< IdentifierHash > &neighbourList) const
 
NEIGHBOURTYPE getType () const
 
const std::string & getName () const
 

Private Member Functions

int getId (ExpandedIdentifier &id, Identifier &rID, const Range &theRange, const int side=+1, const int dphi=0) const
 

Private Attributes

std::string m_name
 
NEIGHBOURTYPE m_type
 
const CaloCell_Base_IDm_calo_id
 
Range m_sourceRange
 
Range m_targetRange
 
bool m_hasPhi
 
int m_iPhiSource
 
int m_iPhiTarget
 
bool m_hasSide
 
int m_iSideSource
 
int m_iSideTarget
 
bool m_isValidMinus
 
bool m_isValidPlus
 
IdentifierHash m_minHashMinus
 
IdentifierHash m_maxHashMinus
 
IdentifierHash m_minHashPlus
 
IdentifierHash m_maxHashPlus
 
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_plus
 
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_minus
 

Detailed Description

Definition at line 40 of file CaloNeighbours.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SIDE 
SAMPL 
REGION 
ETA 
PHI 
TILESECTION 
TILEPHI 
TILEETA 
TILESAMPL 
FCALETA 
FCALPHI 

Definition at line 43 of file CaloNeighbours.h.

43 {SIDE = 2, SAMPL = 3, REGION = 4, ETA = 5, PHI = 6, TILESECTION = 1, TILEPHI = 3, TILEETA = 4, TILESAMPL = 5, FCALETA = 4, FCALPHI = 5};

Constructor & Destructor Documentation

◆ CaloNeighbourRegion()

CaloNeighbourRegion::CaloNeighbourRegion ( const std::string &  name,
const CaloCell_Base_ID theCaloId 
)

Definition at line 40 of file CaloNeighbours.cxx.

41  :
42  m_name(name),
44  m_calo_id(theCaloId),
45  m_hasPhi(false),
46  m_iPhiSource(0),
47  m_iPhiTarget(0),
48  m_hasSide(false),
49  m_iSideSource(0),
50  m_iSideTarget(0),
51  m_isValidMinus(false),
52  m_isValidPlus(false)
53 {
54 }

◆ ~CaloNeighbourRegion()

CaloNeighbourRegion::~CaloNeighbourRegion ( )
virtualdefault

Member Function Documentation

◆ getId()

int CaloNeighbourRegion::getId ( ExpandedIdentifier id,
Identifier rID,
const Range theRange,
const int  side = +1,
const int  dphi = 0 
) const
private

Definition at line 109 of file CaloNeighbours.cxx.

110 {
111  // modify id for side and phi
112  // ExpandedIdentifier id(oid);
113  if ( m_hasSide && side != 1 )
114  id[SIDE] = side*id[SIDE];
115  if ( m_hasPhi && dphi != 0 ) {
116  if ( m_calo_id->is_lar_em(id) || m_calo_id->is_lar_hec(id) )
117  id[PHI] = id[PHI]+dphi;
118  else if ( m_calo_id->is_lar_fcal(id) )
119  id[FCALPHI] = id[FCALPHI]+dphi;
120  else
121  id[TILEPHI] = id[TILEPHI]+dphi;
122  }
123 
124  // first check if id is in the specified range
125  if ( !theRange.match(id) ) {
126  std::cout << "CaloNeighbours::set_neighbours ERROR: " << (std::string)id << " is not within the Range " << (std::string)theRange << std::endl;
127  return 1;
128  }
129 
130  CaloCell_ID::SUBCALO subCalo;
131  if ( m_calo_id->is_lar_em(id) ) {
132  subCalo = CaloCell_ID::LAREM;
133  rID = m_calo_id->cell_id(subCalo,
134  id[SIDE],
135  id[SAMPL],
136  id[REGION],
137  id[ETA],
138  id[PHI]);
139  }
140  else if ( m_calo_id->is_lar_hec(id) ) {
141  subCalo = CaloCell_ID::LARHEC;
142  rID = m_calo_id->cell_id(subCalo,
143  id[SIDE],
144  id[SAMPL],
145  id[REGION],
146  id[ETA],
147  id[PHI]);
148  }
149  else if ( m_calo_id->is_lar_fcal(id) ) {
150  subCalo = CaloCell_ID::LARFCAL;
151  rID = m_calo_id->cell_id(subCalo,
152  id[SIDE],
153  id[SAMPL],
154  0,
155  id[FCALETA],
156  id[FCALPHI]);
157  }
158  else if ( m_calo_id->is_tile(id) ) {
159  subCalo = CaloCell_ID::TILE;
161  if (id.fields() > TILESAMPL)
162  sampl = id[TILESAMPL];
163  rID = m_calo_id->cell_id(subCalo,
164  id[TILESECTION],
165  id[SIDE],
166  id[TILEPHI],
167  id[TILEETA],
168  sampl);
169  }
170  else {
171  std::cout << "CaloNeighbours::get_id ERROR: " << (std::string)id << " is not in the LAr or Tile calorimeters" << std::endl;
172  return 1;
173  }
174  return 0;
175 }

◆ getName()

const std::string& CaloNeighbourRegion::getName ( ) const
inline

Definition at line 65 of file CaloNeighbours.h.

65  {
66  return m_name;
67  }

◆ getNeighbours()

int CaloNeighbourRegion::getNeighbours ( const IdentifierHash  caloHash,
std::vector< IdentifierHash > &  neighbourList 
) const

Definition at line 261 of file CaloNeighbours.cxx.

262 {
263  int result = 0;
264 
265  if ( m_isValidMinus && caloHash >= m_minHashMinus && caloHash <= m_maxHashMinus && m_neighbours_minus[(unsigned int)(caloHash-m_minHashMinus)] ) {
266  neighbourList.insert(neighbourList.end(),
267  m_neighbours_minus[(unsigned int)(caloHash-m_minHashMinus)]->begin(),
268  m_neighbours_minus[(unsigned int)(caloHash-m_minHashMinus)]->end());
269  }
270  else if ( m_isValidPlus && caloHash >= m_minHashPlus && caloHash <= m_maxHashPlus && m_neighbours_plus[(unsigned int)(caloHash-m_minHashPlus)] ) {
271  neighbourList.insert(neighbourList.end(),
272  m_neighbours_plus[(unsigned int)(caloHash-m_minHashPlus)]->begin(),
273  m_neighbours_plus[(unsigned int)(caloHash-m_minHashPlus)]->end());
274  }
275 
276  return result;
277 }

◆ getType()

NEIGHBOURTYPE CaloNeighbourRegion::getType ( ) const
inline

Definition at line 61 of file CaloNeighbours.h.

61  {
62  return m_type;
63  }

◆ initializeVectors()

void CaloNeighbourRegion::initializeVectors ( std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &  neighbourMapPlus,
std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &  neighbourMapMinus 
)

Definition at line 238 of file CaloNeighbours.cxx.

239 {
240  if ( m_isValidMinus ) {
241  m_minHashMinus = neighbourMapMinus.begin()->first;
242  m_maxHashMinus = neighbourMapMinus.rbegin()->first;
243  m_neighbours_minus.resize((unsigned int)(m_maxHashMinus-m_minHashMinus+1));
244  for (const auto& p : neighbourMapMinus) {
245  m_neighbours_minus[(unsigned int)(p.first-m_minHashMinus)] = std::make_unique<std::vector<IdentifierHash> >(p.second);
246  }
247  }
248  if ( m_isValidPlus ) {
249  m_minHashPlus = neighbourMapPlus.begin()->first;
250  m_maxHashPlus = neighbourMapPlus.rbegin()->first;
251  m_neighbours_plus.resize((unsigned int)(m_maxHashPlus-m_minHashPlus+1));
252  for (const auto& p : neighbourMapPlus) {
253  m_neighbours_plus[(unsigned int)(p.first-m_minHashPlus)] = std::make_unique<std::vector<IdentifierHash> >(p.second);
254  }
255  }
256 
257 }

◆ setNeighbours()

int CaloNeighbourRegion::setNeighbours ( ExpandedIdentifier id1,
std::vector< ExpandedIdentifier > &  id2,
std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &  neighbourMapPlus,
std::map< IdentifierHash, std::vector< IdentifierHash >, ltIdHash > &  neighbourMapMinus 
)

Definition at line 179 of file CaloNeighbours.cxx.

183 {
184  int result = 0;
185 
186  // build an Identifier from the ExpandedIdentifier
187  int nMaxSides=1;
188  int nMaxPhi=1;
189  float rPhi=1;
190  if ( m_hasSide )
191  nMaxSides = 2;
192  if ( m_hasPhi ) {
193  nMaxPhi = m_sourceRange[m_iPhiSource].get_indices();
194  rPhi = ((float)m_targetRange[m_iPhiTarget].get_indices())/((float)nMaxPhi);
195  }
196 
197  for (int theSide = 0;theSide<nMaxSides;theSide++) {
198  for (int theDPhi = 0;theDPhi<nMaxPhi;theDPhi++) {
199  int side = +1;
200  int dphi2 = (int)(theDPhi*rPhi+0.05);
201  if ( theSide > 0 ) {
202  side = -1;
203  }
204  // only continous region mapping in phi is supported -
205  // therefore theDPhi = delta phi ...
206  Identifier myId;
207  ExpandedIdentifier myExpID(id1);
208  if ( getId(myExpID,myId,m_sourceRange,side,theDPhi) ) {
209  return 1;
210  }
211  // get hash ID's for the source
212  IdentifierHash myHash = m_calo_id->calo_cell_hash (myId);
213  // get ID's and hash ID's for the target
214  std::vector<IdentifierHash> theTargetHashIDs;
215  for (const ExpandedIdentifier& eid : id2) {
216  Identifier myTargetId;
217  ExpandedIdentifier myNExpID(eid);
218  if ( getId(myNExpID,myTargetId,m_targetRange,side,dphi2) ) {
219  return 1;
220  }
221  // get hash ID's for the target
222  IdentifierHash myTargetHash = m_calo_id->calo_cell_hash (myTargetId);
223  theTargetHashIDs.push_back(myTargetHash);
224  }
225  if ( id1[SIDE]*side > 0 ) {
226  neighbourMapPlus[myHash] = std::move(theTargetHashIDs);
227  }
228  else {
229  neighbourMapMinus[myHash] = std::move(theTargetHashIDs);
230  }
231  }
232  }
233  return result;
234 }

◆ setPhi()

void CaloNeighbourRegion::setPhi ( const int  phi1,
const int  phi2 
)

Definition at line 99 of file CaloNeighbours.cxx.

100 {
101  m_hasPhi = true;
102  m_iPhiSource = phi1;
103  m_iPhiTarget = phi2;
104 
105 }

◆ setSide()

void CaloNeighbourRegion::setSide ( const int  side1,
const int  side2 
)

Definition at line 90 of file CaloNeighbours.cxx.

91 {
92  m_hasSide = true;
93  m_iSideSource = side1;
94  m_iSideTarget = side2;
95 }

◆ setSourceRange()

void CaloNeighbourRegion::setSourceRange ( const Range theRange)

Definition at line 70 of file CaloNeighbours.cxx.

71 {
72  m_sourceRange = theRange;
73  for(unsigned int i=0;i<theRange[SIDE].get_indices();i++) {
74  if ( theRange[SIDE].get_value_at(i) < 0 )
75  m_isValidMinus = true;
76  else
77  m_isValidPlus = true;
78  }
79 }

◆ setTargetRange()

void CaloNeighbourRegion::setTargetRange ( const Range theRange)

Definition at line 83 of file CaloNeighbours.cxx.

84 {
85  m_targetRange = theRange;
86 }

◆ setType()

void CaloNeighbourRegion::setType ( const NEIGHBOURTYPE  type)

Definition at line 63 of file CaloNeighbours.cxx.

64 {
65  m_type = type;
66 }

Member Data Documentation

◆ m_calo_id

const CaloCell_Base_ID* CaloNeighbourRegion::m_calo_id
private

Definition at line 75 of file CaloNeighbours.h.

◆ m_hasPhi

bool CaloNeighbourRegion::m_hasPhi
private

Definition at line 79 of file CaloNeighbours.h.

◆ m_hasSide

bool CaloNeighbourRegion::m_hasSide
private

Definition at line 82 of file CaloNeighbours.h.

◆ m_iPhiSource

int CaloNeighbourRegion::m_iPhiSource
private

Definition at line 80 of file CaloNeighbours.h.

◆ m_iPhiTarget

int CaloNeighbourRegion::m_iPhiTarget
private

Definition at line 80 of file CaloNeighbours.h.

◆ m_iSideSource

int CaloNeighbourRegion::m_iSideSource
private

Definition at line 83 of file CaloNeighbours.h.

◆ m_iSideTarget

int CaloNeighbourRegion::m_iSideTarget
private

Definition at line 83 of file CaloNeighbours.h.

◆ m_isValidMinus

bool CaloNeighbourRegion::m_isValidMinus
private

Definition at line 85 of file CaloNeighbours.h.

◆ m_isValidPlus

bool CaloNeighbourRegion::m_isValidPlus
private

Definition at line 85 of file CaloNeighbours.h.

◆ m_maxHashMinus

IdentifierHash CaloNeighbourRegion::m_maxHashMinus
private

Definition at line 87 of file CaloNeighbours.h.

◆ m_maxHashPlus

IdentifierHash CaloNeighbourRegion::m_maxHashPlus
private

Definition at line 87 of file CaloNeighbours.h.

◆ m_minHashMinus

IdentifierHash CaloNeighbourRegion::m_minHashMinus
private

Definition at line 87 of file CaloNeighbours.h.

◆ m_minHashPlus

IdentifierHash CaloNeighbourRegion::m_minHashPlus
private

Definition at line 87 of file CaloNeighbours.h.

◆ m_name

std::string CaloNeighbourRegion::m_name
private

Definition at line 73 of file CaloNeighbours.h.

◆ m_neighbours_minus

std::vector< std::unique_ptr<std::vector<IdentifierHash> > > CaloNeighbourRegion::m_neighbours_minus
private

Definition at line 89 of file CaloNeighbours.h.

◆ m_neighbours_plus

std::vector< std::unique_ptr<std::vector<IdentifierHash> > > CaloNeighbourRegion::m_neighbours_plus
private

Definition at line 88 of file CaloNeighbours.h.

◆ m_sourceRange

Range CaloNeighbourRegion::m_sourceRange
private

Definition at line 77 of file CaloNeighbours.h.

◆ m_targetRange

Range CaloNeighbourRegion::m_targetRange
private

Definition at line 77 of file CaloNeighbours.h.

◆ m_type

NEIGHBOURTYPE CaloNeighbourRegion::m_type
private

Definition at line 74 of file CaloNeighbours.h.


The documentation for this class was generated from the following files:
CaloNeighbourRegion::m_iPhiSource
int m_iPhiSource
Definition: CaloNeighbours.h:80
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:43
CaloNeighbourRegion::TILESECTION
@ TILESECTION
Definition: CaloNeighbours.h:43
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
get_generator_info.result
result
Definition: get_generator_info.py:21
CaloNeighbourRegion::m_hasPhi
bool m_hasPhi
Definition: CaloNeighbours.h:79
CaloNeighbourRegion::m_isValidPlus
bool m_isValidPlus
Definition: CaloNeighbours.h:85
Range::match
int match(const ExpandedIdentifier &id) const
Match an identifier.
Definition: DetectorDescription/Identifier/src/Range.cxx:126
AtlasDetectorID::is_lar_fcal
bool is_lar_fcal(Identifier id) const
Definition: AtlasDetectorID.h:834
CaloNeighbourRegion::TILEPHI
@ TILEPHI
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::REGION
@ REGION
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::m_isValidMinus
bool m_isValidMinus
Definition: CaloNeighbours.h:85
CaloNeighbourRegion::m_name
std::string m_name
Definition: CaloNeighbours.h:73
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
CaloNeighbourRegion::getId
int getId(ExpandedIdentifier &id, Identifier &rID, const Range &theRange, const int side=+1, const int dphi=0) const
Definition: CaloNeighbours.cxx:109
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:43
CaloNeighbourRegion::m_maxHashPlus
IdentifierHash m_maxHashPlus
Definition: CaloNeighbours.h:87
CaloNeighbourRegion::m_minHashMinus
IdentifierHash m_minHashMinus
Definition: CaloNeighbours.h:87
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
CaloNeighbourRegion::m_targetRange
Range m_targetRange
Definition: CaloNeighbours.h:77
CaloNeighbourRegion::m_hasSide
bool m_hasSide
Definition: CaloNeighbours.h:82
CaloNeighbourRegion::m_sourceRange
Range m_sourceRange
Definition: CaloNeighbours.h:77
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
CaloNeighbourRegion::FCALETA
@ FCALETA
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::m_type
NEIGHBOURTYPE m_type
Definition: CaloNeighbours.h:74
TRT::Hit::side
@ side
Definition: HitInfo.h:83
CaloNeighbourRegion::m_minHashPlus
IdentifierHash m_minHashPlus
Definition: CaloNeighbours.h:87
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV0.cxx:562
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloNeighbourRegion::SIDE
@ SIDE
Definition: CaloNeighbours.h:43
nextInCalo
@ nextInCalo
Definition: CaloNeighbours.h:30
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:43
CaloNeighbourRegion::m_maxHashMinus
IdentifierHash m_maxHashMinus
Definition: CaloNeighbours.h:87
CaloNeighbourRegion::TILEETA
@ TILEETA
Definition: CaloNeighbours.h:43
AtlasDetectorID::is_lar_hec
bool is_lar_hec(Identifier id) const
Definition: AtlasDetectorID.h:824
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:43
CaloNeighbourRegion::m_neighbours_minus
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_minus
Definition: CaloNeighbours.h:89
CaloNeighbourRegion::m_iSideSource
int m_iSideSource
Definition: CaloNeighbours.h:83
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloNeighbourRegion::m_neighbours_plus
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_plus
Definition: CaloNeighbours.h:88
CaloNeighbourRegion::m_iSideTarget
int m_iSideTarget
Definition: CaloNeighbours.h:83
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
CaloNeighbourRegion::TILESAMPL
@ TILESAMPL
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::SAMPL
@ SAMPL
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::m_calo_id
const CaloCell_Base_ID * m_calo_id
Definition: CaloNeighbours.h:75
CaloNeighbourRegion::m_iPhiTarget
int m_iPhiTarget
Definition: CaloNeighbours.h:80
SIDE
SIDE
Definition: CellClusterLinkTool.h:52
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:105
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:43
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:106
AtlasDetectorID::is_lar_em
bool is_lar_em(Identifier id) const
Definition: AtlasDetectorID.h:813
CaloNeighbourRegion::ETA
@ ETA
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::FCALPHI
@ FCALPHI
Definition: CaloNeighbours.h:43
CaloNeighbourRegion::PHI
@ PHI
Definition: CaloNeighbours.h:43
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65
Identifier
Definition: IdentifierFieldParser.cxx:14