Catching up to NewIO -> Particle stores all passible PID and their probabilities
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPairCut.cxx
CommitLineData
ea197c3e 1/* $Id$ */
2
3//-------------------------------------------------------------------
4// Class AliHBTPairCut:
5// implements cut on the pair of particles
6// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
7// Author: Piotr.Skowronski@cern.ch
8//-------------------------------------------------------------------
9
1b446896 10#include "AliHBTPairCut.h"
11#include "AliHBTPair.h"
ea197c3e 12#include "AliHBTParticleCut.h"
1b446896 13
14ClassImp(AliHBTPairCut)
ea197c3e 15const Int_t AliHBTPairCut::fgkMaxCuts = 50;
1b446896 16/**********************************************************/
17
e3131968 18AliHBTPairCut::AliHBTPairCut():
19 fNCuts(0)
1b446896 20{
ea197c3e 21 //constructor
1b446896 22 fFirstPartCut = new AliHBTEmptyParticleCut(); //empty cuts
23 fSecondPartCut= new AliHBTEmptyParticleCut(); //empty cuts
24
ea197c3e 25 fCuts = new AliHbtBasePairCut*[fgkMaxCuts];
1b446896 26}
27/**********************************************************/
28
29AliHBTPairCut::AliHBTPairCut(const AliHBTPairCut& in)
30{
ea197c3e 31 //copy constructor
32 fCuts = new AliHbtBasePairCut*[fgkMaxCuts];
33 fNCuts = in.fNCuts;
34
35 fFirstPartCut = (AliHBTParticleCut*)in.fFirstPartCut->Clone();
36 fSecondPartCut = (AliHBTParticleCut*)in.fSecondPartCut->Clone();
37
38 for (Int_t i = 0;i<fNCuts;i++)
39 {
40 fCuts[i] = (AliHbtBasePairCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
41 }
42}
43/**********************************************************/
44
45AliHBTPairCut& AliHBTPairCut::operator=(const AliHBTPairCut& in)
46{
47 //assignment operator
48 fCuts = new AliHbtBasePairCut*[fgkMaxCuts];
49 fNCuts = in.fNCuts;
1b446896 50
ea197c3e 51 fFirstPartCut = (AliHBTParticleCut*)in.fFirstPartCut->Clone();
52 fSecondPartCut = (AliHBTParticleCut*)in.fSecondPartCut->Clone();
1b446896 53
ea197c3e 54 for (Int_t i = 0;i<fNCuts;i++)
55 {
56 fCuts[i] = (AliHbtBasePairCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
57 }
58 return * this;
1b446896 59}
60/**********************************************************/
61
62AliHBTPairCut::~AliHBTPairCut()
63{
ea197c3e 64 //destructor
e3131968 65 if (fFirstPartCut != fSecondPartCut)
ea197c3e 66 {
67 delete fSecondPartCut;
68 }
e3131968 69 delete fFirstPartCut;
1b446896 70 for (Int_t i = 0;i<fNCuts;i++)
ea197c3e 71 {
72 delete fCuts[i];
73 }
1b446896 74 delete []fCuts;
75}
76/**********************************************************/
77
78/**********************************************************/
79
80void AliHBTPairCut::AddBasePairCut(AliHbtBasePairCut* basecut)
ea197c3e 81{
82 //adds the base pair cut (cut on one value)
83
84 if (!basecut) return;
85 if( fNCuts == (fgkMaxCuts-1) )
1b446896 86 {
87 Warning("AddBasePairCut","Not enough place for another cut");
88 return;
89 }
ea197c3e 90 fCuts[fNCuts++]=basecut;
91}
1b446896 92/**********************************************************/
93
ea197c3e 94Bool_t AliHBTPairCut::Pass(AliHBTPair* pair) const
1b446896 95{
ea197c3e 96 //methods which checks if given pair meets all criteria of the cut
97 //if it meets returns FALSE
98 //if NOT returns TRUE
99 if(!pair)
100 {
101 Warning("Pass","No Pasaran! We never accept NULL pointers");
102 return kTRUE;
103 }
104
105 //check particle's cuts
106 if( ( fFirstPartCut->Pass( pair->Particle1()) ) ||
107 ( fSecondPartCut->Pass(pair->Particle2()) ) )
108 {
109 return kTRUE;
110 }
111 return PassPairProp(pair);
48704f50 112}
113/**********************************************************/
114
ea197c3e 115Bool_t AliHBTPairCut::PassPairProp(AliHBTPair* pair) const
48704f50 116{
ea197c3e 117 //methods which checks if given pair meets all criteria of the cut
118 //if it meets returns FALSE
119 //if NOT returns TRUE
120 //examine all base pair cuts
121 for (Int_t i = 0;i<fNCuts;i++)
122 {
123 if ( (fCuts[i]->Pass(pair)) ) return kTRUE; //if one of the cuts reject, then reject
124 }
125 return kFALSE;
1b446896 126}
127/**********************************************************/
128
129void AliHBTPairCut::SetFirstPartCut(AliHBTParticleCut* cut)
130{
ea197c3e 131 // set cut for the first particle
132 if(!cut)
133 {
134 Error("SetFirstPartCut","argument is NULL");
135 return;
136 }
137 delete fFirstPartCut;
138 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
139
1b446896 140}
141/**********************************************************/
142
143void AliHBTPairCut::SetSecondPartCut(AliHBTParticleCut* cut)
144{
ea197c3e 145 // set cut for the second particle
146 if(!cut)
147 {
148 Error("SetSecondPartCut","argument is NULL");
149 return;
150 }
151 delete fSecondPartCut;
152 fSecondPartCut = (AliHBTParticleCut*)cut->Clone();
1b446896 153}
154/**********************************************************/
155
156void AliHBTPairCut::SetPartCut(AliHBTParticleCut* cut)
157{
ea197c3e 158 //sets the the same cut on both particles
159 if(!cut)
160 {
161 Error("SetFirstPartCut","argument is NULL");
162 return;
163 }
164 delete fFirstPartCut;
165 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
166
167 delete fSecondPartCut; //even if null should not be harmful
168 fSecondPartCut = fFirstPartCut;
1b446896 169}
170/**********************************************************/
171
172void AliHBTPairCut::SetQInvRange(Double_t min, Double_t max)
173{
ea197c3e 174 // set range of accepted invariant masses
1b446896 175 AliHBTQInvCut* cut= (AliHBTQInvCut*)FindCut(kHbtPairCutPropQInv);
176 if(cut) cut->SetRange(min,max);
177 else fCuts[fNCuts++] = new AliHBTQInvCut(min,max);
a37908e0 178}
179/**********************************************************/
180void AliHBTPairCut::SetQOutCMSLRange(Double_t min, Double_t max)
181{
ea197c3e 182 // set range of accepted QOut in CMS
a37908e0 183 AliHBTQOutCMSLCCut* cut= (AliHBTQOutCMSLCCut*)FindCut(kHbtPairCutPropQOutCMSLC);
184 if(cut) cut->SetRange(min,max);
185 else fCuts[fNCuts++] = new AliHBTQOutCMSLCCut(min,max);
186}
1b446896 187
a37908e0 188/**********************************************************/
189void AliHBTPairCut::SetQSideCMSLRange(Double_t min, Double_t max)
190{
ea197c3e 191 // set range of accepted QSide in CMS
a37908e0 192 AliHBTQSideCMSLCCut* cut= (AliHBTQSideCMSLCCut*)FindCut(kHbtPairCutPropQSideCMSLC);
193 if(cut) cut->SetRange(min,max);
194 else fCuts[fNCuts++] = new AliHBTQSideCMSLCCut(min,max);
1b446896 195}
196
a37908e0 197/**********************************************************/
198void AliHBTPairCut::SetQLongCMSLRange(Double_t min, Double_t max)
199{
ea197c3e 200 // set range of accepted QLong in CMS
a37908e0 201 AliHBTQLongCMSLCCut* cut= (AliHBTQLongCMSLCCut*)FindCut(kHbtPairCutPropQLongCMSLC);
202 if(cut) cut->SetRange(min,max);
203 else fCuts[fNCuts++] = new AliHBTQLongCMSLCCut(min,max);
204}
205
206/**********************************************************/
207
bce80f3b 208void AliHBTPairCut::SetKtRange(Double_t min, Double_t max)
209{
ea197c3e 210 // set range of accepted Kt (?)
bce80f3b 211 AliHBTKtCut* cut= (AliHBTKtCut*)FindCut(kHbtPairCutPropKt);
212 if(cut) cut->SetRange(min,max);
213 else fCuts[fNCuts++] = new AliHBTKtCut(min,max);
214}
215/**********************************************************/
216
e3131968 217void AliHBTPairCut::SetKStarRange(Double_t min, Double_t max)
218{
ea197c3e 219 // set range of accepted KStar (?)
e3131968 220 AliHBTKStarCut* cut= (AliHBTKStarCut*)FindCut(kHbtPairCutPropKStar);
221 if(cut) cut->SetRange(min,max);
222 else fCuts[fNCuts++] = new AliHBTKStarCut(min,max);
223}
224/**********************************************************/
225
1b446896 226AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
227{
ea197c3e 228 // Find the cut corresponding to "property"
229 for (Int_t i = 0;i<fNCuts;i++)
230 {
231 if (fCuts[i]->GetProperty() == property)
232 return fCuts[i]; //we found the cut we were searching for
233 }
234
235 return 0x0; //we did not found this cut
1b446896 236
237}
238/**********************************************************/
239
240void AliHBTPairCut::Streamer(TBuffer &b)
241{
e3131968 242 // Stream all objects in the array to or from the I/O buffer.
ea197c3e 243
244 UInt_t R__s, R__c;
245 if (b.IsReading())
1b446896 246 {
247 Version_t v = b.ReadVersion(&R__s, &R__c);
1b934a85 248 if (v > -1)
ea197c3e 249 {
250 delete fFirstPartCut;
251 delete fSecondPartCut;
252 fFirstPartCut = 0x0;
253 fSecondPartCut = 0x0;
254 TObject::Streamer(b);
255 b >> fFirstPartCut;
256 b >> fSecondPartCut;
257 b >> fNCuts;
258 for (Int_t i = 0;i<fNCuts;i++)
259 {
260 b >> fCuts[i];
261 }
1b934a85 262 }
ea197c3e 263 b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
264
1b446896 265 }
ea197c3e 266 else
1b446896 267 {
ea197c3e 268 R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
269 TObject::Streamer(b);
270 b << fFirstPartCut;
271 b << fSecondPartCut;
272 b << fNCuts;
273 for (Int_t i = 0;i<fNCuts;i++)
274 {
275 b << fCuts[i];
276 }
277 b.SetByteCount(R__c, kTRUE);
278 }
1b446896 279}
280
281ClassImp(AliHBTEmptyPairCut)
ea197c3e 282
1b446896 283void AliHBTEmptyPairCut::Streamer(TBuffer &b)
ea197c3e 284{
285 AliHBTPairCut::Streamer(b);
286}
1b446896 287
288ClassImp(AliHbtBasePairCut)
ea197c3e 289
1b446896 290ClassImp(AliHBTQInvCut)
ea197c3e 291
bce80f3b 292ClassImp(AliHBTKtCut)
ea197c3e 293
c6b93712 294ClassImp(AliHBTQSideCMSLCCut)
295ClassImp(AliHBTQOutCMSLCCut)
296ClassImp(AliHBTQLongCMSLCCut)