CMS 3D CMS Logo

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