11 #include "CLHEP/Units/GlobalPhysicalConstants.h"
21 firstHERing_(999), lastHERing_(0),
22 firstHFRing_(29), lastHFRing_(41),
23 firstHORing_(1), lastHORing_(15),
24 firstHEDoublePhiRing_(999), firstHEQuadPhiRing_(999),
25 firstHFQuadPhiRing_(40), firstHETripleDepthRing_(999),
26 singlePhiBins_(72), doublePhiBins_(36) {
94 const double fiveDegInRad = 2*
M_PI/72;
108 std::cout <<
"Set segmentation for ring " <<
ring <<
" with "
109 << segmentation.size() <<
" elements:";
110 for (
unsigned int k=0;
k<segmentation.size(); ++
k)
131 mode_(mode), triggerMode_(tmode),
132 firstHBRing_(1), lastHBRing_(16),
133 firstHERing_(16), lastHERing_(29),
134 firstHFRing_(29), lastHFRing_(41),
135 firstHORing_(1), lastHORing_(15),
136 firstHEDoublePhiRing_((mode==HcalTopologyMode::
H2 || mode==HcalTopologyMode::
H2HE)?(22):(21)),
137 firstHEQuadPhiRing_(999), firstHFQuadPhiRing_(40),
138 firstHETripleDepthRing_((mode==HcalTopologyMode::
H2 || mode==HcalTopologyMode::
H2HE)?(24):(27)),
139 singlePhiBins_(72), doublePhiBins_(36),
140 maxDepthHB_(maxDepthHB), maxDepthHE_(maxDepthHE), maxDepthHF_(2),
141 etaHE2HF_(30), etaHF2HE_(29),
142 HBSize_(kHBSizePreLS1),
143 HESize_(kHESizePreLS1),
146 HTSize_(kHTSizePreLS1),
147 numberOfShapes_(( mode==HcalTopologyMode::
SLHC ) ? 500 : 87 ) {
158 HESize_= maxDepthHE*(29-16+1)*72*2;
167 edm::LogWarning(
"CaloTopology") <<
"This is an incomplete constructor of HcalTopology - be warned that many functionalities will not be there - revert from this - get from EventSetup";
194 switch (
id.subdet()) {
227 std::vector<DetId> vNeighborsDetId;
230 vNeighborsDetId.push_back(
DetId(neighbors[
i].rawId()));
231 return vNeighborsDetId;
235 std::vector<DetId> vNeighborsDetId;
238 vNeighborsDetId.push_back(
DetId(neighbors[
i].rawId()));
239 return vNeighborsDetId;
243 std::vector<DetId> vNeighborsDetId;
246 vNeighborsDetId.push_back(
DetId(neighbor.
rawId()));
247 return vNeighborsDetId;
251 std::vector<DetId> vNeighborsDetId;
254 vNeighborsDetId.push_back(
DetId(neighbor.
rawId()));
255 return vNeighborsDetId;
260 std::vector<DetId> vNeighborsDetId;
262 vNeighborsDetId.push_back(neighbor);
264 return vNeighborsDetId;
269 std::vector<DetId> vNeighborsDetId;
271 vNeighborsDetId.push_back(neighbor);
273 return vNeighborsDetId;
293 int depth_l=
std::min(depth1,depth2);
294 int depth_h=
std::max(depth1,depth2);
297 for (
int ieta=ieta_l; ieta<=ieta_h; ieta++)
298 for (
int iphi=iphi_l; iphi<=iphi_h; iphi++)
337 const int ie (
id.ietaAbs());
338 const int ip (
id.iphi());
339 const int dp (
id.
depth());
341 return ( ( ip >= 1 ) &&
348 ( ( ( ie == 15 ) || ( ie == 16 ) ) &&
368 ( ip%2 == 1 ) ) ) ) ||
379 ( ip%4 == 3 ) ) ) ) ) ) ;
386 int aieta=
id.ietaAbs();
387 int depth=
id.depth();
389 if ((ieta==0 || iphi<=0 || iphi>
IPHI_MAX) || aieta>
maxEta_)
return false;
397 if (aieta>
lastHBRing() || depth>2 || (aieta<=14 && depth>1)) ok=
false;
418 (((aieta>=17 && aieta<firstHETripleDepthRing()) || aieta==lastHERing()) && depth>2) ||
422 if (aieta>
lastHORing() || iphi>IPHI_MAX || depth!=4) ok=
false;
435 switch (
id.subdet()) {
439 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.
depth());
444 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.
depth());
447 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.
depth());
450 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.
depth());
456 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.
depth());
459 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.
depth());
472 switch (
id.subdet()) {
476 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.
depth());
481 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
484 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
487 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.
depth());
493 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
496 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
518 int aieta=
id.ietaAbs();
523 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
525 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
533 if (!
valid(neighbors[0])) n=0;
540 int aieta=
id.ietaAbs();
556 }
else if (aieta==1) {
565 if (!
valid(neighbors[0]) && n==2) {
566 if (!
valid(neighbors[1])) n=0;
569 neighbors[0]=neighbors[1];
572 if (n==2 && !
valid(neighbors[1])) n=1;
573 if (n==1 && !
valid(neighbors[0])) n=0;
580 int & nDepthBins,
int & startingBin)
const {
612 }
else if (etaRing==17) {
630 std::cerr <<
"Bad HCAL subdetector " << subdet << std::endl;
637 int ieta = detId.
ieta();
640 int nDepthBins, startingBin;
645 if (depth > nDepthBins) {
658 (ieta > 0) ? ++ieta : --ieta;
663 (ieta > 0) ? --ieta : ++ieta;
676 int ieta = detId.
ieta();
679 int nDepthBins, startingBin;
695 (ieta > 0) ? --ieta : ++ieta;
696 }
else if (depth <= 0) {
701 ieta = (ieta > 0) ? etaRing : -etaRing;
727 static const double twopi =
M_PI+
M_PI;
767 static const double twopi =
M_PI+
M_PI;
783 if (phi<0.0) phi += twopi;
784 if (phi>twopi) phi -= twopi;
785 int phibin(1),
unit(1);
798 if (unit == 2) iphi = (phibin-1)*2+1;
799 else if (unit == 4) iphi = (phibin-1)*4+3;
808 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
812 readoutDepths = pos->second;
820 std::vector<int> readoutDepths;
822 int d1 = std::lower_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
823 int d2 = std::upper_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
824 return std::pair<int, int>(d1, d2);
844 int ieta = (keta > 0) ? keta : -keta;
853 if ((ietal < (
int)(
etaTable.size())) && (ieta > 0))
854 return std::pair<double,double>(
etaTable[ieta-1],etaTable[ietal]);
856 return std::pair<double,double>(0,0);
863 const int ip (hid.
iphi() ) ;
864 const int ie (hid.
ietaAbs() ) ;
865 const int dp (hid.
depth() ) ;
866 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
868 ( ip - 1 )*18 + dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf :
870 2*
kHBhalf + ( ip - 1 )*8 + ( ip/2 )*20 +
871 ( ( ie==16 || ie==17 ) ? ie - 16 :
872 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) + dp - 1 :
873 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) + dp - 1 :
874 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) + dp - 1 :
875 26 + 2*( ie - 29 ) + dp - 1 ) ) ) ) + zn*
kHEhalf :
880 ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
881 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf : 0xFFFFFFFFu ) ) ) ) ;
888 const int ip (hid.
iphi() ) ;
889 const int ie (hid.
ietaAbs() ) ;
890 const int dp (hid.
depth() ) ;
891 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
892 unsigned int retval = 0xFFFFFFFFu;
894 retval=( ip - 1 )*18 + dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf;
905 const int ip (hid.
iphi() ) ;
906 const int ie (hid.
ietaAbs() ) ;
907 const int dp (hid.
depth() ) ;
908 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
909 unsigned int retval = 0xFFFFFFFFu;
911 retval=( ip - 1 )*8 + ( ip/2 )*20 +
912 ( ( ie==16 || ie==17 ) ? ie - 16 :
913 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) + dp - 1 :
914 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) + dp - 1 :
915 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) + dp - 1 :
916 26 + 2*( ie - 29 ) + dp - 1 ) ) ) ) + zn*
kHEhalf;
927 const int ip (hid.
iphi() ) ;
928 const int ie (hid.
ietaAbs() ) ;
929 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
931 unsigned int retval = 0xFFFFFFFFu;
933 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
935 if (hid.
ieta()>0) retval=(ip-1)+72*(hid.
ieta()-1);
936 else retval=(ip-1)+72*(30+hid.
ieta());
943 const int ip (hid.
iphi() ) ;
944 const int ie (hid.
ietaAbs() ) ;
945 const int dp (hid.
depth() ) ;
946 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
948 unsigned int retval = 0xFFFFFFFFu;
950 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
951 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf;
953 retval=dp-1+2*(ip-1);
963 unsigned int ietaAbs = tid.
ietaAbs();
964 unsigned int iphi = tid.
iphi();
967 if ((iphi-1)%4==0) index = (iphi-1)*32 + (ietaAbs-1) - (12*((iphi-1)/4));
968 else index = (iphi-1)*28 + (ietaAbs-1) + (4*(((iphi-1)/4)+1));
970 if (zside == -1) index +=
kHThalf;
978 int ieta = tid.
ieta();
979 int iphi = tid.
iphi();
981 unsigned int index=0xFFFFFFFFu;
991 index = ((iphi+1)/4-1) + 18*channel + 27*(ieta+1);
996 if (channel>2) channel-=1;
997 index = ((iphi+1)/4-1) + 18*channel + 54*(ieta+1) + 108;
1001 if (channel==8) channel = 2;
1003 index = (iphi-1)/18 + 4*channel + 6*(ieta+1) + 324;
1009 index = (ieta+2) + 420;
1013 if (ieta<0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 348;
1014 else if (ieta>0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 6 + 348;
1015 else index = ((iphi+1)/6-1) + 36*channel + 6*(ieta+2) + 348;
1026 if (
abs(ieta)==4) index = ((iphi-1)%36) + (((zside+1)*36)/2) + 72 + 425;
1027 else index = (iphi-1) + (36*(zside+1)*2) + 425;
1035 unsigned int retval(0);
1051 if (hid.
ieta()>0) retval+=(hid.
iphi()-1)+72*(hid.
ieta()-1);
1052 else retval+=(hid.
iphi()-1)+72*(30+hid.
ieta());
1074 int in ( denseid ) ;
1081 iz = ( in<
kHFhalf ? 1 : -1 ) ;
1085 ip += 1 + ( in>21 ? 2 : 0 ) ;
1086 if( 3 == ip%4 ) in -= 22 ;
1092 iz = ( in<
kHOhalf ? 1 : -1 ) ;
1096 ie = 1 + ( in - 15*( ip - 1 ) ) ;
1097 }
else if ( in > 2*
kHBhalf - 1 ) {
1100 iz = ( in<
kHEhalf ? 1 : -1 ) ;
1105 if( 0 == ip%2 ) in %= 28 ;
1106 ie = 15 + ( in<2 ? 1 + in : 2 +
1107 ( in<20 ? 1 + ( in - 2 )/2 : 9 +
1108 ( in<26 ? 1 + ( in - 20 )/3 : 3 ) ) ) ;
1111 ( in<20 ? 1 + ( in - 2 )%2 :
1112 ( in<26 ? 1 + ( in - 20 )%3 :
1113 ( 1 + ( in - 26 )%2 ) ) ) ) ) ;
1115 iz = ( in<
kHBhalf ? 1 : -1 ) ;
1130 if (denseid <
ncells()) {
1138 if (ie > 12) {ie = 54 -ie; iz = -1;}
1139 else {ie += 29; iz = 1;}
1145 ie = (in - ip + 1)/72;
1146 if (ie > 14) {ie = 30 -ie; iz = -1;}
1147 else {ie += 1; iz = 1;}
1148 }
else if (denseid >= (
HBSize_)) {
1171 return HcalDetId( sd, iz*
int(ie), ip, dp );
std::vector< int > unitPhiHF
int zside() const
get the z-side of the tower (1/-1)
int decIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
unsigned int numberOfShapes_
unsigned int detId2denseIdPreLS1(const DetId &id) const
virtual unsigned int detId2denseId(const DetId &id) const
return a linear packed id
std::vector< double > dPhiTableHF
void excludeSubdetector(HcalSubdetector subdet)
HcalSubdetector subdet() const
get the subdetector
std::vector< HcalDDDRecConstants::HcalEtaBin > etaBinsHB_
int phiBin(HcalSubdetector subdet, int etaRing, double phi) const
std::vector< int > unitPhi
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)
bool validDetId(HcalSubdetector subdet, int ieta, int iphi, int depth) const
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)
const std::vector< double > & getEtaTableHF() const
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
std::vector< HcalDDDRecConstants::HcalEtaBin > etaBinsHE_
int ieta() const
get the rbx name (if relevant)
const std::vector< double > & getPhiOffs() const
virtual int topoVersion() const
return a version which identifies the given topology
uint32_t rawId() const
get the raw id
int getMaxDepth(const int type) const
bool isExcluded(const HcalDetId &id) const
int depth() const
get the tower depth
bool incIPhi(const HcalDetId &id, HcalDetId &neighbor) const
bool validRaw(const HcalDetId &id) const
int decAIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
int maxDepth(HcalSubdetector subdet) const
HcalTopologyMode::Mode mode_
int etaRing(HcalSubdetector subdet, double eta) const
eta and phi index from eta, phi values
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
std::vector< double > etaTableHF
int firstHEDoublePhiRing() const
SegmentationMap depthSegmentation_
std::vector< double > etaTable
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)
std::vector< double > phioff
const std::vector< double > & getPhiTable() const
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
const std::vector< double > & getEtaTable() const
std::pair< int, int > getEtaRange(const int i) const
int firstHFQuadPhiRing() const
Geom::Phi< T > phi() const
virtual std::vector< DetId > up(const DetId &id) const
const std::vector< int > & getDepth(const unsigned int i) const
std::vector< double > dPhiTable
int cboxChannel() const
get the calibration box channel (if relevant)
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
TString units(TString variable, Char_t axis)
const std::vector< double > & getPhiTableHF() const
int firstHETripleDepthRing_
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
int firstHEQuadPhiRing() const
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
virtual std::vector< DetId > east(const DetId &id) const
volatile std::atomic< bool > shutdown_flag false
HcalTopology(const HcalDDDRecConstants *hcons, HcalTopologyMode::TriggerMode tmode=HcalTopologyMode::tm_LHC_PreLS1)
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)
double etaMax(HcalSubdetector subdet) const
int firstHEDoublePhiRing_
const HcalDDDRecConstants * hcons_
static const int IPHI_MAX
std::vector< HcalEtaBin > getEtaBins(const int itype) const