]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronTrackCuts.cxx
including switch to set on/off iso-track core removal, cleaning and bug fix
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronTrackCuts.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 ///////////////////////////////////////////////////////////////////////////
17 //                Dielectron TrackCuts                                  //
18 //                                                                       //
19 //                                                                       //
20 /*
21 Detailed description
22
23
24 */
25 //                                                                       //
26 ///////////////////////////////////////////////////////////////////////////
27
28
29 #include <TMath.h>
30
31 #include "AliDielectronTrackCuts.h"
32 #include "AliVTrack.h"
33 #include "AliAODTrack.h"
34
35 ClassImp(AliDielectronTrackCuts)
36
37 AliDielectronTrackCuts::AliDielectronTrackCuts() :
38   AliAnalysisCuts(),
39   fV0DaughterCut(0),
40   fNegateV0DauterCut(kFALSE),
41   fITSclusterBitMap(0),
42   fITSclusterCutType(kOneOf),
43   fRequireITSRefit(kFALSE),
44   fRequireTPCRefit(kFALSE),
45   fTPCNclRobustCut(-1),
46   fTPCcrossedOverFindable(-1.),
47   fAODFilterBit(kSwitchOff),
48   fWaiveITSNcls(-1)
49 {
50   //
51   // Default Constructor
52   //
53
54   for (Int_t i = 0; i < 3; i++)
55     fCutClusterRequirementITS[i] = kOff;
56   
57 }
58
59 //______________________________________________
60 AliDielectronTrackCuts::AliDielectronTrackCuts(const char* name, const char* title) :
61   AliAnalysisCuts(name, title),
62   fV0DaughterCut(0),
63   fNegateV0DauterCut(kFALSE),
64   fITSclusterBitMap(0),
65   fITSclusterCutType(kOneOf),
66   fRequireITSRefit(kFALSE),
67   fRequireTPCRefit(kFALSE),
68   fTPCNclRobustCut(-1),
69   fTPCcrossedOverFindable(-1.),
70   fAODFilterBit(kSwitchOff),
71   fWaiveITSNcls(-1)
72 {
73   //
74   // Named Constructor
75   //
76
77   for (Int_t i = 0; i < 3; i++)
78     fCutClusterRequirementITS[i] = kOff;
79   
80 }
81
82 //______________________________________________
83 AliDielectronTrackCuts::~AliDielectronTrackCuts()
84 {
85   //
86   // Default Destructor
87   //
88   
89 }
90
91 //______________________________________________
92 Bool_t AliDielectronTrackCuts::IsSelected(TObject* track)
93 {
94   //
95   // Apply configured cuts
96   //
97
98   AliVTrack *vtrack=dynamic_cast<AliVTrack*>(track);
99   if (!vtrack) return kFALSE;
100   
101   Bool_t accept=kTRUE;
102   if (fV0DaughterCut) {
103     Bool_t isV0=track->TestBit(BIT(fV0DaughterCut));
104     if (fNegateV0DauterCut) isV0=!isV0;
105     accept*=isV0;
106   }
107
108   //ESD track cut like ITS cluster cut
109   for (Int_t i=0;i<3;++i){
110     Bool_t layer1=TESTBIT(vtrack->GetITSClusterMap(),i*2);
111     Bool_t layer2=TESTBIT(vtrack->GetITSClusterMap(),i*2+1);
112     accept*=CheckITSClusterRequirement(fCutClusterRequirementITS[i], layer1, layer2);
113   }
114
115   //more flexible ITS cluster cut
116   if (fITSclusterBitMap) accept*=CheckITSClusterCut(vtrack->GetITSClusterMap());
117
118   //different its cluster cut
119   if (fWaiveITSNcls > -1) {
120     Int_t nITScls      = 0;
121     Int_t requiredNcls = 7;
122     for(Int_t i=5; i>=0; i--) {
123       if(TESTBIT(vtrack->GetITSClusterMap(),i)) {
124         nITScls++;
125         requiredNcls=6-fWaiveITSNcls-i; 
126       }
127     }
128     accept*=(requiredNcls<=nITScls);
129   }
130
131   //its and tpc refit
132   if (fRequireITSRefit) accept*=(vtrack->GetStatus()&AliVTrack::kITSrefit)>0;
133   if (fRequireTPCRefit) accept*=(vtrack->GetStatus()&AliVTrack::kTPCrefit)>0;
134
135   Int_t nclr=0;
136   if (fTPCNclRobustCut>0){
137     nclr=TMath::Nint(vtrack->GetTPCClusterInfo(2,1));
138     accept*=(nclr>fTPCNclRobustCut);
139   }
140   if (fTPCcrossedOverFindable > 0.) {
141     if(fTPCNclRobustCut<=0) nclr=TMath::Nint(vtrack->GetTPCClusterInfo(2,1));
142     Int_t tpcNclsF = vtrack->GetTPCNclsF();
143     accept*=(tpcNclsF); //ESDtrackCut would return here true
144     if (tpcNclsF != 0) {//'accept' already negated above in this case above
145       accept*=(((Double_t)nclr/(Double_t)vtrack->GetTPCNclsF()) >= fTPCcrossedOverFindable);
146     }
147   }
148
149
150   // use filter bit to speed up the AOD analysis (track pre-filter)
151   // relevant filter bits are:
152   // kTPCqual==1             -> TPC quality cuts
153   // kTPCqualSPDany==4       -> + SPD any
154   // kTPCqualSPDanyPIDele==8 -> + nSigmaTPCele +-3 (inclusion) 
155   if (track->IsA()==AliAODTrack::Class() && fAODFilterBit!=kSwitchOff) {
156     accept*=((AliAODTrack*)track)->TestFilterBit(fAODFilterBit);
157   }
158
159   return accept;
160 }
161
162 //______________________________________________
163 void AliDielectronTrackCuts::SetV0DaughterCut(AliPID::EParticleType type, Bool_t negate/*=kFALSE*/)
164 {
165   //
166   // Set V0 Daughter cut bit
167   //
168   const Int_t bitMap[5] = {14, -1, 15, -1, 16}; // convert the AliPID to bit positions
169   fV0DaughterCut=bitMap[type];
170   fNegateV0DauterCut=negate;
171 }
172
173 //____________________________________________________________________
174 Bool_t AliDielectronTrackCuts::CheckITSClusterRequirement(ITSClusterRequirement req, Bool_t clusterL1, Bool_t clusterL2) const
175 {
176   // checks if the cluster requirement is fullfilled (in this case: return kTRUE)
177   
178   switch (req)
179   {
180   case kOff:        return kTRUE;
181   case kNone:       return !clusterL1 && !clusterL2;
182   case kAny:        return clusterL1 || clusterL2;
183   case kFirst:      return clusterL1;
184   case kOnlyFirst:  return clusterL1 && !clusterL2;
185   case kSecond:     return clusterL2;
186   case kOnlySecond: return clusterL2 && !clusterL1;
187   case kBoth:       return clusterL1 && clusterL2;
188   }
189   
190   return kFALSE;
191 }
192
193 //______________________________________________
194 Bool_t AliDielectronTrackCuts::CheckITSClusterCut(UChar_t itsBits) const
195 {
196   // check the its cluster cut
197   switch (fITSclusterCutType){
198   case kOneOf:   return itsBits & fITSclusterBitMap;
199   case kAtLeast: return (itsBits & fITSclusterBitMap)==fITSclusterBitMap;
200   case kExact:   return (itsBits==fITSclusterBitMap);
201   }
202   return kTRUE;  
203 }