]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTPairCut.cxx
This commit was generated by cvs2svn to compensate for changes in r4472,
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPairCut.cxx
1 #include "AliHBTPairCut.h"
2 #include "AliHBTPair.h"
3 #include <iostream.h>
4
5
6 ClassImp(AliHBTPairCut)
7 const Int_t AliHBTPairCut::fkgMaxCuts = 50;
8 /**********************************************************/
9
10 AliHBTPairCut::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
21 AliHBTPairCut::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
37 AliHBTPairCut::~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
50 void 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
64 Bool_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
93 void 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
106 void 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
118 void 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
134 void 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
142 AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
143 {
144  for (Int_t i = 0;i<fNCuts;i++)
145   {
146     if (fCuts[i]->GetProperty() == property) 
147        return fCuts[i]; //we found the cut we were searching for
148   }
149  
150  return 0x0; //we did not found this cut
151   
152 }
153 /**********************************************************/
154
155 void AliHBTPairCut::Streamer(TBuffer &b)
156 {
157      // Stream all objects in the array to or from the I/O buffer.
158
159    UInt_t R__s, R__c;
160    if (b.IsReading()) 
161     {
162       Version_t v = b.ReadVersion(&R__s, &R__c);
163       TObject::Streamer(b);
164       b >> fFirstPartCut;
165       b >> fSecondPartCut;
166       b >> fNCuts;
167       for (Int_t i = 0;i<fNCuts;i++)
168        {
169         b >> fCuts[i];
170        }
171       b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
172     } 
173    else 
174     {
175      R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
176      TObject::Streamer(b);
177      b << fFirstPartCut;
178      b << fSecondPartCut;
179      b << fNCuts;
180      for (Int_t i = 0;i<fNCuts;i++)
181       {
182        b << fCuts[i];
183       }
184      b.SetByteCount(R__c, kTRUE);
185    }
186 }
187
188 ClassImp(AliHBTEmptyPairCut)
189
190 void AliHBTEmptyPairCut::Streamer(TBuffer &b)
191  {
192    AliHBTPairCut::Streamer(b);
193  }
194
195 ClassImp(AliHbtBasePairCut)
196
197 ClassImp(AliHBTQInvCut)