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 int ieta = (keta > 0) ? keta : -keta;
164 int zside = (keta > 0) ? 1 : -1;
166 if ((subdet == static_cast<int>(
HcalOuter)) ||
175 phi0 = (
iphi + 1) / 2;
177 }
else if (
unit == 4) {
178 phi0 = (
iphi + 1) / 4;
197 kphi = (kphi - 1) % 4 + 1;
198 if (kphi == 2 || kphi == 3)
206 << lay <<
" output " <<
eta <<
":" <<
phi <<
":" <<
depth;
212 std::vector<HcalDDDRecConstants::HFCellParameters>
cells;
215 for (
unsigned int k = 0;
k <
nEta; ++
k) {
218 int iphi = (dphi == 4) ? 3 : 1;
219 int nphi = 72 / dphi;
241 for (
unsigned int k = 0;
k <
nEta; ++
k) {
244 int iphi = (dphi == 4) ? 3 : 1;
245 int nphi = 72 / dphi;
256 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants returns " <<
cells.size() <<
" HF cell parameters";
257 for (
unsigned int k = 0;
k <
cells.size(); ++
k)
273 for (std::map<int, int>::iterator itr =
layers.begin(); itr !=
layers.end(); ++itr)
279 int subdet = (idet == 1) ? 1 : 2;
284 if (layBack < 0 && eta <= hpar->
etaMax[1]) {
292 if (layBack < 0 || layBack > laymax)
296 <<
" Output " << layBack;
302 int subdet = (idet == 1) ? 1 : 2;
307 if ((layFront < 0) || ((subdet == static_cast<int>(
HcalEndcap)) && (
eta == 16))) {
308 if ((subdet == static_cast<int>(
HcalEndcap)) && (
eta == 16)) {
310 }
else if (eta <= hpar->
etaMax[1]) {
313 if ((
int)(
k) >= laymin) {
321 if (layFront < laymin)
326 <<
" Output " << layFront;
332 unsigned int type = (itype == 0) ? 0 : 1;
349 <<
" Output " << lmax;
359 }
else if (itype == 3) {
362 unsigned int type = (itype == 0) ? 0 : 1;
375 std::vector<std::pair<int, double>> phis;
379 double fioff = ficons.first;
381 int nphi =
int((2._pi + 0.1 * dphi) / dphi);
383 for (
int ifi = 0; ifi <
nphi; ++ifi) {
384 double phi = -fioff + (ifi + 0.5) * dphi;
386 phis.emplace_back(std::pair<int, double>(
iphi,
phi));
389 edm::LogVerbatim(
"HCalGeom") <<
"getEtaPhi: subdet|ieta|iphi " << subdet <<
"|" <<
ieta <<
" with " << phis.size()
391 for (
unsigned int k = 0;
k < phis.size(); ++
k)
404 int zside = (
k > 0) ? 1 : -1;
405 int phi = (
k > 0) ?
k : -
k;
406 phiz.emplace_back(std::pair<int, int>(
phi,
zside));
410 edm::LogVerbatim(
"HCalGeom") <<
"Special RBX for detector " << subdet <<
" with " << phiz.size() <<
" phi/z bins";
411 for (
unsigned int k = 0;
k < phiz.size(); ++
k)
412 edm::LogVerbatim(
"HCalGeom") <<
" [" <<
k <<
"] " << phiz[
k].first <<
":" << phiz[
k].second;
427 <<
depth <<
" lay|rz " << layf <<
"|" << rz;
443 int subdet =
id.subdetId();
444 int ieta =
id.ieta();
445 int iphi =
id.iphi();
446 int depth =
id.depth();
449 double rzf = (layf < 0)
454 double rzb = (layb < 0)
460 <<
depth <<
" lay|rz (front) " << layf <<
"|" << rzf <<
" lay|rz (back) " << layb <<
"|" 463 return std::pair<double, double>(rzf, rzb);
467 std::vector<HcalDDDRecConstants::HcalActiveLength> actives;
470 unsigned int kount(0);
475 int stype = (
bin.phis.size() > 4) ? 0 : 1;
478 double eta = 0.5 * (
bin.etaMin +
bin.etaMax);
484 <<
":" << layl <<
":" <<
bin.layer.size();
485 for (
auto ll :
bin.layer)
490 for (
unsigned int i = 0;
i <
bin.layer.size(); ++
i) {
494 for (
int j = lmin;
j <= lmax; ++
j) {
502 edm::LogVerbatim(
"HCalGeom") <<
"Type " <<
type <<
" L " << lmin <<
":" << lmax <<
" T " << thick;
504 thick *= (2. *
scale);
507 active.
iphis.emplace_back(
phi.first);
508 actives.emplace_back(active);
513 <<
" zside " << active.
zside <<
" depth " << active.
depth <<
" type " << active.
stype 514 <<
" thick " << active.
thick;
523 std::vector<HcalCellType>
cells;
526 std::vector<int> missPhi;
527 for (
const auto& etabin :
etabins) {
528 std::vector<HcalCellType>
temp;
529 std::vector<int>
count;
530 std::vector<double> dmin, dmax;
531 for (
unsigned int il = 0; il < etabin.layer.size(); ++il) {
533 temp.emplace_back(cell);
534 count.emplace_back(0);
535 dmin.emplace_back(0);
536 dmax.emplace_back(0);
538 int ieta = etabin.ieta;
541 for (
unsigned int il = 0; il < etabin.layer.size(); ++il) {
542 for (
auto& ic : cellsm) {
543 if (ic.depthSegment() >= etabin.layer[il].first && ic.depthSegment() <= etabin.layer[il].second &&
544 ic.etaBin() ==
temp[il].etaBin() && ic.zside() ==
temp[il].zside()) {
545 if (
count[il] == 0) {
547 dmin[il] = ic.depthMin();
548 dmax[il] = ic.depthMax();
551 if (ic.depthMin() < dmin[il])
552 dmin[il] = ic.depthMin();
553 if (ic.depthMax() > dmax[il])
554 dmax[il] = ic.depthMax();
559 for (
unsigned int il = 0; il < etabin.layer.size(); ++il) {
560 int depth = etabin.depthStart + (
int)(il);
561 temp[il].setEta(
ieta, etabin.etaMin, etabin.etaMax);
562 temp[il].setDepth(
depth, dmin[il], dmax[il]);
565 temp[il].setPhi(etabin.phis, missPhi, foff, etabin.dphi,
unit);
570 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants: found " <<
cells.size() <<
" cells for sub-detector type " 572 for (
unsigned int ic = 0; ic <
cells.size(); ++ic)
602 depths.reserve(depthMax - depthMin + 1);
611 unsigned int num = 0;
613 for (
auto& cellType : cellTypes) {
614 num += (
unsigned int)(cellType.nPhiBins());
617 edm::LogInfo(
"HCalGeom") <<
"HcalDDDRecConstants:numberOfCells " << cellTypes.size() <<
" " <<
num 618 <<
" for subdetector " << subdet;
630 unsigned int ncell(0);
632 ncell += ((etabin.phis.size()) * (etabin.layer.size()));
649 std::map<HcalDetId, HcalDetId>::const_iterator itr =
detIdSp_.find(
id);
658 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr =
detIdSpR_.find(
id);
660 hid =
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi(), (itr->second)[0].
depth());
666 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr =
detIdSpR_.find(
id);
668 hid =
HcalDetId(
id.subdet(),
id.ieta(),
id.iphi(), (itr->second).back().depth());
674 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr =
detIdSpR_.find(
id);
676 ids.emplace_back(
id);
678 for (
auto k : itr->second) {
680 ids.emplace_back(hid);
686 for (
auto k : idsOld) {
687 std::map<HcalDetId, HcalDetId>::const_iterator itr =
detIdSp_.find(
k);
689 idsNew.emplace_back(
k);
691 idsNew.emplace_back(itr->second);
697 std::map<HcalDetId, HcalDetId>::const_iterator itr;
699 ids.emplace_back(itr->first);
701 std::map<HcalDetId, std::vector<HcalDetId>>::const_iterator itr;
703 ids.emplace_back(itr->first);
705 return (!ids.empty());
712 std::map<int, int>&
layers,
714 std::vector<HcalDDDRecConstants::HcalEtaBin>&
bins)
const {
720 etabin.
phis.insert(etabin.
phis.end(), phis.begin(), phis.end());
726 int lmin(0), lmax(0);
728 std::map<int, int>::iterator itr =
layers.begin();
730 int dep = itr->second;
733 unsigned lymx0 = (
layers.size() > lymax) ? lymax :
layers.size();
736 <<
":" << lymax <<
" Depth " << dep <<
":" << itr->second;
739 edm::LogVerbatim(
"HCalGeom") <<
"Layer [" <<
l <<
"] " << itr->first <<
":" << itr->second;
741 for (
unsigned int l = 0;
l < phis.size(); ++
l)
744 for (itr =
layers.begin(); itr !=
layers.end(); ++itr) {
745 if (itr->first <= (
int)(lymx0)) {
746 if (itr->second == dep) {
750 }
else if (itr->second > dep) {
753 int lmax0 = (lmax >= lmin) ? lmax : lmin;
755 etabin0.
layer.emplace_back(std::pair<int, int>(lmin, lmax0));
757 etabin.
layer.emplace_back(std::pair<int, int>(lmin, lmax0));
769 if (itr->first == (
int)(lymx0))
775 etabin0.
layer.emplace_back(std::pair<int, int>(lmin, lmax));
776 etabin0.
phis.insert(etabin0.
phis.end(), phis.begin(), phis.end());
777 bins.emplace_back(etabin0);
780 <<
":" << lmin <<
":" << lmax <<
" phis " << phis.size();
781 for (
unsigned int k = 0;
k < etabin0.
layer.size(); ++
k)
786 etabin.
layer.emplace_back(std::pair<int, int>(lmin, lmax));
793 bins.emplace_back(etabin);
796 << lmin <<
":" << lmax <<
" phis " << etabin.
phis.size();
797 for (
unsigned int k = 0;
k < etabin.
layer.size(); ++
k)
806 edm::LogError(
"HCalGeom") <<
"HcalDDDRecConstants: sizes of the vectors " 809 throw cms::Exception(
"DDException") <<
"HcalDDDRecConstants: inconsistent array sizes" <<
nEta <<
":" 819 int ieta(0), ietaHB(0), ietaHE(0), ietaHEM(0);
821 for (
int i = 0;
i <
nEta; ++
i) {
826 <<
" at index " <<
i <<
" of etaTable from SimConstant";
828 <<
"HcalDDDRecConstants: Going beyond the array boundary " <<
hpar->
etaTable.size() <<
" at index " <<
i 829 <<
" of etaTable from SimConstant";
836 if (ieta <= hpar->
etaMax[0])
838 if (ieta <= hpar->
etaMin[1])
840 if (ieta <= hpar->
etaMax[1])
849 for (
unsigned int k = 0;
k < 4; ++
k)
854 for (
int i = 0;
i <
nEta; ++
i) {
856 phibin.emplace_back(dphi);
857 int nphi = (
int)((2._pi + 0.001) / dphi);
873 int nphi = (
int)((2._pi + 0.001) /
i);
878 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants: Modified eta/deltaphi table for " <<
nEta <<
" bins";
896 for (
int i = 0;
i <
nEta; ++
i) {
898 int laymax = (imx > 0) ?
layerGroup(
i, imx - 1) : 0;
900 int laymax0 = (imx > 16) ?
layerGroup(
i, 16) : laymax;
904 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:HB " <<
i <<
" " << imx <<
" " << laymax <<
" " << laymax0;
911 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:HE " <<
i <<
" " << imx <<
" " << laymax;
918 for (
int i = 0;
i < 4; ++
i)
926 for (
unsigned int i = 0;
i <
hpar->
rHB.size(); ++
i) {
931 <<
" halves and " <<
gconsHB.size() <<
" layers";
932 for (
unsigned int i = 0;
i <
gconsHB.size(); ++
i)
937 for (
unsigned int i = 0;
i <
hpar->
zHE.size(); ++
i) {
942 <<
" halves and " <<
gconsHE.size() <<
" layers";
943 for (
unsigned int i = 0;
i <
gconsHE.size(); ++
i)
961 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:Detector type and maximum depth for all RBX " 967 std::vector<int> phis;
972 int phi = (phis[0] > 0) ? phis[0] : -phis[0];
973 int zside = (phis[0] > 0) ? 1 : -1;
977 std::map<int, std::pair<int, int>> oldDep;
980 for (
int lay = 0; lay < lymax; ++lay) {
984 oldDep[
depth] = std::pair<int, int>(lmin, lay - 1);
990 oldDep[
depth] = std::pair<int, int>(lmin, lymax - 1);
993 <<
" with " << oldDep.size() <<
" old Depths";
995 for (
std::map<
int, std::pair<int, int>>::const_iterator itr = oldDep.begin(); itr != oldDep.end(); ++itr, ++
kk)
996 edm::LogVerbatim(
"HCalGeom") <<
"[" <<
kk <<
"] " << itr->first <<
" --> " << itr->second.first <<
":" 997 << itr->second.second;
1004 std::vector<int>
count(oldDep.size(), 0);
1007 for (
int lay = layFront; lay <= layBack; ++lay) {
1009 for (
std::map<
int, std::pair<int, int>>::iterator itr = oldDep.begin(); itr != oldDep.end(); ++itr, ++
l) {
1010 if (lay >= (itr->second).first && lay <= (itr->second).
second) {
1016 int odepth(0), maxlay(0);
1018 for (
std::map<
int, std::pair<int, int>>::iterator itr = oldDep.begin(); itr != oldDep.end(); ++itr, ++
l) {
1020 odepth = itr->first;
1026 <<
" max " << maxlay;
1028 for (
int k : phis) {
1029 zside = (
k > 0) ? 1 : -1;
1036 std::vector<HcalDetId> ids;
1037 std::map<HcalDetId, std::vector<HcalDetId>>::iterator itr =
detIdSpR_.find(oldId);
1040 ids.emplace_back(newId);
1047 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:Map for merging new channels to old channel" 1048 <<
" IDs with " <<
detIdSp_.size() <<
" entries";
1051 edm::LogVerbatim(
"HCalGeom") <<
"[" <<
l <<
"] Special " << itr.first <<
" Standard " << itr.second;
1054 edm::LogVerbatim(
"HCalGeom") <<
"HcalDDDRecConstants:Reverse Map for mapping old to new IDs with " 1058 edm::LogVerbatim(
"HCalGeom") <<
"[" <<
l <<
"] Standard " << itr.first <<
" Special";
1059 for (
auto itr1 : itr.second)
1070 if (it.layer == (
unsigned int)(
eta + 1)) {
1071 return it.layerGroup.size();
1073 if (it.layer > (
unsigned int)(
eta + 1))
1075 k = it.layerGroup.size();
1083 if (it.layer == (
unsigned int)(
eta + 1)) {
1084 return it.layerGroup.at(
i);
1086 if (it.layer > (
unsigned int)(
eta + 1))
1088 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
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