6 #include "CLHEP/Units/GlobalPhysicalConstants.h" 7 #include "CLHEP/Units/GlobalSystemOfUnits.h" 14 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::HcalDDDSimConstants (const HcalParameter* hp) constructor\n";
20 std::cout <<
"HcalDDDSimConstants: " << cellTypes.size()
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
113 std::cout <<
"HcalDDDSimConstants: det/side/depth/etaR/phi " 114 << idet <<
"/" << zside <<
"/" << depth <<
"/" 115 << etaR <<
"/" << iphi <<
" Cell Flag " << tmp.
ok 116 <<
" " << tmp.
eta <<
" " << tmp.
deta <<
" phi " 117 << tmp.
phi <<
" " << tmp.
dphi <<
" r(z) " << tmp.
rz 118 <<
" " << tmp.
drz <<
" " << tmp.
flagrz << std::endl;
125 const int lay)
const {
133 unsigned int id = layerGroup.size();
134 for (
unsigned int i = 0;
i < layerGroup.size();
i++) {
135 if (layer == (
int)(layerGroup[
i].layer)) {
145 std::vector<std::pair<double,double> > gcons;
147 for (
unsigned int i=0;
i<
hpar->
rHB.size(); ++
i) {
151 for (
unsigned int i=0;
i<
hpar->
zHE.size(); ++
i) {
159 const int zside)
const {
164 std::cout <<
"getDepthEta16: " << det <<
":" << depth << std::endl;
171 std::vector<int> phis;
174 int zside = (phis[0] > 0) ? 1 : -1;
175 int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
177 if (det == 1 && depthsp > depth) depth = depthsp;
178 if (det == 2 && depthsp < depth) depth = depthsp;
192 const bool planOne)
const {
194 if (i == 0 && planOne) {
195 std::vector<int> phis;
198 int zside = (phis[0] > 0) ? 1 : -1;
199 int iphi = (phis[0] > 0) ? phis[0] : -phis[0];
201 if (depthsp > depth) depth = depthsp;
210 int hsubdet(0), ieta(0);
212 double heta = fabs(eta);
227 etaR = (eta >= 0. ? hR : -hR);
229 return std::pair<int,double>(hsubdet,etaR);
233 const double hetaR) {
238 for (
int i =
nR-1;
i > 0;
i--)
239 if (hetaR < hpar->rTable[
i]) ieta =
hpar->
etaMin[2] +
nR - i - 1;
242 for (
int i = 0;
i <
nEta-1;
i++)
249 }
else if (det == static_cast<int>(
HcalEndcap)) {
258 int depth,
int lay) {
261 if ((det == static_cast<int>(
HcalEndcap)) && (etaR == 17) && (lay == 1))
264 }
else if (det == static_cast<int>(
HcalOuter)) {
268 depth=
layerGroup(det, etaR, phi, zside, lay-1);
269 if (etaR ==
hpar->
noff[0] && lay > 1) {
271 kphi = (kphi-1)%4 + 1;
272 if (kphi == 2 || kphi == 3)
273 depth =
layerGroup(det, etaR, phi, zside, lay-2);
275 }
else if (det == static_cast<int>(
HcalBarrel)) {
291 return std::pair<int,int>(etaR,
depth);
298 double eta = fabs(etaR);
303 if (eta <= hpar->etaTable[10]) eta =
hpar->
etaTable[10]+0.001;
304 }
else if (zz >
hpar->
zHO[1]) {
305 if (eta <= hpar->etaTable[4]) eta =
hpar->
etaTable[4]+0.001;
308 eta = (z >= 0. ? eta : -
eta);
310 std::cout <<
"R " << r <<
" Z " << z <<
" eta " << etaR
311 <<
":" << eta << std::endl;
312 if (eta != etaR)
edm::LogInfo (
"HCalGeom") <<
"**** Check *****";
321 const int zside)
const {
330 const int depth)
const {
334 if (det == 1 || det == 2) {
350 const int depth)
const {
354 if (det == 1 || det ==2) {
355 layer =
depths[depth-1][eta-1];
371 const bool partialDetOnly)
const {
374 if (partialDetOnly) {
378 }
else if (det == 1 || det == 2) {
387 }
else if (det == 3) {
389 }
else if (det == 4) {
399 const bool partialDetOnly)
const {
402 if (partialDetOnly) {
406 }
else if (det == 3) {
408 }
else if (det == 4) {
415 unsigned int type = (det == 1) ? 0 : 1;
435 const int ieta)
const {
437 double fioff(0), fibin(0);
452 return std::pair<double,double>(fioff,fibin);
455 std::vector<std::pair<int,double> >
458 std::vector<std::pair<int,double> > phis;
459 int ietaAbs = (ieta > 0) ? ieta : -ieta;
460 std::pair<double,double> ficons =
getPhiCons(subdet, ietaAbs);
461 int nphi =
int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
463 for (
int ifi = 0; ifi < nphi; ++ifi) {
464 double phi =-ficons.first + (ifi+0.5)*ficons.second;
466 phis.push_back(std::pair<int,double>(iphi,phi));
469 std::cout <<
"getPhis: subdet|ieta|iphi " << subdet <<
"|" << ieta
470 <<
" with " << phis.size() <<
" phi bins" << std::endl;
471 for (
unsigned int k=0;
k<phis.size(); ++
k)
473 << phis[
k].
second/CLHEP::deg << std::endl;
482 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
483 <<
" cells of type HCal Barrel\n";
484 for (
unsigned int i=0;
i<cellTypes.size();
i++)
485 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << cellTypes[
i] <<
"\n";
490 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hoCells.size()
491 <<
" cells of type HCal Outer\n";
492 for (
unsigned int i=0;
i<hoCells.size();
i++)
493 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hoCells[
i] <<
"\n";
495 cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
499 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << heCells.size()
500 <<
" cells of type HCal Endcap\n";
501 for (
unsigned int i=0;
i<heCells.size();
i++)
502 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << heCells[
i] <<
"\n";
504 cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
508 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hfCells.size()
509 <<
" cells of type HCal Forward\n";
510 for (
unsigned int i=0;
i<hfCells.size();
i++)
511 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hfCells[
i] <<
"\n";
513 cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
520 std::vector<HcalCellType> cellTypes;
522 if (
dzVcal < 0)
return cellTypes;
525 int dmin, dmax, indx, nz;
535 dmin = 4; dmax = 4; indx = 0; nz =
nzHB;
541 if (depthl > 0) dmin = dmax = depthl;
542 int ietamin = (ieta>0) ? ieta :
hpar->
etaMin[indx];
543 int ietamax = (ieta>0) ? ieta :
hpar->
etaMax[indx];
544 int phi = (indx == 2) ? 3 : 1;
547 int subdet0 =
static_cast<int>(subdet);
555 for (
int eta=ietamin;
eta<=ietamax;
eta++) {
556 for (
int iz=0; iz<nz; ++iz) {
557 int zside = -2*iz + 1;
560 std::vector<std::pair<int,double> > phis =
getPhis(subdet0,
eta);
564 std::vector<int> phiMiss2;
571 for (
int miss=0; miss<
hpar->
noff[5+iz]; miss++) {
586 temp2.
setPhi(phis,phiMiss2,fioff,dphi,unit);
587 cellTypes.push_back(temp2);
592 std::vector<int> phiMiss3;
593 for (
unsigned int k=0;
k<phis.size(); ++
k) {
602 if (!ok) phiMiss3.push_back(phis[
k].
first);
607 temp3.
setPhi(phis,phiMiss2,fioff,dphi,unit);
608 cellTypes.push_back(temp3);
626 if (!ok) mxdepth = 2;
633 unsigned int num = 0;
635 for (
unsigned int i=0;
i<cellTypes.size();
i++) {
639 std::cout <<
"HcalDDDSimConstants:numberOfCells " 640 << cellTypes.size() <<
" " << num
641 <<
" for subdetector " << subdet << std::endl;
649 if (units==2) iphi_skip = (phi-1)*2+1;
650 else if (units==4) iphi_skip = (phi-1)*4-1;
651 if (iphi_skip < 0) iphi_skip += 72;
657 std::vector<int> phis;
659 int kphi = (detsp > 0) ? phis[0] : 1;
660 int zside = (kphi > 0) ? 1 : -1;
661 int iphi = (kphi > 0) ? kphi : -kphi;
696 const double fiveDegInRad = 2*
M_PI/72;
697 int units =
int(dphi/fiveDegInRad+0.5);
698 if (units < 1) units = 1;
711 std::cout <<
"HcalDDDSimConstants:Read LayerGroup" <<
i <<
":";
724 <<
" and dzVcal " <<
dzVcal << std::endl;
730 for (
int i=0;
i<nEta-1; ++
i) {
732 int laymax = (imx > 0) ?
layerGroup(
i, imx-1 ) : 0;
733 if (i < hpar->
etaMax[0]) {
734 int laymax0 = (imx > 16) ?
layerGroup(
i, 16) : laymax;
735 if (
i+1 ==
hpar->
etaMax[0] && laymax0 > 2) laymax0 = 2;
738 if (
i >=
hpar->
etaMin[1]-1 && i < hpar->etaMax[1]) {
743 for (
int i=0;
i<4; ++
i)
749 for (
int i=0;
i<maxdepth; ++
i) {
750 for (
int k=0;
k<nEta-1; ++
k) {
753 for (
int l=layermx-1;
l >= 0; --
l) {
775 <<
" endcap half-sectors" << std::endl;
790 <<
" " <<
etaHO[2] <<
" " <<
etaHO[3] << std::endl;
793 for (
unsigned int i=0;
i<
hpar->
zHO.size(); ++
i)
799 int noffl(noffsize+5);
800 if ((
int)(
hpar->
noff.size()) > (noffsize+3)) {
805 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
806 noffl += (2*
hpar->
noff[noffsize+4]);
817 << noffl <<
":" <<
isBH_ << std::endl;
819 <<
" HE (min) " <<
depthEta16[1] <<
"; max depth for itea = 29 : (" 823 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
826 for (
int k=0;
k<npair; ++
k) {
839 int noffk(noffsize+5);
840 if ((
int)(
hpar->
noff.size()) > (noffsize+5)) {
841 noffk += (2*
hpar->
noff[noffsize+4]);
842 if ((
int)(
hpar->
noff.size()) > noffk+5) {
848 double wt = 0.1*(
hpar->
noff[noffk+6]);
849 if (dtype == 1 || dtype == 2) {
850 if ((
int)(
hpar->
noff.size()) >= (noffk+7+nphi+3*ndeps)) {
851 std::vector<int> ifi, iet, ily, idp;
852 for (
int i=0;
i<nphi; ++
i) ifi.push_back(
hpar->
noff[noffk+7+
i]);
853 for (
int i=0;
i<ndeps;++
i) {
854 iet.push_back(
hpar->
noff[noffk+7+nphi+3*
i]);
855 ily.push_back(
hpar->
noff[noffk+7+nphi+3*
i+1]);
856 idp.push_back(
hpar->
noff[noffk+7+nphi+3*
i+2]);
859 std::cout <<
"Initialize HcalLayerDepthMap for Detector " << dtype
863 std::cout <<
" and " << ndeps <<
" depth sections" << std::endl;
864 for (
int i=0;
i<ndeps;++
i)
865 std::cout <<
" [" <<
i <<
"] " << iet[
i] <<
" " << ily[
i] <<
" " 866 << idp[
i] << std::endl;
868 <<
":" << ndp16 <<
":" << ndp29 <<
" L0 Wt " 873 int zside = (ifi[0]>0) ? 1 : -1;
874 int iphi = (ifi[0]>0) ? ifi[0] : -ifi[0];
890 std::cout <<
"Detector type and maximum depth for all RBX " 892 <<
" and for special RBX " <<
depthMaxSp_.first <<
":" 898 const int depth)
const {
903 if (ir > 0 && ir <
nR) {
905 if (depth%2 != 1) z +=
dlShort;
909 if (etaR > 0 && etaR <
nEta) {
912 }
else if (det == static_cast<int>(
HcalOuter)) {
915 }
else if (etaR ==
hpar->
noff[2]+1) {
919 }
else if (etaR ==
hpar->
noff[3]+1) {
930 std::cout <<
"HcalDDDSimConstants::deltaEta " << etaR <<
" " 931 << depth <<
" ==> " << tmp << std::endl;
942 if (ir > 0 && ir <
nR) {
944 if (depth%2 != 1) z +=
dlShort;
948 if (etaR > 0 && etaR <
nEta) {
951 }
else if (det == static_cast<int>(
HcalOuter)) {
954 }
else if (etaR ==
hpar->
noff[2]+1) {
958 }
else if (etaR ==
hpar->
noff[3]+1) {
968 if (zside == 0) tmp = -
tmp;
970 std::cout <<
"HcalDDDSimConstants::getEta " << etaR <<
" " 971 << zside <<
" " << depth <<
" ==> " << tmp <<
"\n";
979 if (z != 0) tmp = -
log(
tan(0.5*atan(r/z)));
981 std::cout <<
"HcalDDDSimConstants::getEta " << r <<
" " << z
982 <<
" ==> " << tmp << std::endl;
988 const int depth)
const {
1009 const int depth)
const {
1031 std::cout <<
"HcalDDDSimConstants::printTileHB for eta " << eta <<
" and depth " << depth <<
"\n";
1034 double thetaL = 2.*atan(
exp(-etaL));
1036 double thetaH = 2.*atan(
exp(-etaH));
1039 std::cout <<
"\ntileHB:: eta|depth " << zside*eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
"\n";
1040 for (
int lay=layL; lay<layH; ++lay) {
1041 std::vector<double> area(2,0);
1054 if (area[0] > 0)
std::cout << std::setw(2) << lay <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
1062 double thetaL = 2.*atan(
exp(-etaL));
1064 double thetaH = 2.*atan(
exp(-etaH));
1069 if (phib > 6*CLHEP::deg) nphi = 1;
1070 std::cout <<
"\ntileHE:: Eta/depth " << zside*eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
" phi " << nphi <<
"\n";
1071 for (
int lay=layL; lay<layH; ++lay) {
1072 std::vector<double> area(4,0);
1078 if ((lay != 0 || eta == 18) &&
1087 double ar1=0, ar2=0;
1089 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*
hpar->
dx1HE[
k]);
1091 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*
hpar->
dx1HE[
k]);
1092 ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*
tan(10.*CLHEP::deg)-4*
hpar->
dx1HE[
k])-ar1;
1100 if (area[0] > 0 && area[1] > 0) {
1102 if (eta == 18) lay0++;
1104 std::cout << std::setw(2) << lay0 <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
1106 std::cout << std::setw(2) << lay0 <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
":" << std::setw(8) << area[2] <<
" " << std::setw(8) << area[3] <<
"\n";
1115 if (it.layer == (
unsigned int)(eta + 1)) {
1116 return it.layerGroup.size();
1118 if (it.layer > (
unsigned int)(eta + 1))
break;
1119 k = it.layerGroup.size();
1125 const int i)
const {
1128 if (it.layer == (
unsigned int)(eta + 1)) {
1129 return it.layerGroup.at(i);
1131 if (it.layer > (
unsigned int)(eta + 1))
break;
1132 k = it.layerGroup.at(i);
1139 const int lay)
const {
1141 int depth0 =
findDepth(det,eta,phi,zside,lay);
1142 unsigned int depth = (depth0 > 0) ? (
unsigned int)(depth0) :
layerGroup(eta-1,lay);
std::vector< double > zHO
void setPhi(std::vector< std::pair< int, double >> &phis, std::vector< int > &iphiMiss, double foff, double dphi, int unit)
int findDepth(const int det, const int eta, const int phi, const int zside, const int lay) const
std::vector< double > etaTable
int maxHFDepth(const int ieta, const int iphi) const
std::pair< int, int > getEtaDepth(const int det, int etaR, int phi, int zside, int depth, int lay)
int getLayerBack(const int det, const int eta, const int phi, const int zside, const int depth) 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
std::pair< double, double > getPhiCons(const int det, const int ieta) const
double getGain(const HcalSubdetector subdet, const int depth) const
std::vector< double > rhoxHB
Sin< T >::type sin(const T &t)
static const int maxLayer_
std::vector< double > HBGains
bool isValid(const int det, const int phi, const int zside) const
Geom::Theta< T > theta() const
std::vector< int > HEShift
int getMaxDepth(const int type) const
std::vector< std::pair< double, double > > getConstHBHE(const int type) const
HcalDDDSimConstants(const HcalParameters *hp)
int getShift(const HcalSubdetector subdet, const int depth) const
void printTileHE(const int eta, const int phi, const int zside, const int depth) const
unsigned int numberOfCells(HcalSubdetector) 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 getDepthEta29M(const int i, const bool planOne) const
int getLayerFront(const int subdet, const int ieta, const int iphi, const int zside, const int depth) const
std::vector< double > rhoxHE
U second(std::pair< T, U > const &p)
std::pair< int, int > getDepths(const int eta) const
double deltaEta(const int det, const int eta, const int depth) const
std::vector< double > zxHE
std::vector< std::pair< int, double > > getPhis(const int subdet, const int ieta) const
int validDet(std::vector< int > &phis) const
std::vector< double > zHE
double getEtaHO(double &etaR, double &x, double &y, double &z) const
std::vector< LayerItem > layerGroupEtaSim
std::pair< int, double > getDetEta(const double eta, const int depth)
std::vector< double > dyHE
std::vector< double > dx1HE
std::vector< double > rHO
int getDepthEta29(const int phi, int zside, int i) const
void printTileHB(const int eta, const int phi, const int zside, const int depth) const
std::pair< int, int > depthMaxDf_
std::vector< double > dzHE
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
std::vector< HcalCellType > HcalCellTypes() const
std::vector< HcalDetId > idHF2QIE
std::pair< int, int > getModHalfHBHE(const int type) const
std::vector< int > HFShift
int getMinDepth(const int det, const int eta, const int phi, const int zside, bool partialOnly) const
int getDepthEta16(const int det, const int phi, const int zside) const
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 findLayer(int layer, const std::vector< HcalParameters::LayerItem > &layerGroup) const
unsigned int layerGroup(const int eta, const int i) const
double getLayer0Wt(const int det, const int phi, const int zside) 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
unsigned int layerGroupSize(const int eta) const
int getEta(const int det, const int lay, const double hetaR)
std::vector< double > Layer0Wt
std::vector< double > dxHB
std::vector< std::vector< double > > tmp
int getLayerFront(const int det, const int eta, const int phi, const int zside, const int depth) const
std::vector< double > rTable
std::vector< double > phitable
int phiNumber(const int phi, const int unit) const
int getDepthEta16M(const int det) const
TString units(TString variable, Char_t axis)
std::vector< double > phibin
int unitPhi(const int det, const int etaR) const
std::vector< double > drHB
HcalCellType::HcalCell cell(const int det, const int zside, const int depth, const int etaR, const int iphi) const
std::vector< double > HFGains
static unsigned int const shift
std::pair< int, int > depthMaxSp_
std::vector< int > HBShift
const HcalParameters * hpar
std::vector< int > maxDepth
static const int maxLayerHB_
int getDepthMax(const int subdet, const int iphi, const int zside) const
int getLayerMax(const int eta, const int depth) const
std::vector< int > etaMin