]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronTrackCuts.cxx
o update dielectron package
[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
34 ClassImp(AliDielectronTrackCuts)
35
36 AliDielectronTrackCuts::AliDielectronTrackCuts() :
37   AliAnalysisCuts(),
38   fV0DaughterCut(0),
39   fNegateV0DauterCut(kFALSE),
40   fITSclusterBitMap(0),
41   fITSclusterCutType(kOneOf),
42   fRequireITSRefit(kFALSE),
43   fRequireTPCRefit(kFALSE),
44   fTPCNclRobustCut(-1)
45 {
46   //
47   // Default Constructor
48   //
49
50   for (Int_t i = 0; i < 3; i++)
51     fCutClusterRequirementITS[i] = kOff;
52   
53 }
54
55 //______________________________________________
56 AliDielectronTrackCuts::AliDielectronTrackCuts(const char* name, const char* title) :
57   AliAnalysisCuts(name, title),
58   fV0DaughterCut(0),
59   fNegateV0DauterCut(kFALSE),
60   fITSclusterBitMap(0),
61   fITSclusterCutType(kOneOf),
62   fRequireITSRefit(kFALSE),
63   fRequireTPCRefit(kFALSE),
64   fTPCNclRobustCut(-1)
65 {
66   //
67   // Named Constructor
68   //
69
70   for (Int_t i = 0; i < 3; i++)
71     fCutClusterRequirementITS[i] = kOff;
72   
73 }
74
75 //______________________________________________
76 AliDielectronTrackCuts::~AliDielectronTrackCuts()
77 {
78   //
79   // Default Destructor
80   //
81   
82 }
83
84 //______________________________________________
85 Bool_t AliDielectronTrackCuts::IsSelected(TObject* track)
86 {
87   //
88   // Apply configured cuts
89   //
90
91   AliVTrack *vtrack=dynamic_cast<AliVTrack*>(track);
92   if (!vtrack) return kFALSE;
93   
94   Bool_t accept=kTRUE;
95   if (fV0DaughterCut) {
96     Bool_t isV0=track->TestBit(BIT(fV0DaughterCut));
97     if (fNegateV0DauterCut) isV0=!isV0;
98     accept*=isV0;
99   }
100
101   //ESD track cut like ITS cluster cut
102   for (Int_t i=0;i<3;++i){
103     Bool_t layer1=TESTBIT(vtrack->GetITSClusterMap(),i*2);
104     Bool_t layer2=TESTBIT(vtrack->GetITSClusterMap(),i*2+1);
105     accept*=CheckITSClusterRequirement(fCutClusterRequirementITS[i], layer1, layer2);
106   }
107
108   //more flexible ITS cluster cut
109   if (fITSclusterBitMap) accept*=CheckITSClusterCut(vtrack->GetITSClusterMap());
110
111   //its and tpc refit
112   if (fRequireITSRefit) accept*=(vtrack->GetStatus()&AliVTrack::kITSrefit)>0;
113   if (fRequireTPCRefit) accept*=(vtrack->GetStatus()&AliVTrack::kTPCrefit)>0;
114
115   if (fTPCNclRobustCut>0){
116     Int_t nclr=TMath::Nint(vtrack->GetTPCClusterInfo(2,1));
117     accept*=(nclr>fTPCNclRobustCut);
118   }
119   return accept;
120 }
121
122 //______________________________________________
123 void AliDielectronTrackCuts::SetV0DaughterCut(AliPID::EParticleType type, Bool_t negate/*=kFALSE*/)
124 {
125   //
126   // Set V0 Daughter cut bit
127   //
128   const Int_t bitMap[5] = {14, -1, 15, -1, 16}; // convert the AliPID to bit positions
129   fV0DaughterCut=bitMap[type];
130   fNegateV0DauterCut=negate;
131 }
132
133 //____________________________________________________________________
134 Bool_t AliDielectronTrackCuts::CheckITSClusterRequirement(ITSClusterRequirement req, Bool_t clusterL1, Bool_t clusterL2) const
135 {
136   // checks if the cluster requirement is fullfilled (in this case: return kTRUE)
137   
138   switch (req)
139   {
140   case kOff:        return kTRUE;
141   case kNone:       return !clusterL1 && !clusterL2;
142   case kAny:        return clusterL1 || clusterL2;
143   case kFirst:      return clusterL1;
144   case kOnlyFirst:  return clusterL1 && !clusterL2;
145   case kSecond:     return clusterL2;
146   case kOnlySecond: return clusterL2 && !clusterL1;
147   case kBoth:       return clusterL1 && clusterL2;
148   }
149   
150   return kFALSE;
151 }
152
153 //______________________________________________
154 Bool_t AliDielectronTrackCuts::CheckITSClusterCut(UChar_t itsBits) const
155 {
156   // check the its cluster cut
157   switch (fITSclusterCutType){
158   case kOneOf:   return itsBits & fITSclusterBitMap;
159   case kAtLeast: return (itsBits & fITSclusterBitMap)==fITSclusterBitMap;
160   case kExact:   return (itsBits==fITSclusterBitMap);
161   }
162   return kTRUE;  
163 }