CMS 3D CMS Logo

TMom.cc
Go to the documentation of this file.
1 /*
2  * \class TMom
3  *
4  * \author: Julie Malcles - CEA/Saclay
5  */
6 
9 #include <TMath.h>
10 
11 #include <cassert>
12 
13 using namespace std;
14 
15 //ClassImp(TMom)
16 
17 
18 // Default Constructor...
20 {
21  init(0.0,10.0e9);
22 }
23 
24 // Constructor...
25 TMom::TMom(double cutlow, double cuthigh)
26 {
27  init(cutlow,cuthigh);
28 }
29 TMom::TMom(const std::vector<double>& cutlow, const std::vector<double>& cuthigh)
30 {
31  init(cutlow,cuthigh);
32 }
33 
34 // Destructor
36 {
37 }
38 
39 void TMom::init(double cutlow, double cuthigh)
40 {
41 
42  nevt=0;
43  mean=0;
44  mean2=0;
45  mean3=0;
46  sum=0;
47  sum2=0;
48  sum3=0;
49  rms=0;
50  M3=0;
51  peak=0;
52  min=10.0e9;
53  max=0.;
54  _cutLow.clear();
55  _cutHigh.clear();
56  _dimCut=1;
57  _cutLow.push_back(cutlow);
58  _cutHigh.push_back(cuthigh);
59  for(int i=0;i<101;i++){
60  bing[i]=0;
61  }
62 
63 }
64 void TMom::init(const std::vector<double>& cutlow, const std::vector<double>& cuthigh)
65 {
66 
67  nevt=0;
68  mean=0;
69  mean2=0;
70  mean3=0;
71  sum=0;
72  sum2=0;
73  sum3=0;
74  rms=0;
75  M3=0;
76  peak=0;
77  min=10.0e9;
78  max=0.;
79  assert(cutlow.size()==cuthigh.size());
80  _cutLow.clear();
81  _cutHigh.clear();
82  _dimCut=cutlow.size();
83  _cutLow=cutlow;
84  _cutHigh=cuthigh;
85  for(int i=0;i<101;i++){
86  bing[i]=0;
87  }
88 
89 }
90 void TMom::setCut(double cutlow, double cuthigh){
91 
92  _cutLow.clear();
93  _cutHigh.clear();
94  _dimCut=1;
95  _cutLow.push_back(cutlow);
96  _cutHigh.push_back(cuthigh);
97 
98 }
99 void TMom::setCut(const std::vector<double>& cutlow ,const std::vector<double>& cuthigh){
100 
101  assert(cutlow.size( )== cuthigh.size());
102  _cutLow.clear();
103  _cutHigh.clear();
104  _dimCut=cutlow.size();
105  _cutLow=cutlow;
106  _cutHigh=cuthigh;
107 
108 }
109 
110 void TMom::addEntry(double val)
111 {
112  std::vector<double> dumb;
113  dumb.push_back(val);
114  addEntry(val,dumb);
115 }
116 
117 void TMom::addEntry(double val, const std::vector<double>& valcut)
118 {
119 
120  int passingAllCuts=1;
121 
122  for (int iCut=0;iCut<_dimCut;iCut++){
123  int passing;
124  if( valcut.at(iCut)>_cutLow.at(iCut) && valcut.at(iCut) <=_cutHigh.at(iCut) ){
125  passing=1;
126  }else passing=0;
127  passingAllCuts*=passing;
128  }
129 
130  if( passingAllCuts == 1 ){
131 
132  nevt+=1;
133  sum+=val;
134  sum2+=val*val;
135  sum3+=val*val*val;
136  if(val>max) max=val;
137  if(val<min) min=val;
138 
139  // for peak stuff
140  _ampl.push_back(val);
141  }
142 
143 }
144 
145 
146 
147 double TMom::getMean(){
148  if(nevt!=0) mean=sum/nevt;
149  else mean=0.0;
150  return mean;
151 }
152 
153 double TMom::getMean2(){
154  if(nevt!=0) mean2=sum2/nevt;
155  else mean2=0.0;
156  return mean2;
157 }
158 double TMom::getMean3(){
159  if(nevt!=0) mean3=sum3/nevt;
160  else mean3=0.0;
161  return mean3;
162 }
163 
164 int TMom::getNevt(){ return nevt;}
165 
166 double TMom::getRMS(){
167  double m=getMean();
168  double m2=getMean2();
169  if(nevt!=0) rms=TMath::Sqrt( m2 - m*m );
170  else rms=0.0;
171  return rms;
172 }
173 
174 double TMom::getM3(){
175 
176  double m=getMean();
177  double m2=getMean2();
178  double m3=getMean3();
179  double sig = getRMS();
180 
181  if(nevt!=0 && sig!=0) M3=( m3 - 3.0*m*(m2-m*m) - m*m*m )/(sig*sig*sig);
182  else M3=0.0;
183  return M3;
184 }
185 
186 double TMom::getMin(){return min;}
187 double TMom::getMax(){return max;}
188 
189 std::vector<double> TMom::getPeak(){
190 
191  std::vector<double> p;
192  double wbin=(max-min)/100.;
193  int bung;
194 
195  for(unsigned int i=0;i<_ampl.size();i++){
196  if(wbin <= 0.0)
197  bung=1;
198  else
199  bung= (int) ((_ampl.at(i)-min)/wbin)+1;
200  if(1 <= bung && bung <= 100)
201  bing[bung]++;
202  }
203 
204  TMarkov *peakM = new TMarkov();
205 
206  int popmax=0;
207 
208  for(int k=1;k<101;k++) {
209  if(bing[k] > popmax) {
210  popmax=bing[k];
211  }
212  }
213 
214  peakM -> peakFinder(&bing[0]);
215  p.push_back(peakM -> getPeakValue(0));
216  p.push_back(peakM -> getPeakValue(1));
217 
218  return p;
219 }
220 
void addEntry(double val)
Definition: TMom.cc:110
void setCut(double, double)
Definition: TMom.cc:90
int init
Definition: HydjetWrapper.h:67
TMom()
Definition: TMom.cc:19
double getM3()
Definition: TMom.cc:174
int getNevt()
Definition: TMom.cc:164
void init(double, double)
Definition: TMom.cc:39
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:343
double getMean2()
Definition: TMom.cc:153
T min(T a, T b)
Definition: MathUtil.h:58
Definition: TMarkov.h:6
int k[5][pyjets_maxn]
double getRMS()
Definition: TMom.cc:166
double getMin()
Definition: TMom.cc:186
~TMom() override
Definition: TMom.cc:35
double getMean3()
Definition: TMom.cc:158
double getMax()
Definition: TMom.cc:187
std::vector< double > getPeak()
Definition: TMom.cc:189
double getMean()
Definition: TMom.cc:147