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;
141 std::vector<DetId> vNeighborsDetId;
143 vNeighborsDetId.push_back(neighbor);
145 return vNeighborsDetId;
150 std::vector<DetId> vNeighborsDetId;
152 vNeighborsDetId.push_back(neighbor);
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++)
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());
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());
321 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
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());
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());
355 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
358 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
380 int aieta=
id.ietaAbs();
385 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
393 if (!
valid(neighbors[0])) n=0;
400 int aieta=
id.ietaAbs();
411 }
else if (aieta==1) {
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();
496 int nDepthBins, startingBin;
501 if(depth > nDepthBins) {
513 (ieta > 0) ? ++ieta : --ieta;
517 (ieta > 0) ? --ieta : ++ieta;
530 int ieta = detId.
ieta();
533 int nDepthBins, startingBin;
543 depth = (etaRing<=14) ? 1 : 2;
550 (ieta > 0) ? --ieta : ++ieta;
551 }
else if (depth <= 0) {
556 ieta = (ieta > 0) ? etaRing : -etaRing;
580 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
584 readoutDepths = pos->second;
593 std::vector<int> readoutDepths;
595 int d1 = std::lower_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
596 int d2 = std::upper_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
597 return std::pair<int, int>(d1, d2);
604 const int ip (hid.
iphi() ) ;
605 const int ie (hid.
ietaAbs() ) ;
606 const int dp (hid.
depth() ) ;
607 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
609 ( ip - 1 )*18 + dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf :
611 2*
kHBhalf + ( ip - 1 )*8 + ( ip/2 )*20 +
612 ( ( ie==16 || ie==17 ) ? ie - 16 :
613 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) + dp - 1 :
614 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) + dp - 1 :
615 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) + dp - 1 :
616 26 + 2*( ie - 29 ) + dp - 1 ) ) ) ) + zn*
kHEhalf :
621 ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
622 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf : 0xFFFFFFFFu ) ) ) ) ;
629 const int ip (hid.
iphi() ) ;
630 const int ie (hid.
ietaAbs() ) ;
631 const int dp (hid.
depth() ) ;
632 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
633 unsigned int retval = 0xFFFFFFFFu;
635 retval=( ip - 1 )*18 + dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf;
644 const int ip (hid.
iphi() ) ;
645 const int ie (hid.
ietaAbs() ) ;
646 const int dp (hid.
depth() ) ;
647 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
648 unsigned int retval = 0xFFFFFFFFu;
650 retval=( ip - 1 )*8 + ( ip/2 )*20 +
651 ( ( ie==16 || ie==17 ) ? ie - 16 :
652 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) + dp - 1 :
653 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) + dp - 1 :
654 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) + dp - 1 :
655 26 + 2*( ie - 29 ) + dp - 1 ) ) ) ) + zn*
kHEhalf;
664 const int ip (hid.
iphi() ) ;
665 const int ie (hid.
ietaAbs() ) ;
666 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
668 unsigned int retval = 0xFFFFFFFFu;
670 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
672 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
679 const int ip (hid.
iphi() ) ;
680 const int ie (hid.
ietaAbs() ) ;
681 const int dp (hid.
depth() ) ;
682 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
684 unsigned int retval = 0xFFFFFFFFu;
686 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
687 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf;
689 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
690 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf;
698 unsigned int ietaAbs = tid.
ietaAbs();
699 unsigned int iphi = tid.
iphi();
702 if ((iphi-1)%4==0) index = (iphi-1)*32 + (ietaAbs-1) - (12*((iphi-1)/4));
703 else index = (iphi-1)*28 + (ietaAbs-1) + (4*(((iphi-1)/4)+1));
705 if (zside == -1) index +=
kHThalf;
713 int ieta = tid.
ieta();
714 int iphi = tid.
iphi();
716 unsigned int index=0xFFFFFFFFu;
726 index = ((iphi+1)/4-1) + 18*channel + 27*(ieta+1);
731 if (channel>2) channel-=1;
732 index = ((iphi+1)/4-1) + 18*channel + 54*(ieta+1) + 108;
736 if (channel==8) channel = 2;
738 index = (iphi-1)/18 + 4*channel + 6*(ieta+1) + 324;
744 index = (ieta+2) + 420;
748 if (ieta<0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 348;
749 else if (ieta>0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 6 + 348;
750 else index = ((iphi+1)/6-1) + 36*channel + 6*(ieta+2) + 348;
753 std::cout <<
"HCAL Det Id not valid!" << std::endl;
761 if (
abs(ieta)==4) index = ((iphi-1)%36) + (((zside+1)*36)/2) + 72 + 425;
762 else index = (iphi-1) + (36*(zside+1)*2) + 425;
770 unsigned int retval(0);
792 if (hid.
ieta()>0) retval+=(hid.
iphi()-1)+72*(hid.
ieta()-1);
793 else retval+=(hid.
iphi()-1)+72*(30+hid.
ieta());
797 if (hid.
ieta()>0) retval+=2*72*(hid.
ieta()-29);
798 else retval+=2*72*((41+13)+hid.
ieta());
823 ip += 1 + ( in>21 ? 2 : 0 ) ;
824 if( 3 == ip%4 ) in -= 22 ;
834 ie = 1 + ( in - 15*( ip - 1 ) ) ;
835 }
else if ( in > 2*
kHBhalf - 1 ) {
843 if( 0 == ip%2 ) in %= 28 ;
844 ie = 15 + ( in<2 ? 1 + in : 2 +
845 ( in<20 ? 1 + ( in - 2 )/2 : 9 +
846 ( in<26 ? 1 + ( in - 20 )/3 : 3 ) ) ) ;
849 ( in<20 ? 1 + ( in - 2 )%2 :
850 ( in<26 ? 1 + ( in - 20 )%3 :
851 ( 1 + ( in - 26 )%2 ) ) ) ) ) ;
873 ip = (in - dp + 1)%144;
875 ie = (in - dp + 1 - 2*(ip -1))/144;
876 if (ie > 12) {ie = 54 -ie; iz = -1;}
877 else {ie += 29; iz = 1;}
883 ie = (in - ip + 1)/72;
884 if (ie > 14) {ie = 30 -ie; iz = -1;}
885 else {ie += 1; iz = 1;}
886 }
else if (denseid >= (
HBSize_)) {
893 if (ie > 13) {ie = 43 - ie; iz = -1;}
894 else {ie += 16; iz = 1;}
901 if (ie > 15) {ie = 32 - ie; iz = -1;}
902 else {ie += 1; iz = 1;}
906 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
bool decrementDepth(HcalDetId &id) 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
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