]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAODPairBaseCut.cxx
small fix
[u/mrichter/AliRoot.git] / ANALYSIS / AliAODPairBaseCut.cxx
1 // Base class AliAODPairBaseCut:
2 // This class defines the range of some property - pure virtual
3 // Property is coded by AliAODCutTypes type
4 // Derived classes:
5 //       AliAODQInvCut
6 //       AliAODKtCut
7 //       AliAODKStarCut
8 //       AliAODKStarOutCut
9 //       AliAODKStarSideCut
10 //       AliAODKStarLongCut
11 //       AliAODQSideLCMSCut
12 //       AliAODQOutLCMSCut
13 //       AliAODQLongLCMSCut
14 //       AliAODDeltaECut
15 //       AliAODDeltaPCut
16 //       AliAODDeltaPvectorCut
17 //       AliAODDeltaPhiCut
18 //       AliAODDeltaThetaCut
19 //       AliAODCluterOverlapCut
20 //       AliAODAvSeparationCut
21 //       AliAODSeparationCut
22 //       AliAODITSSeparationCut
23 //       AliAODOutSideSameSignCut
24 //       AliAODOutSideDiffSignCut
25 //       AliAODLogicalOperPairCut
26 //       AliAODOrPairCut
27 //       AliAODAndPairCut
28 // Author: Piotr.Skowronski@cern.ch
29 #include "AliAODPairBaseCut.h"
30
31 #include "AliTrackPoints.h"
32 #include "AliClusterMap.h"
33
34
35 ClassImp(AliAODPairBaseCut)
36 ClassImp(AliAODQInvCut)
37 ClassImp(AliAODKtCut)
38 ClassImp(AliAODQSideLCMSCut)
39 ClassImp(AliAODQOutLCMSCut)
40 ClassImp(AliAODQLongLCMSCut)
41 ClassImp(AliAODDeltaECut)
42 ClassImp(AliAODDeltaPCut)
43 ClassImp(AliAODDeltaPvectorCut)
44 ClassImp(AliAODDeltaPhiCut)
45 ClassImp(AliAODDeltaThetaCut)
46
47 /******************************************************************/
48 ClassImp(AliAODAvSeparationCut)
49     
50 Double_t AliAODAvSeparationCut::GetValue(AliAODPair* pair) const 
51 {
52   //chacks if avarage distance of two tracks is in given range
53   AliTrackPoints* tpts1 = pair->Particle1()->GetTPCTrackPoints();
54   if ( tpts1 == 0x0)
55    {//it could be simulated pair
56 //     Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
57      return -1.0;
58    }
59
60   AliTrackPoints* tpts2 = pair->Particle2()->GetTPCTrackPoints();
61   if ( tpts2 == 0x0)
62    {
63 //     Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
64      return -1.0;
65    }
66    
67   return tpts1->AvarageDistance(*tpts2);
68 }
69 /******************************************************************/
70 ClassImp(AliAODSeparationCut)
71     
72 Double_t AliAODSeparationCut::GetValue(AliAODPair* pair) const 
73 {
74   //chacks if avarage distance of two tracks is in given range
75   AliTrackPoints* tpts1 = pair->Particle1()->GetTPCTrackPoints();
76   if ( tpts1 == 0x0)
77    {//it could be simulated pair
78 //     Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
79      return -1.0;
80    }
81
82   AliTrackPoints* tpts2 = pair->Particle2()->GetTPCTrackPoints();
83   if ( tpts2 == 0x0)
84    {
85 //     Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
86      return -1.0;
87    }
88   Float_t x1=0,y1=0,z1=0; 
89   Float_t x2=0,y2=0,z2=0;
90   
91   tpts1->PositionAt(fPoint,x1,y1,z1);
92   tpts2->PositionAt(fPoint,x2,y2,z2);
93   Double_t dx1 = x1 - x2;
94   Double_t dy1 = y1 - y2;
95   Double_t dz1 = z1 - z2;
96   Double_t d = TMath::Sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
97   return d;
98 }
99 /******************************************************************/
100
101 ClassImp(AliAODITSSeparationCut)
102
103 Bool_t AliAODITSSeparationCut::Rejected(AliAODPair* pair) const
104 {
105  //Checks if two tracks do not cross first pixels too close to each other
106  //If two tracks use the same cluster in pixels they are given
107  //the same position what skews theta angles (both are the same)
108  //These guys create artificial correlation in non-id analyses
109  //which is positive for identical polar angles (Qlong=0) 
110  //and negative for a little bit different theta angle (Qlong=epsilon)
111  //Such tracks "attracks" each other.
112  
113   AliTrackPoints* tpts1 = pair->Particle1()->GetITSTrackPoints();
114   if ( tpts1 == 0x0)
115    {//it could be simulated pair
116      Warning("Pass","Track 1 does not have ITS Track Points. Pair NOT Passed.");
117      return kTRUE;//reject 
118    }
119
120   AliTrackPoints* tpts2 = pair->Particle2()->GetITSTrackPoints();
121   if ( tpts2 == 0x0)
122    {
123      Warning("Pass","Track 2 does not have ITS Track Points. Pair NOT Passed.");
124      return kTRUE;//reject 
125    }
126   Float_t  x1=0.0,y1=0.0,z1=0.0,x2=0.0,y2=0.0,z2=0.0;
127   tpts1->PositionAt(fLayer,x1,y1,z1);
128   tpts2->PositionAt(fLayer,x2,y2,z2);
129   
130 //  Info("Pass","rphi %f z %f",fMin,fMax);
131 //  Info("Pass","P1: %f %f %f", x1,y1,z1);
132 //  Info("Pass","P2: %f %f %f", x2,y2,z2);
133   
134   Double_t dz = TMath::Abs(z1-z2);
135   
136   //fMax encodes treshold valaue of distance in Z
137   if (dz > fMax) return kFALSE;//pair accepted
138   
139   Double_t drphi = TMath::Hypot(x1-x2,y1-y2);
140   
141   //fMin encodes treshold valaue of distance in r-phi
142   if (drphi > fMin) return kFALSE;
143   
144   return kTRUE;//they are too close, rejected
145 }
146 /******************************************************************/
147
148 ClassImp(AliAODCluterOverlapCut)
149
150 Double_t  AliAODCluterOverlapCut::GetValue(AliAODPair* pair) const
151 {
152   //Returns Cluter Overlap Factor
153   //It ranges between -0.5 (in all padrows both tracks have cluters) 
154   // and 1 (in all padrows one track has cluter and second has not)
155   // When Overlap Factor is 1 this pair of tracks in highly probable to be
156   // splitted track: one particle that is recontructed twise
157
158   AliClusterMap* cm1 = pair->Particle1()->GetClusterMap();
159   if ( cm1 == 0x0)
160    {
161      Warning("GetValue","Track 1 does not have Cluster Map. Returning -0.5.");
162      return -.5;
163    }
164
165   AliClusterMap* cm2 = pair->Particle2()->GetClusterMap();
166   if ( cm2 == 0x0)
167    {
168      Warning("GetValue","Track 2 does not have Cluster Map. Returning -0.5.");
169      return -.5;
170    }
171   return cm1->GetOverlapFactor(*cm2);
172 }
173 /******************************************************************/
174 ClassImp(AliAODOutSideSameSignCut)
175
176 Bool_t AliAODOutSideSameSignCut::Rejected(AliAODPair *p) const
177 {
178   //returns kTRUE if pair DO NOT meet cut criteria
179   
180   if ( p->GetQOutLCMS()*p->GetQSideLCMS() > 0 ) 
181    {
182      return kFALSE;//accpeted
183    }
184
185   return kTRUE ;//rejected
186 }
187 /******************************************************************/
188 ClassImp(AliAODOutSideDiffSignCut)
189
190 Bool_t AliAODOutSideDiffSignCut::Rejected(AliAODPair *p) const
191 {
192   //returns kTRUE if pair DO NOT meet cut criteria
193   
194   if ( p->GetQOutLCMS()*p->GetQSideLCMS() > 0 ) 
195    {
196      return kTRUE;//rejected
197    }
198   
199   return kFALSE;//accepted
200 }
201 /******************************************************************/
202 ClassImp( AliAODLogicalOperPairCut )
203
204 AliAODLogicalOperPairCut::AliAODLogicalOperPairCut():
205  AliAODPairBaseCut(-10e10,10e10,kHbtPairCutPropNone),
206  fFirst(new AliAODDummyBasePairCut),
207  fSecond(new AliAODDummyBasePairCut)
208 {
209  //ctor
210 }
211 /******************************************************************/
212
213 AliAODLogicalOperPairCut::AliAODLogicalOperPairCut(AliAODPairBaseCut* first, AliAODPairBaseCut* second):
214  AliAODPairBaseCut(-10e10,10e10,kHbtPairCutPropNone),
215  fFirst((first)?(AliAODPairBaseCut*)first->Clone():0x0),
216  fSecond((second)?(AliAODPairBaseCut*)second->Clone():0x0)
217 {
218   //ctor
219   //note that base cuts are copied, not just pointers assigned
220   if ( (fFirst && fSecond) == kFALSE) 
221    {
222      Fatal("AliAODLogicalOperPairCut","One of parameters is NULL!");
223    }
224 }
225 /******************************************************************/
226
227 AliAODLogicalOperPairCut::~AliAODLogicalOperPairCut()
228 {
229   //destructor
230   delete fFirst;
231   delete fSecond;
232 }
233 /******************************************************************/
234
235 Bool_t AliAODLogicalOperPairCut::AliAODDummyBasePairCut::Rejected(AliAODPair* /*pair*/)  const
236 {
237   //checks if particles passes properties defined by this cut
238   Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
239   return kFALSE;//accept
240 }
241 /******************************************************************/
242
243 void AliAODLogicalOperPairCut::Streamer(TBuffer &b)
244 {
245   // Stream all objects in the array to or from the I/O buffer.
246   UInt_t R__s, R__c;
247   if (b.IsReading()) 
248    {
249      delete fFirst;
250      delete fSecond;
251      fFirst  = 0x0;
252      fSecond = 0x0;
253
254      b.ReadVersion(&R__s, &R__c);
255      TObject::Streamer(b);
256      b >> fFirst;
257      b >> fSecond;
258      b.CheckByteCount(R__s, R__c,AliAODLogicalOperPairCut::IsA());
259    } 
260   else 
261    {
262      R__c = b.WriteVersion(AliAODLogicalOperPairCut::IsA(), kTRUE);
263      TObject::Streamer(b);
264      b << fFirst;
265      b << fSecond;
266      b.SetByteCount(R__c, kTRUE);
267   }
268 }
269
270 /******************************************************************/
271 ClassImp(AliAODOrPairCut)
272
273 Bool_t AliAODOrPairCut::Rejected(AliAODPair * p) const
274 {
275   //returns true when rejected 
276   //AND operation is a little bit misleading but is correct
277   //User wants to build logical cuts with natural (positive) logic
278   //while ALIAN use inernally reverse (returns true when rejected)
279   if (fFirst->Rejected(p) && fSecond->Rejected(p) ) return kTRUE;//rejected (both rejected, returned kTRUE)
280   return kFALSE;//accepted, at least one accepted (returned kFALSE)
281 }
282 /******************************************************************/
283
284 ClassImp(AliAODAndPairCut)
285
286 Bool_t AliAODAndPairCut::Rejected(AliAODPair * p)  const
287 {
288   //returns true when rejected 
289   //OR operation is a little bit misleading but is correct
290   //User wants to build logical cuts with natural (positive) logic
291   //while ALIAN use inernally reverse (returns true when rejected)
292   if (fFirst->Rejected(p))
293    {//first rejected - we reject
294      return kTRUE;
295    }
296   else
297    {//first accepted
298     if (fSecond->Rejected(p))
299      {//second rejected - we reject
300        return kTRUE;
301      }
302    }  
303 //  if (fFirst->Rejected(p) || fSecond->Rejected(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
304   
305   return kFALSE;//accepted (both accepted (returned kFALSE))
306 }
307 /******************************************************************/