new ctors
[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);
139
140}
141
bce80f3b 142void AliHBTPairCut::SetKtRange(Double_t min, Double_t max)
143{
144 AliHBTKtCut* cut= (AliHBTKtCut*)FindCut(kHbtPairCutPropKt);
145 if(cut) cut->SetRange(min,max);
146 else fCuts[fNCuts++] = new AliHBTKtCut(min,max);
147}
148/**********************************************************/
149
1b446896 150AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
151{
152 for (Int_t i = 0;i<fNCuts;i++)
153 {
154 if (fCuts[i]->GetProperty() == property)
155 return fCuts[i]; //we found the cut we were searching for
156 }
157
158 return 0x0; //we did not found this cut
159
160}
161/**********************************************************/
162
163void AliHBTPairCut::Streamer(TBuffer &b)
164{
165 // Stream all objects in the array to or from the I/O buffer.
166
167 UInt_t R__s, R__c;
168 if (b.IsReading())
169 {
170 Version_t v = b.ReadVersion(&R__s, &R__c);
1b934a85 171 if (v > -1)
1b446896 172 {
1b934a85 173 TObject::Streamer(b);
174 b >> fFirstPartCut;
175 b >> fSecondPartCut;
176 b >> fNCuts;
177 for (Int_t i = 0;i<fNCuts;i++)
178 {
179 b >> fCuts[i];
180 }
181 }
182 b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
183
1b446896 184 }
185 else
186 {
187 R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
188 TObject::Streamer(b);
189 b << fFirstPartCut;
190 b << fSecondPartCut;
191 b << fNCuts;
192 for (Int_t i = 0;i<fNCuts;i++)
193 {
194 b << fCuts[i];
195 }
196 b.SetByteCount(R__c, kTRUE);
197 }
198}
199
200ClassImp(AliHBTEmptyPairCut)
201
202void AliHBTEmptyPairCut::Streamer(TBuffer &b)
203 {
204 AliHBTPairCut::Streamer(b);
205 }
206
207ClassImp(AliHbtBasePairCut)
208
209ClassImp(AliHBTQInvCut)
bce80f3b 210
211ClassImp(AliHBTKtCut)
c6b93712 212
213ClassImp(AliHBTQSideCMSLCCut)
214ClassImp(AliHBTQOutCMSLCCut)
215ClassImp(AliHBTQLongCMSLCCut)