]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronTrackCuts.cxx
o 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   fAODFilterBit(kSwitchOff),
47   fWaiveITSNcls(-1)
48 {
49   //
50   // Default Constructor
51   //
52
53   for (Int_t i = 0; i < 3; i++)
54     fCutClusterRequirementITS[i] = kOff;
55   
56 }
57
58 //______________________________________________
59 AliDielectronTrackCuts::AliDielectronTrackCuts(const char* name, const char* title) :
60   AliAnalysisCuts(name, title),
61   fV0DaughterCut(0),
62   fNegateV0DauterCut(kFALSE),
63   fITSclusterBitMap(0),
64   fITSclusterCutType(kOneOf),
65   fRequireITSRefit(kFALSE),
66   fRequireTPCRefit(kFALSE),
67   fTPCNclRobustCut(-1),
68   fAODFilterBit(kSwitchOff),
69   fWaiveITSNcls(-1)
70 {
71   //
72   // Named Constructor
73   //
74
75   for (Int_t i = 0; i < 3; i++)
76     fCutClusterRequirementITS[i] = kOff;
77   
78 }
79
80 //______________________________________________
81 AliDielectronTrackCuts::~AliDielectronTrackCuts()
82 {
83   //
84   // Default Destructor
85   //
86   
87 }
88
89 //______________________________________________
90 Bool_t AliDielectronTrackCuts::IsSelected(TObject* track)
91 {
92   //
93   // Apply configured cuts
94   //
95
96   AliVTrack *vtrack=dynamic_cast<AliVTrack*>(track);
97   if (!vtrack) return kFALSE;
98   
99   Bool_t accept=kTRUE;
100   if (fV0DaughterCut) {
101     Bool_t isV0=track->TestBit(BIT(fV0DaughterCut));
102     if (fNegateV0DauterCut) isV0=!isV0;
103     accept*=isV0;
104   }
105
106   //ESD track cut like ITS cluster cut
107   for (Int_t i=0;i<3;++i){
108     Bool_t layer1=TESTBIT(vtrack->GetITSClusterMap(),i*2);
109     Bool_t layer2=TESTBIT(vtrack->GetITSClusterMap(),i*2+1);
110     accept*=CheckITSClusterRequirement(fCutClusterRequirementITS[i], layer1, layer2);
111   }
112
113   //more flexible ITS cluster cut
114   if (fITSclusterBitMap) accept*=CheckITSClusterCut(vtrack->GetITSClusterMap());
115
116   //different its cluster cut
117   if (fWaiveITSNcls > -1) {
118     Int_t nITScls      = 0;
119     Int_t requiredNcls = 7;
120     for(Int_t i=5; i>=0; i--) {
121       if(TESTBIT(vtrack->GetITSClusterMap(),i)) {
122         nITScls++;
123         requiredNcls=6-fWaiveITSNcls-i; 
124       }
125     }
126     accept*=(requiredNcls<=nITScls);
127   }
128
129   //its and tpc refit
130   if (fRequireITSRefit) accept*=(vtrack->GetStatus()&AliVTrack::kITSrefit)>0;
131   if (fRequireTPCRefit) accept*=(vtrack->GetStatus()&AliVTrack::kTPCrefit)>0;
132
133   if (fTPCNclRobustCut>0){
134     Int_t nclr=TMath::Nint(vtrack->GetTPCClusterInfo(2,1));
135     accept*=(nclr>fTPCNclRobustCut);
136   }
137
138   // use filter bit to speed up the AOD analysis (track pre-filter)
139   // relevant filter bits are:
140   // kTPCqual==1             -> TPC quality cuts
141   // kTPCqualSPDany==4       -> + SPD any
142   // kTPCqualSPDanyPIDele==8 -> + nSigmaTPCele +-3 (inclusion) 
143   if (track->IsA()==AliAODTrack::Class() && fAODFilterBit!=kSwitchOff) {
144     accept*=((AliAODTrack*)track)->TestFilterBit(fAODFilterBit);
145   }
146
147   return accept;
148 }
149
150 //______________________________________________
151 void AliDielectronTrackCuts::SetV0DaughterCut(AliPID::EParticleType type, Bool_t negate/*=kFALSE*/)
152 {
153   //
154   // Set V0 Daughter cut bit
155   //
156   const Int_t bitMap[5] = {14, -1, 15, -1, 16}; // convert the AliPID to bit positions
157   fV0DaughterCut=bitMap[type];
158   fNegateV0DauterCut=negate;
159 }
160
161 //____________________________________________________________________
162 Bool_t AliDielectronTrackCuts::CheckITSClusterRequirement(ITSClusterRequirement req, Bool_t clusterL1, Bool_t clusterL2) const
163 {
164   // checks if the cluster requirement is fullfilled (in this case: return kTRUE)
165   
166   switch (req)
167   {
168   case kOff:        return kTRUE;
169   case kNone:       return !clusterL1 && !clusterL2;
170   case kAny:        return clusterL1 || clusterL2;
171   case kFirst:      return clusterL1;
172   case kOnlyFirst:  return clusterL1 && !clusterL2;
173   case kSecond:     return clusterL2;
174   case kOnlySecond: return clusterL2 && !clusterL1;
175   case kBoth:       return clusterL1 && clusterL2;
176   }
177   
178   return kFALSE;
179 }
180
181 //______________________________________________
182 Bool_t AliDielectronTrackCuts::CheckITSClusterCut(UChar_t itsBits) const
183 {
184   // check the its cluster cut
185   switch (fITSclusterCutType){
186   case kOneOf:   return itsBits & fITSclusterBitMap;
187   case kAtLeast: return (itsBits & fITSclusterBitMap)==fITSclusterBitMap;
188   case kExact:   return (itsBits==fITSclusterBitMap);
189   }
190   return kTRUE;  
191 }