6 #include "CLHEP/Units/GlobalPhysicalConstants.h"
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::HcalDDDSimConstants (const HcalParameter* hp) constructor";
20 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
21 <<
" cells of type HCal (All)";
28 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants::destructed!!!";
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 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants: wrong depth " << depth
104 <<
" or etaR " << etaR <<
" for detector "
111 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants: wrong depth " << depth
118 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants: det/side/depth/etaR/phi "
119 << idet <<
"/" << zside <<
"/" << depth <<
"/"
120 << etaR <<
"/" << iphi <<
" Cell Flag " << tmp.
ok
121 <<
" " << tmp.
eta <<
" " << tmp.
deta <<
" phi "
122 << tmp.
phi <<
" " << tmp.
dphi <<
" r(z) " << tmp.
rz
130 std::vector<std::pair<double,double> > gcons;
132 for (
unsigned int i=0;
i<
hpar->
rHB.size(); ++
i) {
136 for (
unsigned int i=0;
i<
hpar->
zHE.size(); ++
i) {
146 int hsubdet(0), ieta(0);
148 double heta = fabs(eta);
162 etaR = (eta >= 0. ? hR : -hR);
164 return std::pair<int,double>(hsubdet,etaR);
172 for (
int i =
nR-1;
i > 0;
i--)
173 if (hetaR < hpar->rTable[
i]) ieta =
hpar->
etaMin[2] +
nR - i - 1;
176 for (
int i = 0;
i <
nEta-1;
i++)
183 }
else if (det == static_cast<int>(
HcalEndcap)) {
191 int depth,
int lay) {
195 }
else if (det == static_cast<int>(
HcalOuter)) {
200 if (etaR ==
hpar->
noff[0] && lay > 1) {
202 kphi = (kphi-1)%4 + 1;
203 if (kphi == 2 || kphi == 3) depth =
layerGroup( etaR-1, lay-2 );
205 }
else if (det == static_cast<int>(
HcalBarrel)) {
218 return std::pair<int,int>(etaR,
depth);
225 double eta = fabs(etaR);
230 if (eta <= hpar->etaTable[10]) eta =
hpar->
etaTable[10]+0.001;
231 }
else if (zz >
hpar->
zHO[1]) {
232 if (eta <= hpar->etaTable[4]) eta =
hpar->
etaTable[4]+0.001;
235 eta = (z >= 0. ? eta : -
eta);
237 edm::LogInfo (
"HCalGeom") <<
"R " << r <<
" Z " << z <<
" eta " << etaR
239 if (eta != etaR)
edm::LogInfo (
"HCalGeom") <<
"**** Check *****";
249 unsigned int id = layerGroup.size();
250 for (
unsigned int i = 0;
i < layerGroup.size();
i++) {
251 if (layer == (
int)(layerGroup[
i].layer)) {
270 double fioff(0), fibin(0);
285 return std::pair<double,double>(fioff,fibin);
292 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
293 <<
" cells of type HCal Barrel";
294 for (
unsigned int i=0;
i<cellTypes.size();
i++)
300 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hoCells.size()
301 <<
" cells of type HCal Outer";
302 for (
unsigned int i=0;
i<hoCells.size();
i++)
305 cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
309 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << heCells.size()
310 <<
" cells of type HCal Endcap";
311 for (
unsigned int i=0;
i<heCells.size();
i++)
314 cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
318 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hfCells.size()
319 <<
" cells of type HCal Forward";
320 for (
unsigned int i=0;
i<hfCells.size();
i++)
323 cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
329 int ieta,
int depthl)
const {
331 std::vector<HcalCellType> cellTypes;
333 if (
dzVcal < 0)
return cellTypes;
336 int dmin, dmax, indx, nz, nmod;
340 dmin = 1; dmax = 19; indx = 1; nz =
nzHE; nmod =
nmodHE;
343 dmin = 1; dmax =
maxDepth[2]; indx = 2; nz = 2; nmod = 18;
346 dmin = 4; dmax = 4; indx = 0; nz =
nzHB; nmod =
nmodHB;
349 dmin = 1; dmax = 17; indx = 0; nz =
nzHB; nmod =
nmodHB;
352 if (depthl > 0) dmin = dmax = depthl;
353 int ietamin = (ieta>0) ? ieta :
hpar->
etaMin[indx];
354 int ietamax = (ieta>0) ? ieta :
hpar->
etaMax[indx];
358 int subdet0 =
static_cast<int>(subdet);
366 for (
int eta=ietamin;
eta<= ietamax;
eta++) {
371 shift, gain, nz, nmod, hsize, units);
374 std::vector<int> missPlus, missMinus;
376 for (
int miss=0; miss<
hpar->
noff[5]; miss++) {
380 for (
int miss=0; miss<
hpar->
noff[6]; miss++) {
381 missMinus.push_back(
hpar->
noff[kk]);
390 if (temp2.
unitPhi() == 4) iphi = 3;
391 std::vector<int> missPlus, missMinus;
393 bool okp(
true), okn(
true);
401 if (okp) missPlus.push_back(iphi);
402 if (okn) missMinus.push_back(iphi);
408 cellTypes.push_back(temp2);
424 if (!ok) mxdepth = 2;
431 unsigned int num = 0;
433 for (
unsigned int i=0;
i<cellTypes.size();
i++) {
434 int ncur = (cellTypes[
i].nHalves() > 1) ? 2*cellTypes[
i].
nPhiBins() :
435 cellTypes[
i].nPhiBins();
436 num += (
unsigned int)(ncur);
437 num -= (
unsigned int)(cellTypes[
i].nPhiMissingBins());
440 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants:numberOfCells "
441 << cellTypes.size() <<
" " << num
442 <<
" for subdetector " << subdet;
450 if (units==2) iphi_skip = (phi-1)*2+1;
451 else if (units==4) iphi_skip = (phi-1)*4-1;
452 if (iphi_skip < 0) iphi_skip += 72;
493 const double fiveDegInRad = 2*
M_PI/72;
494 int units = int(dphi/fiveDegInRad+0.5);
506 std::cout <<
"HcalDDDSimConstants:Read LayerGroup" <<
i <<
":";
519 <<
" and dzVcal " <<
dzVcal << std::endl;
525 for (
int i=0;
i<nEta-1; ++
i) {
527 int laymax = (imx > 0) ?
layerGroup(
i, imx-1 ) : 0;
528 if (i < hpar->
etaMax[0]) {
529 int laymax0 = (imx > 16) ?
layerGroup(
i, 16 ) : laymax;
530 if (
i+1 ==
hpar->
etaMax[0] && laymax0 > 2) laymax0 = 2;
533 if (
i >=
hpar->
etaMin[1]-1 && i < hpar->etaMax[1]) {
538 for (
int i=0;
i<4; ++
i)
544 for (
int i=0;
i<maxdepth; ++
i) {
545 for (
int k=0;
k<nEta-1; ++
k) {
548 for (
int l=layermx-1;
l >= 0; --
l) {
570 <<
" endcap half-sectors" << std::endl;
585 <<
" " <<
etaHO[2] <<
" " <<
etaHO[3] << std::endl;
588 for (
unsigned int i=0;
i<
hpar->
zHO.size(); ++
i)
594 if ((
int)(
hpar->
noff.size()) > (noffsize+3)) {
607 <<
" HE (min) " <<
depthEta16[1] <<
"; max depth for itea = 29 : ("
611 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
614 for (
int k=0;
k<npair; ++
k) {
632 if (ir > 0 && ir <
nR) {
634 if (depth%2 != 1) z +=
dlShort;
638 if (etaR > 0 && etaR <
nEta) {
639 if (etaR ==
hpar->
noff[1]-1 && depth > 2) {
641 }
else if (det == static_cast<int>(
HcalOuter)) {
644 }
else if (etaR ==
hpar->
noff[2]+1) {
648 }
else if (etaR ==
hpar->
noff[3]+1) {
659 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::deltaEta " << etaR <<
" "
660 << depth <<
" ==> " <<
tmp;
671 if (ir > 0 && ir <
nR) {
673 if (depth%2 != 1) z +=
dlShort;
677 if (etaR > 0 && etaR <
nEta) {
678 if (etaR ==
hpar->
noff[1]-1 && depth > 2) {
680 }
else if (det == static_cast<int>(
HcalOuter)) {
683 }
else if (etaR ==
hpar->
noff[2]+1) {
687 }
else if (etaR ==
hpar->
noff[3]+1) {
697 if (zside == 0) tmp = -
tmp;
699 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::getEta " << etaR <<
" "
700 << zside <<
" " << depth <<
" ==> " <<
tmp;
708 if (z != 0) tmp = -
log(
tan(0.5*atan(r/z)));
710 edm::LogInfo(
"HCalGeom") <<
"HcalDDDSimConstants::getEta " << r <<
" " << z
757 std::cout <<
"HcalDDDSimConstants::printTileHB for eta " << eta <<
" and depth " << depth <<
"\n";
760 double thetaL = 2.*atan(
exp(-etaL));
762 double thetaH = 2.*atan(
exp(-etaH));
770 std::cout <<
"\ntileHB:: eta|depth " << eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
"\n";
771 for (
int lay=layL; lay<layH; ++lay) {
772 std::vector<double> area(2,0);
785 if (area[0] > 0)
std::cout << std::setw(2) << lay <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
792 double thetaL = 2.*atan(
exp(-etaL));
794 double thetaH = 2.*atan(
exp(-etaH));
798 }
else if (depth == 1) {
800 }
else if (depth == 2) {
809 if (phib > 6*CLHEP::deg) nphi = 1;
810 std::cout <<
"\ntileHE:: Eta/depth " << eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
" phi " << nphi <<
"\n";
811 for (
int lay=layL; lay<layH; ++lay) {
812 std::vector<double> area(4,0);
818 if ((lay != 0 || eta == 18) &&
829 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*
hpar->
dx1HE[
k]);
831 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*
hpar->
dx1HE[
k]);
832 ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*
tan(10.*CLHEP::deg)-4*
hpar->
dx1HE[
k])-ar1;
840 if (area[0] > 0 && area[1] > 0) {
842 if (eta == 18) lay0++;
844 std::cout << std::setw(2) << lay0 <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
846 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";
855 if( it.layer == eta + 1 ) {
856 return it.layerGroup.size();
858 if( it.layer > eta + 1 )
break;
859 k = it.layerGroup.size();
865 unsigned int i)
const {
868 if( it.layer == eta + 1 ) {
869 return it.layerGroup.at( i );
871 if( it.layer > eta + 1 )
break;
872 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)
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 > 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