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 
118  // Utility functions
119  static double dPhi(double f0, double f1);
120  static double aPhi(double f0, double f1);
121 
122  static double expCorrection(double a, const double *p);
123  static double gausCorrection(double a, const double *p);
124 
125  // Actual data for each instantiated object
126  unsigned _be,_hl;
127  double _e,_eta,_phi,_r9;
128  double _aC,_aS,_aM,_bC,_bS,_bM;
129 
130  // Constants
131  static const double _onePi;
132  static const double _twoPi;
133 
134  // Initialisation flag
135  static bool _initialised;
136 
137  // Parameters for fixes
138  static double _meanScale[2][2][4];
139  static double _meanAT[2][2][4];
140  static double _meanAC[2][2][4];
141  static double _meanAS[2][2][4];
142  static double _meanAM[2][2][4];
143  static double _meanBT[2][2][4];
144  static double _meanBC[2][2][4];
145  static double _meanBS[2][2][4];
146  static double _meanBM[2][2][4];
147  static double _meanR9[2][2][4];
148 
149  // Parameters for resolution
150  static double _sigmaScale[2][2][4];
151  static double _sigmaAT[2][2][4];
152  static double _sigmaAC[2][2][4];
153  static double _sigmaAS[2][2][4];
154  static double _sigmaAM[2][2][4];
155  static double _sigmaBT[2][2][4];
156  static double _sigmaBC[2][2][4];
157  static double _sigmaBS[2][2][4];
158  static double _sigmaBM[2][2][4];
159  static double _sigmaR9[2][2][4];
160 
161  // EB gap positions
162  static double _barrelCGap[169][360][2];
163  static double _barrelSGap[33][180][2];
164  static double _barrelMGap[7][18][2];
165 
166  // EE crystal existence and gap positions
167  static bool _endcapCrystal[100][100];
168  static double _endcapCGap[2][7080][2];
169  static double _endcapSGap[2][264][2];
170  static double _endcapMGap[2][1][2];
171 
172 };
173 
174 #endif
static void getParameters(unsigned be, unsigned hl, double *p)
Definition: PhotonFix.cc:383
static double _meanScale[2][2][4]
Definition: PhotonFix.h:138
static double _meanAS[2][2][4]
Definition: PhotonFix.h:141
double xC() const
Definition: PhotonFix.cc:289
static double _meanBM[2][2][4]
Definition: PhotonFix.h:146
double _phi
Definition: PhotonFix.h:127
static double _endcapCGap[2][7080][2]
Definition: PhotonFix.h:168
unsigned _hl
Definition: PhotonFix.h:126
static void dumpGaps(std::ostream &o)
Definition: PhotonFix.cc:557
double fixedEnergy() const
Definition: PhotonFix.cc:139
PhotonFix(double e, double eta, double phi, double r9)
Definition: PhotonFix.cc:9
static bool _endcapCrystal[100][100]
Definition: PhotonFix.h:167
static bool initialised()
Definition: PhotonFix.cc:651
static double expCorrection(double a, const double *p)
Definition: PhotonFix.cc:636
double rawEnergy() const
Definition: PhotonFix.cc:238
static double _sigmaAS[2][2][4]
Definition: PhotonFix.h:153
static double _barrelSGap[33][180][2]
Definition: PhotonFix.h:163
static double _meanBC[2][2][4]
Definition: PhotonFix.h:144
static double aPhi(double f0, double f1)
Definition: PhotonFix.cc:623
static double _sigmaAM[2][2][4]
Definition: PhotonFix.h:154
double phiS() const
Definition: PhotonFix.cc:274
static double _meanR9[2][2][4]
Definition: PhotonFix.h:147
double _bC
Definition: PhotonFix.h:128
static double _meanAC[2][2][4]
Definition: PhotonFix.h:140
static double gausCorrection(double a, const double *p)
Definition: PhotonFix.cc:644
static double _sigmaBS[2][2][4]
Definition: PhotonFix.h:157
double xZ() const
Definition: PhotonFix.cc:284
static double _sigmaR9[2][2][4]
Definition: PhotonFix.h:159
static double _barrelCGap[169][360][2]
Definition: PhotonFix.h:162
static bool initialiseGeometry(const std::string &s)
Definition: PhotonFix.cc:2042
double yZ() const
Definition: PhotonFix.cc:304
static void endcapSGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:343
static bool initialise(const std::string &s="Nominal")
Definition: PhotonFix.cc:654
unsigned _be
Definition: PhotonFix.h:126
static double asinh(double s)
Definition: PhotonFix.cc:552
static double _sigmaScale[2][2][4]
Definition: PhotonFix.h:150
void setup()
Definition: PhotonFix.cc:15
static void barrelMGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:334
double etaM() const
Definition: PhotonFix.cc:264
static double _meanBS[2][2][4]
Definition: PhotonFix.h:145
static void printParameters(std::ostream &o)
Definition: PhotonFix.cc:479
static void barrelCGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:328
static void endcapMGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:346
double phi() const
Definition: PhotonFix.cc:246
static double _endcapSGap[2][264][2]
Definition: PhotonFix.h:169
static double _meanAT[2][2][4]
Definition: PhotonFix.h:139
static void barrelSGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:331
static double _endcapMGap[2][1][2]
Definition: PhotonFix.h:170
static const double _onePi
Definition: PhotonFix.h:131
double _aM
Definition: PhotonFix.h:128
double etaS() const
Definition: PhotonFix.cc:259
static void endcapCGap(unsigned i, unsigned j, unsigned k, double c)
Definition: PhotonFix.cc:340
double _r9
Definition: PhotonFix.h:127
static void endcapCrystal(unsigned i, unsigned j, bool c)
Definition: PhotonFix.cc:337
double _bM
Definition: PhotonFix.h:128
static double _meanAM[2][2][4]
Definition: PhotonFix.h:142
static void setParameters(unsigned be, unsigned hl, const double *p)
Definition: PhotonFix.cc:357
double _eta
Definition: PhotonFix.h:127
int k[5][pyjets_maxn]
double yM() const
Definition: PhotonFix.cc:319
static double _sigmaBC[2][2][4]
Definition: PhotonFix.h:156
double etaC() const
Definition: PhotonFix.cc:254
double sigmaEnergy() const
Definition: PhotonFix.cc:178
static bool initialiseParameters(const std::string &s)
Definition: PhotonFix.cc:663
static bool _initialised
Definition: PhotonFix.h:135
double yS() const
Definition: PhotonFix.cc:314
double _aS
Definition: PhotonFix.h:128
static double _sigmaAT[2][2][4]
Definition: PhotonFix.h:151
double _bS
Definition: PhotonFix.h:128
double yC() const
Definition: PhotonFix.cc:309
double eta() const
Definition: PhotonFix.cc:242
static double _meanBT[2][2][4]
Definition: PhotonFix.h:143
static double _sigmaBT[2][2][4]
Definition: PhotonFix.h:155
static const double _twoPi
Definition: PhotonFix.h:132
double phiC() const
Definition: PhotonFix.cc:269
double a
Definition: hdecay.h:121
double r9() const
Definition: PhotonFix.cc:250
double phiM() const
Definition: PhotonFix.cc:279
static double _sigmaBM[2][2][4]
Definition: PhotonFix.h:158
double _aC
Definition: PhotonFix.h:128
double xM() const
Definition: PhotonFix.cc:299
static double dPhi(double f0, double f1)
Definition: PhotonFix.cc:616
double _e
Definition: PhotonFix.h:127
static void dumpParameters(std::ostream &o)
Definition: PhotonFix.cc:409
static double _barrelMGap[7][18][2]
Definition: PhotonFix.h:164
void print() const
Definition: PhotonFix.cc:351
static double _sigmaAC[2][2][4]
Definition: PhotonFix.h:152
double xS() const
Definition: PhotonFix.cc:294
static double GetaPhi(double f0, double f1)
Definition: PhotonFix.cc:324