CMS 3D CMS Logo

PhotonFix.h
Go to the documentation of this file.
1 #ifndef PhotonFix_Defined_hh
2 #define PhotonFix_Defined_hh
3 
4 //-------------------------------------------------------//
5 // Project: PhotonFix
6 // Author: Paul Dauncey (p.dauncey@imperial.ac.uk)
7 // Modified: 11/07/2011
8 // Admins: Paul Dauncey (p.dauncey@imperial.ac.uk)
9 // Matt Kenzie (matthew.william.kenzie@cern.ch)
10 //-------------------------------------------------------//
11 
12 /*
13  Does post-reco fixes to ECAL photon energy and estimates resolution.
14  This can run outside of the usual CMS software framework but requires
15  access to a file 'EcalGaps.dat' which must be in the same directory as
16  that used to run.
17 
18  To run within CMSSW use PhotonFixCMS.h (which can access the geometry
19  directly - go to "RecoEcal/EgammaCoreTools/plugins/PhotonFixCMS.h"
20  for details.
21 
22  Before instantiating any objects of PhotonFix, the constants must be
23  initialised in the first event using
24  PhotonFix::initialise("3_8");
25 
26  The string gives the reco version used. Valid strings are
27  "3_8", "3_11", "4_2" and "Nominal", where the latter gives no correction
28  to the energy and a nominal resolution value. There is also "4_2e" which
29  provides corrections for electrons which are reconstructed as photons (to
30  aid with testing the performance of these corrections in data).
31 
32  Make objects using
33  PhotonFix a(energy,eta,phi,r9);
34  where energy is the photon energy, eta and phi are the ECAL
35  cluster positions (NB from the Supercluster object, _not_ the
36  Photon object, as the latter gives eta and phi directions,
37  not positions), and r9 is the R9 value of the SC.
38 
39  Get the corrected energy using
40  a.fixedEnergy();
41  and the resolution using
42  a.sigmaEnergy();
43 
44 */
45 
46 #include <iostream>
47 #include <string>
48 
49 class PhotonFix {
50 public:
51  PhotonFix(double e, double eta, double phi, double r9);
52 
53  // Must be called before instantiating any PhotonFix objects
54  static bool initialise(const std::string &s = "Nominal");
55  static bool initialised();
56 
57  // Used by above; do not call directly
58  static bool initialiseParameters(const std::string &s);
59  static bool initialiseGeometry(const std::string &s);
60 
61  void setup();
62 
63  // Corrected energy and sigma
64  double fixedEnergy() const;
65  double sigmaEnergy() const;
66 
67  // Input values
68  double rawEnergy() const;
69  double eta() const;
70  double phi() const;
71  double r9() const;
72 
73  // Derived EB crystal, submodule and module relative coordinates
74  double etaC() const;
75  double etaS() const;
76  double etaM() const;
77 
78  double phiC() const;
79  double phiS() const;
80  double phiM() const;
81 
82  // Derived EE zeta, crystal, subcrystal and D-module relative coordinates
83  double xZ() const;
84  double xC() const;
85  double xS() const;
86  double xM() const;
87 
88  double yZ() const;
89  double yC() const;
90  double yS() const;
91  double yM() const;
92 
93  // Return arrays containing positions of ecal gaps
94  static void barrelCGap(unsigned i, unsigned j, unsigned k, double c);
95  static void barrelSGap(unsigned i, unsigned j, unsigned k, double c);
96  static void barrelMGap(unsigned i, unsigned j, unsigned k, double c);
97  static void endcapCrystal(unsigned i, unsigned j, bool c);
98  static void endcapCGap(unsigned i, unsigned j, unsigned k, double c);
99  static void endcapSGap(unsigned i, unsigned j, unsigned k, double c);
100  static void endcapMGap(unsigned i, unsigned j, unsigned k, double c);
101 
102  void print() const;
103 
104  // Input and output the fit parameters
105  static void setParameters(unsigned be, unsigned hl, const double *p);
106  static void getParameters(unsigned be, unsigned hl, double *p);
107 
108  static void dumpParameters(std::ostream &o);
109  static void printParameters(std::ostream &o);
110 
111  // Utility functions
112  static double GetaPhi(double f0, double f1);
113  static double asinh(double s);
114  static void dumpGaps(std::ostream &o);
115 
116 private:
117  // Utility functions
118  static double dPhi(double f0, double f1);
119  static double aPhi(double f0, double f1);
120 
121  static double expCorrection(double a, const double *p);
122  static double gausCorrection(double a, const double *p);
123 
124  // Actual data for each instantiated object
125  unsigned _be, _hl;
126  double _e, _eta, _phi, _r9;
127  double _aC, _aS, _aM, _bC, _bS, _bM;
128 
129  // Constants
130  static const double _onePi;
131  static const double _twoPi;
132 
133  // Initialisation flag
134  static bool _initialised;
135 
136  // Parameters for fixes
137  static double _meanScale[2][2][4];
138  static double _meanAT[2][2][4];
139  static double _meanAC[2][2][4];
140  static double _meanAS[2][2][4];
141  static double _meanAM[2][2][4];
142  static double _meanBT[2][2][4];
143  static double _meanBC[2][2][4];
144  static double _meanBS[2][2][4];
145  static double _meanBM[2][2][4];
146  static double _meanR9[2][2][4];
147 
148  // Parameters for resolution
149  static double _sigmaScale[2][2][4];
150  static double _sigmaAT[2][2][4];
151  static double _sigmaAC[2][2][4];
152  static double _sigmaAS[2][2][4];
153  static double _sigmaAM[2][2][4];
154  static double _sigmaBT[2][2][4];
155  static double _sigmaBC[2][2][4];
156  static double _sigmaBS[2][2][4];
157  static double _sigmaBM[2][2][4];
158  static double _sigmaR9[2][2][4];
159 
160  // EB gap positions
161  static double _barrelCGap[169][360][2];
162  static double _barrelSGap[33][180][2];
163  static double _barrelMGap[7][18][2];
164 
165  // EE crystal existence and gap positions
166  static bool _endcapCrystal[100][100];
167  static double _endcapCGap[2][7080][2];
168  static double _endcapSGap[2][264][2];
169  static double _endcapMGap[2][1][2];
170 };
171 
172 #endif
static void getParameters(unsigned be, unsigned hl, double *p)
Definition: PhotonFix.cc:368
static double _meanScale[2][2][4]
Definition: PhotonFix.h:137
static double _meanAS[2][2][4]
Definition: PhotonFix.h:140
double xC() const
Definition: PhotonFix.cc:292
static double _meanBM[2][2][4]
Definition: PhotonFix.h:145
double _phi
Definition: PhotonFix.h:126
static double _endcapCGap[2][7080][2]
Definition: PhotonFix.h:167
unsigned _hl
Definition: PhotonFix.h:125
static void dumpGaps(std::ostream &o)
Definition: PhotonFix.cc:564
double fixedEnergy() const
Definition: PhotonFix.cc:149
PhotonFix(double e, double eta, double phi, double r9)
Definition: PhotonFix.cc:9
static bool _endcapCrystal[100][100]
Definition: PhotonFix.h:166
static bool initialised()
Definition: PhotonFix.cc:670
static double expCorrection(double a, const double *p)
Definition: PhotonFix.cc:649
double rawEnergy() const
Definition: PhotonFix.cc:249
static double _sigmaAS[2][2][4]
Definition: PhotonFix.h:152
static double _barrelSGap[33][180][2]
Definition: PhotonFix.h:162
static double _meanBC[2][2][4]
Definition: PhotonFix.h:143
static double aPhi(double f0, double f1)
Definition: PhotonFix.cc:634
static double _sigmaAM[2][2][4]
Definition: PhotonFix.h:153
double phiS() const
Definition: PhotonFix.cc:277
static double _meanR9[2][2][4]
Definition: PhotonFix.h:146
double _bC
Definition: PhotonFix.h:127
static double _meanAC[2][2][4]
Definition: PhotonFix.h:139
static double gausCorrection(double a, const double *p)
Definition: PhotonFix.cc:660
static double _sigmaBS[2][2][4]
Definition: PhotonFix.h:156
double xZ() const
Definition: PhotonFix.cc:287
static double _sigmaR9[2][2][4]
Definition: PhotonFix.h:158
static double _barrelCGap[169][360][2]
Definition: PhotonFix.h:161
static bool initialiseGeometry(const std::string &s)
Definition: PhotonFix.cc:2059
double yZ() const
Definition: PhotonFix.cc:307
static void endcapSGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:334
static bool initialise(const std::string &s="Nominal")
Definition: PhotonFix.cc:671
unsigned _be
Definition: PhotonFix.h:125
static double asinh(double s)
Definition: PhotonFix.cc:557
static double _sigmaScale[2][2][4]
Definition: PhotonFix.h:149
void setup()
Definition: PhotonFix.cc:11
static void barrelMGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:331
double etaM() const
Definition: PhotonFix.cc:267
static double _meanBS[2][2][4]
Definition: PhotonFix.h:144
static void printParameters(std::ostream &o)
Definition: PhotonFix.cc:464
static void barrelCGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:329
static void endcapMGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:335
double phi() const
Definition: PhotonFix.cc:253
static double _endcapSGap[2][264][2]
Definition: PhotonFix.h:168
static double _meanAT[2][2][4]
Definition: PhotonFix.h:138
static void barrelSGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:330
static double _endcapMGap[2][1][2]
Definition: PhotonFix.h:169
static const double _onePi
Definition: PhotonFix.h:130
double _aM
Definition: PhotonFix.h:127
double etaS() const
Definition: PhotonFix.cc:262
static void endcapCGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:333
double _r9
Definition: PhotonFix.h:126
static void endcapCrystal(unsigned i, unsigned j, bool c)
Definition: PhotonFix.cc:332
double _bM
Definition: PhotonFix.h:127
static double _meanAM[2][2][4]
Definition: PhotonFix.h:141
static void setParameters(unsigned be, unsigned hl, const double *p)
Definition: PhotonFix.cc:342
double _eta
Definition: PhotonFix.h:126
double yM() const
Definition: PhotonFix.cc:322
static double _sigmaBC[2][2][4]
Definition: PhotonFix.h:155
double etaC() const
Definition: PhotonFix.cc:257
double sigmaEnergy() const
Definition: PhotonFix.cc:189
static bool initialiseParameters(const std::string &s)
Definition: PhotonFix.cc:680
static bool _initialised
Definition: PhotonFix.h:134
double yS() const
Definition: PhotonFix.cc:317
double _aS
Definition: PhotonFix.h:127
static double _sigmaAT[2][2][4]
Definition: PhotonFix.h:150
double _bS
Definition: PhotonFix.h:127
double yC() const
Definition: PhotonFix.cc:312
double eta() const
Definition: PhotonFix.cc:251
static double _meanBT[2][2][4]
Definition: PhotonFix.h:142
static double _sigmaBT[2][2][4]
Definition: PhotonFix.h:154
static const double _twoPi
Definition: PhotonFix.h:131
double phiC() const
Definition: PhotonFix.cc:272
double a
Definition: hdecay.h:119
double r9() const
Definition: PhotonFix.cc:255
double phiM() const
Definition: PhotonFix.cc:282
static double _sigmaBM[2][2][4]
Definition: PhotonFix.h:157
double _aC
Definition: PhotonFix.h:127
double xM() const
Definition: PhotonFix.cc:302
static double dPhi(double f0, double f1)
Definition: PhotonFix.cc:625
double _e
Definition: PhotonFix.h:126
static void dumpParameters(std::ostream &o)
Definition: PhotonFix.cc:394
static double _barrelMGap[7][18][2]
Definition: PhotonFix.h:163
void print() const
Definition: PhotonFix.cc:337
static double _sigmaAC[2][2][4]
Definition: PhotonFix.h:151
double xS() const
Definition: PhotonFix.cc:297
static double GetaPhi(double f0, double f1)
Definition: PhotonFix.cc:327