CMS 3D CMS Logo

PhotonFixCMS.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <cassert>
3 #include <fstream>
4 #include <iomanip>
5 
23 
25 
27  : pf(p.energy(), p.superCluster()->eta(), p.superCluster()->phi(), p.r9()) {}
28 
31  return false;
32 
34 
35  // Get ECAL geometry
37  iSetup.get<CaloGeometryRecord>().get(geoHandle);
38  const CaloGeometry &geometry = *geoHandle;
39 
40  // EB
41  const CaloSubdetectorGeometry *barrelGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
42 
43  double bc[170][360][2];
44  for (int iz(0); iz < 2; iz++) {
45  for (int ie(0); ie < 85; ie++) {
46  int id = ie + 1;
47  if (iz == 0)
48  id = ie - 85;
49  for (int ip(0); ip < 360; ip++) {
50  EBDetId eb(id, ip + 1);
51 
52  auto cellGeometry = barrelGeometry->getGeometry(eb);
53  const GlobalPoint &crystalPos = cellGeometry->getPosition();
54  bc[85 * iz + ie][ip][0] = crystalPos.eta();
55  bc[85 * iz + ie][ip][1] = crystalPos.phi();
56  }
57  }
58  }
59 
60  for (unsigned i(0); i < 169; i++) {
61  for (unsigned j(0); j < 360; j++) {
62  unsigned k((j + 1) % 360);
63 
64  double eta = 0.25 * (bc[i][j][0] + bc[i + 1][j][0] + bc[i][k][0] + bc[i + 1][k][0]);
65  double phi = PhotonFix::GetaPhi(PhotonFix::GetaPhi(bc[i][j][1], bc[i + 1][j][1]),
66  PhotonFix::GetaPhi(bc[i][k][1], bc[i + 1][k][1]));
67 
70 
71  if ((i % 5) == 4 && (j % 2) == 1) {
72  PhotonFix::barrelSGap(i / 5, j / 2, 0, eta);
73  PhotonFix::barrelSGap(i / 5, j / 2, 1, phi);
74  }
75 
76  if ((j % 20) == 19) {
77  if (i == 19) {
78  PhotonFix::barrelMGap(0, j / 20, 0, eta);
79  PhotonFix::barrelMGap(0, j / 20, 1, phi);
80  }
81  if (i == 39) {
82  PhotonFix::barrelMGap(1, j / 20, 0, eta);
83  PhotonFix::barrelMGap(1, j / 20, 1, phi);
84  }
85  if (i == 59) {
86  PhotonFix::barrelMGap(2, j / 20, 0, eta);
87  PhotonFix::barrelMGap(2, j / 20, 1, phi);
88  }
89  if (i == 84) {
90  PhotonFix::barrelMGap(3, j / 20, 0, eta);
91  PhotonFix::barrelMGap(3, j / 20, 1, phi);
92  }
93  if (i == 109) {
94  PhotonFix::barrelMGap(4, j / 20, 0, eta);
95  PhotonFix::barrelMGap(4, j / 20, 1, phi);
96  }
97  if (i == 129) {
98  PhotonFix::barrelMGap(5, j / 20, 0, eta);
99  PhotonFix::barrelMGap(5, j / 20, 1, phi);
100  }
101  if (i == 149) {
102  PhotonFix::barrelMGap(6, j / 20, 0, eta);
103  PhotonFix::barrelMGap(6, j / 20, 1, phi);
104  }
105  }
106  }
107  }
108 
109  // EE
110  const CaloSubdetectorGeometry *endcapGeometry = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
111 
112  double ec[2][100][100][2];
113  bool valid[100][100];
114  int val_count = 0;
115  for (int iz(0); iz < 2; iz++) {
116  for (int ix(0); ix < 100; ix++) {
117  for (int iy(0); iy < 100; iy++) {
118  valid[ix][iy] = EEDetId::validDetId(ix + 1, iy + 1, 2 * iz - 1);
119  if (iz == 0)
120  PhotonFix::endcapCrystal(ix, iy, valid[ix][iy]);
121  if (valid[ix][iy]) {
122  EEDetId ee(ix + 1, iy + 1, 2 * iz - 1);
123  val_count += 1;
124 
125  auto cellGeometry = endcapGeometry->getGeometry(ee);
126  const GlobalPoint &crystalPos = cellGeometry->getPosition();
127  ec[iz][ix][iy][0] = asinh(crystalPos.x() / fabs(crystalPos.z()));
128  ec[iz][ix][iy][1] = asinh(crystalPos.y() / fabs(crystalPos.z()));
129  }
130  }
131  }
132  }
133  std::cout << "GG valid " << val_count << std::endl;
134  double c[2];
135  for (unsigned iz(0); iz < 2; iz++) {
136  unsigned nC(0), nS(0);
137  for (unsigned i(0); i < 99; i++) {
138  for (unsigned j(0); j < 99; j++) {
139  if (valid[i][j] && valid[i + 1][j] && valid[i][j + 1] && valid[i + 1][j + 1]) {
140  for (unsigned k(0); k < 2; k++) {
141  c[k] = 0.25 * (ec[iz][i][j][k] + ec[iz][i + 1][j][k] + ec[iz][i][j + 1][k] + ec[iz][i + 1][j + 1][k]);
142 
143  PhotonFix::endcapCGap(iz, nC, k, c[k]);
144  }
145 
146  if ((i % 5) == 4 && (j % 5) == 4) {
147  for (unsigned k(0); k < 2; k++) {
148  PhotonFix::endcapSGap(iz, nS, k, c[k]);
149  }
150  nS++;
151  }
152  nC++;
153  }
154  }
155  }
156  std::cout << "Endcap number of crystal, submodule boundaries = " << nC << ", " << nS << std::endl;
157  }
158 
159  // Hardcode EE D-module gap to 0,0
160  PhotonFix::endcapMGap(0, 0, 0, 0.0);
161  PhotonFix::endcapMGap(0, 0, 1, 0.0);
162  PhotonFix::endcapMGap(1, 0, 0, 0.0);
163  PhotonFix::endcapMGap(1, 0, 1, 0.0);
164 
165  return true;
166 }
167 
168 double PhotonFixCMS::fixedEnergy() const { return pf.fixedEnergy(); }
169 
170 double PhotonFixCMS::sigmaEnergy() const { return pf.sigmaEnergy(); }
171 
172 const PhotonFix &PhotonFixCMS::photonFix() const { return pf; }
electrons_cff.r9
r9
Definition: electrons_cff.py:387
mps_fire.i
i
Definition: mps_fire.py:428
EcalBarrelGeometry.h
PhotonFixCMS::photonFix
const PhotonFix & photonFix() const
Definition: PhotonFixCMS.cc:172
ESHandle.h
PhotonFix::fixedEnergy
double fixedEnergy() const
Definition: PhotonFix.cc:149
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
PhotonFixCMS::fixedEnergy
double fixedEnergy() const
Definition: PhotonFixCMS.cc:168
PhotonFixCMS.h
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EBDetId
Definition: EBDetId.h:17
PhotonFix::initialiseParameters
static bool initialiseParameters(const std::string &s)
Definition: PhotonFix.cc:680
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PhotonFixCMS::pf
PhotonFix pf
Definition: PhotonFixCMS.h:63
gather_cfg.cout
cout
Definition: gather_cfg.py:144
geometry
Definition: geometry.py:1
PhotonFix::barrelMGap
static void barrelMGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:331
EDAnalyzer.h
EcalBarrel
Definition: EcalSubdetector.h:10
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
MakerMacros.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
CaloGeometry
Definition: CaloGeometry.h:21
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
PVValHelper::eta
Definition: PVValidationHelpers.h:69
TruncatedPyramid.h
EcalBarrelGeometryRecord.h
PhotonFix::initialised
static bool initialised()
Definition: PhotonFix.cc:670
PhotonFix::barrelCGap
static void barrelCGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:329
edm::ESHandle< CaloGeometry >
PhotonFix::endcapMGap
static void endcapMGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:335
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Point3DBase< float, GlobalTag >
PhotonFix
Definition: PhotonFix.h:49
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
PhotonFix::GetaPhi
static double GetaPhi(double f0, double f1)
Definition: PhotonFix.cc:327
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
CaloSubdetectorGeometry.h
PhotonFixCMS::PhotonFixCMS
PhotonFixCMS(const reco::Photon &p)
Definition: PhotonFixCMS.cc:26
PhotonFixCMS::initialise
static bool initialise(const edm::EventSetup &iSetup, const std::string &s="Nominal")
Definition: PhotonFixCMS.cc:29
Event.h
PVValHelper::phi
Definition: PVValidationHelpers.h:68
EcalEndcapGeometry.h
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
PhotonFixCMS::sigmaEnergy
double sigmaEnergy() const
Definition: PhotonFixCMS.cc:170
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
PhotonFix::endcapCrystal
static void endcapCrystal(unsigned i, unsigned j, bool c)
Definition: PhotonFix.cc:332
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
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DetId::Ecal
Definition: DetId.h:27
get
#define get
DDAxes::phi
reco::Photon
Definition: Photon.h:21
CaloCellGeometry.h
PhotonFix::endcapSGap
static void endcapSGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:334
DetId.h
Frameworkfwd.h
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
SuperCluster.h
CaloGeometry.h
PhotonFix::sigmaEnergy
double sigmaEnergy() const
Definition: PhotonFix.cc:189
EcalEndcapGeometryRecord.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
ParameterSet.h
PhotonFix::barrelSGap
static void barrelSGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:330
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
PhotonFix::endcapCGap
static void endcapCGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:333