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);
158 etaR = (eta >= 0. ? hR : -hR);
160 return std::pair<int,double>(hsubdet,etaR);
168 for (
int i =
nR-1;
i > 0;
i--)
169 if (hetaR < hpar->rTable[
i]) ieta =
hpar->
etaMin[2] +
nR - i - 1;
172 for (
int i = 0;
i <
nEta-1;
i++)
179 }
else if (det == static_cast<int>(
HcalEndcap)) {
187 int depth,
int lay) {
191 }
else if (det == static_cast<int>(
HcalOuter)) {
196 if (etaR ==
hpar->
noff[0] && lay > 1) {
198 kphi = (kphi-1)%4 + 1;
199 if (kphi == 2 || kphi == 3) depth =
layerGroup( etaR-1, lay-2 );
201 }
else if (det == static_cast<int>(
HcalBarrel)) {
214 if ((det == static_cast<int>(
HcalEndcap)) && (etaR == 17) && (lay == 1))
216 return std::pair<int,int>(etaR,
depth);
223 double eta = fabs(etaR);
228 if (eta <= hpar->etaTable[10]) eta =
hpar->
etaTable[10]+0.001;
229 }
else if (zz >
hpar->
zHO[1]) {
230 if (eta <= hpar->etaTable[4]) eta =
hpar->
etaTable[4]+0.001;
233 eta = (z >= 0. ? eta : -
eta);
235 std::cout <<
"R " << r <<
" Z " << z <<
" eta " << etaR
236 <<
":" << eta << std::endl;
237 if (eta != etaR)
edm::LogInfo (
"HCalGeom") <<
"**** Check *****";
247 unsigned int id = layerGroup.size();
248 for (
unsigned int i = 0;
i < layerGroup.size();
i++) {
249 if (layer == (
int)(layerGroup[
i].layer)) {
268 double fioff(0), fibin(0);
283 return std::pair<double,double>(fioff,fibin);
290 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << cellTypes.size()
291 <<
" cells of type HCal Barrel\n";
292 for (
unsigned int i=0;
i<cellTypes.size();
i++)
293 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << cellTypes[
i] <<
"\n";
298 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hoCells.size()
299 <<
" cells of type HCal Outer\n";
300 for (
unsigned int i=0;
i<hoCells.size();
i++)
301 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hoCells[
i] <<
"\n";
303 cellTypes.insert(cellTypes.end(), hoCells.begin(), hoCells.end());
307 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << heCells.size()
308 <<
" cells of type HCal Endcap\n";
309 for (
unsigned int i=0;
i<heCells.size();
i++)
310 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << heCells[
i] <<
"\n";
312 cellTypes.insert(cellTypes.end(), heCells.begin(), heCells.end());
316 edm::LogInfo (
"HCalGeom") <<
"HcalDDDSimConstants: " << hfCells.size()
317 <<
" cells of type HCal Forward\n";
318 for (
unsigned int i=0;
i<hfCells.size();
i++)
319 edm::LogInfo (
"HCalGeom") <<
"Cell " <<
i <<
" " << hfCells[
i] <<
"\n";
321 cellTypes.insert(cellTypes.end(), hfCells.begin(), hfCells.end());
327 int ieta,
int depthl)
const {
329 std::vector<HcalCellType> cellTypes;
331 if (
dzVcal < 0)
return cellTypes;
334 int dmin, dmax, indx, nz, nmod;
338 dmin = 1; dmax = 19; indx = 1; nz =
nzHE; nmod =
nmodHE;
341 dmin = 1; dmax =
maxDepth[2]; indx = 2; nz = 2; nmod = 18;
344 dmin = 4; dmax = 4; indx = 0; nz =
nzHB; nmod =
nmodHB;
347 dmin = 1; dmax = 17; indx = 0; nz =
nzHB; nmod =
nmodHB;
350 if (depthl > 0) dmin = dmax = depthl;
351 int ietamin = (ieta>0) ? ieta :
hpar->
etaMin[indx];
352 int ietamax = (ieta>0) ? ieta :
hpar->
etaMax[indx];
356 int subdet0 =
static_cast<int>(subdet);
364 for (
int eta=ietamin;
eta<= ietamax;
eta++) {
369 shift, gain, nz, nmod, hsize, units);
372 std::vector<int> missPlus, missMinus;
374 for (
int miss=0; miss<
hpar->
noff[5]; miss++) {
378 for (
int miss=0; miss<
hpar->
noff[6]; miss++) {
379 missMinus.push_back(
hpar->
noff[kk]);
388 if (temp2.
unitPhi() == 4) iphi = 3;
389 std::vector<int> missPlus, missMinus;
391 bool okp(
true), okn(
true);
399 if (okp) missPlus.push_back(iphi);
400 if (okn) missMinus.push_back(iphi);
406 cellTypes.push_back(temp2);
422 if (!ok) mxdepth = 2;
429 unsigned int num = 0;
431 for (
unsigned int i=0;
i<cellTypes.size();
i++) {
432 int ncur = (cellTypes[
i].nHalves() > 1) ? 2*cellTypes[
i].
nPhiBins() :
433 cellTypes[
i].nPhiBins();
434 num += (
unsigned int)(ncur);
435 num -= (
unsigned int)(cellTypes[
i].nPhiMissingBins());
438 std::cout <<
"HcalDDDSimConstants:numberOfCells "
439 << cellTypes.size() <<
" " << num
440 <<
" for subdetector " << subdet << std::endl;
448 if (units==2) iphi_skip = (phi-1)*2+1;
449 else if (units==4) iphi_skip = (phi-1)*4-1;
450 if (iphi_skip < 0) iphi_skip += 72;
491 const double fiveDegInRad = 2*
M_PI/72;
492 int units = int(dphi/fiveDegInRad+0.5);
493 if (units < 1) units = 1;
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 int noffl(noffsize+5);
595 if ((
int)(
hpar->
noff.size()) > (noffsize+3)) {
600 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
601 noffl += (2*
hpar->
noff[noffsize+4]);
612 << noffl <<
":" <<
isBH_ << std::endl;
614 <<
" HE (min) " <<
depthEta16[1] <<
"; max depth for itea = 29 : ("
618 if ((
int)(
hpar->
noff.size()) > (noffsize+4)) {
621 for (
int k=0;
k<npair; ++
k) {
639 if (ir > 0 && ir <
nR) {
641 if (depth%2 != 1) z +=
dlShort;
645 if (etaR > 0 && etaR <
nEta) {
646 if (etaR ==
hpar->
noff[1]-1 && depth > 2) {
648 }
else if (det == static_cast<int>(
HcalOuter)) {
651 }
else if (etaR ==
hpar->
noff[2]+1) {
655 }
else if (etaR ==
hpar->
noff[3]+1) {
666 std::cout <<
"HcalDDDSimConstants::deltaEta " << etaR <<
" "
667 << depth <<
" ==> " << tmp << std::endl;
678 if (ir > 0 && ir <
nR) {
680 if (depth%2 != 1) z +=
dlShort;
684 if (etaR > 0 && etaR <
nEta) {
685 if (etaR ==
hpar->
noff[1]-1 && depth > 2) {
687 }
else if (det == static_cast<int>(
HcalOuter)) {
690 }
else if (etaR ==
hpar->
noff[2]+1) {
694 }
else if (etaR ==
hpar->
noff[3]+1) {
704 if (zside == 0) tmp = -
tmp;
706 std::cout <<
"HcalDDDSimConstants::getEta " << etaR <<
" "
707 << zside <<
" " << depth <<
" ==> " << tmp <<
"\n";
715 if (z != 0) tmp = -
log(
tan(0.5*atan(r/z)));
717 std::cout <<
"HcalDDDSimConstants::getEta " << r <<
" " << z
718 <<
" ==> " << tmp << std::endl;
764 std::cout <<
"HcalDDDSimConstants::printTileHB for eta " << eta <<
" and depth " << depth <<
"\n";
767 double thetaL = 2.*atan(
exp(-etaL));
769 double thetaH = 2.*atan(
exp(-etaH));
777 std::cout <<
"\ntileHB:: eta|depth " << eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
"\n";
778 for (
int lay=layL; lay<layH; ++lay) {
779 std::vector<double> area(2,0);
792 if (area[0] > 0)
std::cout << std::setw(2) << lay <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
799 double thetaL = 2.*atan(
exp(-etaL));
801 double thetaH = 2.*atan(
exp(-etaH));
805 }
else if (depth == 1) {
807 }
else if (depth == 2) {
816 if (phib > 6*CLHEP::deg) nphi = 1;
817 std::cout <<
"\ntileHE:: Eta/depth " << eta <<
"|" << depth <<
" theta " << thetaH/CLHEP::deg <<
":" << thetaL/CLHEP::deg <<
" Layer " << layL <<
":" << layH-1 <<
" phi " << nphi <<
"\n";
818 for (
int lay=layL; lay<layH; ++lay) {
819 std::vector<double> area(4,0);
825 if ((lay != 0 || eta == 18) &&
836 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-4.*
hpar->
dx1HE[
k]);
838 ar1 = 0.5*(rmax-rmin)*(dx1+dx2-2.*
hpar->
dx1HE[
k]);
839 ar2 = 0.5*(rmax-rmin)*((rmax+rmin)*
tan(10.*CLHEP::deg)-4*
hpar->
dx1HE[
k])-ar1;
847 if (area[0] > 0 && area[1] > 0) {
849 if (eta == 18) lay0++;
851 std::cout << std::setw(2) << lay0 <<
" Area " << std::setw(8) << area[0] <<
" " << std::setw(8) << area[1] <<
"\n";
853 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";
862 if( it.layer == eta + 1 ) {
863 return it.layerGroup.size();
865 if( it.layer > eta + 1 )
break;
866 k = it.layerGroup.size();
872 unsigned int i)
const {
875 if( it.layer == eta + 1 ) {
876 return it.layerGroup.at( i );
878 if( it.layer > eta + 1 )
break;
879 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