ATLAS Offline Software
Loading...
Searching...
No Matches
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.

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),
51 m_isValidMinus(false),
52 m_isValidPlus(false)
53{
54}
@ nextInCalo
NEIGHBOURTYPE m_type
const CaloCell_Base_ID * m_calo_id

◆ ~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}
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
int match(const ExpandedIdentifier &id) const
Match an identifier.

◆ 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}
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_minus
IdentifierHash m_maxHashPlus
IdentifierHash m_minHashPlus
IdentifierHash m_maxHashMinus
IdentifierHash m_minHashMinus
std::vector< std::unique_ptr< std::vector< IdentifierHash > > > m_neighbours_plus

◆ 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}
HWIdentifier id2
int getId(ExpandedIdentifier &id, Identifier &rID, const Range &theRange, const int side=+1, const int dphi=0) const

◆ 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.

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: