CMS 3D CMS Logo

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