ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/interface/PhotonFix.h
Revision: 1.1
Committed: Wed Jul 27 15:17:37 2011 UTC (13 years, 9 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_024b, Mit_024a, Mit_024
Log Message:
update photon stuff

File Contents

# User Rev Content
1 bendavid 1.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 'PhotonFix.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.
29    
30     Make objects using
31     PhotonFix a(energy,eta,phi,r9);
32     where energy is the photon energy, eta and phi are the ECAL
33     cluster positions (NB from the Supercluster object, _not_ the
34     Photon object, as the latter gives eta and phi directions,
35     not positions), and r9 is the R9 value of the SC.
36    
37     Get the corrected energy using
38     a.fixedEnergy();
39     and the resolution using
40     a.sigmaEnergy();
41    
42     */
43    
44     #include <iostream>
45     #include <string>
46    
47     class PhotonFix {
48     public:
49     PhotonFix(double e, double eta, double phi, double r9);
50    
51     // Must be called before instantiating any PhotonFix objects
52     static bool initialise(const std::string &s="Nominal", const std::string &infile = "PhotonFix.dat");
53     static bool initialised() ;
54    
55     // Used by above; do not call directly
56     static bool initialiseParameters(const std::string &s);
57     static bool initialiseGeometry(const std::string &s, const std::string &infile);
58    
59     void setup();
60    
61     // Corrected energy and sigma
62     double fixedEnergy() const;
63     double sigmaEnergy() const;
64    
65     // Input values
66     double rawEnergy() const;
67     double eta() const;
68     double phi() const;
69     double r9() const;
70    
71     // Derived EB crystal, submodule and module relative coordinates
72     double etaC() const;
73     double etaS() const;
74     double etaM() const;
75    
76     double phiC() const;
77     double phiS() const;
78     double phiM() const;
79    
80     // Derived EE zeta, crystal, subcrystal and D-module relative coordinates
81     double xZ() const;
82     double xC() const;
83     double xS() const;
84     double xM() const;
85    
86     double yZ() const;
87     double yC() const;
88     double yS() const;
89     double yM() const;
90    
91     // Return arrays containing positions of ecal gaps
92     static void barrelCGap(unsigned i, unsigned j, unsigned k, double c);
93     static void barrelSGap(unsigned i, unsigned j, unsigned k, double c);
94     static void barrelMGap(unsigned i, unsigned j, unsigned k, double c);
95     static void endcapCrystal(unsigned i, unsigned j, bool c);
96     static void endcapCGap(unsigned i, unsigned j, unsigned k, double c);
97     static void endcapSGap(unsigned i, unsigned j, unsigned k, double c);
98     static void endcapMGap(unsigned i, unsigned j, unsigned k, double c);
99    
100     void print() const;
101    
102     // Input and output the fit parameters
103     static void setParameters(unsigned be, unsigned hl, const double *p);
104     static void getParameters(unsigned be, unsigned hl, double *p);
105    
106     static void dumpParameters(std::ostream &o);
107     static void printParameters(std::ostream &o);
108    
109     // Utility functions
110     static double GetaPhi(double f0, double f1);
111     static double asinh(double s);
112     static void dumpGaps(std::ostream &o);
113    
114     private:
115    
116     // Utility functions
117     static double dPhi(double f0, double f1);
118     static double aPhi(double f0, double f1);
119    
120     static double expCorrection(double a, const double *p);
121     static double gausCorrection(double a, const double *p);
122    
123     // Actual data for each instantiated object
124     unsigned _be,_hl;
125     double _e,_eta,_phi,_r9;
126     double _aC,_aS,_aM,_bC,_bS,_bM;
127    
128     // Constants
129     static const double _onePi;
130     static const double _twoPi;
131    
132     // Initialisation flag
133     static bool _initialised;
134    
135     // Parameters for fixes
136     static double _meanScale[2][2][4];
137     static double _meanAC[2][2][4];
138     static double _meanAS[2][2][4];
139     static double _meanAM[2][2][4];
140     static double _meanBC[2][2][4];
141     static double _meanBS[2][2][4];
142     static double _meanBM[2][2][4];
143     static double _meanR9[2][2][4];
144    
145     // Parameters for resolution
146     static double _sigmaScale[2][2][4];
147     static double _sigmaAT[2][2][4];
148     static double _sigmaAC[2][2][4];
149     static double _sigmaAS[2][2][4];
150     static double _sigmaAM[2][2][4];
151     static double _sigmaBT[2][2][4];
152     static double _sigmaBC[2][2][4];
153     static double _sigmaBS[2][2][4];
154     static double _sigmaBM[2][2][4];
155     static double _sigmaR9[2][2][4];
156    
157     // EB gap positions
158     static double _barrelCGap[169][360][2];
159     static double _barrelSGap[33][180][2];
160     static double _barrelMGap[7][18][2];
161    
162     // EE crystal existence and gap positions
163     static bool _endcapCrystal[100][100];
164     static double _endcapCGap[2][7080][2];
165     static double _endcapSGap[2][264][2];
166     static double _endcapMGap[2][1][2];
167    
168     };
169    
170     #endif