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";
28 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants::destructed!!!\n";
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;
49 else if (idet == static_cast<int>(
HcalBarrel) && depth > 17) 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)) {
87 laymax = ((int)(
hpar->
zHE.size()));
103 << depth <<
" or etaR " << etaR
104 <<
" for detector " << idet;
108 edm::LogWarning(
"HCalGeom") <<
"HcalDDDSimConstants: wrong depth " << depth
114 std::cout <<
"HcalDDDSimConstants: det/side/depth/etaR/phi "
115 << idet <<
"/" << zside <<
"/" << depth <<
"/"
116 << etaR <<
"/" << iphi <<
" Cell Flag " << tmp.
ok
117 <<
" " << tmp.
eta <<
" " << tmp.
deta <<
" phi "
118 << tmp.
phi <<
" " << tmp.
dphi <<
" r(z) " << tmp.
rz
119 <<
" " << tmp.
drz <<
" " << tmp.
flagrz << std::endl;
126 std::vector<std::pair<double,double> > gcons;
128 for (
unsigned int i=0;
i<
hpar->
rHB.size(); ++
i) {
132 for (
unsigned int i=0;
i<
hpar->
zHE.size(); ++
i) {
142 int hsubdet(0), ieta(0);
144 double heta = fabs(eta);
159 etaR = (eta >= 0. ? hR : -hR);
161 return std::pair<int,double>(hsubdet,etaR);
169 for (
int i =
nR-1;
i > 0;
i--)
170 if (hetaR < hpar->rTable[
i]) ieta =
hpar->
etaMin[2] +
nR - i - 1;
173 for (
int i = 0;
i <
nEta-1;
i++)
180 }
else if (det == static_cast<int>(
HcalEndcap)) {
188 int depth,
int lay) {
192 }
else if (det == static_cast<int>(
HcalOuter)) {
197 if (etaR ==
hpar->
noff[0] && lay > 1) {
199 kphi = (kphi-1)%4 + 1;
200 if (kphi == 2 || kphi == 3) depth =
layerGroup(etaR-1, lay-2);
202 }
else if (det == static_cast<int>(
HcalBarrel)) {
215 if ((det == static_cast<int>(
HcalEndcap)) && (etaR == 17) && (lay == 1))
217 return std::pair<int,int>(etaR,
depth);
224 double eta = fabs(etaR);
229 if (eta <= hpar->etaTable[10]) eta =
hpar->
etaTable[10]+0.001;
230 }
else if (zz >
hpar->
zHO[1]) {
231 if (eta <= hpar->etaTable[4]) eta =
hpar->
etaTable[4]+0.001;
234 eta = (z >= 0. ? eta : -
eta);
236 std::cout <<
"R " << r <<
" Z " << z <<
" eta " << etaR
237 <<
":" << eta << std::endl;
238 if (eta != etaR)
edm::LogInfo (
"HCalGeom") <<
"**** Check *****";
253 unsigned int id = layerGroup.size();
254 for (
unsigned int i = 0;
i < layerGroup.size();
i++) {
255 if (layer == (
int)(layerGroup[
i].layer)) {
274 double fioff(0), fibin(0);
289 return std::pair<double,double>(fioff,fibin);
296 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
297 <<
" cells of type HCal Barrel\n";
298 for (
unsigned int i=0;
i<cellTypes.size();
i++)
299 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << cellTypes[
i] <<
"\n";
304 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hoCells.size()
305 <<
" cells of type HCal Outer\n";
306 for (
unsigned int i=0;
i<hoCells.size();
i++)
307 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hoCells[
i] <<
"\n";
309 cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
313 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << heCells.size()
314 <<
" cells of type HCal Endcap\n";
315 for (
unsigned int i=0;
i<heCells.size();
i++)
316 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << heCells[
i] <<
"\n";
318 cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
322 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hfCells.size()
323 <<
" cells of type HCal Forward\n";
324 for (
unsigned int i=0;
i<hfCells.size();
i++)
325 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hfCells[
i] <<
"\n";
327 cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
333 int ieta,
int depthl)
const {
335 std::vector<HcalCellType> cellTypes;
337 if (
dzVcal < 0)
return cellTypes;
340 int dmin, dmax, indx, nz, nmod;
344 dmin = 1; dmax = 19; indx = 1; nz =
nzHE; nmod =
nmodHE;
347 dmin = 1; dmax =
maxDepth[2]; indx = 2; nz = 2; nmod = 18;
350 dmin = 4; dmax = 4; indx = 0; nz =
nzHB; nmod =
nmodHB;
353 dmin = 1; dmax = 17; indx = 0; nz =
nzHB; nmod =
nmodHB;
356 if (depthl > 0) dmin = dmax = depthl;
357 int ietamin = (ieta>0) ? ieta :
hpar->
etaMin[indx];
358 int ietamax = (ieta>0) ? ieta :
hpar->
etaMax[indx];
362 int subdet0 =
static_cast<int>(subdet);
370 for (
int eta=ietamin;
eta<= ietamax;
eta++) {
375 shift, gain, nz, nmod, hsize, units);
378 std::vector<int> missPlus, missMinus;
380 for (
int miss=0; miss<
hpar->
noff[5]; miss++) {
384 for (
int miss=0; miss<
hpar->
noff[6]; miss++) {
385 missMinus.push_back(
hpar->
noff[kk]);
394 if (temp2.
unitPhi() == 4) iphi = 3;
395 std::vector<int> missPlus, missMinus;
397 bool okp(
true), okn(
true);
405 if (okp) missPlus.push_back(iphi);
406 if (okn) missMinus.push_back(iphi);
412 cellTypes.push_back(temp2);
428 if (!ok) mxdepth = 2;
435 unsigned int num = 0;
437 for (
unsigned int i=0;
i<cellTypes.size();
i++) {
438 int ncur = (cellTypes[
i].nHalves() > 1) ? 2*cellTypes[
i].
nPhiBins() :
439 cellTypes[
i].nPhiBins();
440 num += (
unsigned int)(ncur);
441 num -= (
unsigned int)(cellTypes[
i].nPhiMissingBins());
444 std::cout <<
"HcalDDDSimConstants:numberOfCells "
445 << cellTypes.size() <<
" " << num
446 <<
" for subdetector " << subdet << std::endl;
454 if (units==2) iphi_skip = (phi-1)*2+1;
455 else if (units==4) iphi_skip = (phi-1)*4-1;
456 if (iphi_skip < 0) iphi_skip += 72;
497 const double fiveDegInRad = 2*
M_PI/72;
498 int units = int(dphi/fiveDegInRad+0.5);
499 if (units < 1) units = 1;
512 std::cout <<
"HcalDDDSimConstants:Read LayerGroup" <<
i <<
":";
525 <<
" and dzVcal " <<
dzVcal << std::endl;
531 for (
int i=0;
i<nEta-1; ++
i) {
534 if (i < hpar->
etaMax[0]) {
535 int laymax0 = (imx > 16) ?
layerGroup(
i, 16) : laymax;
536 if (
i+1 ==
hpar->
etaMax[0] && laymax0 > 2) laymax0 = 2;
539 if (
i >=
hpar->
etaMin[1]-1 && i < hpar->etaMax[1]) {
544 for (
int i=0;
i<4; ++
i)
550 for (
int i=0;
i<maxdepth; ++
i) {
551 for (
int k=0;
k<nEta-1; ++
k) {
554 for (
int l=layermx-1;
l >= 0; --
l) {
576 <<
" endcap half-sectors" << std::endl;
591 <<
" " <<
etaHO[2] <<
" " <<
etaHO[3] << std::endl;
594 for (
unsigned int i=0;
i<
hpar->
zHO.size(); ++
i)
600 int noffl(noffsize+5);
601 if ((
int)(
hpar->
noff.size()) > (noffsize+3)) {
606 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
607 noffl += (2*
hpar->
noff[noffsize+4]);
618 << noffl <<
":" <<
isBH_ << std::endl;
620 <<
" HE (min) " <<
depthEta16[1] <<
"; max depth for itea = 29 : ("
624 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
627 for (
int k=0;
k<npair; ++
k) {
645 if (ir > 0 && ir <
nR) {
647 if (depth%2 != 1) z +=
dlShort;
651 if (etaR > 0 && etaR <
nEta) {
654 }
else if (det == static_cast<int>(
HcalOuter)) {
657 }
else if (etaR ==
hpar->
noff[2]+1) {
661 }
else if (etaR ==
hpar->
noff[3]+1) {
672 std::cout <<
"HcalDDDSimConstants::deltaEta " << etaR <<
" "
673 << depth <<
" ==> " << tmp << std::endl;
684 if (ir > 0 && ir <
nR) {
686 if (depth%2 != 1) z +=
dlShort;
690 if (etaR > 0 && etaR <
nEta) {
693 }
else if (det == static_cast<int>(
HcalOuter)) {
696 }
else if (etaR ==
hpar->
noff[2]+1) {
700 }
else if (etaR ==
hpar->
noff[3]+1) {
710 if (zside == 0) tmp = -
tmp;
712 std::cout <<
"HcalDDDSimConstants::getEta " << etaR <<
" "
713 << zside <<
" " << depth <<
" ==> " << tmp <<
"\n";
721 if (z != 0) tmp = -
log(
tan(0.5*atan(r/z)));
723 std::cout <<
"HcalDDDSimConstants::getEta " << r <<
" " << z
724 <<
" ==> " << tmp << std::endl;
770 std::cout <<
"HcalDDDSimConstants::printTileHB for eta " << eta <<
" and depth " << depth <<
"\n";
773 double thetaL = 2.*atan(
exp(-etaL));
775 double thetaH = 2.*atan(
exp(-etaH));
783 std::cout <<
"\ntileHB:: eta|depth " << eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
"\n";
784 for (
int lay=layL; lay<layH; ++lay) {
785 std::vector<double> area(2,0);
798 if (area[0] > 0)
std::cout << std::setw(2) << lay <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
805 double thetaL = 2.*atan(
exp(-etaL));
807 double thetaH = 2.*atan(
exp(-etaH));
811 }
else if (depth == 1) {
813 }
else if (depth == 2) {
822 if (phib > 6*CLHEP::deg) nphi = 1;
823 std::cout <<
"\ntileHE:: Eta/depth " << eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
" phi " << nphi <<
"\n";
824 for (
int lay=layL; lay<layH; ++lay) {
825 std::vector<double> area(4,0);
831 if ((lay != 0 || eta == 18) &&
842 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*
hpar->
dx1HE[
k]);
844 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*
hpar->
dx1HE[
k]);
845 ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*
tan(10.*CLHEP::deg)-4*
hpar->
dx1HE[
k])-ar1;
853 if (area[0] > 0 && area[1] > 0) {
855 if (eta == 18) lay0++;
857 std::cout << std::setw(2) << lay0 <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
859 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";
868 if (it.layer == eta + 1) {
869 return it.layerGroup.size();
871 if (it.layer > eta + 1)
break;
872 k = it.layerGroup.size();
878 unsigned int i)
const {
881 if (it.layer == eta + 1) {
882 return it.layerGroup.at(i);
884 if (it.layer > eta + 1)
break;
885 k = it.layerGroup.at(i);
std::pair< int, int > getEtaDepth(int det, int etaR, int phi, int depth, int lay)
std::vector< double > zHO
std::vector< double > etaTable
void setMissingPhi(std::vector< int > &, std::vector< int > &)
int unitPhi(int det, int etaR) const
void printTileHB(int eta, int depth) const
std::vector< int > maxDepth
std::vector< double > rHB
int getEta(int det, int lay, double hetaR)
double getLayer0Wt(int det, int phi, int zside) const
std::vector< double > rhoxHB
Sin< T >::type sin(const T &t)
std::vector< double > HBGains
Geom::Theta< T > theta() const
std::vector< int > HEShift
std::vector< std::pair< double, double > > getConstHBHE(const int type) const
HcalDDDSimConstants(const HcalParameters *hp)
unsigned int numberOfCells(HcalSubdetector) const
std::vector< int > etaMax
std::vector< int > depths[nDepthMax]
std::vector< double > rhoxHE
std::vector< double > zxHE
T x() const
Cartesian x coordinate.
std::vector< double > zHE
double getEtaHO(double &etaR, double &x, double &y, double &z) const
std::vector< LayerItem > layerGroupEtaSim
void printTileHE(int eta, int depth) const
std::vector< double > dyHE
std::vector< double > dx1HE
std::vector< double > rHO
std::vector< double > dzHE
Cos< T >::type cos(const T &t)
int getShift(HcalSubdetector subdet, int depth) const
double getGain(HcalSubdetector subdet, int depth) const
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
unsigned int findLayer(int layer, const std::vector< HcalParameters::LayerItem > &layerGroup) const
std::vector< double > HEGains
std::pair< int, double > getDetEta(double eta, int depth)
std::vector< double > dyHB
std::vector< double > phioff
std::pair< double, double > getPhiCons(int det, int ieta)
std::vector< double > gparHF
double deltaEta(int det, int eta, int depth) const
Geom::Phi< T > phi() const
std::vector< double > Layer0Wt
std::vector< double > dxHB
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
HcalCellType::HcalCell cell(int det, int zside, int depth, int etaR, int iphi) const
int phiNumber(int phi, int unit) const
std::vector< double > drHB
std::vector< double > HFGains
static unsigned int const shift
std::vector< int > HBShift
int nPhiBins() const
the number of these cells in a ring
const HcalParameters * hpar
std::vector< int > maxDepth
unsigned int layerGroup(unsigned int eta, unsigned int i) const
std::vector< int > etaMin
int maxHFDepth(int ieta, int iphi) const
unsigned int layerGroupSize(unsigned int eta) const