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 // Default Constructor...
18 TMom::TMom() { init(0.0, 10.0e9); }
19 
20 // Constructor...
21 TMom::TMom(double cutlow, double cuthigh) { init(cutlow, cuthigh); }
22 TMom::TMom(const std::vector<double>& cutlow, const std::vector<double>& cuthigh) { init(cutlow, cuthigh); }
23 
24 // Destructor
26 
27 void TMom::init(double cutlow, double cuthigh) {
28  nevt = 0;
29  mean = 0;
30  mean2 = 0;
31  mean3 = 0;
32  sum = 0;
33  sum2 = 0;
34  sum3 = 0;
35  rms = 0;
36  M3 = 0;
37  peak = 0;
38  min = 10.0e9;
39  max = 0.;
40  _cutLow.clear();
41  _cutHigh.clear();
42  _dimCut = 1;
43  _cutLow.push_back(cutlow);
44  _cutHigh.push_back(cuthigh);
45  for (int i = 0; i < 101; i++) {
46  bing[i] = 0;
47  }
48 }
49 void TMom::init(const std::vector<double>& cutlow, const std::vector<double>& cuthigh) {
50  nevt = 0;
51  mean = 0;
52  mean2 = 0;
53  mean3 = 0;
54  sum = 0;
55  sum2 = 0;
56  sum3 = 0;
57  rms = 0;
58  M3 = 0;
59  peak = 0;
60  min = 10.0e9;
61  max = 0.;
62  assert(cutlow.size() == cuthigh.size());
63  _cutLow.clear();
64  _cutHigh.clear();
65  _dimCut = cutlow.size();
66  _cutLow = cutlow;
67  _cutHigh = cuthigh;
68  for (int i = 0; i < 101; i++) {
69  bing[i] = 0;
70  }
71 }
72 void TMom::setCut(double cutlow, double cuthigh) {
73  _cutLow.clear();
74  _cutHigh.clear();
75  _dimCut = 1;
76  _cutLow.push_back(cutlow);
77  _cutHigh.push_back(cuthigh);
78 }
79 void TMom::setCut(const std::vector<double>& cutlow, const std::vector<double>& cuthigh) {
80  assert(cutlow.size() == cuthigh.size());
81  _cutLow.clear();
82  _cutHigh.clear();
83  _dimCut = cutlow.size();
84  _cutLow = cutlow;
85  _cutHigh = cuthigh;
86 }
87 
88 void TMom::addEntry(double val) {
89  std::vector<double> dumb;
90  dumb.push_back(val);
91  addEntry(val, dumb);
92 }
93 
94 void TMom::addEntry(double val, const std::vector<double>& valcut) {
95  int passingAllCuts = 1;
96 
97  for (int iCut = 0; iCut < _dimCut; iCut++) {
98  int passing;
99  if (valcut.at(iCut) > _cutLow.at(iCut) && valcut.at(iCut) <= _cutHigh.at(iCut)) {
100  passing = 1;
101  } else
102  passing = 0;
103  passingAllCuts *= passing;
104  }
105 
106  if (passingAllCuts == 1) {
107  nevt += 1;
108  sum += val;
109  sum2 += val * val;
110  sum3 += val * val * val;
111  if (val > max)
112  max = val;
113  if (val < min)
114  min = val;
115 
116  // for peak stuff
117  _ampl.push_back(val);
118  }
119 }
120 
121 double TMom::getMean() {
122  if (nevt != 0)
123  mean = sum / nevt;
124  else
125  mean = 0.0;
126  return mean;
127 }
128 
129 double TMom::getMean2() {
130  if (nevt != 0)
131  mean2 = sum2 / nevt;
132  else
133  mean2 = 0.0;
134  return mean2;
135 }
136 double TMom::getMean3() {
137  if (nevt != 0)
138  mean3 = sum3 / nevt;
139  else
140  mean3 = 0.0;
141  return mean3;
142 }
143 
144 int TMom::getNevt() { return nevt; }
145 
146 double TMom::getRMS() {
147  double m = getMean();
148  double m2 = getMean2();
149  if (nevt != 0)
150  rms = TMath::Sqrt(m2 - m * m);
151  else
152  rms = 0.0;
153  return rms;
154 }
155 
156 double TMom::getM3() {
157  double m = getMean();
158  double m2 = getMean2();
159  double m3 = getMean3();
160  double sig = getRMS();
161 
162  if (nevt != 0 && sig != 0)
163  M3 = (m3 - 3.0 * m * (m2 - m * m) - m * m * m) / (sig * sig * sig);
164  else
165  M3 = 0.0;
166  return M3;
167 }
168 
169 double TMom::getMin() { return min; }
170 double TMom::getMax() { return max; }
171 
172 std::vector<double> TMom::getPeak() {
173  std::vector<double> p;
174  double wbin = (max - min) / 100.;
175  int bung;
176 
177  for (unsigned int i = 0; i < _ampl.size(); i++) {
178  if (wbin <= 0.0)
179  bung = 1;
180  else
181  bung = (int)((_ampl.at(i) - min) / wbin) + 1;
182  if (1 <= bung && bung <= 100)
183  bing[bung]++;
184  }
185 
186  TMarkov* peakM = new TMarkov();
187 
188  int popmax = 0;
189 
190  for (int k = 1; k < 101; k++) {
191  if (bing[k] > popmax) {
192  popmax = bing[k];
193  }
194  }
195 
196  peakM->peakFinder(&bing[0]);
197  p.push_back(peakM->getPeakValue(0));
198  p.push_back(peakM->getPeakValue(1));
199 
200  return p;
201 }
TMom::addEntry
void addEntry(double val)
Definition: TMom.cc:88
init
int init
Definition: HydjetWrapper.h:64
mps_fire.i
i
Definition: mps_fire.py:428
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
TMom::getMean3
double getMean3()
Definition: TMom.cc:136
min
T min(T a, T b)
Definition: MathUtil.h:58
cms::cuda::assert
assert(be >=bs)
TMom::TMom
TMom()
Definition: TMom.cc:18
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
TMarkov
Definition: TMarkov.h:6
TMarkov::getPeakValue
double getPeakValue(int i) const
Definition: TMarkov.h:24
TMom::setCut
void setCut(double, double)
Definition: TMom.cc:72
TMarkov::peakFinder
void peakFinder(int *)
Definition: TMarkov.cc:105
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
dqmdumpme.k
k
Definition: dqmdumpme.py:60
TMom::init
void init(double, double)
Definition: TMom.cc:27
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
TagProbeFitTreeAnalyzer_cfi.passing
passing
Definition: TagProbeFitTreeAnalyzer_cfi.py:25
createfilelist.int
int
Definition: createfilelist.py:10
TMom::getM3
double getM3()
Definition: TMom.cc:156
TMom::~TMom
~TMom() override
Definition: TMom.cc:25
TMom::getNevt
int getNevt()
Definition: TMom.cc:144
combinedConstraintHelpers::sum2
void sum2(T &x, T y)
Definition: CombinedKinematicConstraintT.h:74
TMom::getMean
double getMean()
Definition: TMom.cc:121
nevt
int nevt
Definition: ReggeGribovPartonMCHadronizer.h:66
callgraph.m2
m2
Definition: callgraph.py:38
TMarkov.h
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
TMom::getMean2
double getMean2()
Definition: TMom.cc:129
TMom::getMax
double getMax()
Definition: TMom.cc:170
TMom.h
TMom::getPeak
std::vector< double > getPeak()
Definition: TMom.cc:172
TMom::getRMS
double getRMS()
Definition: TMom.cc:146
TMom::getMin
double getMin()
Definition: TMom.cc:169