CMS 3D CMS Logo

EcalGeomPhiSymHelper.cc
Go to the documentation of this file.
2 
4 
5 // Geometry
11 
12 //Channel status
13 
16 #include <fstream>
17 
18 void EcalGeomPhiSymHelper::setup(const CaloGeometry* geometry, const EcalChannelStatus* chStatus, int statusThresold) {
19  for (int ieta = 0; ieta < kBarlRings; ieta++)
20  nBads_barl[ieta] = 0;
21  for (int ring = 0; ring < kEndcEtaRings; ring++)
22  nBads_endc[ring] = 0;
23 
24  for (int ix = 0; ix < kEndcWedgesX; ix++) {
25  for (int iy = 0; iy < kEndcWedgesY; iy++) {
26  cellPhi_[ix][iy] = 0.;
27  cellArea_[ix][iy] = 0.;
28  endcapRing_[ix][iy] = -1;
29  }
30  }
31 
32  // loop over all barrel crystals
33  const std::vector<DetId>& barrelCells = geometry->getValidDetIds(DetId::Ecal, EcalBarrel);
34  std::vector<DetId>::const_iterator barrelIt;
35 
36  for (barrelIt = barrelCells.begin(); barrelIt != barrelCells.end(); barrelIt++) {
37  EBDetId eb(*barrelIt);
38 
39  int sign = eb.zside() > 0 ? 1 : 0;
40 
41  int chs = (*chStatus)[*barrelIt].getStatusCode() & 0x001F;
42  if (chs <= statusThresold)
43  goodCell_barl[abs(eb.ieta()) - 1][eb.iphi() - 1][sign] = true;
44 
45  if (!goodCell_barl[abs(eb.ieta()) - 1][eb.iphi() - 1][sign])
46  nBads_barl[abs(eb.ieta()) - 1]++;
47  }
48 
49  const CaloSubdetectorGeometry* endcapGeometry = geometry->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
50 
51  for (int ix = 0; ix < kEndcWedgesX; ix++) {
52  for (int iy = 0; iy < kEndcWedgesY; iy++) {
53  cellPos_[ix][iy] = GlobalPoint(0., 0., 0.);
54  cellPhi_[ix][iy] = 0.;
55  cellArea_[ix][iy] = 0.;
56  endcapRing_[ix][iy] = -1;
57  }
58  }
59 
60  const std::vector<DetId>& endcapCells = geometry->getValidDetIds(DetId::Ecal, EcalEndcap);
61  std::vector<DetId>::const_iterator endcapIt;
62  for (endcapIt = endcapCells.begin(); endcapIt != endcapCells.end(); endcapIt++) {
63  auto cellGeometry = endcapGeometry->getGeometry(*endcapIt);
64  EEDetId ee(*endcapIt);
65  int ix = ee.ix() - 1;
66  int iy = ee.iy() - 1;
67 
68  int sign = ee.zside() > 0 ? 1 : 0;
69 
70  // store all crystal positions
71  cellPos_[ix][iy] = cellGeometry->getPosition();
72  cellPhi_[ix][iy] = cellGeometry->getPosition().phi();
73 
74  // calculate and store eta-phi area for each crystal front face Shoelace formuls
75  const CaloCellGeometry::CornersVec& cellCorners(cellGeometry->getCorners());
76  cellArea_[ix][iy] = 0.;
77 
78  for (int i = 0; i < 4; i++) {
79  int iplus1 = i == 3 ? 0 : i + 1;
80  cellArea_[ix][iy] += cellCorners[i].eta() * float(cellCorners[iplus1].phi()) -
81  cellCorners[iplus1].eta() * float(cellCorners[i].phi());
82  }
83 
84  cellArea_[ix][iy] = fabs(cellArea_[ix][iy]) / 2.;
85  /*
86  const double deltaPhi =
87  (dynamic_cast<const EcalEndcapGeometry*>(endcapGeometry))->deltaPhi(ee);
88 
89  const double deltaEta =
90  (dynamic_cast<const EcalEndcapGeometry*>(endcapGeometry))->deltaEta(ee) ;
91 
92  cellArea_[ix][iy] = deltaEta*deltaPhi;
93 */
94  int chs = (*chStatus)[*endcapIt].getStatusCode() & 0x001F;
95  if (chs <= statusThresold)
96  goodCell_endc[ix][iy][sign] = true;
97  }
98 
99  // get eta boundaries for each endcap ring
100  etaBoundary_[0] = 1.479;
101  etaBoundary_[39] = 3.; //It was 4. !!!
102  for (int ring = 1; ring < kEndcEtaRings; ring++) {
103  double eta_ring_minus1 = cellPos_[ring - 1][50].eta();
104  double eta_ring = cellPos_[ring][50].eta();
105  etaBoundary_[ring] = (eta_ring + eta_ring_minus1) / 2.;
106  std::cout << "Eta ring " << ring << " : " << eta_ring << std::endl;
107  }
108 
109  // determine to which ring each endcap crystal belongs,
110  // the number of crystals in each ring,
111  // and the mean eta-phi area of the crystals in each ring
112 
113  for (int ring = 0; ring < kEndcEtaRings; ring++) {
114  nRing_[ring] = 0;
115  meanCellArea_[ring] = 0.;
116  for (int ix = 0; ix < kEndcWedgesX; ix++) {
117  for (int iy = 0; iy < kEndcWedgesY; iy++) {
118  if (fabs(cellPos_[ix][iy].eta()) > etaBoundary_[ring] &&
119  fabs(cellPos_[ix][iy].eta()) < etaBoundary_[ring + 1]) {
120  meanCellArea_[ring] += cellArea_[ix][iy];
121  endcapRing_[ix][iy] = ring;
122  nRing_[ring]++;
123 
124  for (int sign = 0; sign < kSides; sign++) {
125  if (!goodCell_endc[ix][iy][sign])
126  nBads_endc[ring]++;
127  } //sign
128 
129  } //if
130  } //ix
131  } //iy
132 
134 
135  } //ring
136 
137  // fill phi_endc[ip][ring] vector
138  for (int ring = 0; ring < kEndcEtaRings; ring++) {
139  for (int i = 0; i < kMaxEndciPhi; i++)
140  phi_endc_[i][ring] = 0.;
141 
142  float philast = -999.;
143  for (int ip = 0; ip < nRing_[ring]; ip++) {
144  float phimin = 999.;
145  for (int ix = 0; ix < kEndcWedgesX; ix++) {
146  for (int iy = 0; iy < kEndcWedgesY; iy++) {
147  if (endcapRing_[ix][iy] == ring) {
148  if (cellPhi_[ix][iy] < phimin && cellPhi_[ix][iy] > philast) {
149  phimin = cellPhi_[ix][iy];
150  } //if edges
151  } //if ring
152  } //iy
153  } //ix
154  phi_endc_[ip][ring] = phimin;
155  philast = phimin;
156  } //ip
157 
158  } //ring
159 
160  // Print out detid->ring association
161  std::fstream eeringsf("endcaprings.dat", std::ios::out);
162  for (endcapIt = endcapCells.begin(); endcapIt != endcapCells.end(); endcapIt++) {
163  EEDetId eedet(*endcapIt);
164  eeringsf << eedet.hashedIndex() << " " << endcapRing_[eedet.ix() - 1][eedet.iy() - 1] << " "
165  << cellPhi_[eedet.ix() - 1][eedet.iy() - 1] << " "
166  << cellArea_[eedet.ix() - 1][eedet.iy() - 1] / meanCellArea_[endcapRing_[eedet.ix() - 1][eedet.iy() - 1]]
167  << std::endl;
168  }
169 }
kBarlRings
static const int kBarlRings
Definition: EcalGeomPhiSymHelper.h:7
EcalGeomPhiSymHelper::nBads_endc
int nBads_endc[kEndcEtaRings]
Definition: EcalGeomPhiSymHelper.h:36
EcalGeomPhiSymHelper.h
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
EcalGeomPhiSymHelper::nBads_barl
int nBads_barl[kBarlRings]
Definition: EcalGeomPhiSymHelper.h:35
ESHandle.h
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
EBDetId
Definition: EBDetId.h:17
gather_cfg.cout
cout
Definition: gather_cfg.py:144
geometry
Definition: geometry.py:1
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
EZArrayFL< GlobalPoint >
EcalGeomPhiSymHelper::goodCell_endc
bool goodCell_endc[kEndcWedgesX][kEndcWedgesX][kSides]
Definition: EcalGeomPhiSymHelper.h:34
EcalGeomPhiSymHelper::goodCell_barl
bool goodCell_barl[kBarlRings][kBarlWedges][kSides]
Definition: EcalGeomPhiSymHelper.h:33
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
kEndcWedgesY
static const int kEndcWedgesY
Definition: EcalGeomPhiSymHelper.h:12
EcalBarrel
Definition: EcalSubdetector.h:10
EcalGeomPhiSymHelper::cellPos_
GlobalPoint cellPos_[kEndcWedgesX][kEndcWedgesY]
Definition: EcalGeomPhiSymHelper.h:23
EcalGeomPhiSymHelper::etaBoundary_
double etaBoundary_[kEndcEtaRings+1]
Definition: EcalGeomPhiSymHelper.h:28
EcalGeomPhiSymHelper::setup
void setup(const CaloGeometry *geometry, const EcalChannelStatus *chstatus, int statusThreshold)
Definition: EcalGeomPhiSymHelper.cc:18
EBDetId::zside
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:45
CaloGeometry
Definition: CaloGeometry.h:21
kMaxEndciPhi
static const int kMaxEndciPhi
Definition: EcalGeomPhiSymHelper.h:15
PVValHelper::eta
Definition: PVValidationHelpers.h:69
EcalGeomPhiSymHelper::endcapRing_
int endcapRing_[kEndcWedgesX][kEndcWedgesY]
Definition: EcalGeomPhiSymHelper.h:29
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
EEDetId::zside
int zside() const
Definition: EEDetId.h:71
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
EcalEndcap
Definition: EcalSubdetector.h:10
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
CaloSubdetectorGeometry.h
EcalGeomPhiSymHelper::cellPhi_
double cellPhi_[kEndcWedgesX][kEndcWedgesY]
Definition: EcalGeomPhiSymHelper.h:24
EcalEndcapGeometry.h
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
EcalGeomPhiSymHelper::meanCellArea_
double meanCellArea_[kEndcEtaRings]
Definition: EcalGeomPhiSymHelper.h:27
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
kEndcEtaRings
static const int kEndcEtaRings
Definition: EcalGeomPhiSymHelper.h:14
DetId::Ecal
Definition: DetId.h:27
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
DDAxes::phi
CaloCellGeometry.h
kEndcWedgesX
static const int kEndcWedgesX
Definition: EcalGeomPhiSymHelper.h:11
CaloGeometry.h
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
EcalGeomPhiSymHelper::phi_endc_
double phi_endc_[kMaxEndciPhi][kEndcEtaRings]
Definition: EcalGeomPhiSymHelper.h:26
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcalGeomPhiSymHelper::nRing_
int nRing_[kEndcEtaRings]
Definition: EcalGeomPhiSymHelper.h:30
EcalChannelStatusCode.h
EcalChannelStatusRcd.h
EcalGeomPhiSymHelper::cellArea_
double cellArea_[kEndcWedgesX][kEndcWedgesY]
Definition: EcalGeomPhiSymHelper.h:25