28 firstHEDoublePhiRing_((mode==HcalTopologyMode::
H2 || mode==HcalTopologyMode::
H2HE)?(22):(21)),
29 firstHFQuadPhiRing_(40),
30 firstHETripleDepthRing_((mode==HcalTopologyMode::
H2 || mode==HcalTopologyMode::
H2HE)?(24):(27)),
33 maxDepthHB_(maxDepthHB),
34 maxDepthHE_(maxDepthHE),
35 HBSize_(kHBSizePreLS1),
36 HESize_(kHESizePreLS1),
37 HOSize_(kHOSizePreLS1),
38 HFSize_(kHFSizePreLS1),
39 numberOfShapes_(( mode==HcalTopologyMode::
SLHC ) ? 500 : 87 ) {
49 HESize_= maxDepthHE*(29-16+1)*72*2;
75 switch (
id.subdet()) {
108 std::vector<DetId> vNeighborsDetId;
111 vNeighborsDetId.push_back(
DetId(neighbors[
i].rawId()));
112 return vNeighborsDetId;
116 std::vector<DetId> vNeighborsDetId;
119 vNeighborsDetId.push_back(
DetId(neighbors[
i].rawId()));
120 return vNeighborsDetId;
124 std::vector<DetId> vNeighborsDetId;
127 vNeighborsDetId.push_back(
DetId(neighbor.
rawId()));
128 return vNeighborsDetId;
132 std::vector<DetId> vNeighborsDetId;
135 vNeighborsDetId.push_back(
DetId(neighbor.
rawId()));
136 return vNeighborsDetId;
143 std::vector<DetId> vNeighborsDetId;
146 vNeighborsDetId.push_back(neighbor);
148 return vNeighborsDetId;
152 std::cout <<
"HcalTopology::down() not yet implemented" << std::endl;
153 std::vector<DetId> vNeighborsDetId;
154 return vNeighborsDetId;
174 int depth_l=
std::min(depth1,depth2);
175 int depth_h=
std::max(depth1,depth2);
178 for (
int ieta=ieta_l; ieta<=ieta_h; ieta++)
179 for (
int iphi=iphi_l; iphi<=iphi_h; iphi++)
180 for (
int depth=depth_l; depth<=depth_h; depth++) {
218 const int ie (
id.ietaAbs());
219 const int ip (
id.iphi());
220 const int dp (
id.depth());
222 return ( ( ip >= 1 ) &&
229 ( ( ( ie == 15 ) || ( ie == 16 ) ) &&
249 ( ip%2 == 1 ) ) ) ) ||
260 ( ip%4 == 3 ) ) ) ) ) ) ;
267 int aieta=
id.ietaAbs();
268 int depth=
id.depth();
278 if (aieta>
lastHBRing() || depth>2 || (aieta<=14 && depth>1)) ok=
false;
289 if (aieta>
lastHORing() || iphi>IPHI_MAX || depth!=4) ok=
false;
303 switch (
id.subdet()) {
307 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.depth());
311 if (
id.iphi()==
IPHI_MAX-1) neighbor=
HcalDetId(
id.subdet(),
id.ieta(),1,
id.depth());
312 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.depth());
315 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.depth());
320 if (
id.iphi()==
IPHI_MAX-1) neighbor=
HcalDetId(
id.subdet(),
id.ieta(),3,
id.depth());
321 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.depth());
323 if (
id.iphi()==
IPHI_MAX-1) neighbor=
HcalDetId(
id.subdet(),
id.ieta(),1,
id.depth());
324 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.depth());
337 switch (
id.subdet()) {
341 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.depth());
345 if (
id.iphi()==1) neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
IPHI_MAX-1,
id.depth());
346 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.depth());
349 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.depth());
354 if (
id.iphi()==3) neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
IPHI_MAX-1,
id.depth());
355 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.depth());
357 if (
id.iphi()==1) neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
IPHI_MAX-1,
id.depth());
358 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.depth());
368 if (
id.zside()==1)
return incAIEta(
id,neighbors);
373 if (
id.zside()==1)
return decAIEta(
id,neighbors);
380 int aieta=
id.ietaAbs();
383 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.zside(),
id.iphi()-1,
id.depth());
385 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.depth());
391 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.zside(),
id.iphi(),
id.depth());
393 if (!
valid(neighbors[0])) n=0;
400 int aieta=
id.ietaAbs();
404 neighbors[0]=
HcalDetId(
id.subdet(),(aieta-1)*
id.zside(),
id.iphi(),
id.depth());
405 neighbors[1]=
HcalDetId(
id.subdet(),(aieta-1)*
id.zside(),
id.iphi()+1,
id.depth());
408 neighbors[0]=
HcalDetId(
id.subdet(),(aieta-1)*
id.zside(),
id.iphi(),
id.depth());
409 if (
id.iphi()==
IPHI_MAX-1) neighbors[1]=
HcalDetId(
id.subdet(),(aieta-1)*
id.zside(),1,
id.depth());
410 else neighbors[1]=
HcalDetId(
id.subdet(),(aieta-1)*
id.zside(),
id.iphi()+2,
id.depth());
411 }
else if (aieta==1) {
412 neighbors[0]=
HcalDetId(
id.subdet(),-aieta*
id.zside(),
id.iphi(),
id.depth());
418 neighbors[0]=
HcalDetId(
id.subdet(),(aieta-1)*
id.zside(),
id.iphi(),
id.depth());
420 if (!
valid(neighbors[0]) && n==2) {
421 if (!
valid(neighbors[1])) n=0;
424 neighbors[0]=neighbors[1];
427 if (n==2 && !
valid(neighbors[1])) n=1;
428 if (n==1 && !
valid(neighbors[0])) n=0;
435 int & nDepthBins,
int & startingBin)
const {
467 }
else if (etaRing==17) {
485 std::cerr <<
"Bad HCAL subdetector " << subdet << std::endl;
493 int ieta = detId.
ieta();
495 int depth = detId.
depth();
496 int nDepthBins, startingBin;
501 if(depth > nDepthBins) {
513 (ieta > 0) ? ++ieta : --ieta;
517 (ieta > 0) ? --ieta : ++ieta;
545 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
549 readoutDepths = pos->second;
558 std::vector<int> readoutDepths;
560 int d1 = std::lower_bound(readoutDepths.begin(), readoutDepths.end(), depth) - readoutDepths.begin();
561 int d2 = std::upper_bound(readoutDepths.begin(), readoutDepths.end(), depth) - readoutDepths.begin();
562 return std::pair<int, int>(d1, d2);
569 const int ip (hid.
iphi() ) ;
570 const int ie (hid.
ietaAbs() ) ;
572 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
574 ( ip - 1 )*18 +
dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf :
576 2*
kHBhalf + ( ip - 1 )*8 + ( ip/2 )*20 +
577 ( ( ie==16 || ie==17 ) ? ie - 16 :
578 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) +
dp - 1 :
579 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) +
dp - 1 :
580 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) +
dp - 1 :
581 26 + 2*( ie - 29 ) +
dp - 1 ) ) ) ) + zn*
kHEhalf :
586 ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
587 2*( ie - 29 ) + (
dp - 1 ) + zn*
kHFhalf : 0xFFFFFFFFu ) ) ) ) ;
594 const int ip (hid.
iphi() ) ;
595 const int ie (hid.
ietaAbs() ) ;
597 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
598 unsigned int retval = 0xFFFFFFFFu;
600 retval=( ip - 1 )*18 +
dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf;
609 const int ip (hid.
iphi() ) ;
610 const int ie (hid.
ietaAbs() ) ;
612 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
613 unsigned int retval = 0xFFFFFFFFu;
615 retval=( ip - 1 )*8 + ( ip/2 )*20 +
616 ( ( ie==16 || ie==17 ) ? ie - 16 :
617 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) +
dp - 1 :
618 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) +
dp - 1 :
619 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) +
dp - 1 :
620 26 + 2*( ie - 29 ) +
dp - 1 ) ) ) ) + zn*
kHEhalf;
629 const int ip (hid.
iphi() ) ;
630 const int ie (hid.
ietaAbs() ) ;
631 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
633 unsigned int retval = 0xFFFFFFFFu;
635 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
637 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
644 const int ip (hid.
iphi() ) ;
645 const int ie (hid.
ietaAbs() ) ;
647 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
649 unsigned int retval = 0xFFFFFFFFu;
651 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
654 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
662 int zside = tid.
zside();
663 unsigned int ietaAbs = tid.
ietaAbs();
664 unsigned int iphi = tid.
iphi();
667 if ((iphi-1)%4==0) index = (iphi-1)*32 + (ietaAbs-1) - (12*((iphi-1)/4));
668 else index = (iphi-1)*28 + (ietaAbs-1) + (4*(((iphi-1)/4)+1));
670 if (zside == -1) index +=
kHThalf;
678 int ieta = tid.
ieta();
679 int iphi = tid.
iphi();
680 int zside = tid.
zside();
681 unsigned int index=0xFFFFFFFFu;
691 index = ((iphi+1)/4-1) + 18*channel + 27*(ieta+1);
696 if (channel>2) channel-=1;
697 index = ((iphi+1)/4-1) + 18*channel + 54*(ieta+1) + 108;
701 if (channel==8) channel = 2;
703 index = (iphi-1)/18 + 4*channel + 6*(ieta+1) + 324;
709 index = (ieta+2) + 420;
713 if (ieta<0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 348;
714 else if (ieta>0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 6 + 348;
715 else index = ((iphi+1)/6-1) + 36*channel + 6*(ieta+2) + 348;
718 std::cout <<
"HCAL Det Id not valid!" << std::endl;
726 if (
abs(ieta)==4) index = ((iphi-1)%36) + (((zside+1)*36)/2) + 72 + 425;
727 else index = (iphi-1) + (36*(zside+1)*2) + 425;
735 unsigned int retval(0);
757 if (hid.
ieta()>0) retval+=(hid.
iphi()-1)+72*(hid.
ieta()-1);
758 else retval+=(hid.
iphi()-1)+72*(30+hid.
ieta());
762 if (hid.
ieta()>0) retval+=2*72*(hid.
ieta()-29);
763 else retval+=2*72*((41+13)+hid.
ieta());
788 ip += 1 + ( in>21 ? 2 : 0 ) ;
789 if( 3 == ip%4 ) in -= 22 ;
799 ie = 1 + ( in - 15*( ip - 1 ) ) ;
800 }
else if ( in > 2*
kHBhalf - 1 ) {
808 if( 0 == ip%2 ) in %= 28 ;
809 ie = 15 + ( in<2 ? 1 + in : 2 +
810 ( in<20 ? 1 + ( in - 2 )/2 : 9 +
811 ( in<26 ? 1 + ( in - 20 )/3 : 3 ) ) ) ;
814 ( in<20 ? 1 + ( in - 2 )%2 :
815 ( in<26 ? 1 + ( in - 20 )%3 :
816 ( 1 + ( in - 26 )%2 ) ) ) ) ) ;
838 ip = (in - dp + 1)%144;
840 ie = (in - dp + 1 - 2*(ip -1))/144;
841 if (ie > 12) {ie = 54 -ie; iz = -1;}
842 else {ie += 29; iz = 1;}
848 ie = (in - ip + 1)/72;
849 if (ie > 14) {ie = 30 -ie; iz = -1;}
850 else {ie += 1; iz = 1;}
851 }
else if (denseid >= (
HBSize_)) {
858 if (ie > 13) {ie = 43 - ie; iz = -1;}
859 else {ie += 16; iz = 1;}
866 if (ie > 15) {ie = 32 - ie; iz = -1;}
867 else {ie += 1; iz = 1;}
871 return HcalDetId( sd, iz*
int(ie), ip, dp );
int zside() const
get the z-side of the tower (1/-1)
int decIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
unsigned int detId2denseIdPreLS1(const DetId &id) const
virtual unsigned int detId2denseId(const DetId &id) const
return a linear packed id
void excludeSubdetector(HcalSubdetector subdet)
HcalSubdetector subdet() const
get the subdetector
CalibDetType calibFlavor() const
get the flavor of this calibration detid
virtual std::vector< DetId > down(const DetId &id) const
int zside() const
get the z-side of the cell (1/-1)
virtual std::vector< DetId > south(const DetId &id) const
unsigned int detId2denseIdHT(const DetId &id) const
return a linear packed id from HT
unsigned int detId2denseIdHF(const DetId &id) const
return a linear packed id from HF
void exclude(const HcalDetId &id)
int nPhiBins(int etaRing) const
how many phi segments in this ring
int incIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
unsigned int detId2denseIdHB(const DetId &id) const
return a linear packed id from HB
bool decIPhi(const HcalDetId &id, HcalDetId &neighbor) const
bool validHcal(const HcalDetId &id) const
int ieta() const
get the rbx name (if relevant)
virtual int topoVersion() const
return a version which identifies the given topology
uint32_t rawId() const
get the raw id
bool isExcluded(const HcalDetId &id) const
int depth() const
get the tower depth
bool incIPhi(const HcalDetId &id, HcalDetId &neighbor) const
HcalTopology(HcalTopologyMode::Mode mode, int maxDepthHB, int maxDepthHE, HcalTopologyMode::TriggerMode tmode=HcalTopologyMode::tm_LHC_PreLS1)
bool validRaw(const HcalDetId &id) const
const T & max(const T &a, const T &b)
int decAIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
HcalTopologyMode::Mode mode_
void setDepthSegmentation(unsigned ring, const std::vector< int > &readoutDepths)
int firstHETripleDepthRing() const
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
virtual std::vector< DetId > west(const DetId &id) const
void depthBinInformation(HcalSubdetector subdet, int etaRing, int &nDepthBins, int &startingBin) const
finds the number of depth bins and which is the number to start with
virtual DetId denseId2detId(unsigned int) const
return a linear packed id
int firstHEDoublePhiRing() const
SegmentationMap depthSegmentation_
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the low-edge iphi (if relevant)
bool validDetIdPreLS1(const HcalDetId &id) const
int iphi() const
get the cell iphi
bool incrementDepth(HcalDetId &id) const
std::pair< int, int > segmentBoundaries(unsigned ring, unsigned depth) const
int zside() const
get the sign of ieta (+/-1)
void getDepthSegmentation(unsigned ring, std::vector< int > &readoutDepths) const
virtual std::vector< DetId > north(const DetId &id) const
virtual bool valid(const DetId &id) const
int firstHFQuadPhiRing() const
virtual std::vector< DetId > up(const DetId &id) const
int cboxChannel() const
get the calibration box channel (if relevant)
unsigned int detId2denseIdHO(const DetId &id) const
return a linear packed id from HO
std::vector< HcalDetId > exclusionList_
unsigned int detId2denseIdHE(const DetId &id) const
return a linear packed id from HE
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
virtual std::vector< DetId > east(const DetId &id) const
volatile std::atomic< bool > shutdown_flag false
int incAIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
unsigned int detId2denseIdCALIB(const DetId &id) const
return a linear packed id from CALIB
int ietaAbs() const
get the absolute value of the tower ieta
int iphi() const
get the tower iphi
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
static const int IPHI_MAX