BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecNeighbor Class Reference

#include <EmcRecNeighbor.h>

Public Member Functions

 EmcRecNeighbor ()
 
 ~EmcRecNeighbor ()
 
bool IsNeighbor (const Identifier &id1, const Identifier &id2)
 
bool IsNextNeighbor (const Identifier &id1, const Identifier &id2)
 
RecEmcIDVector GetNeighbors (const Identifier &id)
 
RecEmcIDVector GetNextNeighbors (const Identifier &id)
 

Detailed Description

Definition at line 11 of file EmcRecNeighbor.h.

Constructor & Destructor Documentation

◆ EmcRecNeighbor()

EmcRecNeighbor::EmcRecNeighbor ( )

Definition at line 11 of file EmcRecNeighbor.cxx.

12{}

◆ ~EmcRecNeighbor()

EmcRecNeighbor::~EmcRecNeighbor ( )

Definition at line 14 of file EmcRecNeighbor.cxx.

15{}

Member Function Documentation

◆ GetNeighbors()

RecEmcIDVector EmcRecNeighbor::GetNeighbors ( const Identifier id)

Definition at line 54 of file EmcRecNeighbor.cxx.

55{
56 unsigned int barrel_ec=EmcID::barrel_ec(id);
57 unsigned int theta=EmcID::theta_module(id);
58 unsigned int phi=EmcID::phi_module(id);
59
60 RecEmcID aNb;
61 RecEmcIDVector NeighborVec;
62
63 NeighborVec.clear();
64
65 if(barrel_ec==EmcID::getBARREL()) {
66 unsigned int phip=999;
67 unsigned int phin=999;
68 if(phi==EmcID::getPHI_BARREL_MIN()) {
70 phin=phi+1;
71 }
72 if(phi==EmcID::getPHI_BARREL_MAX()) {
73 phip=phi-1;
75 }
76 if((phi>EmcID::getPHI_BARREL_MIN()) &&
78 phip=phi-1;
79 phin=phi+1;
80 }
81
82 aNb=EmcID::crystal_id(barrel_ec,theta,phip);
83 NeighborVec.push_back(aNb);
84 aNb=EmcID::crystal_id(barrel_ec,theta,phin);
85 NeighborVec.push_back(aNb);
86
87 if((theta==EmcID::getTHETA_BARREL_MIN()) || (theta==EmcID::getTHETA_BARREL_MAX())) {
88 unsigned int east_west=0;
89 if(theta==EmcID::getTHETA_BARREL_MIN()) { //theta=0
90 aNb=EmcID::crystal_id(barrel_ec,theta+1,phip);
91 NeighborVec.push_back(aNb);
92 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi);
93 NeighborVec.push_back(aNb);
94 aNb=EmcID::crystal_id(barrel_ec,theta+1,phin);
95 NeighborVec.push_back(aNb);
96 east_west=EmcID::getENDCAP_EAST();
97 } else { //theta=43
98 aNb=EmcID::crystal_id(barrel_ec,theta-1,phip);
99 NeighborVec.push_back(aNb);
100 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi);
101 NeighborVec.push_back(aNb);
102 aNb=EmcID::crystal_id(barrel_ec,theta-1,phin);
103 NeighborVec.push_back(aNb);
104 east_west=EmcID::getENDCAP_WEST();
105 }
106 //neighbors in endcap
108 /(EmcID::getPHI_BARREL_MAX()+1); //phi1=phi*4/5
110 NeighborVec.push_back(aNb);
111 if(phi%5==0) {
112 if(phi==EmcID::getPHI_BARREL_MIN()) { //phi=0
115 NeighborVec.push_back(aNb);
116 } else {
118 NeighborVec.push_back(aNb);
119 }
120 } else {
121 if(phi==EmcID::getPHI_BARREL_MAX()) { //phi=119
123 EmcID::getPHI_ENDCAP_MIN()); //id=(0,5,0)
124 NeighborVec.push_back(aNb);
125 } else {
127 NeighborVec.push_back(aNb);
128 }
129 }
130 }
131
132 else if((theta>EmcID::getTHETA_BARREL_MIN()) && (theta<EmcID::getTHETA_BARREL_MAX())) {
133 aNb=EmcID::crystal_id(barrel_ec,theta+1,phip);
134 NeighborVec.push_back(aNb);
135 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi);
136 NeighborVec.push_back(aNb);
137 aNb=EmcID::crystal_id(barrel_ec,theta+1,phin);
138 NeighborVec.push_back(aNb);
139 aNb=EmcID::crystal_id(barrel_ec,theta-1,phip);
140 NeighborVec.push_back(aNb);
141 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi);
142 NeighborVec.push_back(aNb);
143 aNb=EmcID::crystal_id(barrel_ec,theta-1,phin);
144 NeighborVec.push_back(aNb);
145 }
146 }
147
148 else if((barrel_ec==EmcID::getENDCAP_EAST()) || //endcap
149 (barrel_ec==EmcID::getENDCAP_WEST())) {
150 unsigned int phiInSec=(EmcID::getPHI_ENDCAP_MAX(theta)+1)/16;
151 unsigned int sector=phi/phiInSec;
152 unsigned int phip=999;
153 unsigned int phin=999;
154 unsigned int InvalidPhi = 999;
155 if(phi==EmcID::getPHI_ENDCAP_MIN()) {
156 phip=EmcID::getPHI_ENDCAP_MAX(theta);
157 phin=phi+1;
158 }
159 else if(phi==EmcID::getPHI_ENDCAP_MAX(theta)) {
160 phip=phi-1;
162 }
163 else if((phi==4*phiInSec-1) || (phi==12*phiInSec-1)){ //crystal next to the gap
164 phip=phi-1;
165 phin=phi+1; //InvalidPhi;
166 }
167 else if((phi==4*phiInSec) || (phi==12*phiInSec)) {
168 phip=phi-1; //InvalidPhi;
169 phin=phi+1;
170 }
171 else if(((phi>EmcID::getPHI_ENDCAP_MIN())&&(phi<4*phiInSec-1)) ||
172 ((phi>4*phiInSec)&&(phi<12*phiInSec-1)) ||
173 ((phi>12*phiInSec)&&(phi<EmcID::getPHI_ENDCAP_MAX(theta)))) {
174 phip=phi-1;
175 phin=phi+1;
176 }
177
178 if(phip!=InvalidPhi) {
179 aNb=EmcID::crystal_id(barrel_ec,theta,phip);
180 NeighborVec.push_back(aNb);
181 }
182 if(phin!=InvalidPhi) {
183 aNb=EmcID::crystal_id(barrel_ec,theta,phin);
184 NeighborVec.push_back(aNb);
185 }
186
187 if(theta==EmcID::getTHETA_ENDCAP_MIN()) { //layer 0
188 if(phip!=InvalidPhi) {
189 aNb=EmcID::crystal_id(barrel_ec,theta+1,phip);
190 NeighborVec.push_back(aNb);
191 }
192 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi);
193 NeighborVec.push_back(aNb);
194 if(phin!=InvalidPhi) {
195 aNb=EmcID::crystal_id(barrel_ec,theta+1,phin);
196 NeighborVec.push_back(aNb);
197 }
198 }
199
200 else if(theta==EmcID::getTHETA_ENDCAP_MAX()) { //layer 5
201 if(phip!=InvalidPhi) {
202 aNb=EmcID::crystal_id(barrel_ec,theta-1,phip);
203 NeighborVec.push_back(aNb);
204 }
205 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi);
206 NeighborVec.push_back(aNb);
207 if(phin!=InvalidPhi) {
208 aNb=EmcID::crystal_id(barrel_ec,theta-1,phin);
209 NeighborVec.push_back(aNb);
210 }
211
212 unsigned int phi1=phi*(EmcID::getPHI_BARREL_MAX()+1)/(EmcID::getPHI_ENDCAP_MAX(theta)+1);
213 unsigned int min_max=0;
214 if(barrel_ec==EmcID::getENDCAP_EAST()){
216 } else {
218 }
220 NeighborVec.push_back(aNb);
221 aNb=EmcID::crystal_id(EmcID::getBARREL(),min_max,phi1+1);
222 NeighborVec.push_back(aNb);
223 if(phi%4==0) {
224 if(phi==EmcID::getPHI_ENDCAP_MIN()) {
226 NeighborVec.push_back(aNb);
227 } else {
228 aNb=EmcID::crystal_id(EmcID::getBARREL(),min_max,phi1-1);
229 NeighborVec.push_back(aNb);
230 }
231 } else if(phi%4==3) {
232 if(phi==EmcID::getPHI_ENDCAP_MAX(theta)){
234 NeighborVec.push_back(aNb);
235 } else {
236 aNb=EmcID::crystal_id(EmcID::getBARREL(),min_max,phi1+2);
237 NeighborVec.push_back(aNb);
238 }
239 }
240 }
241
242 else if((theta==EmcID::getTHETA_ENDCAP_MIN()+1) || //layer 1,3
243 (theta==EmcID::getTHETA_ENDCAP_MIN()+3)) {
244 if(phip!=InvalidPhi) {
245 aNb=EmcID::crystal_id(barrel_ec,theta-1,phip);
246 NeighborVec.push_back(aNb);
247 }
248 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi);
249 NeighborVec.push_back(aNb);
250 if(phin!=InvalidPhi) {
251 aNb=EmcID::crystal_id(barrel_ec,theta-1,phin);
252 NeighborVec.push_back(aNb);
253 }
254
255 unsigned int phi1=phi*(phiInSec+1)/phiInSec;
256 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi1);
257 NeighborVec.push_back(aNb);
258 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi1+1);
259 NeighborVec.push_back(aNb);
260 if(phi%phiInSec==0) {
261 if(sector==0){
262 aNb=EmcID::crystal_id(barrel_ec,theta+1,EmcID::getPHI_ENDCAP_MAX(theta+1));
263 NeighborVec.push_back(aNb);
264 } else {
265 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi1-1);
266 NeighborVec.push_back(aNb);
267 }
268 } else if(phi%phiInSec==phiInSec-1) {
269 if(sector==15){
270 aNb=EmcID::crystal_id(barrel_ec,theta+1,EmcID::getPHI_ENDCAP_MIN());
271 NeighborVec.push_back(aNb);
272 } else {
273 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi1+2);
274 NeighborVec.push_back(aNb);
275 }
276 }
277 }
278
279 else if((theta==EmcID::getTHETA_ENDCAP_MIN()+2) || //layer 2,4
280 (theta==EmcID::getTHETA_ENDCAP_MIN()+4)) {
281 unsigned int phi1=phi*(phiInSec-1)/phiInSec;
282 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi1);
283 NeighborVec.push_back(aNb);
284 if(phi%phiInSec==0){
285 if(sector==0){
286 aNb=EmcID::crystal_id(barrel_ec,theta+1,EmcID::getPHI_ENDCAP_MAX(theta-1));
287 NeighborVec.push_back(aNb);
288 } else {
289 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi1-1);
290 NeighborVec.push_back(aNb);
291 }
292 } else {
293 if(phi==EmcID::getPHI_ENDCAP_MAX(theta)){
294 aNb=EmcID::crystal_id(barrel_ec,theta-1,EmcID::getPHI_ENDCAP_MIN());
295 NeighborVec.push_back(aNb);
296 } else {
297 aNb=EmcID::crystal_id(barrel_ec,theta-1,phi1+1);
298 NeighborVec.push_back(aNb);
299 }
300 }
301
302 if(phip!=InvalidPhi) {
303 aNb=EmcID::crystal_id(barrel_ec,theta+1,phip);
304 NeighborVec.push_back(aNb);
305 }
306 aNb=EmcID::crystal_id(barrel_ec,theta+1,phi);
307 NeighborVec.push_back(aNb);
308 if(phin!=InvalidPhi) {
309 aNb=EmcID::crystal_id(barrel_ec,theta+1,phin);
310 NeighborVec.push_back(aNb);
311 }
312 }
313 }
314
315 return NeighborVec;
316}
Double_t phi1
vector< RecEmcID > RecEmcIDVector
static unsigned int getPHI_BARREL_MAX()
Definition: EmcID.cxx:107
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
Definition: EmcID.cxx:71
static unsigned int getENDCAP_WEST()
Definition: EmcID.cxx:151
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: EmcID.cxx:38
static unsigned int getENDCAP_EAST()
Definition: EmcID.cxx:141
static unsigned int getTHETA_ENDCAP_MIN()
Definition: EmcID.cxx:103
static unsigned int getTHETA_ENDCAP_MAX()
Definition: EmcID.cxx:99
static unsigned int getBARREL()
Definition: EmcID.cxx:146
static unsigned int getTHETA_BARREL_MIN()
Definition: EmcID.cxx:95
static unsigned int getTHETA_BARREL_MAX()
Definition: EmcID.cxx:91
static unsigned int theta_module(const Identifier &id)
Definition: EmcID.cxx:43
static unsigned int getPHI_ENDCAP_MAX(const unsigned int theta)
Definition: EmcID.cxx:115
static unsigned int getPHI_ENDCAP_MIN()
Definition: EmcID.cxx:128
static unsigned int getPHI_BARREL_MIN()
Definition: EmcID.cxx:111
static unsigned int phi_module(const Identifier &id)
Definition: EmcID.cxx:48
void clear()
Reset to invalid state.
Definition: Identifier.h:152

Referenced by EmcRecHit2Cluster::Convert(), EmcRecShowerEnergy::Energy(), GetNextNeighbors(), IsNeighbor(), main(), EmcRecSeedEThreshold::Seed(), and EmcRecSeedLocalMax::Seed().

◆ GetNextNeighbors()

RecEmcIDVector EmcRecNeighbor::GetNextNeighbors ( const Identifier id)

Definition at line 319 of file EmcRecNeighbor.cxx.

320{
321 unsigned int barrel_ec=EmcID::barrel_ec(id);
322 unsigned int theta=EmcID::theta_module(id);
323 unsigned int phi=EmcID::phi_module(id);
324
325 RecEmcID aNb;
326 RecEmcIDVector NeighborVec;
327
328 NeighborVec.clear();
329
330 //if(barrel_ec==EmcID::getBARREL()) {
331 if(0) { //not used now
332 unsigned int phip,phipp;
333 unsigned int phin,phinn;
334 unsigned int thetap,thetapp;
335 unsigned int thetan,thetann;
336 unsigned int invalidTheta=999999;
337 if(phi==EmcID::getPHI_BARREL_MIN()) {
338 phipp=EmcID::getPHI_BARREL_MAX()-1;
340 phin=phi+1;
341 phinn=phi+2;
342 }
343 if(phi==EmcID::getPHI_BARREL_MIN()+1) {
345 phip=phi-1;
346 phin=phi+1;
347 phinn=phi+2;
348 }
349 if(phi==EmcID::getPHI_BARREL_MAX()-1) {
350 phipp=phi-2;
351 phip=phi-1;
352 phin=phi+1;
354 }
355 if(phi==EmcID::getPHI_BARREL_MAX()) {
356 phipp=phi-2;
357 phip=phi-1;
359 phinn=EmcID::getPHI_BARREL_MIN()+1;
360 }
361 if((phi>EmcID::getPHI_BARREL_MIN()+1) &&
362 (phi<EmcID::getPHI_BARREL_MAX()-1)) {
363 phipp=phi-2;
364 phip=phi-1;
365 phin=phi+1;
366 phinn=phi+2;
367 }
368
369 if(theta==EmcID::getTHETA_BARREL_MIN()) {
370 thetapp=invalidTheta;
371 thetap=invalidTheta;
372 thetan=theta+1;
373 thetann=theta+2;
374 }
375 if(theta==EmcID::getTHETA_BARREL_MIN()+1) {
376 thetapp=invalidTheta;
377 thetap=theta-1;
378 thetan=theta+1;
379 thetann=theta+2;
380 }
381 if((theta>EmcID::getTHETA_BARREL_MIN()+1) &&
382 (theta<EmcID::getTHETA_BARREL_MAX()-1)) {
383 thetapp=theta-2;
384 thetap=theta-1;
385 thetan=theta+1;
386 thetann=theta+2;
387 }
388 if(theta==EmcID::getTHETA_BARREL_MAX()-1) {
389 thetapp=theta-2;
390 thetap=theta-1;
391 thetan=theta+1;
392 thetann=invalidTheta;
393 }
394 if(theta==EmcID::getTHETA_BARREL_MAX()) {
395 thetapp=theta-2;
396 thetap=theta-1;
397 thetan=invalidTheta;
398 thetann=invalidTheta;
399 }
400
401 // Check them out.
402 //cout<<phipp<<" "<<phip<<" "<<phi<<" "<<phin<<" "<<phinn<<endl;
403 //cout<<thetapp<<" "<<thetap<<" "<<theta<<" "<<thetan<<" "<<thetann<<endl;
404
405 aNb=EmcID::crystal_id(barrel_ec,theta,phipp);
406 NeighborVec.push_back(aNb);
407 aNb=EmcID::crystal_id(barrel_ec,theta,phinn);
408 NeighborVec.push_back(aNb);
409
410 if(thetapp!=invalidTheta) {
411 aNb=EmcID::crystal_id(barrel_ec,thetapp,phipp);
412 NeighborVec.push_back(aNb);
413 aNb=EmcID::crystal_id(barrel_ec,thetapp,phip);
414 NeighborVec.push_back(aNb);
415 aNb=EmcID::crystal_id(barrel_ec,thetapp,phi);
416 NeighborVec.push_back(aNb);
417 aNb=EmcID::crystal_id(barrel_ec,thetapp,phin);
418 NeighborVec.push_back(aNb);
419 aNb=EmcID::crystal_id(barrel_ec,thetapp,phinn);
420 NeighborVec.push_back(aNb);
421 }
422 if(thetap!=invalidTheta) {
423 aNb=EmcID::crystal_id(barrel_ec,thetap,phipp);
424 NeighborVec.push_back(aNb);
425 aNb=EmcID::crystal_id(barrel_ec,thetap,phinn);
426 NeighborVec.push_back(aNb);
427 }
428 if(thetan!=invalidTheta) {
429 aNb=EmcID::crystal_id(barrel_ec,thetan,phipp);
430 NeighborVec.push_back(aNb);
431 aNb=EmcID::crystal_id(barrel_ec,thetan,phinn);
432 NeighborVec.push_back(aNb);
433 }
434 if(thetann!=invalidTheta) {
435 aNb=EmcID::crystal_id(barrel_ec,thetann,phipp);
436 NeighborVec.push_back(aNb);
437 aNb=EmcID::crystal_id(barrel_ec,thetann,phip);
438 NeighborVec.push_back(aNb);
439 aNb=EmcID::crystal_id(barrel_ec,thetann,phi);
440 NeighborVec.push_back(aNb);
441 aNb=EmcID::crystal_id(barrel_ec,thetann,phin);
442 NeighborVec.push_back(aNb);
443 aNb=EmcID::crystal_id(barrel_ec,thetann,phinn);
444 NeighborVec.push_back(aNb);
445 }
446 }
447
448 //else if((barrel_ec==EmcID::getENDCAP_EAST()) || //endcap
449 //(barrel_ec==EmcID::getENDCAP_WEST())) {
450 else {
451 RecEmcIDVector tmpNeighborVec,tmpNextNeighborVec;
452 ci_RecEmcIDVector ci_NV,ci_tmpNV,ci_tmpNV1,ci_tmpNNV;
453 tmpNeighborVec=GetNeighbors(id);
454 bool flag=false; //whether NeighborVec already includes this crystal
455 bool flagNeighbor=false; //whether this crystal belongs to NeighborVec
456
457 //------------------------------------------------------------------
458 for(ci_tmpNV=tmpNeighborVec.begin();
459 ci_tmpNV!=tmpNeighborVec.end();
460 ci_tmpNV++){
461 tmpNextNeighborVec=GetNeighbors(*ci_tmpNV);
462 //================================================================
463 for(ci_tmpNNV=tmpNextNeighborVec.begin();
464 ci_tmpNNV!=tmpNextNeighborVec.end();
465 ci_tmpNNV++){
466
467 for(ci_NV=NeighborVec.begin();
468 ci_NV!=NeighborVec.end();
469 ci_NV++){
470 if(*ci_tmpNNV==*ci_NV){ //this crystal is already included
471 flag=true;
472 continue;
473 }
474 }
475
476 if(!flag){ //find a new crystal
477 for(ci_tmpNV1=tmpNeighborVec.begin();
478 ci_tmpNV1!=tmpNeighborVec.end();
479 ci_tmpNV1++){
480 if(*ci_tmpNNV==*ci_tmpNV1){ //this crystal belongs to NeighborVec
481 flagNeighbor=true;
482 continue;
483 }
484 }
485
486 if(*ci_tmpNNV==id)
487 flagNeighbor=true;
488
489 if(!flagNeighbor)
490 NeighborVec.push_back(*ci_tmpNNV);
491 else
492 flagNeighbor=false;
493 }
494 else
495 flag=false;
496 }
497 //================================================================
498 }
499 //------------------------------------------------------------------
500 }
501
502 return NeighborVec;
503}
RecEmcIDVector::const_iterator ci_RecEmcIDVector
RecEmcIDVector GetNeighbors(const Identifier &id)

Referenced by EmcRecShowerEnergy::Energy(), IsNextNeighbor(), and main().

◆ IsNeighbor()

bool EmcRecNeighbor::IsNeighbor ( const Identifier id1,
const Identifier id2 
)

Definition at line 18 of file EmcRecNeighbor.cxx.

20{
21 bool is;
22 RecEmcIDVector NeighborVec;
24
25 is=false;
26 NeighborVec=GetNeighbors(id1);
27 for(ci_NV=NeighborVec.begin();
28 ci_NV!=NeighborVec.end();
29 ++ci_NV) {
30 if((*ci_NV)==id2) { is=true; }
31 }
32 return is;
33}

Referenced by EmcRecSeedEThreshold::Seed().

◆ IsNextNeighbor()

bool EmcRecNeighbor::IsNextNeighbor ( const Identifier id1,
const Identifier id2 
)

Definition at line 36 of file EmcRecNeighbor.cxx.

38{
39 bool is;
40 RecEmcIDVector NeighborVec;
42
43 is=false;
44 NeighborVec=GetNextNeighbors(id1);
45 for(ci_NV=NeighborVec.begin();
46 ci_NV!=NeighborVec.end();
47 ++ci_NV) {
48 if((*ci_NV)==id2) { is=true; }
49 }
50 return is;
51}
RecEmcIDVector GetNextNeighbors(const Identifier &id)

The documentation for this class was generated from the following files: