6 #include "CLHEP/Units/GlobalPhysicalConstants.h" 7 #include "CLHEP/Units/GlobalSystemOfUnits.h" 17 : hpar(
hp), hcons(hc) {
19 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants::HcalDDDRecConstants (const HcalParameters* hp) constructor";
36 if (it->layer ==
eta + 1)
37 return it->layerGroup;
38 if (it->layer >
eta + 1)
39 return last->layerGroup;
42 return last->layerGroup;
47 for (
unsigned int lay = 0; lay <
layers.size(); ++lay)
56 const unsigned int&
eta)
const {
63 for (
unsigned int lay = 0; lay <
layers.size(); ++lay)
70 std::vector<HcalDDDRecConstants::HcalEtaBin>
bins;
71 unsigned int type = (itype == 0) ? 0 : 1;
73 std::vector<int> phiSp;
76 for (
int iz = 0; iz < 2; ++iz) {
77 int zside = 2 * iz - 1;
79 std::vector<std::pair<int, double>> phis =
getPhis(subdet,
ieta);
80 std::vector<std::pair<int, double>> phiUse;
82 if (subdet == subdetSp) {
83 for (
auto&
phi : phis) {
85 phiUse.emplace_back(
phi);
89 phiUse.insert(phiUse.end(), phis.begin(), phis.end());
95 if (subdetSp == subdet) {
97 std::vector<std::pair<int, double>> phis =
getPhis(subdet,
ieta);
98 for (
int iz = 0; iz < 2; ++iz) {
99 int zside = 2 * iz - 1;
100 std::vector<std::pair<int, double>> phiUse;
101 for (
int i : phiSp) {
102 for (
auto&
phi : phis) {
104 phiUse.emplace_back(
phi);
109 if (!phiUse.empty()) {
118 for (
unsigned int i = 0;
i <
bins.size(); ++
i) {
120 <<
bins[
i].etaMax <<
"), Zside = " <<
bins[
i].zside <<
", phis = (" 121 <<
bins[
i].phis.size() <<
":" <<
bins[
i].dphi <<
") and " <<
bins[
i].layer.size()
122 <<
" depths (start) " <<
bins[
i].depthStart;
123 for (
unsigned int k = 0;
k <
bins[
i].layer.size(); ++
k)
126 for (
unsigned int k = 0;
k <
bins[
i].phis.size(); ++
k)
137 (subdet == static_cast<int>(
HcalOuter))) {
142 phi = foff + (kphi - 0.5) *
phibin[ietaAbs - 1];
146 int kphi = (
unit == 4) ? ((
iphi - 3) / 4 + 1) : ((
iphi - 1) / 2 + 1);
156 edm::LogVerbatim(
"HCalGeom") <<
"getEtaPhi: subdet|ieta|iphi " << subdet <<
"|" <<
ieta <<
"|" <<
iphi <<
" eta|phi " 159 return std::pair<double, double>(
eta,
phi);
163 uint32_t
ieta = (keta > 0) ? keta : -keta;
164 int zside = (keta > 0) ? 1 : -1;
169 <<
"getHCID: receives an eta value " <<
ieta <<
" outside the limit (1:" <<
hpar->
etaMaxHBHE() <<
")";
171 if ((subdet == static_cast<int>(
HcalOuter)) ||
180 phi0 = (
iphi + 1) / 2;
182 }
else if (
unit == 4) {
183 phi0 = (
iphi + 1) / 4;
202 kphi = (kphi - 1) % 4 + 1;
203 if (kphi == 2 || kphi == 3)
211 << lay <<
" output " <<
eta <<
":" <<
phi <<
":" <<
depth;
217 std::vector<HcalDDDRecConstants::HFCellParameters>
cells;
220 for (
unsigned int k = 0;
k <
nEta; ++
k) {
223 int iphi = (dphi == 4) ? 3 : 1;
224 int nphi = 72 / dphi;
246 for (
unsigned int k = 0;
k <
nEta; ++
k) {
249 int iphi = (dphi == 4) ? 3 : 1;
250 int nphi = 72 / dphi;
261 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants returns " <<
cells.size() <<
" HF cell parameters";
262 for (
unsigned int k = 0;
k <
cells.size(); ++
k)
278 for (std::map<int, int>::iterator itr =
layers.begin(); itr !=
layers.end(); ++itr)
284 int subdet = (idet == 1) ? 1 : 2;
289 if (layBack < 0 && eta <= hpar->
etaMax[1]) {
297 if (layBack < 0 || layBack > laymax)
301 <<
" Output " << layBack;
307 int subdet = (idet == 1) ? 1 : 2;
312 if ((layFront < 0) || ((subdet == static_cast<int>(
HcalEndcap)) && (
eta == 16))) {
313 if ((subdet == static_cast<int>(
HcalEndcap)) && (
eta == 16)) {
315 }
else if (eta <= hpar->
etaMax[1]) {
318 if ((
int)(
k) >= laymin) {
326 if (layFront < laymin)
331 <<
" Output " << layFront;
337 unsigned int type = (itype == 0) ? 0 : 1;
354 <<
" Output " << lmax;
364 }
else if (itype == 3) {
367 unsigned int type = (itype == 0) ? 0 : 1;
380 std::vector<std::pair<int, double>> phis;
384 double fioff = ficons.first;
386 int nphi =
int((2._pi + 0.1 * dphi) / dphi);
388 for (
int ifi = 0; ifi <
nphi; ++ifi) {
389 double phi = -fioff + (ifi + 0.5) * dphi;
391 phis.emplace_back(std::pair<int, double>(
iphi,
phi));
394 edm::LogVerbatim(
"HCalGeom") <<
"getEtaPhi: subdet|ieta|iphi " << subdet <<
"|" <<
ieta <<
" with " << phis.size()
396 for (
unsigned int k = 0;
k < phis.size(); ++
k)
409 int zside = (
k > 0) ? 1 : -1;
410 int phi = (
k > 0) ?
k : -
k;
411 phiz.emplace_back(std::pair<int, int>(
phi,
zside));
415 edm::LogVerbatim(
"HCalGeom") <<
"Special RBX for detector " << subdet <<
" with " << phiz.size() <<
" phi/z bins";
416 for (
unsigned int k = 0;
k < phiz.size(); ++
k)
417 edm::LogVerbatim(
"HCalGeom") <<
" [" <<
k <<
"] " << phiz[
k].first <<
":" << phiz[
k].second;
432 <<
depth <<
" lay|rz " << layf <<
"|" << rz;
448 int subdet =
id.subdetId();
449 int ieta =
id.ieta();
450 int iphi =
id.iphi();
451 int depth =
id.depth();
454 double rzf = (layf < 0)
459 double rzb = (layb < 0)
465 <<
depth <<
" lay|rz (front) " << layf <<
"|" << rzf <<
" lay|rz (back) " << layb <<
"|" 468 return std::pair<double, double>(rzf, rzb);
472 std::vector<HcalDDDRecConstants::HcalActiveLength> actives;
475 unsigned int kount(0);
480 int stype = (
bin.phis.size() > 4) ? 0 : 1;
483 double eta = 0.5 * (
bin.etaMin +
bin.etaMax);
489 <<
":" << layl <<
":" <<
bin.layer.size();
490 for (
auto ll :
bin.layer)
495 for (
unsigned int i = 0;
i <
bin.layer.size(); ++
i) {
499 for (
int j = lmin;
j <= lmax; ++
j) {
507 edm::LogVerbatim(
"HCalGeom") <<
"Type " <<
type <<
" L " << lmin <<
":" << lmax <<
" T " << thick;
509 thick *= (2. *
scale);
512 active.
iphis.emplace_back(
phi.first);
513 actives.emplace_back(active);
518 <<
" zside " << active.
zside <<
" depth " << active.
depth <<
" type " << active.
stype 519 <<
" thick " << active.
thick;
528 std::vector<HcalCellType>
cells;
531 std::vector<int> missPhi;
532 for (
const auto& etabin :
etabins) {
533 std::vector<HcalCellType>
temp;
534 std::vector<int>
count;
535 std::vector<double> dmin, dmax;
536 for (
unsigned int il = 0; il < etabin.layer.size(); ++il) {
538 temp.emplace_back(cell);
539 count.emplace_back(0);
540 dmin.emplace_back(0);
541 dmax.emplace_back(0);
543 int ieta = etabin.ieta;
546 for (
unsigned int il = 0; il < etabin.layer.size(); ++il) {
547 for (
auto& ic : cellsm) {
548 if (ic.depthSegment() >= etabin.layer[il].first && ic.depthSegment() <= etabin.layer[il].second &&
549 ic.etaBin() ==
temp[il].etaBin() && ic.zside() ==
temp[il].zside()) {
550 if (
count[il] == 0) {
552 dmin[il] = ic.depthMin();
553 dmax[il] = ic.depthMax();
556 if (ic.depthMin() < dmin[il])
557 dmin[il] = ic.depthMin();
558 if (ic.depthMax() > dmax[il])
559 dmax[il] = ic.depthMax();
564 for (
unsigned int il = 0; il < etabin.layer.size(); ++il) {
565 int depth = etabin.depthStart + (
int)(il);
566 temp[il].setEta(
ieta, etabin.etaMin, etabin.etaMax);
567 temp[il].setDepth(
depth, dmin[il], dmax[il]);
570 temp[il].setPhi(etabin.phis, missPhi, foff, etabin.dphi,
unit);
575 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants: found " <<
cells.size() <<
" cells for sub-detector type " 577 for (
unsigned int ic = 0; ic <
cells.size(); ++ic)
607 depths.reserve(depthMax - depthMin + 1);
616 unsigned int num = 0;
618 for (
auto& cellType : cellTypes) {
619 num += (
unsigned int)(cellType.nPhiBins());
622 edm::LogInfo(
"HCalGeom") <<
"HcalDDDRecConstants:numberOfCells " << cellTypes.size() <<
" " <<
num 623 <<
" for subdetector " << subdet;
635 unsigned int ncell(0);
637 ncell += ((etabin.phis.size()) * (etabin.layer.size()));
654 std::map<HcalDetId, HcalDetId>::const_iterator itr =
detIdSp_.find(
id);
663 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr =
detIdSpR_.find(
id);
665 hid =
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi(), (itr->second)[0].
depth());
671 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr =
detIdSpR_.find(
id);
673 hid =
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi(), (itr->second).back().depth());
679 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr =
detIdSpR_.find(
id);
681 ids.emplace_back(
id);
683 for (
auto k : itr->second) {
685 ids.emplace_back(hid);
691 for (
auto k : idsOld) {
692 std::map<HcalDetId, HcalDetId>::const_iterator itr =
detIdSp_.find(
k);
694 idsNew.emplace_back(
k);
696 idsNew.emplace_back(itr->second);
702 std::map<HcalDetId, HcalDetId>::const_iterator itr;
704 ids.emplace_back(itr->first);
706 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr;
708 ids.emplace_back(itr->first);
710 return (!ids.empty());
717 std::map<int, int>&
layers,
719 std::vector<HcalDDDRecConstants::HcalEtaBin>&
bins)
const {
725 etabin.
phis.insert(etabin.
phis.end(), phis.begin(), phis.end());
731 int lmin(0), lmax(0);
733 std::map<int, int>::iterator itr =
layers.begin();
735 int dep = itr->second;
738 unsigned lymx0 = (
layers.size() > lymax) ? lymax :
layers.size();
741 <<
":" << lymax <<
" Depth " << dep <<
":" << itr->second;
744 edm::LogVerbatim(
"HCalGeom") <<
"Layer [" <<
l <<
"] " << itr->first <<
":" << itr->second;
746 for (
unsigned int l = 0;
l < phis.size(); ++
l)
749 for (itr =
layers.begin(); itr !=
layers.end(); ++itr) {
750 if (itr->first <= (
int)(lymx0)) {
751 if (itr->second == dep) {
755 }
else if (itr->second > dep) {
758 int lmax0 = (lmax >= lmin) ? lmax : lmin;
760 etabin0.
layer.emplace_back(std::pair<int, int>(lmin, lmax0));
762 etabin.
layer.emplace_back(std::pair<int, int>(lmin, lmax0));
774 if (itr->first == (
int)(lymx0))
780 etabin0.
layer.emplace_back(std::pair<int, int>(lmin, lmax));
781 etabin0.
phis.insert(etabin0.
phis.end(), phis.begin(), phis.end());
782 bins.emplace_back(etabin0);
785 <<
":" << lmin <<
":" << lmax <<
" phis " << phis.size();
786 for (
unsigned int k = 0;
k < etabin0.
layer.size(); ++
k)
791 etabin.
layer.emplace_back(std::pair<int, int>(lmin, lmax));
798 bins.emplace_back(etabin);
801 << lmin <<
":" << lmax <<
" phis " << etabin.
phis.size();
802 for (
unsigned int k = 0;
k < etabin.
layer.size(); ++
k)
811 edm::LogError(
"HCalGeom") <<
"HcalDDDRecConstants: sizes of the vectors " 814 throw cms::Exception(
"DDException") <<
"HcalDDDRecConstants: inconsistent array sizes" <<
nEta <<
":" 824 int ieta(0), ietaHB(0), ietaHE(0), ietaHEM(0);
826 for (
int i = 0;
i <
nEta; ++
i) {
831 <<
" at index " <<
i <<
" of etaTable from SimConstant";
833 <<
"HcalDDDRecConstants: Going beyond the array boundary " <<
hpar->
etaTable.size() <<
" at index " <<
i 834 <<
" of etaTable from SimConstant";
841 if (ieta <= hpar->
etaMax[0])
843 if (ieta <= hpar->
etaMin[1])
845 if (ieta <= hpar->
etaMax[1])
854 for (
unsigned int k = 0;
k < 4; ++
k)
859 for (
int i = 0;
i <
nEta; ++
i) {
861 phibin.emplace_back(dphi);
862 int nphi = (
int)((2._pi + 0.001) / dphi);
878 int nphi = (
int)((2._pi + 0.001) /
i);
883 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants: Modified eta/deltaphi table for " <<
nEta <<
" bins";
901 for (
int i = 0;
i <
nEta; ++
i) {
903 int laymax = (imx > 0) ?
layerGroup(
i, imx - 1) : 0;
905 int laymax0 = (imx > 16) ?
layerGroup(
i, 16) : laymax;
909 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:HB " <<
i <<
" " << imx <<
" " << laymax <<
" " << laymax0;
916 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:HE " <<
i <<
" " << imx <<
" " << laymax;
923 for (
int i = 0;
i < 4; ++
i)
931 for (
unsigned int i = 0;
i <
hpar->
rHB.size(); ++
i) {
936 <<
" halves and " <<
gconsHB.size() <<
" layers";
937 for (
unsigned int i = 0;
i <
gconsHB.size(); ++
i)
942 for (
unsigned int i = 0;
i <
hpar->
zHE.size(); ++
i) {
947 <<
" halves and " <<
gconsHE.size() <<
" layers";
948 for (
unsigned int i = 0;
i <
gconsHE.size(); ++
i)
966 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:Detector type and maximum depth for all RBX " 972 std::vector<int> phis;
977 int phi = (phis[0] > 0) ? phis[0] : -phis[0];
978 int zside = (phis[0] > 0) ? 1 : -1;
982 std::map<int, std::pair<int, int>> oldDep;
985 for (
int lay = 0; lay < lymax; ++lay) {
989 oldDep[
depth] = std::pair<int, int>(lmin, lay - 1);
995 oldDep[
depth] = std::pair<int, int>(lmin, lymax - 1);
998 <<
" with " << oldDep.size() <<
" old Depths";
1000 for (
std::map<
int, std::pair<int, int>>::const_iterator itr = oldDep.begin(); itr != oldDep.end(); ++itr, ++
kk)
1001 edm::LogVerbatim(
"HCalGeom") <<
"[" <<
kk <<
"] " << itr->first <<
" --> " << itr->second.first <<
":" 1002 << itr->second.second;
1009 std::vector<int>
count(oldDep.size(), 0);
1012 for (
int lay = layFront; lay <= layBack; ++lay) {
1014 for (
std::map<
int, std::pair<int, int>>::iterator itr = oldDep.begin(); itr != oldDep.end(); ++itr, ++
l) {
1015 if (lay >= (itr->second).first && lay <= (itr->second).
second) {
1021 int odepth(0), maxlay(0);
1023 for (
std::map<
int, std::pair<int, int>>::iterator itr = oldDep.begin(); itr != oldDep.end(); ++itr, ++
l) {
1025 odepth = itr->first;
1031 <<
" max " << maxlay;
1033 for (
int k : phis) {
1034 zside = (
k > 0) ? 1 : -1;
1041 std::vector<HcalDetId> ids;
1042 std::map<HcalDetId, std::vector<HcalDetId>>::iterator itr =
detIdSpR_.find(oldId);
1045 ids.emplace_back(newId);
1052 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:Map for merging new channels to old channel" 1053 <<
" IDs with " <<
detIdSp_.size() <<
" entries";
1056 edm::LogVerbatim(
"HCalGeom") <<
"[" <<
l <<
"] Special " << itr.first <<
" Standard " << itr.second;
1059 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:Reverse Map for mapping old to new IDs with " 1063 edm::LogVerbatim(
"HCalGeom") <<
"[" <<
l <<
"] Standard " << itr.first <<
" Special";
1064 for (
auto itr1 : itr.second)
1075 if (it.layer == (
unsigned int)(
eta + 1)) {
1076 return it.layerGroup.size();
1078 if (it.layer > (
unsigned int)(
eta + 1))
1080 k = it.layerGroup.size();
1088 if (it.layer == (
unsigned int)(
eta + 1)) {
1089 return it.layerGroup.at(
i);
1091 if (it.layer > (
unsigned int)(
eta + 1))
1093 k = it.layerGroup.at(
i);
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
Log< level::Info, true > LogVerbatim
std::map< HcalDetId, HcalDetId > detIdSp_
double getRZ(const int &subdet, const int &ieta, const int &depth) const
std::vector< double > etaTable
std::vector< int > iEtaMin
std::vector< int > etagroup
int getFrontLayer(const int &det, const int &eta) const
std::pair< int, int > depthMaxSp_
HcalDetId mergedDepthDetId(const HcalDetId &id) const
std::vector< double > rHB
void getOneEtaBin(HcalSubdetector subdet, int ieta, int zside, std::vector< std::pair< int, double >> &phis, std::map< int, int > &layers, bool planOne, std::vector< HcalDDDRecConstants::HcalEtaBin > &bins) const
int getDepthEta29M(const int &i, const bool &planOne) const
std::vector< std::pair< int, double > > getPhis(const int &subdet, const int &ieta) const
constexpr NumType convertRadToDeg(NumType radians)
bool mergedDepthList29(int ieta, int iphi, int depth) const
Sin< T >::type sin(const T &t)
int getLayerFront(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
int getDepthEta29(const int &phi, const int &zside, const int &i) const
static const int maxLayer_
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
HcalDetId idBack(const HcalDetId &id) const
uint32_t etaMaxHBHE() const
std::vector< int > maxDepth
std::pair< double, double > getPhiCons(const int &det, const int &ieta) const
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned int nCells() const
std::vector< HcalEtaBin > getEtaBins(const int &itype) const
std::vector< double > etaTableHF
int getDepthEta16M(const int &det) const
unsigned int numberOfCells(const HcalSubdetector &) const
std::vector< int > etaMax
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< int > phiUnitS
int phiNumber(const int &phi, const int &unit) const
std::vector< HFCellParameters > getHFCellParameters() const
U second(std::pair< T, U > const &p)
std::vector< std::pair< double, double > > gconsHE
const HcalParameters * hpar
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
void specialRBXHBHE(const std::vector< HcalDetId > &, std::vector< HcalDetId > &) const
const std::vector< double > & getRTableHF() const
std::pair< int, int > getMaxDepthDet(const int &i) const
std::pair< int, int > depthMaxDf_
std::vector< double > zHE
std::vector< double > phibin
std::pair< int, int > getDepths(const int eta) const
std::vector< double > dzHE
Cos< T >::type cos(const T &t)
std::vector< int > iEtaMax
Abs< T >::type abs(const T &t)
std::vector< HcalCellType > HcalCellTypes() const
std::vector< int > ietaMap
std::vector< int > nPhiBins
const std::vector< double > & getPhiTableHF() const
const std::vector< int > & getPhis() const
const HcalLayerDepthMap * ldMap() const
std::vector< std::pair< int, int > > layer
std::vector< std::pair< int, int > > etaSimValu
int getMaxDepth(const int &type) const
int findDepth(const int &det, const int &eta, const int &phi, const int &zside, const int &lay) const
unsigned int layerGroupSize(int eta) const
Basic3DVector unit() const
int unitPhi(const int &det, const int &etaR) const
std::vector< HcalCellType > HcalCellTypes(HcalSubdetector) const
std::vector< std::pair< double, double > > gconsHB
int getLayerBack(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
Log< level::Info, false > LogInfo
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
std::vector< double > phioff
int getPhiZOne(std::vector< std::pair< int, int >> &phiz) const
std::vector< double > etaTable
const std::vector< HcalDetId > & getIdHF2QIE() const
HcalDDDRecConstants(const HcalParameters *hp, const HcalDDDSimConstants &hc)
unsigned int numberOfCells(HcalSubdetector) const
void getLayerDepth(const int &ieta, std::map< int, int > &layers) const
int getMinDepth(const int &det, const int &eta, const int &phi, const int &zside, const bool &partialOnly) const
std::vector< double > phitable
HcalDetId idFront(const HcalDetId &id) const
TString units(TString variable, Char_t axis)
std::vector< double > phibin
std::vector< LayerItem > layerGroupEtaRec
int getLayerFront(const int &det, const int &eta, const int &phi, const int &depth) const
std::vector< double > drHB
const HcalDDDSimConstants & hcons
std::vector< HcalActiveLength > getThickActive(const int &type) const
unsigned int layerGroup(int eta, int i) const
std::vector< std::pair< int, double > > phis
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
void getLayerDepth(const int subdet, const int ieta, const int iphi, const int zside, std::map< int, int > &layers) const
std::vector< int > maxDepth
std::vector< int > phigroup
std::pair< int, int > validEta() const
std::vector< int > getDepth(const int &det, const int &phi, const int &zside, const unsigned int &eta) const
int getMaxDepth(const int &type) const
int getLastLayer(const int &det, const int &eta) const
Geom::Theta< T > theta() const
static const int maxLayerHB_
int validDet(std::vector< int > &phis) const
int getDepthEta16(const int &det, const int &phi, const int &zside) const
int getLayerBack(const int &det, const int &eta, const int &phi, const int &depth) const
std::map< HcalDetId, std::vector< HcalDetId > > detIdSpR_
std::vector< int > etaMin