CMS 3D CMS Logo

ZIterativeAlgorithmWithFit.h
Go to the documentation of this file.
1 #ifndef ZITERATIVEALGORITHMWITHFIT_H
2 #define ZITERATIVEALGORITHMWITHFIT_H
3 
4 /* ******************************************
5  * ZIterativeAlgorithmWithFit.h
6  *
7  * Paolo Meridiani 06/03/2003
8  ********************************************/
9 
10 #include <TROOT.h>
11 #include <TClonesArray.h>
12 #include <vector>
13 #include <string>
14 #include <TH1.h>
15 
17 
21 
25 #define nMaxIterations 50
26 #define nMaxChannels 250
27 
28 
29 
31 {
32  public:
37  };
38 
41 
44  //, unsigned int events);
45 
48  return *this;
49  }
50 
53 
54  bool resetIteration();
55 
56  bool iterate();
57 
59 
61 
63 
64  int getNumberOfChannels() const { return channels_; }
65 
66  const std::vector<float>& getOptimizedCoefficients() const { return optimizedCoefficients_; }
67 
68  const std::vector<float>& getOptimizedCoefficientsError() const { return optimizedCoefficientsError_; }
69 
70  const std::vector<float>& getOptimizedChiSquare() const { return optimizedChiSquare_; }
71 
72  const std::vector<int>& getOptimizedIterations() const { return optimizedIterations_; }
73 
74  const std::vector<float>& getWeightSum() const { return weight_sum_; }
75 
76  const std::vector<float>& getEpsilonSum() const { return calib_fac_; }
77 
78  //Helper Methods
79 
80  static inline float invMassCalc(float Energy1, float Eta1, float Phi1, float Energy2, float Eta2, float Phi2) {
81  return (sqrt(2 * Energy1 * Energy2 * (1 - cosTheta12(Eta1, Phi1, Eta2, Phi2))));
82  }
83 
84  static inline float cosTheta12(float Eta1, float Phi1, float Eta2, float Phi2) {
85  return ((cos(Phi1 - Phi2) + sinh(Eta1) * sinh(Eta2)) / (cosh(Eta1) * cosh(Eta2)));
86  }
87 
88  /*
89  static TF1* gausfit(TH1F * histoou,double* par,double* errpar) {
90  return gausfit(histoou,par,errpar,1.,2.);
91  }
92  */
93 
94  static void gausfit(TH1F * histoou,double* par,double* errpar,float nsigmalow, float nsigmaup, double* mychi2, int* iterations);
95 
96  private:
97 
98  void addWeightsCorrections(unsigned int event_id);
99 
100  void getStatWeights(const std::string& file);
101 
102  float getEventWeight(unsigned int event_id);
103 
105 
106  void recalculateMasses();
107 
109 
110  void getWeight(unsigned int evid,std::pair<calib::CalibElectron*,calib::CalibElectron*>, float);
111 
112  void getWeight(unsigned int evid,calib::CalibElectron* ele,float);
113 
114  void bookHistograms();
115 
117 
119 
120  unsigned int channels_;
121  unsigned int totalEvents_;
122  unsigned int numberOfIterations_;
123 
124  unsigned int currentEvent_;
125  unsigned int currentIteration_;
126 
127  std::vector< std::pair<calib::CalibElectron*,calib::CalibElectron*> > electrons_;
128 
129  std::vector<float> optimizedCoefficients_;
130  std::vector<float> optimizedCoefficientsError_;
131  std::vector<float> calib_fac_;
132  std::vector<float> weight_sum_;
133  std::vector<float> massReco_;
134  std::vector<float> optimizedChiSquare_;
135  std::vector<int> optimizedIterations_;
136 
138 
141 
142  std::vector<float> StatWeights_;
143  std::vector<float> Event_Weight_;
144 
145  TString calibType_;
146 
147  static const double M_Z_;
148 };
149 
150 #endif // ZIterativeAlgorithmWithFit_H
151 
152 
const ZIterativeAlgorithmWithFitPlots * getHistos() const
void getWeight(unsigned int evid, std::pair< calib::CalibElectron *, calib::CalibElectron * >, float)
ZIterativeAlgorithmWithFit()
Default constructor.
const std::vector< float > & getOptimizedChiSquare() const
std::vector< std::pair< calib::CalibElectron *, calib::CalibElectron * > > electrons_
virtual ~ZIterativeAlgorithmWithFit()
Destructor.
#define nMaxIterations
Definition: weight.py:1
const std::vector< float > & getOptimizedCoefficients() const
bool addEvent(calib::CalibElectron *, calib::CalibElectron *, float)
std::vector< float > optimizedCoefficients_
static void gausfit(TH1F *histoou, double *par, double *errpar, float nsigmalow, float nsigmaup, double *mychi2, int *iterations)
void addWeightsCorrections(unsigned int event_id)
T sqrt(T t)
Definition: SSEVec.h:18
ZIterativeAlgorithmWithFit & operator=(const ZIterativeAlgorithmWithFit &r)
Assignment operator.
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const std::vector< float > & getOptimizedCoefficientsError() const
#define nMaxChannels
const std::vector< float > & getWeightSum() const
const std::vector< float > & getEpsilonSum() const
float getEventWeight(unsigned int event_id)
static float invMassCalc(float Energy1, float Eta1, float Phi1, float Energy2, float Eta2, float Phi2)
ZIterativeAlgorithmWithFitPlots * thePlots_
static float cosTheta12(float Eta1, float Phi1, float Eta2, float Phi2)
void getStatWeights(const std::string &file)
std::vector< float > optimizedCoefficientsError_
const std::vector< int > & getOptimizedIterations() const