cuts on Q out, side, long added
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPairCut.cxx
CommitLineData
1b446896 1#include "AliHBTPairCut.h"
2#include "AliHBTPair.h"
3#include <iostream.h>
4
5
6ClassImp(AliHBTPairCut)
7const Int_t AliHBTPairCut::fkgMaxCuts = 50;
8/**********************************************************/
9
10AliHBTPairCut::AliHBTPairCut()
11{
12//constructor
13 fFirstPartCut = new AliHBTEmptyParticleCut(); //empty cuts
14 fSecondPartCut= new AliHBTEmptyParticleCut(); //empty cuts
15
16 fCuts = new AliHbtBasePairCut*[fkgMaxCuts];
17 fNCuts = 0;
18}
19/**********************************************************/
20
21AliHBTPairCut::AliHBTPairCut(const AliHBTPairCut& in)
22{
23 //copy constructor
24 fCuts = new AliHbtBasePairCut*[fkgMaxCuts];
25 fNCuts = in.fNCuts;
26
27 fFirstPartCut = (AliHBTParticleCut*)in.fFirstPartCut->Clone();
28 fSecondPartCut = (AliHBTParticleCut*)in.fSecondPartCut->Clone();
29
30 for (Int_t i = 0;i<fNCuts;i++)
31 {
32 fCuts[i] = (AliHbtBasePairCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
33 }
34}
35/**********************************************************/
36
37AliHBTPairCut::~AliHBTPairCut()
38{
39//destructor
40 for (Int_t i = 0;i<fNCuts;i++)
41 {
42 delete fCuts[i];
43 }
44 delete []fCuts;
45}
46/**********************************************************/
47
48/**********************************************************/
49
50void AliHBTPairCut::AddBasePairCut(AliHbtBasePairCut* basecut)
51 {
52 //adds the base pair cut (cut on one value)
53
54 if (!basecut) return;
55 if( fNCuts == (fkgMaxCuts-1) )
56 {
57 Warning("AddBasePairCut","Not enough place for another cut");
58 return;
59 }
60 fCuts[fNCuts++]=basecut;
61 }
62/**********************************************************/
63
64Bool_t AliHBTPairCut::Pass(AliHBTPair* pair)
65{
66//methods which checks if given pair meets all criteria of the cut
67//if it meets returns FALSE
68//if NOT returns TRUE
69 if(!pair)
70 {
71 Warning("Pass()","No Pasaran! We never accept NULL pointers");
72 return kTRUE;
73 }
74
75 //check particle's cuts
76 if( ( fFirstPartCut->Pass( pair->Particle1() ) ) ||
77 ( fSecondPartCut->Pass(pair->Particle2() ) ) )
78 {
79 return kTRUE;
80 }
81
82 //examine all base pair cuts
83 for (Int_t i = 0;i<fNCuts;i++)
84 {
85 if ( (fCuts[i]->Pass(pair)) ) return kTRUE; //if one of the cuts reject, then reject
86 }
87
88// cout<<"passed "<<pair->Particle1()->GetPdgCode()<<" "<<pair->Particle2()->GetPdgCode()<<endl;
89 return kFALSE;
90}
91/**********************************************************/
92
93void AliHBTPairCut::SetFirstPartCut(AliHBTParticleCut* cut)
94{
95 if(!cut)
96 {
97 Error("SetFirstPartCut","argument is NULL");
98 return;
99 }
100 delete fFirstPartCut;
101 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
102
103}
104/**********************************************************/
105
106void AliHBTPairCut::SetSecondPartCut(AliHBTParticleCut* cut)
107{
108 if(!cut)
109 {
110 Error("SetSecondPartCut","argument is NULL");
111 return;
112 }
113 delete fSecondPartCut;
114 fSecondPartCut = (AliHBTParticleCut*)cut->Clone();
115}
116/**********************************************************/
117
118void AliHBTPairCut::SetPartCut(AliHBTParticleCut* cut)
119{
120//sets the the same cut on both particles
121 if(!cut)
122 {
123 Error("SetFirstPartCut","argument is NULL");
124 return;
125 }
126 delete fFirstPartCut;
127 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
128
129 delete fSecondPartCut; //even if null should not be harmful
130 fSecondPartCut = fFirstPartCut;
131}
132/**********************************************************/
133
134void AliHBTPairCut::SetQInvRange(Double_t min, Double_t max)
135{
136 AliHBTQInvCut* cut= (AliHBTQInvCut*)FindCut(kHbtPairCutPropQInv);
137 if(cut) cut->SetRange(min,max);
138 else fCuts[fNCuts++] = new AliHBTQInvCut(min,max);
a37908e0 139}
140/**********************************************************/
141void AliHBTPairCut::SetQOutCMSLRange(Double_t min, Double_t max)
142{
143 AliHBTQOutCMSLCCut* cut= (AliHBTQOutCMSLCCut*)FindCut(kHbtPairCutPropQOutCMSLC);
144 if(cut) cut->SetRange(min,max);
145 else fCuts[fNCuts++] = new AliHBTQOutCMSLCCut(min,max);
146}
1b446896 147
a37908e0 148/**********************************************************/
149void AliHBTPairCut::SetQSideCMSLRange(Double_t min, Double_t max)
150{
151 AliHBTQSideCMSLCCut* cut= (AliHBTQSideCMSLCCut*)FindCut(kHbtPairCutPropQSideCMSLC);
152 if(cut) cut->SetRange(min,max);
153 else fCuts[fNCuts++] = new AliHBTQSideCMSLCCut(min,max);
1b446896 154}
155
a37908e0 156/**********************************************************/
157void AliHBTPairCut::SetQLongCMSLRange(Double_t min, Double_t max)
158{
159 AliHBTQLongCMSLCCut* cut= (AliHBTQLongCMSLCCut*)FindCut(kHbtPairCutPropQLongCMSLC);
160 if(cut) cut->SetRange(min,max);
161 else fCuts[fNCuts++] = new AliHBTQLongCMSLCCut(min,max);
162}
163
164/**********************************************************/
165
bce80f3b 166void AliHBTPairCut::SetKtRange(Double_t min, Double_t max)
167{
168 AliHBTKtCut* cut= (AliHBTKtCut*)FindCut(kHbtPairCutPropKt);
169 if(cut) cut->SetRange(min,max);
170 else fCuts[fNCuts++] = new AliHBTKtCut(min,max);
171}
172/**********************************************************/
173
1b446896 174AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
175{
176 for (Int_t i = 0;i<fNCuts;i++)
177 {
178 if (fCuts[i]->GetProperty() == property)
179 return fCuts[i]; //we found the cut we were searching for
180 }
181
182 return 0x0; //we did not found this cut
183
184}
185/**********************************************************/
186
187void AliHBTPairCut::Streamer(TBuffer &b)
188{
189 // Stream all objects in the array to or from the I/O buffer.
190
191 UInt_t R__s, R__c;
192 if (b.IsReading())
193 {
194 Version_t v = b.ReadVersion(&R__s, &R__c);
1b934a85 195 if (v > -1)
1b446896 196 {
1b934a85 197 TObject::Streamer(b);
198 b >> fFirstPartCut;
199 b >> fSecondPartCut;
200 b >> fNCuts;
201 for (Int_t i = 0;i<fNCuts;i++)
202 {
203 b >> fCuts[i];
204 }
205 }
206 b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
207
1b446896 208 }
209 else
210 {
211 R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
212 TObject::Streamer(b);
213 b << fFirstPartCut;
214 b << fSecondPartCut;
215 b << fNCuts;
216 for (Int_t i = 0;i<fNCuts;i++)
217 {
218 b << fCuts[i];
219 }
220 b.SetByteCount(R__c, kTRUE);
221 }
222}
223
224ClassImp(AliHBTEmptyPairCut)
225
226void AliHBTEmptyPairCut::Streamer(TBuffer &b)
227 {
228 AliHBTPairCut::Streamer(b);
229 }
230
231ClassImp(AliHbtBasePairCut)
232
233ClassImp(AliHBTQInvCut)
bce80f3b 234
235ClassImp(AliHBTKtCut)
c6b93712 236
237ClassImp(AliHBTQSideCMSLCCut)
238ClassImp(AliHBTQOutCMSLCCut)
239ClassImp(AliHBTQLongCMSLCCut)