10 #include "CLHEP/Units/GlobalPhysicalConstants.h" 17 const bool mergePosition) :
18 hcons_(hcons), mergePosition_(mergePosition),
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),
41 int unit = (
int)((
i.dphi+0.01)/(5.0*CLHEP::deg));
85 double eta = etaBinsHE_[etaBinsHE_.size()-1].etaMax;
95 for (
auto &
i : etaBinsHE_) {
101 const double fiveDegInRad = 2*
M_PI/72;
115 std::cout <<
"Set segmentation for ring " <<
ring <<
" with " 116 << segmentation.size() <<
" elements:";
117 for (
unsigned int k=0;
k<segmentation.size(); ++
k)
124 std::cout <<
"Set Plan-1 segmentation for ring " <<
ring <<
" with " 125 << segmentation.size() <<
" elements:";
126 for (
unsigned int k=0;
k<segmentation.size(); ++
k)
186 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";
206 if (
id.iphi()<1 ||
id.iphi()>
IPHI_MAX ||
id.ieta()==0)
return false;
207 if (
id.
depth() != 0)
return false;
209 if (
id.ietaAbs() > 28) {
212 if ((
id.iphi() % 4) != 1)
return false;
213 if (
id.ietaAbs() > 32)
return false;
217 if (
id.ietaAbs()<30 ||
id.ietaAbs()>41)
return false;
218 if (
id.ietaAbs()>29 && ((
id.iphi()%2)==0))
return false;
219 if (
id.ietaAbs()>39 && ((
id.iphi()%4)!=3))
return false;
247 switch (
id.subdet()) {
280 std::vector<DetId> vNeighborsDetId;
283 if (neighbors[
i].oldFormat()) neighbors[
i].changeForm();
284 vNeighborsDetId.emplace_back(
DetId(neighbors[
i].rawId()));
286 return vNeighborsDetId;
290 std::vector<DetId> vNeighborsDetId;
293 if (neighbors[
i].oldFormat()) neighbors[
i].changeForm();
294 vNeighborsDetId.emplace_back(
DetId(neighbors[
i].rawId()));
296 return vNeighborsDetId;
300 std::vector<DetId> vNeighborsDetId;
304 vNeighborsDetId.emplace_back(
DetId(neighbor.
rawId()));
306 return vNeighborsDetId;
310 std::vector<DetId> vNeighborsDetId;
314 vNeighborsDetId.emplace_back(
DetId(neighbor.
rawId()));
316 return vNeighborsDetId;
321 std::vector<DetId> vNeighborsDetId;
324 vNeighborsDetId.emplace_back(neighbor);
326 return vNeighborsDetId;
331 std::vector<DetId> vNeighborsDetId;
334 vNeighborsDetId.emplace_back(neighbor);
336 return vNeighborsDetId;
356 int depth_l=
std::min(depth1,depth2);
357 int depth_h=
std::max(depth1,depth2);
360 for (
int ieta=ieta_l; ieta<=ieta_h; ieta++)
361 for (
int iphi=iphi_l; iphi<=iphi_h; iphi++)
400 const int ie (
id.ietaAbs());
401 const int ip (
id.iphi());
404 return ( ( ip >= 1 ) &&
411 ( ( ( ie == 15 ) || ( ie == 16 ) ) &&
431 ( ip%2 == 1 ) ) ) ) ||
442 ( ip%4 == 3 ) ) ) ) ) ) ;
449 int aieta=
id.ietaAbs();
450 int depth=
id.depth();
452 int zside=
id.zside();
455 if ((ieta==0 || iphi<=0 || iphi>maxPhi) || aieta>
maxEta_) ok =
false;
462 (depth<hcons_->getMinDepth(0,aieta,iphi,zside))) ok=
false;
464 if (aieta>
lastHBRing() || depth>2 || (aieta<=14 && depth>1)) ok=
false;
469 (depth<hcons_->getMinDepth(1,aieta,iphi,zside)) ||
474 if (aieta ==
i.ieta) {
478 if (depth < 1) ok =
false;
480 if (depth <
i.depthStart) ok =
false;
513 switch (
id.subdet()) {
517 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.
depth());
522 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.
depth());
525 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.
depth());
528 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+1,
id.
depth());
534 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+4,
id.
depth());
537 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()+2,
id.
depth());
539 if (!
validRaw(neighbor)) ok =
false;
551 switch (
id.subdet()) {
555 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.
depth());
560 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
563 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
566 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-1,
id.
depth());
572 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-4,
id.
depth());
575 else neighbor=
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi()-2,
id.
depth());
577 if (!
validRaw(neighbor)) ok =
false;
598 int aieta=
id.ietaAbs();
603 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
605 neighbors[0]=
HcalDetId(
id.subdet(),(aieta+1)*
id.
zside(),((
id.iphi()==1)?(71):(
id.iphi()-2)),
id.
depth());
613 if (!
valid(neighbors[0])) n=0;
620 int aieta=
id.ietaAbs();
636 }
else if (aieta==1) {
645 if (!
valid(neighbors[0]) && n==2) {
646 if (!
valid(neighbors[1])) n=0;
649 neighbors[0]=neighbors[1];
652 if (n==2 && !
valid(neighbors[1])) n=1;
653 if (n==1 && !
valid(neighbors[0])) n=0;
660 int iphi,
int zside,
int & nDepthBins,
661 int & startingBin)
const {
692 }
else if (etaRing==17) {
710 std::cerr <<
"Bad HCAL subdetector " << subdet << std::endl;
717 int ieta = detId.
ieta();
720 int iphi = detId.
iphi();
722 int nDepthBins, startingBin;
727 if (depth >= (startingBin+nDepthBins)) {
742 (ieta > 0) ? ++ieta : --ieta;
747 (ieta > 0) ? --ieta : ++ieta;
754 detId =
HcalDetId(subdet, ieta, iphi, depth);
760 int ieta = detId.
ieta();
763 int iphi = detId.
iphi();
765 int nDepthBins, startingBin;
782 (ieta > 0) ? --ieta : ++ieta;
783 }
else if (depth <= 0) {
788 ieta = (ieta > 0) ? etaRing : -etaRing;
790 if (etaRing ==
i.ieta) {
791 depth =
i.depthStart+
i.layer.size()-1;
819 static const double twopi =
M_PI+
M_PI;
859 static const double twopi =
M_PI+
M_PI;
875 if (phi<0.0) phi += twopi;
876 if (phi>twopi) phi -= twopi;
877 int phibin(1),
unit(1);
890 if (unit == 2) iphi = (phibin-1)*2+1;
891 else if (unit == 4) iphi = (phibin-1)*4+3;
896 std::vector<int> & readoutDepths,
897 const bool one)
const {
900 SegmentationMap::const_iterator
pos;
904 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
909 throw cms::Exception(
"HcalTopology") <<
"No depth segmentation found for ring" <<
ring;
914 readoutDepths = pos->second;
918 const std::vector<int> & readoutDepths,
928 const unsigned depth,
929 const bool one)
const {
930 std::vector<int> readoutDepths;
932 int d1 = std::lower_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
933 int d2 = std::upper_bound(readoutDepths.begin(), readoutDepths.end(),
depth) - readoutDepths.begin();
934 return std::pair<int, int>(d1, d2);
958 int ieta = (keta > 0) ? keta : -keta;
967 if ((ietal < (
int)(
etaTable.size())) && (ieta > 0))
968 return std::pair<double,double>(
etaTable[ieta-1],etaTable[ietal]);
970 return std::pair<double,double>(0,0);
977 const int ip (hid.
iphi() ) ;
978 const int ie (hid.
ietaAbs() ) ;
980 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
982 ( ip - 1 )*18 +
dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf :
984 2*
kHBhalf + ( ip - 1 )*8 + ( ip/2 )*20 +
985 ( ( ie==16 || ie==17 ) ? ie - 16 :
986 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) +
dp - 1 :
987 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) +
dp - 1 :
988 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) +
dp - 1 :
989 26 + 2*( ie - 29 ) +
dp - 1 ) ) ) ) + zn*
kHEhalf :
994 ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
995 2*( ie - 29 ) + (
dp - 1 ) + zn*
kHFhalf : 0xFFFFFFFFu ) ) ) ) ;
1002 const int ip (hid.
iphi() ) ;
1003 const int ie (hid.
ietaAbs() ) ;
1005 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1006 unsigned int retval = 0xFFFFFFFFu;
1008 retval=( ip - 1 )*18 +
dp - 1 + ie - ( ie<16 ? 1 : 0 ) + zn*
kHBhalf;
1019 const int ip (hid.
iphi() ) ;
1020 const int ie (hid.
ietaAbs() ) ;
1022 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1023 unsigned int retval = 0xFFFFFFFFu;
1025 retval=( ip - 1 )*8 + ( ip/2 )*20 +
1026 ( ( ie==16 || ie==17 ) ? ie - 16 :
1027 ( ( ie>=18 && ie<=20 ) ? 2 + 2*( ie - 18 ) +
dp - 1 :
1028 ( ( ie>=21 && ie<=26 ) ? 8 + 2*( ie - 21 ) +
dp - 1 :
1029 ( ( ie>=27 && ie<=28 ) ? 20 + 3*( ie - 27 ) +
dp - 1 :
1030 26 + 2*( ie - 29 ) +
dp - 1 ) ) ) ) + zn*
kHEhalf;
1041 const int ip (hid.
iphi() ) ;
1042 const int ie (hid.
ietaAbs() ) ;
1043 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1045 unsigned int retval = 0xFFFFFFFFu;
1047 retval=( ip - 1 )*15 + ( ie - 1 ) + zn*
kHOhalf;
1057 const int ip (hid.
iphi() ) ;
1058 const int ie (hid.
ietaAbs() ) ;
1060 const int zn (hid.
zside() < 0 ? 1 : 0 ) ;
1062 unsigned int retval = 0xFFFFFFFFu;
1064 retval = ( ( ip - 1 )/4 )*4 + ( ( ip - 1 )/2 )*22 +
1065 2*( ie - 29 ) + (
dp - 1 ) + zn*
kHFhalf;
1067 retval=
dp-1+2*(ip-1);
1077 unsigned int ietaAbs = tid.
ietaAbs();
1078 unsigned int iphi = tid.
iphi();
1079 unsigned int ivers = tid.
version();
1083 if ((iphi-1)%4==0) index = (iphi-1)*32 + (ietaAbs-1) - (12*((iphi-1)/4));
1084 else index = (iphi-1)*28 + (ietaAbs-1) + (4*(((iphi-1)/4)+1));
1085 if (zside == -1) index +=
kHThalf;
1089 index += (36 * (ietaAbs - 30) + ((iphi - 1)/2));
1098 int ieta = tid.
ieta();
1099 int iphi = tid.
iphi();
1101 unsigned int index=0xFFFFFFFFu;
1111 index = ((iphi+1)/4-1) + 18*channel + 27*(ieta+1);
1116 if (channel>2) channel-=1;
1117 index = ((iphi+1)/4-1) + 18*channel + 54*(ieta+1) + 108;
1121 if (channel==8) channel = 2;
1123 index = (iphi-1)/18 + 4*channel + 6*(ieta+1) + 324;
1128 index = (ieta+2) + 420;
1132 if (ieta<0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 348;
1133 else if (ieta>0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 6 + 348;
1134 else index = ((iphi+1)/6-1) + 36*channel + 6*(ieta+2) + 348;
1145 if (
abs(ieta)==4) index = ((iphi-1)%36) + (((zside+1)*36)/2) + 72 + 425;
1146 else index = (iphi-1) + (36*(zside+1)*2) + 425;
1154 unsigned int retval(0);
1184 << std::hex << retval <<
std::dec << std::endl;
1195 int in ( denseid ) ;
1202 iz = ( in<
kHFhalf ? 1 : -1 ) ;
1206 ip += 1 + ( in>21 ? 2 : 0 ) ;
1207 if( 3 == ip%4 ) in -= 22 ;
1213 iz = ( in<
kHOhalf ? 1 : -1 ) ;
1217 ie = 1 + ( in - 15*( ip - 1 ) ) ;
1218 }
else if ( in > 2*
kHBhalf - 1 ) {
1221 iz = ( in<
kHEhalf ? 1 : -1 ) ;
1226 if( 0 == ip%2 ) in %= 28 ;
1227 ie = 15 + ( in<2 ? 1 + in : 2 +
1228 ( in<20 ? 1 + ( in - 2 )/2 : 9 +
1229 ( in<26 ? 1 + ( in - 20 )/3 : 3 ) ) ) ;
1232 ( in<20 ? 1 + ( in - 2 )%2 :
1233 ( in<26 ? 1 + ( in - 20 )%3 :
1234 ( 1 + ( in - 26 )%2 ) ) ) ) ) ;
1236 iz = ( in<
kHBhalf ? 1 : -1 ) ;
1251 if (denseid <
ncells()) {
1259 if (ie > 12) {ie = 54 -ie; iz = -1;}
1260 else {ie += 29; iz = 1;}
1267 if (ie > 14) {ie = 30 -ie; iz = -1;}
1268 else {ie += 1; iz = 1;}
1269 }
else if (denseid >= (
HBSize_)) {
1292 <<
" : " << 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
void exclude(const HcalDetId &id)
const std::vector< double > & getEtaTableHF() const
HcalTopologyMode::TriggerMode triggerMode_
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
std::pair< int, int > getEtaRange(const int &i) const
HcalTopologyMode::Mode mode() const
int getTriggerMode() const
uint32_t rawId() const
get the raw id
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 maxDepth(HcalSubdetector subdet) 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