418d2cb752cbaabefd4fbecd18ebca7bd694f518
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEextraCuts.h
1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 // Extra Cuts from the ALICE HFE Group
17 // Container for cuts which are currently not implemented by
18 // the Correction Framework
19 //
20 #ifndef ALIHFEEXTRACUTS_H
21 #define ALIHFEEXTRACUTS_H
22
23 // #ifndef ALICFCUTBASE_H
24 #include "AliCFCutBase.h"
25 // #endif
26
27 class TList;
28
29 class AliVEvent;
30 class AliVParticle;
31 class AliVTrack;
32
33 class AliHFEextraCuts: public AliCFCutBase{
34   public:
35     typedef enum{
36       kFirst = 0,
37       kSecond = 1,
38       kBoth = 2,
39       kNone = 3,
40       kAny = 4,
41       kExclusiveSecond = 5
42     } ITSPixel_t;
43     typedef enum{
44       kFirstD = 0  
45     } ITSDrift_t;
46     typedef enum{
47       kFound = 0,
48       kFoundIter1 = 1,
49       kCrossedRows = 2
50     } ETPCclusterDef_t;
51     typedef enum{
52       kFoundOverFindable = 0,
53       kFoundOverFindableIter1 = 1,
54       kFoundOverCR = 2,
55       kCROverFindable = 3
56     } ETPCclrDef_t;
57     AliHFEextraCuts(const Char_t *name, const Char_t *title);
58     AliHFEextraCuts(const AliHFEextraCuts &c);
59     AliHFEextraCuts &operator=(const AliHFEextraCuts &c);
60     virtual ~AliHFEextraCuts();
61     
62     virtual Bool_t IsSelected(TObject *o);
63     virtual Bool_t IsSelected(TList *) { return kTRUE; };
64     virtual void SetRecEventInfo(const TObject *event);
65
66     inline void SetClusterRatioTPC(Double_t ratio, ETPCclrDef_t def);
67     inline void SetRequireITSpixel(ITSPixel_t pixel);
68     inline void SetRequireITSdrift(ITSDrift_t drift);
69     inline void SetMinImpactParamR(Double_t impactParam);
70     inline void SetMaxImpactParamR(Double_t impactParam);
71     inline void SetMinImpactParamZ(Double_t impactParam);
72     inline void SetMaxImpactParamZ(Double_t impactParam);
73     inline void SetMinHFEImpactParamR(Float_t ipcutParam[4], Bool_t issigmacut, Bool_t isabs);
74     inline void SetMinTrackletsTRD(Int_t minTracklets, Bool_t exact = kFALSE);
75     inline void SetMinNClustersTPC(Int_t minclusters, ETPCclusterDef_t def);
76     void SetMinNClustersTPCPID(Int_t minclusters) { SETBIT(fRequirements, kMinNClustersTPCPID); fMinNClustersTPCPID = minclusters; }
77     void SetTOFPID(Bool_t tofPid) { tofPid ? SETBIT(fRequirements, kTOFPID) : CLRBIT(fRequirements, kTOFPID); }
78     void SetTOFMISMATCH(Bool_t tofMismatch) { tofMismatch ? SETBIT(fRequirements, kTOFmismatch) : CLRBIT(fRequirements, kTOFmismatch); }
79     void SetTPCPIDCleanUp(Bool_t tpcPIDCleanUp) { tpcPIDCleanUp ? SETBIT(fRequirements, kTPCPIDCleanUp) : CLRBIT(fRequirements, kTPCPIDCleanUp); }
80     void SetMaxImpactParameterRpar(Bool_t maxImpactParameterRpar) { maxImpactParameterRpar ? SETBIT(fRequirements, kMaxImpactParameterRpar) : CLRBIT(fRequirements, kMaxImpactParameterRpar); }
81     void SetFractionOfTPCSharedClusters(Double_t fractionShared) { fFractionTPCShared= fractionShared; SETBIT(fRequirements, kTPCfractionShared); }
82     void SetMinNbITScls(UChar_t minNbITScls) { fMinNbITScls = minNbITScls; SETBIT(fRequirements, kMinNbITScls); }
83     void SetTOFsignalDxz(Double_t tofsignalDx,Double_t tofsignalDz) { fTOFsignalDx=tofsignalDx; fTOFsignalDz=tofsignalDz; SETBIT(fRequirements, kTOFsignalDxy); }
84     void SetRejectKinkDaughter() { SETBIT(fRequirements, kRejectKinkDaughter);}; 
85     void SetRejectKinkMother() { SETBIT(fRequirements, kRejectKinkMother);}; 
86     void SetCheckITSstatus(Bool_t check) { fCheck = check; };
87     void SetDebugLevel(Int_t level) { fDebugLevel = level; };
88
89     Bool_t GetCheckITSstatus() const { return fCheck; };
90     Int_t GetDebugLevel() const { return fDebugLevel; };
91     void GetHFEImpactParameters(AliVTrack *track, Double_t &dcaxy, Double_t &dcansigmaxy); // temporary moved from protected to publich for IP QA 
92     void GetHFEImpactParameters(AliVTrack *track, Double_t dcaD[2], Double_t covD[3]);
93     Int_t GetITSstatus(AliVTrack *track, Int_t layer);
94     Bool_t CheckITSstatus(Int_t itsStatus) const;
95
96     void UnSetRejectKinkDaughter() { CLRBIT(fRequirements, kRejectKinkDaughter);}; 
97     void UnSetRejectKinkMother() { CLRBIT(fRequirements, kRejectKinkMother);}; 
98
99     
100   protected:
101     virtual void AddQAHistograms(TList *qaList);
102     Bool_t CheckRecCuts(AliVTrack *track);
103     Bool_t CheckMCCuts(AliVParticle * /*track*/) const;
104     void FillQAhistosRec(AliVTrack *track, UInt_t when);
105     //void FillQAhistosMC(AliMCParticle *track, UInt_t when);
106     void FillCutCorrelation(ULong64_t survivedCut);
107     void PrintBitMap(Int_t bitmap);
108     
109     // Getter Functions for ESD/AOD compatible mode
110     UInt_t GetTPCncls(AliVTrack *track);
111     Bool_t GetTPCCountSharedMapBitsAboveThreshold(AliVTrack *track);
112     Double_t GetTPCclusterRatio(AliVTrack *track);
113     void GetImpactParameters(AliVTrack *track, Float_t &radial, Float_t &z);
114     //void GetHFEImpactParameters(AliVTrack *track, Double_t &dcaxy, Double_t &dcansigmaxy);
115     void GetHFEImpactParameterCuts(AliVTrack *track, Double_t &hfeimpactRcut, Double_t &hfeimpactnsigmaRcut);
116     void GetMaxImpactParameterCutR(AliVTrack *track, Double_t &maximpactRcut);
117     void GetTOFsignalDxDz(AliVTrack *track, Double_t &tofsignalDx, Double_t &tofsignalDz);
118     Float_t GetTPCsharedClustersRatio(AliVTrack *track);
119     Int_t GetITSNbOfcls(AliVTrack *track);
120     Bool_t IsKinkDaughter(AliVTrack *track);
121     Bool_t IsKinkMother(AliVTrack *track);
122
123   private:
124     typedef enum{
125       kMinImpactParamR = 0,
126       kMaxImpactParamR = 1,
127       kMinImpactParamZ = 2,
128       kMaxImpactParamZ = 3,
129       kClusterRatioTPC = 4,
130       kMinTrackletsTRD = 5,
131       kPixelITS = 6,
132       kMinHFEImpactParamR = 7,
133       kMinHFEImpactParamNsigmaR = 8,
134       kMinNClustersTPC = 9,
135       kMinNClustersTPCPID = 10,
136       kTPCfractionShared = 11,
137       kTOFPID = 12,
138       kTOFmismatch = 13,
139       kTPCPIDCleanUp = 14,
140       kEMCALmatch = 15,
141       kMaxImpactParameterRpar = 16,
142       kMinNbITScls = 17,
143       kRejectKinkDaughter = 18,
144       kRejectKinkMother = 19,
145       kDriftITS = 20,
146       kTOFsignalDxy = 21,
147       kNcuts = 22
148     } Cut_t;
149     enum{
150       //
151       // Common Constants
152       //
153       kBeforeCuts =0,
154       kAfterCuts = 1
155     };
156     static const Int_t fgkNQAhistos;   // Number of QA histos
157     AliVEvent *fEvent;                //! working event
158     ULong64_t fCutCorrelation;        // Cut Correlation
159     ULong64_t fRequirements;          // Cut Requirements
160     Float_t fImpactParamCut[4];       // Impact Parmameter Cut
161     Float_t fIPcutParam[4];           // Parmameter of impact parameter cut parametrization
162     UInt_t fMinNClustersTPC;          // Minimum TPC clusters cut
163     UInt_t fMinNClustersTPCPID;       // Minimum TPC PID clusters cut
164     Float_t fClusterRatioTPC;         // Ratio of findable vs. found clusters in TPC
165     UChar_t fMinTrackletsTRD;         // Min. Number of Tracklets inside TRD
166     UChar_t fMinNbITScls;             // Min. Number of ITS clusters
167     Bool_t  fTRDtrackletsExact;       // Require exact number of tracklets
168     UChar_t fPixelITS;                // Cut on ITS Pixels
169     UChar_t fDriftITS;                // Cut on ITS Drift
170     UChar_t fTPCclusterDef;           // TPC cluster definition Bitmap
171     UChar_t fTPCclusterRatioDef;      // TPC cluster ratio definition Bitmap
172     Double_t  fFractionTPCShared;     // Cut on fraction of shared clusters
173     Bool_t fAbsHFEImpactParamNsigmaR; // flag to use abs ip cut
174     Double_t fTOFsignalDx;            // TOF signal dx
175     Double_t fTOFsignalDz;            // TOF signal dz
176
177     Bool_t  fCheck;                     // check
178     TList *fQAlist;                     //! Directory for QA histograms
179     Int_t   fDebugLevel;                // Debug Level
180   
181     ClassDef(AliHFEextraCuts, 5)      // Additional cuts implemented by the ALICE HFE group
182 };
183
184 //__________________________________________________________
185 void AliHFEextraCuts::SetClusterRatioTPC(Double_t ratio, ETPCclrDef_t def) {
186   SETBIT(fRequirements, kClusterRatioTPC);
187   SETBIT(fTPCclusterRatioDef, def);
188   fClusterRatioTPC = ratio; 
189 }
190
191 //__________________________________________________________
192 void AliHFEextraCuts::SetRequireITSpixel(ITSPixel_t pixel) {
193   SETBIT(fRequirements, kPixelITS);
194   fPixelITS = pixel; 
195 }
196
197 //__________________________________________________________
198 void AliHFEextraCuts::SetRequireITSdrift(ITSDrift_t drift) {
199   SETBIT(fRequirements, kDriftITS);
200   fDriftITS = drift; 
201 }
202
203 //__________________________________________________________
204 void AliHFEextraCuts::SetMinImpactParamR(Double_t impactParam){
205   SETBIT(fRequirements, kMinImpactParamR);
206   fImpactParamCut[0] = impactParam;
207 }
208
209 //__________________________________________________________
210 void AliHFEextraCuts::SetMaxImpactParamR(Double_t impactParam){
211   SETBIT(fRequirements, kMaxImpactParamR);
212   fImpactParamCut[2] = impactParam;
213 }
214
215 //__________________________________________________________
216 void AliHFEextraCuts::SetMinImpactParamZ(Double_t impactParam){
217   SETBIT(fRequirements, kMinImpactParamZ);
218   fImpactParamCut[1] = impactParam;
219 }
220
221 //__________________________________________________________
222 void AliHFEextraCuts::SetMaxImpactParamZ(Double_t impactParam){
223   SETBIT(fRequirements, kMaxImpactParamZ);
224   fImpactParamCut[3] = impactParam;
225 }
226
227 //__________________________________________________________
228 void AliHFEextraCuts::SetMinHFEImpactParamR(Float_t ipcutParam[4], Bool_t isSigmacut, Bool_t isabs){
229   if(isSigmacut) SETBIT(fRequirements, kMinHFEImpactParamNsigmaR);
230   else SETBIT(fRequirements, kMinHFEImpactParamR);
231   fIPcutParam[0]=ipcutParam[0];
232   fIPcutParam[1]=ipcutParam[1];
233   fIPcutParam[2]=ipcutParam[2];
234   fIPcutParam[3]=ipcutParam[3];
235   fAbsHFEImpactParamNsigmaR = isabs;
236 }
237
238 //__________________________________________________________
239 void AliHFEextraCuts::SetMinTrackletsTRD(Int_t minTracklets, Bool_t exact){
240   SETBIT(fRequirements, kMinTrackletsTRD);
241   fMinTrackletsTRD = minTracklets;
242   fTRDtrackletsExact = exact;
243 }
244
245 //__________________________________________________________
246 void AliHFEextraCuts::SetMinNClustersTPC(Int_t minClusters, ETPCclusterDef_t tpcdef){
247   SETBIT(fRequirements, kMinNClustersTPC);
248   SETBIT(fTPCclusterDef, tpcdef);
249   fMinNClustersTPC = minClusters;
250 }
251 #endif