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