20 const bool mergePosition) :
21 hcons_(hcons), mergePosition_(mergePosition),
24 firstHERing_(999), lastHERing_(0),
25 firstHFRing_(29), lastHFRing_(41),
26 firstHORing_(1), lastHORing_(15),
27 firstHEDoublePhiRing_(999), firstHEQuadPhiRing_(999),
28 firstHFQuadPhiRing_(40), firstHETripleDepthRing_(999),
44 int unit =
static_cast<int>((
i.dphi / 5.0_deg) + 0.01);
95 if (etaBinsHE_.size() > 1) {
96 double eta = etaBinsHE_[etaBinsHE_.size()-1].etaMax;
104 for (
auto &
i : etaBinsHE_) {
105 if (eta <
i.etaMax) {
111 const double fiveDegInRad = 5.0_deg;
125 std::cout <<
"Set segmentation for ring " <<
ring <<
" with " 126 << segmentation.size() <<
" elements:";
127 for (
unsigned int k=0;
k<segmentation.size(); ++
k)
134 std::cout <<
"Set Plan-1 segmentation for ring " <<
ring <<
" with " 135 << segmentation.size() <<
" elements:";
136 for (
unsigned int k=0;
k<segmentation.size(); ++
k)
196 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";
216 if (
id.iphi()<1 ||
id.iphi()>
IPHI_MAX ||
id.ieta()==0)
return false;
217 if (
id.
depth() != 0)
return false;
222 if (
id.ietaAbs() > 28) {
225 if ((
id.iphi() % 4) != 1)
return false;
226 if (
id.ietaAbs() > 32)
return false;
230 if (
id.ietaAbs()<30 ||
id.ietaAbs()>41)
return false;
231 if (
id.ietaAbs()>29 && ((
id.iphi()%2)==0))
return false;
232 if (
id.ietaAbs()>39 && ((
id.iphi()%4)!=3))
return false;
260 switch (
id.subdet()) {
293 std::vector<DetId> vNeighborsDetId;
296 if (neighbors[
i].oldFormat()) neighbors[
i].changeForm();
297 vNeighborsDetId.emplace_back(
DetId(neighbors[
i].rawId()));
299 return vNeighborsDetId;
303 std::vector<DetId> vNeighborsDetId;
306 if (neighbors[
i].oldFormat()) neighbors[
i].changeForm();
307 vNeighborsDetId.emplace_back(
DetId(neighbors[
i].rawId()));
309 return vNeighborsDetId;
313 std::vector<DetId> vNeighborsDetId;
317 vNeighborsDetId.emplace_back(
DetId(neighbor.
rawId()));
319 return vNeighborsDetId;
323 std::vector<DetId> vNeighborsDetId;
327 vNeighborsDetId.emplace_back(
DetId(neighbor.
rawId()));
329 return vNeighborsDetId;
334 std::vector<DetId> vNeighborsDetId;
337 vNeighborsDetId.emplace_back(neighbor);
339 return vNeighborsDetId;
344 std::vector<DetId> vNeighborsDetId;
347 vNeighborsDetId.emplace_back(neighbor);
349 return vNeighborsDetId;
369 int depth_l=
std::min(depth1,depth2);
370 int depth_h=
std::max(depth1,depth2);
373 for (
int ieta=ieta_l; ieta<=ieta_h; ieta++)
374 for (
int iphi=iphi_l; iphi<=iphi_h; iphi++)
413 const int ie (
id.ietaAbs());
414 const int ip (
id.iphi());
415 const int dp (
id.
depth());
417 return ( ( ip >= 1 ) &&
424 ( ( ( ie == 15 ) || ( ie == 16 ) ) &&
444 ( ip%2 == 1 ) ) ) ) ||
455 ( ip%4 == 3 ) ) ) ) ) ) ;
462 int aieta=
id.ietaAbs();
463 int depth=
id.depth();
465 int zside=
id.zside();
468 if ((ieta==0 || iphi<=0 || iphi>maxPhi) || aieta>
maxEta_) ok =
false;
475 (depth<hcons_->getMinDepth(0,aieta,iphi,zside))) ok=
false;
477 if (aieta>
lastHBRing() || depth>2 || (aieta<=14 && depth>1)) ok=
false;
482 (depth<hcons_->getMinDepth(1,aieta,iphi,zside)) ||
487 if (aieta ==
i.ieta) {
491 if (depth < 1) ok =
false;
493 if (depth <
i.depthStart) ok =
false;
526 switch (
id.subdet()) {
530 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.
depth());
535 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.
depth());
538 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.
depth());
541 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.
depth());
547 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.
depth());
550 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.
depth());
552 if (!
validRaw(neighbor)) ok =
false;
564 switch (
id.subdet()) {
568 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.
depth());
573 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
576 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
579 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.
depth());
585 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
588 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
590 if (!
validRaw(neighbor)) ok =
false;
611 int aieta=
id.ietaAbs();
616 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
618 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
626 if (!
valid(neighbors[0])) n=0;
633 int aieta=
id.ietaAbs();
649 }
else if (aieta==1) {
658 if (!
valid(neighbors[0]) && n==2) {
659 if (!
valid(neighbors[1])) n=0;
662 neighbors[0]=neighbors[1];
665 if (n==2 && !
valid(neighbors[1])) n=1;
666 if (n==1 && !
valid(neighbors[0])) n=0;
673 int iphi,
int zside,
int & nDepthBins,
674 int & startingBin)
const {
705 }
else if (etaRing==17) {
723 std::cerr <<
"Bad HCAL subdetector " << subdet << std::endl;
730 int ieta = detId.
ieta();
733 int iphi = detId.
iphi();
735 int nDepthBins(0), startingBin(0);
740 if (depth >= (startingBin+nDepthBins)) {
755 (ieta > 0) ? ++ieta : --ieta;
760 (ieta > 0) ? --ieta : ++ieta;
767 detId =
HcalDetId(subdet, ieta, iphi, depth);
773 int ieta = detId.
ieta();
776 int iphi = detId.
iphi();
778 int nDepthBins, startingBin;
795 (ieta > 0) ? --ieta : ++ieta;
796 }
else if (depth <= 0) {
801 ieta = (ieta > 0) ? etaRing : -etaRing;
803 if (etaRing ==
i.ieta) {
804 depth =
i.depthStart+
i.layer.size()-1;
837 if (phiTableVal != 0.0)
838 lastPhiBin =
static_cast<int>((2._pi / phiTableVal) + 0.001);
888 if (index < static_cast<int>(
dPhiTableHF.size())) {
895 if (phi < 0.0) phi += 2._pi;
896 else if (phi > 2._pi) phi -= 2._pi;
897 int phibin(1),
unit(1);
910 if (unit == 2) iphi = (phibin-1)*2+1;
911 else if (unit == 4) iphi = (phibin-1)*4+3;
916 std::vector<int> & readoutDepths,
917 const bool one)
const {
920 SegmentationMap::const_iterator
pos;
924 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
929 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
934 readoutDepths = pos->second;
938 const std::vector<int> & readoutDepths,
948 const unsigned depth,
949 const bool one)
const {
950 std::vector<int> readoutDepths;
952 int d1 = std::lower_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
953 int d2 = std::upper_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
954 return std::pair<int, int>(d1, d2);
978 int ieta = (keta > 0) ? keta : -keta;
987 if ((ietal < (
int)(
etaTable.size())) && (ieta > 0))
988 return std::pair<double,double>(
etaTable[ieta-1],etaTable[ietal]);
990 return std::pair<double,double>(0,0);
997 const int ip (hid.
iphi() ) ;
998 const int ie (hid.
ietaAbs() ) ;
999 const int dp (hid.
depth() ) ;
1000 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1002 ( ip - 1 )*18 + dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf :
1004 2*
kHBhalf + ( ip - 1 )*8 + ( ip/2 )*20 +
1005 ( ( ie==16 || ie==17 ) ? ie - 16 :
1006 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) + dp - 1 :
1007 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) + dp - 1 :
1008 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) + dp - 1 :
1009 26 + 2*( ie - 29 ) + dp - 1 ) ) ) ) + zn*
kHEhalf :
1014 ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
1015 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf : 0xFFFFFFFFu ) ) ) ) ;
1022 const int ip (hid.
iphi() ) ;
1023 const int ie (hid.
ietaAbs() ) ;
1024 const int dp (hid.
depth() ) ;
1025 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1026 unsigned int retval = 0xFFFFFFFFu;
1028 retval=( ip - 1 )*18 + dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf;
1039 const int ip (hid.
iphi() ) ;
1040 const int ie (hid.
ietaAbs() ) ;
1041 const int dp (hid.
depth() ) ;
1042 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1043 unsigned int retval = 0xFFFFFFFFu;
1045 retval=( ip - 1 )*8 + ( ip/2 )*20 +
1046 ( ( ie==16 || ie==17 ) ? ie - 16 :
1047 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) + dp - 1 :
1048 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) + dp - 1 :
1049 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) + dp - 1 :
1050 26 + 2*( ie - 29 ) + dp - 1 ) ) ) ) + zn*
kHEhalf;
1061 const int ip (hid.
iphi() ) ;
1062 const int ie (hid.
ietaAbs() ) ;
1063 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1065 unsigned int retval = 0xFFFFFFFFu;
1067 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
1077 const int ip (hid.
iphi() ) ;
1078 const int ie (hid.
ietaAbs() ) ;
1079 const int dp (hid.
depth() ) ;
1080 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1082 unsigned int retval = 0xFFFFFFFFu;
1084 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
1085 2*( ie - 29 ) + ( dp - 1 ) + zn*
kHFhalf;
1087 retval=dp-1+2*(ip-1);
1097 unsigned int ietaAbs = tid.
ietaAbs();
1098 unsigned int iphi = tid.
iphi();
1099 unsigned int ivers = tid.
version();
1103 if ((iphi-1)%4==0) index = (iphi-1)*32 + (ietaAbs-1) - (12*((iphi-1)/4));
1104 else index = (iphi-1)*28 + (ietaAbs-1) + (4*(((iphi-1)/4)+1));
1105 if (zside == -1) index +=
kHThalf;
1109 index += (36 * (ietaAbs - 30) + ((iphi - 1)/2));
1118 int ieta = tid.
ieta();
1119 int iphi = tid.
iphi();
1121 unsigned int index=0xFFFFFFFFu;
1131 index = ((iphi+1)/4-1) + 18*channel + 27*(ieta+1);
1136 if (channel>2) channel-=1;
1137 index = ((iphi+1)/4-1) + 18*channel + 54*(ieta+1) + 108;
1141 if (channel==8) channel = 2;
1143 index = (iphi-1)/18 + 4*channel + 6*(ieta+1) + 324;
1148 index = (ieta+2) + 420;
1152 if (ieta<0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 348;
1153 else if (ieta>0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 6 + 348;
1154 else index = ((iphi+1)/6-1) + 36*channel + 6*(ieta+2) + 348;
1165 if (
abs(ieta)==4) index = ((iphi-1)%36) + (((zside+1)*36)/2) + 72 + 425;
1166 else index = (iphi-1) + (36*(zside+1)*2) + 425;
1174 unsigned int retval(0);
1204 << std::hex << retval <<
std::dec << std::endl;
1215 int in ( denseid ) ;
1222 iz = ( in<
kHFhalf ? 1 : -1 ) ;
1226 ip += 1 + ( in>21 ? 2 : 0 ) ;
1227 if( 3 == ip%4 ) in -= 22 ;
1233 iz = ( in<
kHOhalf ? 1 : -1 ) ;
1237 ie = 1 + ( in - 15*( ip - 1 ) ) ;
1238 }
else if ( in > 2*
kHBhalf - 1 ) {
1241 iz = ( in<
kHEhalf ? 1 : -1 ) ;
1246 if( 0 == ip%2 ) in %= 28 ;
1247 ie = 15 + ( in<2 ? 1 + in : 2 +
1248 ( in<20 ? 1 + ( in - 2 )/2 : 9 +
1249 ( in<26 ? 1 + ( in - 20 )/3 : 3 ) ) ) ;
1252 ( in<20 ? 1 + ( in - 2 )%2 :
1253 ( in<26 ? 1 + ( in - 20 )%3 :
1254 ( 1 + ( in - 26 )%2 ) ) ) ) ) ;
1256 iz = ( in<
kHBhalf ? 1 : -1 ) ;
1271 if (denseid <
ncells()) {
1279 if (ie > 12) {ie = 54 -ie; iz = -1;}
1280 else {ie += 29; iz = 1;}
1287 if (ie > 14) {ie = 30 -ie; iz = -1;}
1288 else {ie += 1; iz = 1;}
1289 }
else if (denseid >= (
HBSize_)) {
1312 <<
" : " << hid.
rawId() <<
std::dec <<
" | " << hid << std::endl;
DetId denseId2detId(unsigned int) const override
return a linear packed id
std::vector< int > getDepth(const int &det, const int &phi, const int &zside, const unsigned int &eta) const
std::vector< int > unitPhiHF
int zside() const
get the z-side of the tower (1/-1)
void getDepthSegmentation(const unsigned ring, std::vector< int > &readoutDepths, const bool flag=false) const
int topoVersion() const override
return a version which identifies the given topology
int decIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
unsigned int numberOfShapes_
unsigned int detId2denseIdPreLS1(const DetId &id) const
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
bool valid(const DetId &id) const override
CalibDetType calibFlavor() const
get the flavor of this calibration detid
std::vector< DetId > up(const DetId &id) const override
unsigned int detId2denseId(const DetId &id) const override
return a linear packed id
int zside() const
get the z-side of the cell (1/-1)
bool validDetId(HcalSubdetector subdet, int ieta, int iphi, int depth) 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
static const int minMaxDepth_
void exclude(const HcalDetId &id)
const std::vector< double > & getEtaTableHF() const
HcalTopologyMode::TriggerMode triggerMode_
constexpr uint32_t rawId() const
get the raw 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
std::vector< HcalDDDRecConstants::HcalEtaBin > etaBinsHE_
const std::vector< double > & getPhiOffs() const
std::pair< int, int > getEtaRange(const int &i) const
HcalTopologyMode::Mode mode() const
int getTriggerMode() const
U second(std::pair< T, U > const &p)
bool isExcluded(const HcalDetId &id) const
void depthBinInformation(HcalSubdetector subdet, int etaRing, int iphi, int zside, int &nDepthBins, int &startingBin) const
finds the number of depth bins and which is the number to start with
std::vector< HcalEtaBin > getEtaBins(const int &itype) const
int depth() const
get the tower depth
std::pair< int, int > segmentBoundaries(const unsigned ring, const unsigned depth, const bool flag=false) const
bool incIPhi(const HcalDetId &id, HcalDetId &neighbor) const
bool isPlan1MergedId(const HcalDetId &id) const
bool validRaw(const HcalDetId &id) const
std::vector< DetId > south(const DetId &id) const override
int decAIEta(const HcalDetId &id, HcalDetId neighbors[2]) const
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
HcalTopologyMode::Mode mode_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
HcalTopology(const HcalDDDRecConstants *hcons, const bool mergePosition=false)
int etaRing(HcalSubdetector subdet, double eta) const
eta and phi index from eta, phi values
int firstHETripleDepthRing() const
int ieta() const
get the cell ieta
int getDepthEta16(const int &det, const int &iphi, const int &zside) const
Abs< T >::type abs(const T &t)
int getDepthEta29(const int &iphi, const int &zside, const int &type) const
std::vector< double > etaTableHF
int firstHEDoublePhiRing() const
SegmentationMap depthSegmentation_
SegmentationMap depthSegmentationOne_
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
int zside() const
get the sign of ieta (+/-1)
std::vector< double > phioff
const std::vector< double > & getPhiTable() const
int getNoff(const int &i) const
int version() const
get the version code for the trigger tower
int getMaxDepth(const int &type) const
const std::vector< double > & getEtaTable() const
int firstHFQuadPhiRing() const
std::vector< double > dPhiTable
std::vector< DetId > west(const DetId &id) const override
int cboxChannel() const
get the calibration box channel (if relevant)
std::vector< DetId > north(const DetId &id) const override
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
TString units(TString variable, Char_t axis)
const std::vector< double > & getPhiTableHF() const
std::vector< DetId > down(const DetId &id) const override
int firstHETripleDepthRing_
unsigned int detId2denseIdHO(const DetId &id) const
return a linear packed id from HO
std::vector< HcalDetId > exclusionList_
unsigned int ncells() const override
return a count of valid cells (for dense indexing use)
unsigned int detId2denseIdHE(const DetId &id) const
return a linear packed id from HE
bool isPlan1ToBeMergedId(const HcalDetId &id) const
int firstHEQuadPhiRing() const
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
void setDepthSegmentation(const unsigned ring, const std::vector< int > &readoutDepths, const bool flag)
int maxHFDepth(int ieta, int iphi) const
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
std::vector< DetId > east(const DetId &id) const override
double etaMax(HcalSubdetector subdet) const
int firstHEDoublePhiRing_
const HcalDDDRecConstants * hcons_
static const int IPHI_MAX
int getNPhi(const int &type) const
bool validHT(const HcalTrigTowerDetId &id) const