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 41 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 44 of file CaloNeighbours.h.

44 {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 42 of file CaloNeighbours.cxx.

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

◆ ~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 111 of file CaloNeighbours.cxx.

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

◆ getName()

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

Definition at line 66 of file CaloNeighbours.h.

66  {
67  return m_name;
68  }

◆ getNeighbours()

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

Definition at line 263 of file CaloNeighbours.cxx.

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

◆ getType()

NEIGHBOURTYPE CaloNeighbourRegion::getType ( ) const
inline

Definition at line 62 of file CaloNeighbours.h.

62  {
63  return m_type;
64  }

◆ initializeVectors()

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

Definition at line 240 of file CaloNeighbours.cxx.

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

◆ 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 181 of file CaloNeighbours.cxx.

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

◆ setPhi()

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

Definition at line 101 of file CaloNeighbours.cxx.

102 {
103  m_hasPhi = true;
104  m_iPhiSource = phi1;
105  m_iPhiTarget = phi2;
106 
107 }

◆ setSide()

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

Definition at line 92 of file CaloNeighbours.cxx.

93 {
94  m_hasSide = true;
95  m_iSideSource = side1;
96  m_iSideTarget = side2;
97 }

◆ setSourceRange()

void CaloNeighbourRegion::setSourceRange ( const Range theRange)

Definition at line 72 of file CaloNeighbours.cxx.

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

◆ setTargetRange()

void CaloNeighbourRegion::setTargetRange ( const Range theRange)

Definition at line 85 of file CaloNeighbours.cxx.

86 {
87  m_targetRange = theRange;
88 }

◆ setType()

void CaloNeighbourRegion::setType ( const NEIGHBOURTYPE  type)

Definition at line 65 of file CaloNeighbours.cxx.

66 {
67  m_type = type;
68 }

Member Data Documentation

◆ m_calo_id

const CaloCell_Base_ID* CaloNeighbourRegion::m_calo_id
private

Definition at line 76 of file CaloNeighbours.h.

◆ m_hasPhi

bool CaloNeighbourRegion::m_hasPhi
private

Definition at line 80 of file CaloNeighbours.h.

◆ m_hasSide

bool CaloNeighbourRegion::m_hasSide
private

Definition at line 83 of file CaloNeighbours.h.

◆ m_iPhiSource

int CaloNeighbourRegion::m_iPhiSource
private

Definition at line 81 of file CaloNeighbours.h.

◆ m_iPhiTarget

int CaloNeighbourRegion::m_iPhiTarget
private

Definition at line 81 of file CaloNeighbours.h.

◆ m_iSideSource

int CaloNeighbourRegion::m_iSideSource
private

Definition at line 84 of file CaloNeighbours.h.

◆ m_iSideTarget

int CaloNeighbourRegion::m_iSideTarget
private

Definition at line 84 of file CaloNeighbours.h.

◆ m_isValidMinus

bool CaloNeighbourRegion::m_isValidMinus
private

Definition at line 86 of file CaloNeighbours.h.

◆ m_isValidPlus

bool CaloNeighbourRegion::m_isValidPlus
private

Definition at line 86 of file CaloNeighbours.h.

◆ m_maxHashMinus

IdentifierHash CaloNeighbourRegion::m_maxHashMinus
private

Definition at line 88 of file CaloNeighbours.h.

◆ m_maxHashPlus

IdentifierHash CaloNeighbourRegion::m_maxHashPlus
private

Definition at line 88 of file CaloNeighbours.h.

◆ m_minHashMinus

IdentifierHash CaloNeighbourRegion::m_minHashMinus
private

Definition at line 88 of file CaloNeighbours.h.

◆ m_minHashPlus

IdentifierHash CaloNeighbourRegion::m_minHashPlus
private

Definition at line 88 of file CaloNeighbours.h.

◆ m_name

std::string CaloNeighbourRegion::m_name
private

Definition at line 74 of file CaloNeighbours.h.

◆ m_neighbours_minus

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

Definition at line 90 of file CaloNeighbours.h.

◆ m_neighbours_plus

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

Definition at line 89 of file CaloNeighbours.h.

◆ m_sourceRange

Range CaloNeighbourRegion::m_sourceRange
private

Definition at line 78 of file CaloNeighbours.h.

◆ m_targetRange

Range CaloNeighbourRegion::m_targetRange
private

Definition at line 78 of file CaloNeighbours.h.

◆ m_type

NEIGHBOURTYPE CaloNeighbourRegion::m_type
private

Definition at line 75 of file CaloNeighbours.h.


The documentation for this class was generated from the following files:
CaloNeighbourRegion::m_iPhiSource
int m_iPhiSource
Definition: CaloNeighbours.h:81
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
CaloNeighbourRegion::TILESECTION
@ TILESECTION
Definition: CaloNeighbours.h:44
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CaloNeighbourRegion::m_hasPhi
bool m_hasPhi
Definition: CaloNeighbours.h:80
CaloNeighbourRegion::m_isValidPlus
bool m_isValidPlus
Definition: CaloNeighbours.h:86
Range::match
int match(const ExpandedIdentifier &id) const
Match an identifier.
Definition: DetectorDescription/Identifier/src/Range.cxx:1333
AtlasDetectorID::is_lar_fcal
bool is_lar_fcal(Identifier id) const
Definition: AtlasDetectorID.h:839
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloNeighbourRegion::TILEPHI
@ TILEPHI
Definition: CaloNeighbours.h:44
CaloNeighbourRegion::REGION
@ REGION
Definition: CaloNeighbours.h:44
CaloNeighbourRegion::m_isValidMinus
bool m_isValidMinus
Definition: CaloNeighbours.h:86
CaloNeighbourRegion::m_name
std::string m_name
Definition: CaloNeighbours.h:74
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:108
CaloNeighbourRegion::getId
int getId(ExpandedIdentifier &id, Identifier &rID, const Range &theRange, const int side=+1, const int dphi=0) const
Definition: CaloNeighbours.cxx:111
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
CaloNeighbourRegion::m_maxHashPlus
IdentifierHash m_maxHashPlus
Definition: CaloNeighbours.h:88
CaloNeighbourRegion::m_minHashMinus
IdentifierHash m_minHashMinus
Definition: CaloNeighbours.h:88
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:78
CaloNeighbourRegion::m_hasSide
bool m_hasSide
Definition: CaloNeighbours.h:83
CaloNeighbourRegion::m_sourceRange
Range m_sourceRange
Definition: CaloNeighbours.h:78
CaloNeighbourRegion::FCALETA
@ FCALETA
Definition: CaloNeighbours.h:44
CaloNeighbourRegion::m_type
NEIGHBOURTYPE m_type
Definition: CaloNeighbours.h:75
TRT::Hit::side
@ side
Definition: HitInfo.h:83
CaloNeighbourRegion::m_minHashPlus
IdentifierHash m_minHashPlus
Definition: CaloNeighbours.h:88
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV0.cxx:564
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloNeighbourRegion::SIDE
@ SIDE
Definition: CaloNeighbours.h:44
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
nextInCalo
@ nextInCalo
Definition: CaloNeighbours.h:31
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
CaloNeighbourRegion::m_maxHashMinus
IdentifierHash m_maxHashMinus
Definition: CaloNeighbours.h:88
CaloNeighbourRegion::TILEETA
@ TILEETA
Definition: CaloNeighbours.h:44
AtlasDetectorID::is_lar_hec
bool is_lar_hec(Identifier id) const
Definition: AtlasDetectorID.h:829
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
CaloNeighbourRegion::m_neighbours_minus
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_minus
Definition: CaloNeighbours.h:90
CaloNeighbourRegion::m_iSideSource
int m_iSideSource
Definition: CaloNeighbours.h:84
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloNeighbourRegion::m_neighbours_plus
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_plus
Definition: CaloNeighbours.h:89
CaloNeighbourRegion::m_iSideTarget
int m_iSideTarget
Definition: CaloNeighbours.h:84
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,...
CaloNeighbourRegion::TILESAMPL
@ TILESAMPL
Definition: CaloNeighbours.h:44
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloNeighbourRegion::SAMPL
@ SAMPL
Definition: CaloNeighbours.h:44
CaloNeighbourRegion::m_calo_id
const CaloCell_Base_ID * m_calo_id
Definition: CaloNeighbours.h:76
CaloNeighbourRegion::m_iPhiTarget
int m_iPhiTarget
Definition: CaloNeighbours.h:81
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:116
SIDE
SIDE
Definition: CellClusterLinkTool.h:52
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
IdentifierHash
Definition: IdentifierHash.h:38
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
AtlasDetectorID::is_lar_em
bool is_lar_em(Identifier id) const
Definition: AtlasDetectorID.h:818
readCCLHist.float
float
Definition: readCCLHist.py:83
CaloNeighbourRegion::ETA
@ ETA
Definition: CaloNeighbours.h:44
CaloNeighbourRegion::FCALPHI
@ FCALPHI
Definition: CaloNeighbours.h:44
CaloNeighbourRegion::PHI
@ PHI
Definition: CaloNeighbours.h:44