This commit was generated by cvs2svn to compensate for changes in r4472,
[u/mrichter/AliRoot.git] / HBTAN / AliHBTParticleCut.cxx
CommitLineData
1b446896 1#include "AliHBTParticleCut.h"
2
3#include <iostream.h>
4
5ClassImp(AliHBTParticleCut)
6const Int_t AliHBTParticleCut::fkgMaxCuts = 50;
7/******************************************************************/
8
9AliHBTParticleCut::AliHBTParticleCut()
10 {
11 fCuts = new AliHbtBaseCut* [fkgMaxCuts];//last property in the property
12 //property enum => defines number of properties
13 fNCuts = 0;
14 fPID = 0;
15 }
16/******************************************************************/
17
18AliHBTParticleCut::AliHBTParticleCut(const AliHBTParticleCut& in)
19{
20 fCuts = new AliHbtBaseCut* [fkgMaxCuts];//last property in the property
21 //property enum => defines number of properties
22 fNCuts = in.fNCuts;
23 fPID = in.fPID;
24 for (Int_t i = 0;i<fNCuts;i++)
25 {
26 fCuts[i] = (AliHbtBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
27 }
28}
29/******************************************************************/
30
31AliHBTParticleCut::~AliHBTParticleCut()
32{
33 for (Int_t i = 0;i<fNCuts;i++)
34 {
35 delete fCuts[i];
36 }
37 delete []fCuts;
38}
39/******************************************************************/
40
41Bool_t AliHBTParticleCut::Pass(AliHBTParticle* p)
42{
43//method checks all the cuts that are set (in the list)
44//If any of the baseCuts rejects particle False(rejection) is returned
45 if(!p)
46 {
47 Warning("Pass()","No Pasaran! We never accept NULL pointers");
48 return kTRUE;
49 }
50 if( (p->GetPdgCode() != fPID) && ( fPID != 0)) return kTRUE;
51
52 for (Int_t i = 0;i<fNCuts;i++)
53 {
54 if ( (fCuts[i]->Pass(p)) ) return kTRUE; //if one of the cuts rejects, then reject
55 }
56 return kFALSE;
57}
58/******************************************************************/
59
60void AliHBTParticleCut::AddBasePartCut(AliHbtBaseCut* basecut)
61{
62 //adds the base pair cut (cut on one value)
63
64 if (!basecut) return;
65 if( fNCuts == (fkgMaxCuts-1) )
66 {
67 Warning("AddBasePartCut","Not enough place for another cut");
68 return;
69 }
70 fCuts[fNCuts++]=basecut;
71
72}
73
74/******************************************************************/
75AliHbtBaseCut* AliHBTParticleCut::FindCut(AliHBTCutProperty property)
76{
77
78 for (Int_t i = 0;i<fNCuts;i++)
79 {
80 if (fCuts[i]->GetProperty() == property)
81 return fCuts[i]; //we found the cut we were searching for
82 }
83
84 return 0x0; //we did not found this cut
85
86}
87/******************************************************************/
88
89void AliHBTParticleCut::SetMomentumRange(Double_t min, Double_t max)
90{
91 AliHBTMomentumCut* cut= (AliHBTMomentumCut*)FindCut(kHbtP);
92 if(cut) cut->SetRange(min,max);
93 else fCuts[fNCuts++] = new AliHBTMomentumCut(min,max);
94}
95/******************************************************************/
96
97
98void AliHBTParticleCut::SetPtRange(Double_t min, Double_t max)
99{
100 AliHBTPtCut* cut= (AliHBTPtCut*)FindCut(kHbtPt);
101 if(cut) cut->SetRange(min,max);
102 else fCuts[fNCuts++] = new AliHBTPtCut(min,max);
103
104}
105/******************************************************************/
106
107void AliHBTParticleCut::SetEnergyRange(Double_t min, Double_t max)
108{
109 AliHBTEnergyCut* cut= (AliHBTEnergyCut*)FindCut(kHbtE);
110 if(cut) cut->SetRange(min,max);
111 else fCuts[fNCuts++] = new AliHBTEnergyCut(min,max);
112
113}
114/******************************************************************/
115
116void AliHBTParticleCut::SetRapidityRange(Double_t min, Double_t max)
117{
118 AliHbtBaseCut* cut = FindCut(kHbtRapidity);
119 if(cut) cut->SetRange(min,max);
120 else fCuts[fNCuts++] = new AliHBTRapidityCut(min,max);
121
122}
123/******************************************************************/
124
125void AliHBTParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
126{
127 AliHbtBaseCut* cut = FindCut(kHbtPseudoRapidity);
128 if(cut) cut->SetRange(min,max);
129 else fCuts[fNCuts++] = new AliHBTPseudoRapidityCut(min,max);
130
131}
132/******************************************************************/
133
134void AliHBTParticleCut::SetPxRange(Double_t min, Double_t max)
135{
136 AliHbtBaseCut* cut = FindCut(kHbtPx);
137 if(cut) cut->SetRange(min,max);
138 else fCuts[fNCuts++] = new AliHBTPxCut(min,max);
139}
140/******************************************************************/
141
142void AliHBTParticleCut::SetPyRange(Double_t min, Double_t max)
143{
144 AliHbtBaseCut* cut = FindCut(kHbtPy);
145 if(cut) cut->SetRange(min,max);
146 else fCuts[fNCuts++] = new AliHBTPyCut(min,max);
147}
148/******************************************************************/
149
150void AliHBTParticleCut::SetPzRange(Double_t min, Double_t max)
151{
152 AliHbtBaseCut* cut = FindCut(kHbtPz);
153 if(cut) cut->SetRange(min,max);
154 else fCuts[fNCuts++] = new AliHBTPzCut(min,max);
155}
156/******************************************************************/
157
158void AliHBTParticleCut::SetPhiRange(Double_t min, Double_t max)
159{
160 AliHbtBaseCut* cut = FindCut(kHbtPhi);
161 if(cut) cut->SetRange(min,max);
162 else fCuts[fNCuts++] = new AliHBTPhiCut(min,max);
163}
164/******************************************************************/
165
166void AliHBTParticleCut::SetThetaRange(Double_t min, Double_t max)
167{
168 AliHbtBaseCut* cut = FindCut(kHbtTheta);
169 if(cut) cut->SetRange(min,max);
170 else fCuts[fNCuts++] = new AliHBTThetaCut(min,max);
171}
172/******************************************************************/
173
174void AliHBTParticleCut::SetVxRange(Double_t min, Double_t max)
175{
176 AliHbtBaseCut* cut = FindCut(kHbtVx);
177 if(cut) cut->SetRange(min,max);
178 else fCuts[fNCuts++] = new AliHBTVxCut(min,max);
179}
180/******************************************************************/
181
182void AliHBTParticleCut::SetVyRange(Double_t min, Double_t max)
183{
184 AliHbtBaseCut* cut = FindCut(kHbtVy);
185 if(cut) cut->SetRange(min,max);
186 else fCuts[fNCuts++] = new AliHBTVyCut(min,max);
187}
188/******************************************************************/
189
190void AliHBTParticleCut::SetVzRange(Double_t min, Double_t max)
191{
192 AliHbtBaseCut* cut = FindCut(kHbtVz);
193 if(cut) cut->SetRange(min,max);
194 else fCuts[fNCuts++] = new AliHBTVzCut(min,max);
195}
196
197/******************************************************************/
198void AliHBTParticleCut::Streamer(TBuffer &b)
199{
200 // Stream all objects in the array to or from the I/O buffer.
201
202 UInt_t R__s, R__c;
203 if (b.IsReading())
204 {
205 Version_t v = b.ReadVersion(&R__s, &R__c);
206 TObject::Streamer(b);
207 b >> fPID;
208 b >> fNCuts;
209 for (Int_t i = 0;i<fNCuts;i++)
210 {
211 b >> fCuts[i];
212 }
213 b.CheckByteCount(R__s, R__c,AliHBTParticleCut::IsA());
214 }
215 else
216 {
217 R__c = b.WriteVersion(AliHBTParticleCut::IsA(), kTRUE);
218 TObject::Streamer(b);
219 b << fPID;
220 b << fNCuts;
221 for (Int_t i = 0;i<fNCuts;i++)
222 {
223 b << fCuts[i];
224 }
225 b.SetByteCount(R__c, kTRUE);
226 }
227}
228
229void AliHBTParticleCut::Print(void)
230{
231 cout<<"Printing AliHBTParticleCut, this = "<<this<<endl;
232 cout<<"fPID "<<fPID<<endl;
233 cout<<"fNCuts "<<fNCuts <<endl;
234 for (Int_t i = 0;i<fNCuts;i++)
235 {
236 cout<<" fCuts["<<i<<"] "<<fCuts[i]<<endl<<" ";
237 fCuts[i]->Print();
238 }
239}
240
241/******************************************************************/
242/******************************************************************/
243
244ClassImp(AliHBTEmptyParticleCut)
245void AliHBTEmptyParticleCut::Streamer(TBuffer &b)
246 {
247 AliHBTParticleCut::Streamer(b);
248 }
249/******************************************************************/
250/******************************************************************/
251/******************************************************************/
252
253/******************************************************************/
254/******************************************************************/
255/******************************************************************/
256
257ClassImp(AliHbtBaseCut)
258void AliHbtBaseCut::Print(void)
259{
260 cout<<"fMin="<<fMin <<", fMax=" <<fMax<<" ";
261 PrintProperty();
262}
263void AliHbtBaseCut::PrintProperty(void)
264{
265 switch (fProperty)
266 {
267 case kHbtP:
268 cout<<"kHbtP"; break;
269 case kHbtPt:
270 cout<<"kHbtPt"; break;
271 case kHbtE:
272 cout<<"kHbtE"; break;
273 case kHbtRapidity:
274 cout<<"kHbtRapidity"; break;
275 case kHbtPseudoRapidity:
276 cout<<"kHbtPseudoRapidity"; break;
277 case kHbtPx:
278 cout<<"kHbtPx"; break;
279 case kHbtPy:
280 cout<<"kHbtPy"; break;
281 case kHbtPz:
282 cout<<"kHbtPz"; break;
283 case kHbtPhi:
284 cout<<"kHbtPhi"; break;
285 case kHbtTheta:
286 cout<<"kHbtTheta"; break;
287 case kHbtVx:
288 cout<<"kHbtVx"; break;
289 case kHbtVy:
290 cout<<"kHbtVy"; break;
291 case kHbtVz:
292 cout<<"kHbtVz"; break;
293 case kHbtNone:
294 cout<<"kHbtNone"; break;
295 default:
296 cout<<"Property Not Found";
297 }
298 cout<<endl;
299}
300ClassImp( AliHBTMomentumCut )
301
302ClassImp( AliHBTPtCut )
303ClassImp( AliHBTEnergyCut )
304ClassImp( AliHBTRapidityCut )
305ClassImp( AliHBTPseudoRapidityCut )
306ClassImp( AliHBTPxCut )
307ClassImp( AliHBTPyCut )
308ClassImp( AliHBTPzCut )
309ClassImp( AliHBTPhiCut )
310ClassImp( AliHBTThetaCut )
311ClassImp( AliHBTVxCut )
312ClassImp( AliHBTVyCut )
313ClassImp( AliHBTVzCut )
314
315