6 #include "CLHEP/Units/GlobalPhysicalConstants.h" 7 #include "CLHEP/Units/GlobalSystemOfUnits.h" 14 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::HcalDDDSimConstants (const HcalParameter* hp) constructor\n";
21 <<
" cells of type HCal (All)\n";
27 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants::destructed!!!\n";
32 const int&
depth,
const int& etaR,
33 const int& iphi)
const {
42 double eta = 0, deta = 0,
phi = 0, dphi = 0, rz = 0, drz = 0;
43 bool ok =
false, flagrz =
true;
46 && etaR >=etaMn && etaR <= etaMx && depth > 0) ok =
true;
47 if (idet == static_cast<int>(
HcalEndcap) && depth>(
int)(
hpar->
zHE.size()))ok=
false;
49 else if (idet == static_cast<int>(
HcalOuter) && depth != 4) ok=
false;
52 eta =
getEta(idet, etaR, zside, depth);
59 }
else if (idet == static_cast<int>(
HcalEndcap)) {
67 phi =-fioff + (iphi - 0.5)*fibin;
71 if (ir > 0 && ir <
nR) {
77 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants: wrong eta " << etaR
78 <<
" (" << ir <<
"/" <<
nR <<
") Detector " 82 }
else if (etaR <=
nEta) {
83 int laymin(depth), laymax(depth);
84 if (idet == static_cast<int>(
HcalOuter)) {
102 << depth <<
" or etaR " << etaR
103 <<
" for detector " << idet;
107 edm::LogWarning(
"HCalGeom") <<
"HcalDDDSimConstants: wrong depth " << depth
114 <<
"phi " << idet <<
"/" << zside <<
"/" 115 << depth <<
"/" << etaR <<
"/" << iphi
116 <<
" Cell Flag " << tmp.
ok <<
" " << tmp.
eta 117 <<
" " << tmp.
deta <<
" phi " << tmp.
phi <<
" " 118 << tmp.
dphi <<
" r(z) " << tmp.
rz <<
" " 126 const int& lay)
const {
134 unsigned int id = layerGroup.size();
135 for (
unsigned int i = 0;
i < layerGroup.size();
i++) {
136 if (layer == (
int)(layerGroup[
i].layer)) {
146 std::vector<std::pair<double,double> > gcons;
148 for (
unsigned int i=0;
i<
hpar->
rHB.size(); ++
i) {
152 for (
unsigned int i=0;
i<
hpar->
zHE.size(); ++
i) {
160 const int&
zside)
const {
172 std::vector<int> phis;
175 int zside = (phis[0] > 0) ? 1 : -1;
176 int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
178 if (det == 1 && depthsp > depth) depth = depthsp;
179 if (det == 2 && depthsp < depth) depth = depthsp;
185 const int&
i)
const {
193 const bool& planOne)
const {
195 if (i == 0 && planOne) {
196 std::vector<int> phis;
199 int zside = (phis[0] > 0) ? 1 : -1;
200 int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
202 if (depthsp > depth) depth = depthsp;
211 int hsubdet(0), ieta(0);
213 double heta = fabs(eta);
228 etaR = (eta >= 0. ? hR : -hR);
230 return std::pair<int,double>(hsubdet,etaR);
234 const double& hetaR) {
239 for (
int i =
nR-1;
i > 0;
i--)
240 if (hetaR < hpar->rTable[
i]) ieta =
hpar->
etaMin[2] +
nR - i - 1;
243 for (
int i = 0;
i <
nEta-1;
i++)
250 }
else if (det == static_cast<int>(
HcalEndcap)) {
259 int depth,
const int& lay) {
263 << det <<
":" << etaR <<
":" << phi <<
":" 264 << zside <<
":" << depth <<
":" << lay;
267 if ((det == static_cast<int>(
HcalEndcap)) && (etaR == 17) && (lay == 1))
270 }
else if (det == static_cast<int>(
HcalOuter)) {
274 depth =
layerGroup(det, etaR, phi, zside, lay-1);
275 if (etaR ==
hpar->
noff[0] && lay > 1) {
277 kphi = (kphi-1)%4 + 1;
278 if (kphi == 2 || kphi == 3)
279 depth =
layerGroup(det, etaR, phi, zside, lay-2);
281 }
else if (det == static_cast<int>(
HcalBarrel)) {
299 << etaR <<
":" <<
depth;
301 return std::pair<int,int>(etaR,
depth);
305 const double&
y,
const double&
z)
const {
308 double eta = fabs(etaR);
313 if (eta <= hpar->etaTable[10]) eta =
hpar->
etaTable[10]+0.001;
314 }
else if (zz >
hpar->
zHO[1]) {
315 if (eta <= hpar->etaTable[4]) eta =
hpar->
etaTable[4]+0.001;
318 eta = (z >= 0. ? eta : -
eta);
322 if (eta != etaR)
edm::LogInfo (
"HCalGeom") <<
"**** Check *****";
361 const int&
zside)
const {
370 const int&
depth)
const {
374 if (det == 1 || det == 2) {
390 const int&
depth)
const {
394 if (det == 1 || det ==2) {
395 layer =
depths[depth-1][eta-1];
411 const bool& partialDetOnly)
const {
414 if (partialDetOnly) {
418 }
else if (det == 1 || det == 2) {
427 }
else if (det == 3) {
429 }
else if (det == 4) {
439 const bool& partialDetOnly)
const {
442 if (partialDetOnly) {
446 }
else if (det == 3) {
448 }
else if (det == 4) {
455 unsigned int type = (det == 1) ? 0 : 1;
475 const int& ieta)
const {
477 double fioff(0), fibin(0);
492 return std::pair<double,double>(fioff,fibin);
495 std::vector<std::pair<int,double> >
498 std::vector<std::pair<int,double> > phis;
499 int ietaAbs = (ieta > 0) ? ieta : -ieta;
500 std::pair<double,double> ficons =
getPhiCons(subdet, ietaAbs);
501 int nphi =
int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
503 for (
int ifi = 0; ifi < nphi; ++ifi) {
504 double phi =-ficons.first + (ifi+0.5)*ficons.second;
506 phis.emplace_back(std::pair<int,double>(iphi,phi));
509 edm::LogVerbatim(
"HcalGeom") <<
"getPhis: subdet|ieta|iphi " << subdet <<
"|" 510 << ieta <<
" with " << phis.size()
512 for (
unsigned int k=0;
k<phis.size(); ++
k)
514 <<
" phi " << phis[
k].second/CLHEP::deg;
523 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
524 <<
" cells of type HCal Barrel\n";
525 for (
unsigned int i=0;
i<cellTypes.size();
i++)
526 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << cellTypes[
i] <<
"\n";
531 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hoCells.size()
532 <<
" cells of type HCal Outer\n";
533 for (
unsigned int i=0;
i<hoCells.size();
i++)
534 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hoCells[
i] <<
"\n";
536 cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
540 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << heCells.size()
541 <<
" cells of type HCal Endcap\n";
542 for (
unsigned int i=0;
i<heCells.size();
i++)
543 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << heCells[
i] <<
"\n";
545 cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
549 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hfCells.size()
550 <<
" cells of type HCal Forward\n";
551 for (
unsigned int i=0;
i<hfCells.size();
i++)
552 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hfCells[
i] <<
"\n";
554 cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
560 int ieta,
int depthl)
const {
562 std::vector<HcalCellType> cellTypes;
564 if (
dzVcal < 0)
return cellTypes;
567 int dmin, dmax, indx, nz;
577 dmin = 4; dmax = 4; indx = 0; nz =
nzHB;
583 if (depthl > 0) dmin = dmax = depthl;
584 int ietamin = (ieta>0) ? ieta :
hpar->
etaMin[indx];
585 int ietamax = (ieta>0) ? ieta :
hpar->
etaMax[indx];
586 int phi = (indx == 2) ? 3 : 1;
589 int subdet0 =
static_cast<int>(subdet);
597 for (
int eta=ietamin;
eta<=ietamax;
eta++) {
598 for (
int iz=0; iz<nz; ++iz) {
599 int zside = -2*iz + 1;
602 std::vector<std::pair<int,double> > phis =
getPhis(subdet0,
eta);
606 std::vector<int> phiMiss2;
613 for (
int miss=0; miss<
hpar->
noff[5+iz]; miss++) {
614 phiMiss2.emplace_back(
hpar->
noff[kk]);
628 temp2.
setPhi(phis,phiMiss2,fioff,dphi,unit);
629 cellTypes.emplace_back(temp2);
634 std::vector<int> phiMiss3;
635 for (
auto & phi : phis) {
638 if ((
eta*zside ==
l.ieta()) &&
639 (phi.first ==
l.iphi())) {
644 if (!ok) phiMiss3.emplace_back(phi.first);
649 temp3.
setPhi(phis,phiMiss2,fioff,dphi,unit);
650 cellTypes.emplace_back(temp3);
664 if ((eta ==
k.ieta()) && (iphi ==
k.iphi())) {
668 if (!ok) mxdepth = 2;
675 unsigned int num = 0;
677 for (
auto & cellType : cellTypes) {
678 num += (
unsigned int)(cellType.nPhiBins());
682 << cellTypes.size() <<
" " << num
683 <<
" for subdetector " << subdet;
691 if (units==2) iphi_skip = (phi-1)*2+1;
692 else if (units==4) iphi_skip = (phi-1)*4-1;
693 if (iphi_skip < 0) iphi_skip += 72;
699 std::vector<int> phis;
701 int kphi = (detsp > 0) ? phis[0] : 1;
702 int zside = (kphi > 0) ? 1 : -1;
703 int iphi = (kphi > 0) ? kphi : -kphi;
742 const double fiveDegInRad = 2*
M_PI/72;
743 int units =
int(dphi/fiveDegInRad+0.5);
744 if (units < 1) units = 1;
770 <<
" zVcal " <<
zVcal <<
" and dzVcal " 777 for (
int i=0;
i<nEta-1; ++
i) {
779 int laymax = (imx > 0) ?
layerGroup(
i, imx-1 ) : 0;
780 if (i < hpar->
etaMax[0]) {
781 int laymax0 = (imx > 16) ?
layerGroup(
i, 16) : laymax;
782 if (
i+1 ==
hpar->
etaMax[0] && laymax0 > 2) laymax0 = 2;
785 if (
i >=
hpar->
etaMin[1]-1 && i < hpar->etaMax[1]) {
790 for (
int i=0;
i<4; ++
i)
797 for (
int i=0;
i<maxdepth; ++
i) {
798 for (
int k=0;
k<nEta-1; ++
k) {
801 for (
int l=layermx-1;
l >= 0; --
l) {
811 <<
depths[
i].size() <<
" etas:";
812 for (
int k=0;
k<nEta-1; ++
k)
824 <<
nmodHE <<
" endcap half-sectors";
843 for (
int i=0;
i<4; ++
i)
845 for (
unsigned int i=0;
i<
hpar->
zHO.size(); ++
i)
850 int noffl(noffsize+5);
851 if ((
int)(
hpar->
noff.size()) > (noffsize+3)) {
856 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
857 noffl += (2*
hpar->
noff[noffsize+4]);
868 << noffsize <<
":" << noffl <<
":" <<
isBH_;
871 <<
"; max depth for itea = 29 : (" 875 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
878 for (
int k=0;
k<npair; ++
k) {
885 <<
" detector channels having 2 QIE cards:";
895 int noffk(noffsize+5);
896 if ((
int)(
hpar->
noff.size()) > (noffsize+5)) {
897 noffk += (2*
hpar->
noff[noffsize+4]);
898 if ((
int)(
hpar->
noff.size()) > noffk+5) {
904 double wt = 0.1*(
hpar->
noff[noffk+6]);
905 if ((
int)(
hpar->
noff.size()) >= (noffk+7+nphi+3*ndeps)) {
906 if (dtype == 1 || dtype == 2) {
907 std::vector<int> ifi, iet, ily, idp;
908 for (
int i=0;
i<nphi; ++
i) ifi.emplace_back(
hpar->
noff[noffk+7+
i]);
909 for (
int i=0;
i<ndeps;++
i) {
910 iet.emplace_back(
hpar->
noff[noffk+7+nphi+3*
i]);
911 ily.emplace_back(
hpar->
noff[noffk+7+nphi+3*
i+1]);
912 idp.emplace_back(
hpar->
noff[noffk+7+nphi+3*
i+2]);
916 <<
"Detector " << dtype <<
" etaMax " 918 << nphi <<
" sectors";
919 for (
int i=0;
i<nphi; ++
i)
922 for (
int i=0;
i<ndeps;++
i)
924 << ily[
i] <<
" " << idp[
i];
926 << depthEta29[0] <<
":" << ndp16 <<
":" 927 << ndp29 <<
" L0 Wt " 932 int zside = (ifi[0]>0) ? 1 : -1;
933 int iphi = (ifi[0]>0) ? ifi[0] : -ifi[0];
937 int noffm = (noffk+7+nphi+3*ndeps);
938 if ((
int)(
hpar->
noff.size()) > noffm) {
940 if (ndnext > 4 && (
int)(
hpar->
noff.size()) >= noffm+ndnext) {
944 if (ndnext > 11 && (
int)(
hpar->
noff.size()) >= noffm+ndnext) {
954 <<
" and for HE: " <<
layFHE[0] <<
":" 958 <<
" and for HE: " <<
layBHE[0] <<
":" 972 edm::LogVerbatim(
"HcalGeom") <<
"Detector type and maximum depth for all RBX " 980 const int&
depth)
const {
985 if (ir > 0 && ir <
nR) {
987 if (depth%2 != 1) z +=
dlShort;
991 if (etaR > 0 && etaR <
nEta) {
994 }
else if (det == static_cast<int>(
HcalOuter)) {
997 }
else if (etaR ==
hpar->
noff[2]+1) {
1001 }
else if (etaR ==
hpar->
noff[3]+1) {
1013 <<
" " << depth <<
" ==> " <<
tmp;
1024 if (ir > 0 && ir <
nR) {
1026 if (depth%2 != 1) z +=
dlShort;
1030 if (etaR > 0 && etaR <
nEta) {
1033 }
else if (det == static_cast<int>(
HcalOuter)) {
1036 }
else if (etaR ==
hpar->
noff[2]+1) {
1038 }
else if (etaR ==
hpar->
noff[3]) {
1040 }
else if (etaR ==
hpar->
noff[3]+1) {
1050 if (zside == 0) tmp = -
tmp;
1052 edm::LogVerbatim(
"HcalGeom") <<
"HcalDDDSimConstants::getEta " << etaR <<
" " 1053 << zside <<
" " << depth <<
" ==> " <<
tmp;
1061 if (z != 0) tmp = -
log(
tan(0.5*atan(r/z)));
1064 << z <<
" ==> " <<
tmp;
1070 const int&
depth)
const {
1091 const int&
depth)
const {
1113 edm::LogVerbatim(
"HcalGeom") <<
"HcalDDDSimConstants::printTileHB for eta " 1114 << eta <<
" and depth " <<
depth;
1117 double thetaL = 2.*atan(
exp(-etaL));
1119 double thetaH = 2.*atan(
exp(-etaH));
1122 edm::LogVerbatim(
"HcalGeom") <<
"\ntileHB:: eta|depth " << zside*eta <<
"|" 1123 << depth <<
" theta " << thetaH/CLHEP::deg
1124 <<
":" << thetaL/CLHEP::deg <<
" Layer " 1125 << layL <<
":" << layH-1;
1126 for (
int lay=layL; lay<layH; ++lay) {
1127 std::vector<double>
area(2,0);
1145 << std::setw(8) << area[0] <<
" " 1146 << std::setw(8) << area[1] <<
" Mean " 1156 double thetaL = 2.*atan(
exp(-etaL));
1158 double thetaH = 2.*atan(
exp(-etaH));
1163 if (phib > 6*CLHEP::deg) nphi = 1;
1164 edm::LogVerbatim(
"HcalGeom") <<
"\ntileHE:: Eta/depth " << zside*eta <<
"|" 1165 << depth <<
" theta " << thetaH/CLHEP::deg
1166 <<
":" << thetaL/CLHEP::deg <<
" Layer " 1167 << layL <<
":" << layH-1 <<
" phi " << nphi;
1168 for (
int lay=layL; lay<layH; ++lay) {
1169 std::vector<double>
area(4,0);
1176 if ((lay != 0 || eta == 18) &&
1185 double ar1=0, ar2=0;
1187 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*
hpar->
dx1HE[
k]);
1190 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*
hpar->
dx1HE[
k]);
1191 ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*
tan(10.*CLHEP::deg)-4*
hpar->
dx1HE[
k])-ar1;
1200 if (area[0] > 0 && area[1] > 0) {
1202 if (eta == 18) lay0++;
1206 << std::setw(8) << area[0] <<
" " 1207 << std::setw(8) << area[1] <<
" Mean " 1212 << std::setw(8) << area[0] <<
" " 1213 << std::setw(8) << area[1] <<
":" 1214 << std::setw(8) << area[2] <<
" " 1215 << std::setw(8) << area[3] <<
" Mean " 1225 if (it.layer == (
unsigned int)(eta + 1)) {
1226 return it.layerGroup.size();
1228 if (it.layer > (
unsigned int)(eta + 1))
break;
1229 k = it.layerGroup.size();
1237 if (it.layer == (
unsigned int)(eta + 1)) {
1238 return it.layerGroup.at(i);
1240 if (it.layer > (
unsigned int)(eta + 1))
break;
1241 k = it.layerGroup.at(i);
1250 int depth0 =
findDepth(det,eta,phi,zside,lay);
1251 unsigned int depth = (depth0 > 0) ? (
unsigned int)(depth0) :
layerGroup(eta-1,lay);
std::vector< double > zHO
std::vector< double > etaTable
unsigned int layerGroupSize(int eta) const
int findDepth(const int &det, const int &eta, const int &phi, const int &zside, const int &lay) const
unsigned int layerGroup(int eta, int i) const
void initialize(const int subdet, const int ietaMax, const int dep16C, const int dep29C, const double wtl0C, std::vector< int > const &iphi, std::vector< int > const &ieta, std::vector< int > const &layer, std::vector< int > const &depth)
std::vector< int > maxDepth
std::vector< double > rHB
int getFrontLayer(const int &det, const int &eta) const
std::vector< double > rhoxHB
Sin< T >::type sin(const T &t)
static const int maxLayer_
std::vector< double > HBGains
int getLayerFront(const int &det, const int &eta, const int &phi, const int &zside, const int &depth) const
int getMinDepth(const int &det, const int &eta, const int &phi, const int &zside, const bool &partialOnly) const
bool isValid(const int det, const int phi, const int zside) const
Geom::Theta< T > theta() const
std::vector< int > HEShift
int phiNumber(const int &phi, const int &unit) const
void printTileHB(const int &eta, const int &phi, const int &zside, const int &depth) const
HcalDDDSimConstants(const HcalParameters *hp)
HcalCellType::HcalCell cell(const int &det, const int &zside, const int &depth, const int &etaR, const int &iphi) const
double getEtaHO(const double &etaR, const double &x, const double &y, const double &z) const
int getShift(const HcalSubdetector &subdet, const int &depth) const
int getLayerBack(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
std::vector< int > etaMax
std::vector< int > depths[nDepthMax]
int getLayerFront(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
std::vector< double > rhoxHE
std::pair< int, int > getDepths(const int eta) const
std::vector< std::pair< double, double > > getConstHBHE(const int &type) const
std::vector< double > zxHE
int validDet(std::vector< int > &phis) const
std::vector< double > zHE
std::vector< LayerItem > layerGroupEtaSim
std::vector< double > dyHE
int getMaxDepth(const int &type) const
void setPhi(const std::vector< std::pair< int, double >> &phis, const std::vector< int > &iphiMiss, double foff, double dphi, int unit)
int getDepthEta29(const int &phi, const int &zside, const int &i) const
int unitPhi(const int &det, const int &etaR) const
std::vector< double > dx1HE
std::vector< double > rHO
std::pair< int, int > depthMaxDf_
unsigned int findLayer(const int &layer, const std::vector< HcalParameters::LayerItem > &layerGroup) const
std::vector< double > dzHE
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::vector< HcalCellType > HcalCellTypes() const
int getLayerMax(const int &eta, const int &depth) const
std::vector< HcalDetId > idHF2QIE
std::pair< int, int > getEtaDepth(const int &det, int etaR, const int &phi, const int &zside, int depth, const int &lay)
int getLastLayer(const int &det, const int &eta) const
std::vector< int > HFShift
int getMaxDepthLastHE(const int subdet, const int iphi, const int zside) const
int getDepth(const int subdet, const int ieta, const int iphi, const int zside, const int layer) const
unsigned int numberOfCells(const HcalSubdetector &) const
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
int getDepthEta16M(const int &det) const
int getDepthEta29M(const int &i, const bool &planOne) const
std::vector< double > HEGains
double getLayer0Wt(const int subdet, const int iphi, const int zside) const
std::vector< double > dyHB
std::vector< double > phioff
int getDepth16(const int subdet, const int iphi, const int zside) const
std::pair< int, double > getDetEta(const double &eta, const int &depth)
std::vector< double > gparHF
std::pair< int, int > getModHalfHBHE(const int &type) const
int getLayerBack(const int &det, const int &eta, const int &phi, const int &zside, const int &depth) const
std::vector< double > Layer0Wt
std::vector< double > dxHB
double deltaEta(const int &det, const int &eta, const int &depth) const
std::vector< std::vector< double > > tmp
std::vector< double > rTable
std::vector< double > phitable
TString units(TString variable, Char_t axis)
std::vector< double > phibin
std::vector< double > drHB
std::vector< double > HFGains
int getEta(const int &det, const int &lay, const double &hetaR)
static unsigned int const shift
std::pair< int, int > depthMaxSp_
std::vector< int > HBShift
const HcalParameters * hpar
std::vector< int > maxDepth
int maxHFDepth(const int &ieta, const int &iphi) const
void printTileHE(const int &eta, const int &phi, const int &zside, const int &depth) const
std::pair< double, double > getPhiCons(const int &det, const int &ieta) const
static const int maxLayerHB_
double getGain(const HcalSubdetector &subdet, const int &depth) const
std::vector< std::pair< int, double > > getPhis(const int &subdet, const int &ieta) const
int getDepthMax(const int subdet, const int iphi, const int zside) const
std::vector< int > etaMin
int getDepthEta16(const int &det, const int &phi, const int &zside) const