6 #include "CLHEP/Units/GlobalPhysicalConstants.h" 7 #include "CLHEP/Units/GlobalSystemOfUnits.h" 15 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::HcalDDDSimConstants (const HcalParameter* hp) constructor\n";
22 <<
" cells of type HCal (All)\n";
28 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants::destructed!!!\n";
33 const int&
depth,
const int& etaR,
34 const int& iphi)
const {
43 double eta = 0, deta = 0,
phi = 0, dphi = 0, rz = 0, drz = 0;
44 bool ok =
false, flagrz =
true;
47 && etaR >=etaMn && etaR <= etaMx && depth > 0) ok =
true;
48 if (idet == static_cast<int>(
HcalEndcap) && depth>(
int)(
hpar->
zHE.size()))ok=
false;
50 else if (idet == static_cast<int>(
HcalOuter) && depth != 4) ok=
false;
53 eta =
getEta(idet, etaR, zside, depth);
60 }
else if (idet == static_cast<int>(
HcalEndcap)) {
68 phi =-fioff + (iphi - 0.5)*fibin;
72 if (ir > 0 && ir <
nR) {
78 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants: wrong eta " << etaR
79 <<
" (" << ir <<
"/" <<
nR <<
") Detector " 83 }
else if (etaR <=
nEta) {
84 int laymin(depth), laymax(depth);
85 if (idet == static_cast<int>(
HcalOuter)) {
103 << depth <<
" or etaR " << etaR
104 <<
" for detector " << idet;
108 edm::LogWarning(
"HCalGeom") <<
"HcalDDDSimConstants: wrong depth " << depth
115 <<
"phi " << idet <<
"/" << zside <<
"/" 116 << depth <<
"/" << etaR <<
"/" << iphi
117 <<
" Cell Flag " << tmp.
ok <<
" " << tmp.
eta 118 <<
" " << tmp.
deta <<
" phi " << tmp.
phi <<
" " 119 << tmp.
dphi <<
" r(z) " << tmp.
rz <<
" " 127 const int& lay)
const {
135 unsigned int id = layerGroup.size();
136 for (
unsigned int i = 0;
i < layerGroup.size();
i++) {
137 if (layer == (
int)(layerGroup[
i].layer)) {
147 std::vector<std::pair<double,double> > gcons;
149 for (
unsigned int i=0;
i<
hpar->
rHB.size(); ++
i) {
153 for (
unsigned int i=0;
i<
hpar->
zHE.size(); ++
i) {
161 const int&
zside)
const {
173 std::vector<int> phis;
176 int zside = (phis[0] > 0) ? 1 : -1;
177 int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
179 if (det == 1 && depthsp > depth) depth = depthsp;
180 if (det == 2 && depthsp < depth) depth = depthsp;
186 const int&
i)
const {
194 const bool& planOne)
const {
196 if (i == 0 && planOne) {
197 std::vector<int> phis;
200 int zside = (phis[0] > 0) ? 1 : -1;
201 int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
203 if (depthsp > depth) depth = depthsp;
210 const int&
depth)
const {
212 int hsubdet(0), ieta(0);
214 double heta = fabs(eta);
229 etaR = (eta >= 0. ? hR : -hR);
231 return std::pair<int,double>(hsubdet,etaR);
235 const double& hetaR)
const {
240 for (
int i =
nR-1;
i > 0;
i--)
241 if (hetaR < hpar->rTable[
i]) ieta =
hpar->
etaMin[2] +
nR - i - 1;
244 for (
int i = 0;
i <
nEta-1;
i++)
251 }
else if (det == static_cast<int>(
HcalEndcap)) {
262 const int& lay)
const {
266 << det <<
":" << etaR <<
":" << phi <<
":" 267 << zside <<
":" << depth <<
":" << lay;
270 if ((det == static_cast<int>(
HcalEndcap)) && (etaR == 17) && (lay == 1))
273 }
else if (det == static_cast<int>(
HcalOuter)) {
277 depth =
layerGroup(det, etaR, phi, zside, lay-1);
278 if (etaR ==
hpar->
noff[0] && lay > 1) {
280 kphi = (kphi-1)%4 + 1;
281 if (kphi == 2 || kphi == 3)
282 depth =
layerGroup(det, etaR, phi, zside, lay-2);
284 }
else if (det == static_cast<int>(
HcalBarrel)) {
302 << etaR <<
":" <<
depth;
304 return std::pair<int,int>(etaR,
depth);
308 const double&
y,
const double&
z)
const {
311 double eta = fabs(etaR);
316 if (eta <= hpar->etaTable[10]) eta =
hpar->
etaTable[10]+0.001;
317 }
else if (zz >
hpar->
zHO[1]) {
318 if (eta <= hpar->etaTable[4]) eta =
hpar->
etaTable[4]+0.001;
321 eta = (z >= 0. ? eta : -
eta);
325 if (eta != etaR)
edm::LogInfo (
"HCalGeom") <<
"**** Check *****";
364 const int&
zside)
const {
373 const int&
depth)
const {
377 if (det == 1 || det == 2) {
393 const int&
depth)
const {
397 if (det == 1 || det ==2) {
398 layer =
depths[depth-1][eta-1];
414 const bool& partialDetOnly)
const {
417 if (partialDetOnly) {
421 }
else if (det == 1 || det == 2) {
430 }
else if (det == 3) {
432 }
else if (det == 4) {
442 const bool& partialDetOnly)
const {
445 if (partialDetOnly) {
449 }
else if (det == 3) {
451 }
else if (det == 4) {
458 unsigned int type = (det == 1) ? 0 : 1;
478 const int& ieta)
const {
480 double fioff(0), fibin(0);
495 return std::pair<double,double>(fioff,fibin);
498 std::vector<std::pair<int,double> >
501 std::vector<std::pair<int,double> > phis;
502 int ietaAbs = (ieta > 0) ? ieta : -ieta;
503 std::pair<double,double> ficons =
getPhiCons(subdet, ietaAbs);
504 int nphi =
int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
506 for (
int ifi = 0; ifi < nphi; ++ifi) {
507 double phi =-ficons.first + (ifi+0.5)*ficons.second;
509 phis.emplace_back(std::pair<int,double>(iphi,phi));
512 edm::LogVerbatim(
"HcalGeom") <<
"getPhis: subdet|ieta|iphi " << subdet <<
"|" 513 << ieta <<
" with " << phis.size()
515 for (
unsigned int k=0;
k<phis.size(); ++
k)
517 <<
" phi " << phis[
k].second/CLHEP::deg;
526 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
527 <<
" cells of type HCal Barrel\n";
528 for (
unsigned int i=0;
i<cellTypes.size();
i++)
529 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << cellTypes[
i] <<
"\n";
534 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hoCells.size()
535 <<
" cells of type HCal Outer\n";
536 for (
unsigned int i=0;
i<hoCells.size();
i++)
537 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hoCells[
i] <<
"\n";
539 cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
543 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << heCells.size()
544 <<
" cells of type HCal Endcap\n";
545 for (
unsigned int i=0;
i<heCells.size();
i++)
546 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << heCells[
i] <<
"\n";
548 cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
552 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hfCells.size()
553 <<
" cells of type HCal Forward\n";
554 for (
unsigned int i=0;
i<hfCells.size();
i++)
555 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hfCells[
i] <<
"\n";
557 cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
563 int ieta,
int depthl)
const {
565 std::vector<HcalCellType> cellTypes;
567 if (
dzVcal < 0)
return cellTypes;
570 int dmin, dmax, indx, nz;
580 dmin = 4; dmax = 4; indx = 0; nz =
nzHB;
586 if (depthl > 0) dmin = dmax = depthl;
587 int ietamin = (ieta>0) ? ieta :
hpar->
etaMin[indx];
588 int ietamax = (ieta>0) ? ieta :
hpar->
etaMax[indx];
589 int phi = (indx == 2) ? 3 : 1;
592 int subdet0 =
static_cast<int>(subdet);
600 for (
int eta=ietamin;
eta<=ietamax;
eta++) {
601 for (
int iz=0; iz<nz; ++iz) {
602 int zside = -2*iz + 1;
605 std::vector<std::pair<int,double> > phis =
getPhis(subdet0,
eta);
609 std::vector<int> phiMiss2;
616 for (
int miss=0; miss<
hpar->
noff[5+iz]; miss++) {
617 phiMiss2.emplace_back(
hpar->
noff[kk]);
631 temp2.
setPhi(phis,phiMiss2,fioff,dphi,unit);
632 cellTypes.emplace_back(temp2);
637 std::vector<int> phiMiss3;
638 for (
auto & phi : phis) {
641 if ((
eta*zside ==
l.ieta()) &&
642 (phi.first ==
l.iphi())) {
647 if (!ok) phiMiss3.emplace_back(phi.first);
652 temp3.
setPhi(phis,phiMiss2,fioff,dphi,unit);
653 cellTypes.emplace_back(temp3);
667 if ((eta ==
k.ieta()) && (iphi ==
k.iphi())) {
671 if (!ok) mxdepth = 2;
678 unsigned int num = 0;
680 for (
auto & cellType : cellTypes) {
681 num += (
unsigned int)(cellType.nPhiBins());
685 << cellTypes.size() <<
" " << num
686 <<
" for subdetector " << subdet;
694 if (units==2) iphi_skip = (phi-1)*2+1;
695 else if (units==4) iphi_skip = (phi-1)*4-1;
696 if (iphi_skip < 0) iphi_skip += 72;
702 std::vector<int> phis;
704 int kphi = (detsp > 0) ? phis[0] : 1;
705 int zside = (kphi > 0) ? 1 : -1;
706 int iphi = (kphi > 0) ? kphi : -kphi;
745 const double fiveDegInRad = 2*
M_PI/72;
746 int units =
int(dphi/fiveDegInRad+0.5);
747 if (units < 1) units = 1;
773 <<
" zVcal " <<
zVcal <<
" and dzVcal " 780 for (
int i=0;
i<nEta-1; ++
i) {
782 int laymax = (imx > 0) ?
layerGroup(
i, imx-1 ) : 0;
783 if (i < hpar->
etaMax[0]) {
784 int laymax0 = (imx > 16) ?
layerGroup(
i, 16) : laymax;
785 if (
i+1 ==
hpar->
etaMax[0] && laymax0 > 2) laymax0 = 2;
788 if (
i >=
hpar->
etaMin[1]-1 && i < hpar->etaMax[1]) {
793 for (
int i=0;
i<4; ++
i)
800 for (
int i=0;
i<maxdepth; ++
i) {
801 for (
int k=0;
k<nEta-1; ++
k) {
804 for (
int l=layermx-1;
l >= 0; --
l) {
814 <<
depths[
i].size() <<
" etas:";
815 for (
int k=0;
k<nEta-1; ++
k)
827 <<
nmodHE <<
" endcap half-sectors";
846 for (
int i=0;
i<4; ++
i)
848 for (
unsigned int i=0;
i<
hpar->
zHO.size(); ++
i)
853 int noffl(noffsize+5);
854 if ((
int)(
hpar->
noff.size()) > (noffsize+3)) {
859 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
860 noffl += (2*
hpar->
noff[noffsize+4]);
871 << noffsize <<
":" << noffl <<
":" <<
isBH_;
874 <<
"; max depth for itea = 29 : (" 878 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
881 for (
int k=0;
k<npair; ++
k) {
888 <<
" detector channels having 2 QIE cards:";
898 int noffk(noffsize+5);
899 if ((
int)(
hpar->
noff.size()) > (noffsize+5)) {
900 noffk += (2*
hpar->
noff[noffsize+4]);
901 if ((
int)(
hpar->
noff.size()) >= noffk+7) {
907 double wt = 0.1*(
hpar->
noff[noffk+6]);
908 if ((
int)(
hpar->
noff.size()) >= (noffk+7+nphi+3*ndeps)) {
909 if (dtype == 1 || dtype == 2) {
910 std::vector<int> ifi, iet, ily, idp;
911 for (
int i=0;
i<nphi; ++
i) ifi.emplace_back(
hpar->
noff[noffk+7+
i]);
912 for (
int i=0;
i<ndeps;++
i) {
913 iet.emplace_back(
hpar->
noff[noffk+7+nphi+3*
i]);
914 ily.emplace_back(
hpar->
noff[noffk+7+nphi+3*
i+1]);
915 idp.emplace_back(
hpar->
noff[noffk+7+nphi+3*
i+2]);
919 <<
"Detector " << dtype <<
" etaMax " 921 << nphi <<
" sectors";
922 for (
int i=0;
i<nphi; ++
i)
925 for (
int i=0;
i<ndeps;++
i)
927 << ily[
i] <<
" " << idp[
i];
929 << depthEta29[0] <<
":" << ndp16 <<
":" 930 << ndp29 <<
" L0 Wt " 935 int zside = (ifi[0]>0) ? 1 : -1;
936 int iphi = (ifi[0]>0) ? ifi[0] : -ifi[0];
940 int noffm = (noffk+7+nphi+3*ndeps);
941 if ((
int)(
hpar->
noff.size()) > noffm) {
943 if (ndnext > 4 && (
int)(
hpar->
noff.size()) >= noffm+ndnext) {
947 if (ndnext > 11 && (
int)(
hpar->
noff.size()) >= noffm+ndnext) {
957 <<
" and for HE: " <<
layFHE[0] <<
":" 961 <<
" and for HE: " <<
layBHE[0] <<
":" 975 edm::LogVerbatim(
"HcalGeom") <<
"Detector type and maximum depth for all RBX " 983 const int&
depth)
const {
988 if (ir > 0 && ir <
nR) {
990 if (depth%2 != 1) z +=
dlShort;
994 if (etaR > 0 && etaR <
nEta) {
997 }
else if (det == static_cast<int>(
HcalOuter)) {
1000 }
else if (etaR ==
hpar->
noff[2]+1) {
1002 }
else if (etaR ==
hpar->
noff[3]) {
1004 }
else if (etaR ==
hpar->
noff[3]+1) {
1016 <<
" " << depth <<
" ==> " <<
tmp;
1027 if (ir > 0 && ir <
nR) {
1029 if (depth%2 != 1) z +=
dlShort;
1033 if (etaR > 0 && etaR <
nEta) {
1036 }
else if (det == static_cast<int>(
HcalOuter)) {
1039 }
else if (etaR ==
hpar->
noff[2]+1) {
1041 }
else if (etaR ==
hpar->
noff[3]) {
1043 }
else if (etaR ==
hpar->
noff[3]+1) {
1053 if (zside == 0) tmp = -
tmp;
1055 edm::LogVerbatim(
"HcalGeom") <<
"HcalDDDSimConstants::getEta " << etaR <<
" " 1056 << zside <<
" " << depth <<
" ==> " <<
tmp;
1064 if (z != 0) tmp = -
log(
tan(0.5*atan(r/z)));
1067 << z <<
" ==> " <<
tmp;
1073 const int&
depth)
const {
1094 const int&
depth)
const {
1116 edm::LogVerbatim(
"HcalGeom") <<
"HcalDDDSimConstants::printTileHB for eta " 1117 << eta <<
" and depth " <<
depth;
1120 double thetaL = 2.*atan(
exp(-etaL));
1122 double thetaH = 2.*atan(
exp(-etaH));
1125 edm::LogVerbatim(
"HcalGeom") <<
"\ntileHB:: eta|depth " << zside*eta <<
"|" 1126 << depth <<
" theta " << thetaH/CLHEP::deg
1127 <<
":" << thetaL/CLHEP::deg <<
" Layer " 1128 << layL <<
":" << layH-1;
1129 for (
int lay=layL; lay<layH; ++lay) {
1130 std::vector<double>
area(2,0);
1148 << std::setw(8) << area[0] <<
" " 1149 << std::setw(8) << area[1] <<
" Mean " 1159 double thetaL = 2.*atan(
exp(-etaL));
1161 double thetaH = 2.*atan(
exp(-etaH));
1166 if (phib > 6*CLHEP::deg) nphi = 1;
1167 edm::LogVerbatim(
"HcalGeom") <<
"\ntileHE:: Eta/depth " << zside*eta <<
"|" 1168 << depth <<
" theta " << thetaH/CLHEP::deg
1169 <<
":" << thetaL/CLHEP::deg <<
" Layer " 1170 << layL <<
":" << layH-1 <<
" phi " << nphi;
1171 for (
int lay=layL; lay<layH; ++lay) {
1172 std::vector<double>
area(4,0);
1179 if ((lay != 0 || eta == 18) &&
1188 double ar1=0, ar2=0;
1190 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*
hpar->
dx1HE[
k]);
1193 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*
hpar->
dx1HE[
k]);
1194 ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*
tan(10.*CLHEP::deg)-4*
hpar->
dx1HE[
k])-ar1;
1203 if (area[0] > 0 && area[1] > 0) {
1205 if (eta == 18) lay0++;
1209 << std::setw(8) << area[0] <<
" " 1210 << std::setw(8) << area[1] <<
" Mean " 1215 << std::setw(8) << area[0] <<
" " 1216 << std::setw(8) << area[1] <<
":" 1217 << std::setw(8) << area[2] <<
" " 1218 << std::setw(8) << area[3] <<
" Mean " 1228 if (it.layer == (
unsigned int)(eta + 1)) {
1229 return it.layerGroup.size();
1231 if (it.layer > (
unsigned int)(eta + 1))
break;
1232 k = it.layerGroup.size();
1240 if (it.layer == (
unsigned int)(eta + 1)) {
1241 return it.layerGroup.at(i);
1243 if (it.layer > (
unsigned int)(eta + 1))
break;
1244 k = it.layerGroup.at(i);
1253 int depth0 =
findDepth(det,eta,phi,zside,lay);
1254 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
std::pair< int, double > getDetEta(const double &eta, const int &depth) const
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
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::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
int getEta(const int &det, const int &lay, const double &hetaR) const
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
std::pair< int, int > getEtaDepth(const int &det, int etaR, const int &phi, const int &zside, int depth, const int &lay) const
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