CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
EcalGeomPhiSymHelper Class Reference

#include <EcalGeomPhiSymHelper.h>

Public Member Functions

void setup (const CaloGeometry *geometry, const EcalChannelStatus *chstatus, int statusThreshold)
 

Public Attributes

double cellArea_ [kEndcWedgesX][kEndcWedgesY]
 
double cellPhi_ [kEndcWedgesX][kEndcWedgesY]
 
GlobalPoint cellPos_ [kEndcWedgesX][kEndcWedgesY]
 
int endcapRing_ [kEndcWedgesX][kEndcWedgesY]
 
double etaBoundary_ [kEndcEtaRings+1]
 
bool goodCell_barl [kBarlRings][kBarlWedges][kSides]
 
bool goodCell_endc [kEndcWedgesX][kEndcWedgesX][kSides]
 
double meanCellArea_ [kEndcEtaRings]
 
int nBads_barl [kBarlRings]
 
int nBads_endc [kEndcEtaRings]
 
int nRing_ [kEndcEtaRings]
 
double phi_endc_ [kMaxEndciPhi][kEndcEtaRings]
 

Detailed Description

Definition at line 19 of file EcalGeomPhiSymHelper.h.

Member Function Documentation

◆ setup()

void EcalGeomPhiSymHelper::setup ( const CaloGeometry geometry,
const EcalChannelStatus chstatus,
int  statusThreshold 
)

Definition at line 18 of file EcalGeomPhiSymHelper.cc.

References funct::abs(), cellArea_, cellPhi_, cellPos_, gather_cfg::cout, DetId::Ecal, EcalBarrel, EcalEndcap, endcapRing_, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaBoundary_, dqmMemoryStats::float, CaloSubdetectorGeometry::getGeometry(), goodCell_barl, goodCell_endc, EEDetId::hashedIndex(), mps_fire::i, EBDetId::ieta(), LEDCalibrationChannels::ieta, EBDetId::iphi(), EEDetId::ix(), EEDetId::iy(), kBarlRings, kEndcEtaRings, kEndcWedgesX, kEndcWedgesY, kMaxEndciPhi, kSides, meanCellArea_, nBads_barl, nBads_endc, nRing_, MillePedeFileConverter_cfg::out, phi, phi_endc_, phimin, relativeConstraints::ring, Validation_hcalonly_cfi::sign, EBDetId::zside(), and EEDetId::zside().

Referenced by o2olib.O2OTool::execute().

18  {
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 }
int nRing_[kEndcEtaRings]
int nBads_endc[kEndcEtaRings]
static const int kBarlRings
bool goodCell_barl[kBarlRings][kBarlWedges][kSides]
T eta() const
Definition: PV3DBase.h:73
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint cellPos_[kEndcWedgesX][kEndcWedgesY]
static const int kMaxEndciPhi
static const int kSides
double phi_endc_[kMaxEndciPhi][kEndcEtaRings]
static const int kEndcWedgesX
int endcapRing_[kEndcWedgesX][kEndcWedgesY]
static const int kEndcEtaRings
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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.
double cellPhi_[kEndcWedgesX][kEndcWedgesY]
double meanCellArea_[kEndcEtaRings]
double cellArea_[kEndcWedgesX][kEndcWedgesY]
int nBads_barl[kBarlRings]
bool goodCell_endc[kEndcWedgesX][kEndcWedgesX][kSides]
double etaBoundary_[kEndcEtaRings+1]
static const int kEndcWedgesY

Member Data Documentation

◆ cellArea_

double EcalGeomPhiSymHelper::cellArea_[kEndcWedgesX][kEndcWedgesY]

Definition at line 25 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ cellPhi_

double EcalGeomPhiSymHelper::cellPhi_[kEndcWedgesX][kEndcWedgesY]

Definition at line 24 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ cellPos_

GlobalPoint EcalGeomPhiSymHelper::cellPos_[kEndcWedgesX][kEndcWedgesY]

Definition at line 23 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ endcapRing_

int EcalGeomPhiSymHelper::endcapRing_[kEndcWedgesX][kEndcWedgesY]

Definition at line 29 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ etaBoundary_

double EcalGeomPhiSymHelper::etaBoundary_[kEndcEtaRings+1]

Definition at line 28 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ goodCell_barl

bool EcalGeomPhiSymHelper::goodCell_barl[kBarlRings][kBarlWedges][kSides]

Definition at line 33 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ goodCell_endc

bool EcalGeomPhiSymHelper::goodCell_endc[kEndcWedgesX][kEndcWedgesX][kSides]

Definition at line 34 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ meanCellArea_

double EcalGeomPhiSymHelper::meanCellArea_[kEndcEtaRings]

Definition at line 27 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ nBads_barl

int EcalGeomPhiSymHelper::nBads_barl[kBarlRings]

Definition at line 35 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ nBads_endc

int EcalGeomPhiSymHelper::nBads_endc[kEndcEtaRings]

Definition at line 36 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ nRing_

int EcalGeomPhiSymHelper::nRing_[kEndcEtaRings]

Definition at line 30 of file EcalGeomPhiSymHelper.h.

Referenced by setup().

◆ phi_endc_

double EcalGeomPhiSymHelper::phi_endc_[kMaxEndciPhi][kEndcEtaRings]

Definition at line 26 of file EcalGeomPhiSymHelper.h.

Referenced by setup().