CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TAPD.cc
Go to the documentation of this file.
1 /*
2  * \class TAPD
3  *
4  * \author: Julie Malcles - CEA/Saclay
5  */
6 
10 #include <TMath.h>
11 
12 using namespace std;
13 #include <iostream>
14 #include <cassert>
15 
16 //ClassImp(TAPD)
17 
18 // Default Constructor...
19 TAPD::TAPD() { init(); }
20 
21 // Destructor
23 
24 void TAPD::init() {
25  for (int j = 0; j < nOutVar; j++) {
26  _apdcuts[0][j].clear();
27  _apdcuts[1][j].clear();
28  _cutvars[j].clear();
29 
30  _apdcuts[0][j].push_back(0.0);
31  _apdcuts[1][j].push_back(10.0e6);
32  _cutvars[j].push_back(j);
33 
34  mom[j] = new TMom();
35  }
36 }
37 
38 void TAPD::addEntry(double apd, double pn, double pn0, double pn1, double time) {
39  addEntry(apd, pn, pn0, pn1, time, 0.0, 0.0);
40 }
41 
42 void TAPD::addEntry(double apd, double pn, double pn0, double pn1, double time, double apd0, double apd1) {
43  double val[nOutVar];
44  std::vector<double> valcuts[nOutVar];
45 
46  val[iAPD] = apd;
47  if (pn != 0)
48  val[iAPDoPN] = apd / pn;
49  else
50  val[iAPDoPN] = 0.0;
51  if (pn0 != 0)
52  val[iAPDoPN0] = apd / pn0;
53  else
54  val[iAPDoPN0] = 0.0;
55  if (pn1 != 0)
56  val[iAPDoPN1] = apd / pn1;
57  else
58  val[iAPDoPN1] = 0.0;
59  val[iTime] = time;
60  if (apd0 != 0.)
61  val[iAPDoAPD0] = apd / apd0;
62  else
63  val[iAPDoAPD0] = 0.0;
64  if (apd1 != 0.)
65  val[iAPDoAPD1] = apd / apd1;
66  else
67  val[iAPDoAPD1] = 0.0;
68 
69  for (int ivar = 0; ivar < nOutVar; ivar++) {
70  int dimcut = _cutvars[ivar].size();
71  for (int ic = 0; ic < dimcut; ic++) {
72  assert(_cutvars[ivar].at(ic) < nOutVar);
73  valcuts[ivar].push_back(val[_cutvars[ivar].at(ic)]);
74  }
75  }
76 
77  for (int ivar = 0; ivar < nOutVar; ivar++) {
78  mom[ivar]->addEntry(val[ivar], valcuts[ivar]);
79  // std::cout << "addEntry: val[ivar=" << ivar <<"] = "<<val[ivar]<< std::endl;
80 
81  for (size_t ic = 0; ic < _cutvars[ivar].size(); ic++) {
82  // std::cout << "addEntry: valcuts[ivar="<< ivar <<"][ic="<<ic<<"] = "<<valcuts[ivar].at(ic)<< std::endl;
83  for (size_t iv = 0; iv < _cutvars[ivar].size(); iv++) {
84  // std::cout <<"low cut:"<<_apdcuts[0][ivar].at(iv)<<", high cut:"<<_apdcuts[1][ivar].at(iv)<<", cutvar: "<<_cutvars[ivar].at(iv)<< std::endl;
85  }
86  }
87  }
88 }
89 
90 void TAPD::setCut(int ivar, double mean, double sig) {
91  assert(ivar < nOutVar);
92 
93  std::vector<int> cutvar;
94  cutvar.push_back(ivar);
95 
96  std::vector<double> lowcut;
97  std::vector<double> highcut;
98 
99  double low = mean - 2.0 * sig;
100  if (low < 0)
101  low = 0.0;
102  double high = mean + 2.0 * sig;
103 
104  lowcut.push_back(low);
105  highcut.push_back(high);
106 
107  setCut(ivar, cutvar, lowcut, highcut);
108 }
109 
110 void TAPD::setCut(int ivar,
111  const std::vector<int>& cutVars,
112  const std::vector<double>& lowCut,
113  const std::vector<double>& highCut) {
114  assert(ivar < nOutVar);
115  int cutdim = cutVars.size();
116  assert(cutdim < nOutVar);
117  assert(cutdim == (int)lowCut.size());
118  assert(cutdim == (int)highCut.size());
119 
120  _apdcuts[0][ivar].clear();
121  _apdcuts[1][ivar].clear();
122  _cutvars[ivar].clear();
123 
124  for (int ic = 0; ic < cutdim; ic++) {
125  // FINISH THIS
126  if (lowCut.at(ic) > 0) {
127  _apdcuts[0][ivar].push_back(lowCut.at(ic));
128  } else
129  _apdcuts[0][ivar].push_back(0.0);
130 
131  _apdcuts[1][ivar].push_back(highCut.at(ic));
132  _cutvars[ivar].push_back(cutVars.at(ic));
133  }
134 
135  mom[ivar]->setCut(_apdcuts[0][ivar], _apdcuts[1][ivar]);
136 }
137 
138 // Simple 1D cuts on main variable at 2 sigmas
139 // ===========================================
140 
141 void TAPD::setAPDCut(double mean, double sig) { setCut(TAPD::iAPD, mean, sig); }
142 void TAPD::setAPDoPNCut(double mean, double sig) { setCut(TAPD::iAPDoPN, mean, sig); }
143 void TAPD::setAPDoPN0Cut(double mean, double sig) { setCut(TAPD::iAPDoPN0, mean, sig); }
144 void TAPD::setAPDoPN1Cut(double mean, double sig) { setCut(TAPD::iAPDoPN1, mean, sig); }
145 void TAPD::setTimeCut(double mean, double sig) { setCut(TAPD::iTime, mean, sig); }
146 
147 // More complicated 2D cuts
148 // =========================
149 
150 // Cut on main var and Time:
151 void TAPD::set2DCut(int ivar, const std::vector<double>& lowCut, const std::vector<double>& highCut) {
152  assert(lowCut.size() == 2);
153  assert(highCut.size() == 2);
154  std::vector<int> cutVars;
155  cutVars.push_back(ivar);
156  cutVars.push_back(TAPD::iTime);
157  setCut(ivar, cutVars, lowCut, highCut);
158 }
159 
160 void TAPD::set2DAPDCut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
161  set2DCut(TAPD::iAPD, lowCut, highCut);
162 }
163 void TAPD::set2DAPDoPNCut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
164  set2DCut(TAPD::iAPDoPN, lowCut, highCut);
165 }
166 void TAPD::set2DAPDoPN0Cut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
167  set2DCut(TAPD::iAPDoPN0, lowCut, highCut);
168 }
169 void TAPD::set2DAPDoPN1Cut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
170  set2DCut(TAPD::iAPDoPN1, lowCut, highCut);
171 }
172 
173 void TAPD::set2DAPDoAPD0Cut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
174  assert(lowCut.size() == 2);
175  assert(highCut.size() == 2);
176  std::vector<int> cutVars;
177  cutVars.push_back(TAPD::iAPD);
178  cutVars.push_back(TAPD::iTime);
179  setCut(TAPD::iAPDoAPD0, cutVars, lowCut, highCut);
180 }
181 void TAPD::set2DAPDoAPD1Cut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
182  assert(lowCut.size() == 2);
183  assert(highCut.size() == 2);
184  std::vector<int> cutVars;
185  cutVars.push_back(TAPD::iAPD);
186  cutVars.push_back(TAPD::iTime);
187  setCut(TAPD::iAPDoAPD1, cutVars, lowCut, highCut);
188 }
189 
190 void TAPD::set2DTimeCut(const std::vector<double>& lowCut, const std::vector<double>& highCut) {
191  assert(lowCut.size() == 2);
192  assert(highCut.size() == 2);
193  std::vector<int> cutVars;
194  cutVars.push_back(TAPD::iAPD);
195  cutVars.push_back(TAPD::iTime);
196  setCut(TAPD::iTime, cutVars, lowCut, highCut);
197 }
198 
199 std::vector<double> TAPD::get(int ivar) {
200  std::vector<double> res;
201 
202  if (ivar < nOutVar) {
203  res.push_back(mom[ivar]->getMean());
204  res.push_back(mom[ivar]->getRMS());
205  res.push_back(mom[ivar]->getM3());
206  res.push_back(mom[ivar]->getNevt());
207  res.push_back(mom[ivar]->getMin());
208  res.push_back(mom[ivar]->getMax());
209  }
210 
211  // std::cout << "In get: ivar="<< ivar << ", mean="<< mom[ivar]->getMean()<<" res size="<< res.size()<< std::endl;
212 
213  return res;
214 }
215 
216 std::vector<double> TAPD::getAPD() {
217  std::vector<double> x = get(TAPD::iAPD);
218  return x;
219 }
220 std::vector<double> TAPD::getAPDoPN() {
221  std::vector<double> x = get(TAPD::iAPDoPN);
222  return x;
223 }
224 std::vector<double> TAPD::getAPDoPN0() {
225  std::vector<double> x = get(TAPD::iAPDoPN0);
226  return x;
227 }
228 std::vector<double> TAPD::getAPDoPN1() {
229  std::vector<double> x = get(TAPD::iAPDoPN1);
230  return x;
231 }
232 std::vector<double> TAPD::getTime() {
233  std::vector<double> x = get(TAPD::iTime);
234  return x;
235 }
236 std::vector<double> TAPD::getAPDoAPD0() {
237  std::vector<double> x = get(TAPD::iAPDoAPD0);
238  // std::cout<< "In GetAPDoAPD0: x[0]="<< x.at(0) << std::endl;
239  return x;
240 }
241 std::vector<double> TAPD::getAPDoAPD1() {
242  std::vector<double> x = get(TAPD::iAPDoAPD1);
243  return x;
244 }
void setAPDCut(double, double)
Definition: TAPD.cc:141
TAPD()
Definition: TAPD.cc:19
int32_t *__restrict__ iv
int init
Definition: HydjetWrapper.h:64
void addEntry(double, double, double, double, double, double, double)
Definition: TAPD.cc:42
void init()
Definition: TAPD.cc:24
Definition: TMom.h:7
assert(be >=bs)
std::vector< double > getAPDoPN0()
Definition: TAPD.cc:224
void setTimeCut(double, double)
Definition: TAPD.cc:145
void setCut(int, double, double)
Definition: TAPD.cc:90
void set2DAPDoPN0Cut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:166
void set2DAPDoAPD1Cut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:181
void setAPDoPN0Cut(double, double)
Definition: TAPD.cc:143
std::vector< double > getAPDoPN1()
Definition: TAPD.cc:228
std::vector< double > getAPDoAPD0()
Definition: TAPD.cc:236
void set2DAPDoAPD0Cut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:173
std::vector< double > get(int)
Definition: TAPD.cc:199
virtual ~TAPD()
Definition: TAPD.cc:22
std::vector< double > getAPDoAPD1()
Definition: TAPD.cc:241
std::vector< double > getAPD()
Definition: TAPD.cc:216
void set2DAPDoPN1Cut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:169
void set2DCut(int, const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:151
void set2DAPDoPNCut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:163
std::vector< double > getAPDoPN()
Definition: TAPD.cc:220
void set2DTimeCut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:190
std::vector< double > getTime()
Definition: TAPD.cc:232
void set2DAPDCut(const std::vector< double > &, const std::vector< double > &)
Definition: TAPD.cc:160
void setAPDoPNCut(double, double)
Definition: TAPD.cc:142
void setAPDoPN1Cut(double, double)
Definition: TAPD.cc:144