Update hfe package
[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 SetMaxChi2TRD(Float_t maxchi2);
76     inline void SetMinNClustersTPC(Int_t minclusters, ETPCclusterDef_t def);
77     void SetMinNClustersTPCPID(Int_t minclusters) { SETBIT(fRequirements, kMinNClustersTPCPID); fMinNClustersTPCPID = minclusters; }
78     void SetTOFPID(Bool_t tofPid) { tofPid ? SETBIT(fRequirements, kTOFPID) : CLRBIT(fRequirements, kTOFPID); }
79     void SetTOFMISMATCH(Bool_t tofMismatch) { tofMismatch ? SETBIT(fRequirements, kTOFmismatch) : CLRBIT(fRequirements, kTOFmismatch); }
80     void SetTPCPIDCleanUp(Bool_t tpcPIDCleanUp) { tpcPIDCleanUp ? SETBIT(fRequirements, kTPCPIDCleanUp) : CLRBIT(fRequirements, kTPCPIDCleanUp); }
81     void SetMaxImpactParameterRpar(Bool_t maxImpactParameterRpar) { maxImpactParameterRpar ? SETBIT(fRequirements, kMaxImpactParameterRpar) : CLRBIT(fRequirements, kMaxImpactParameterRpar); }
82     void SetFractionOfTPCSharedClusters(Double_t fractionShared) { fFractionTPCShared= fractionShared; SETBIT(fRequirements, kTPCfractionShared); }
83     void SetMinNbITScls(UChar_t minNbITScls) { fMinNbITScls = minNbITScls; SETBIT(fRequirements, kMinNbITScls); }
84     void SetTOFsignalDxz(Double_t tofsignalDx,Double_t tofsignalDz) { fTOFsignalDx=tofsignalDx; fTOFsignalDz=tofsignalDz; SETBIT(fRequirements, kTOFsignalDxy); }
85     void SetRejectKinkDaughter() { SETBIT(fRequirements, kRejectKinkDaughter);}; 
86     void SetRejectKinkMother() { SETBIT(fRequirements, kRejectKinkMother);}; 
87     void SetCheckITSstatus(Bool_t check) { fCheck = check; };
88     void SetITSpatternCut() { SETBIT(fRequirements, kITSpattern); }
89     void SetDebugLevel(Int_t level) { fDebugLevel = level; };
90
91     Bool_t GetCheckITSstatus() const { return fCheck; };
92     Int_t GetDebugLevel() const { return fDebugLevel; };
93     void GetHFEImpactParameters(AliVTrack *track, Double_t &dcaxy, Double_t &dcansigmaxy); // temporary moved from protected to publich for IP QA 
94     void GetHFEImpactParameters(AliVTrack *track, Double_t dcaD[2], Double_t covD[3]);
95     Int_t GetITSstatus(const AliVTrack * const track, Int_t layer) const;
96     Bool_t CheckITSstatus(Int_t itsStatus) const;
97     Bool_t CheckITSpattern(const AliVTrack *const track) const;
98
99     void UnSetRejectKinkDaughter() { CLRBIT(fRequirements, kRejectKinkDaughter);}; 
100     void UnSetRejectKinkMother() { CLRBIT(fRequirements, kRejectKinkMother);}; 
101
102     
103   protected:
104     virtual void AddQAHistograms(TList *qaList);
105     Bool_t CheckRecCuts(AliVTrack *track);
106     Bool_t CheckMCCuts(AliVParticle * /*track*/) const;
107     void FillQAhistosRec(AliVTrack *track, UInt_t when);
108     //void FillQAhistosMC(AliMCParticle *track, UInt_t when);
109     void FillCutCorrelation(ULong64_t survivedCut);
110     void PrintBitMap(Int_t bitmap);
111     
112     // Getter Functions for ESD/AOD compatible mode
113     UInt_t GetTPCncls(AliVTrack *track);
114     Bool_t GetTPCCountSharedMapBitsAboveThreshold(AliVTrack *track);
115     Double_t GetTPCclusterRatio(AliVTrack *track);
116     void GetImpactParameters(AliVTrack *track, Float_t &radial, Float_t &z);
117     //void GetHFEImpactParameters(AliVTrack *track, Double_t &dcaxy, Double_t &dcansigmaxy);
118     void GetHFEImpactParameterCuts(AliVTrack *track, Double_t &hfeimpactRcut, Double_t &hfeimpactnsigmaRcut);
119     void GetMaxImpactParameterCutR(AliVTrack *track, Double_t &maximpactRcut);
120     void GetTOFsignalDxDz(AliVTrack *track, Double_t &tofsignalDx, Double_t &tofsignalDz);
121     Float_t GetTPCsharedClustersRatio(AliVTrack *track);
122     Float_t GetTRDchi(AliVTrack *track);
123     Int_t GetITSNbOfcls(AliVTrack *track);
124     Bool_t IsKinkDaughter(AliVTrack *track);
125     Bool_t IsKinkMother(AliVTrack *track);
126
127   private:
128     typedef enum{
129       kMinImpactParamR = 0,
130       kMaxImpactParamR = 1,
131       kMinImpactParamZ = 2,
132       kMaxImpactParamZ = 3,
133       kClusterRatioTPC = 4,
134       kMinTrackletsTRD = 5,
135       kPixelITS = 6,
136       kMinHFEImpactParamR = 7,
137       kMinHFEImpactParamNsigmaR = 8,
138       kMinNClustersTPC = 9,
139       kMinNClustersTPCPID = 10,
140       kTPCfractionShared = 11,
141       kTOFPID = 12,
142       kTOFmismatch = 13,
143       kTPCPIDCleanUp = 14,
144       kEMCALmatch = 15,
145       kMaxImpactParameterRpar = 16,
146       kMinNbITScls = 17,
147       kRejectKinkDaughter = 18,
148       kRejectKinkMother = 19,
149       kDriftITS = 20,
150       kTOFsignalDxy = 21,
151       kMaxTRDChi2 = 22,
152       kITSpattern = 23,
153       kNcuts = 24
154     } Cut_t;
155     enum{
156       //
157       // Common Constants
158       //
159       kBeforeCuts =0,
160       kAfterCuts = 1
161     };
162     static const Int_t fgkNQAhistos;   // Number of QA histos
163     AliVEvent *fEvent;                //! working event
164     ULong64_t fCutCorrelation;        // Cut Correlation
165     ULong64_t fRequirements;          // Cut Requirements
166     Float_t fImpactParamCut[4];       // Impact Parmameter Cut
167     Float_t fIPcutParam[4];           // Parmameter of impact parameter cut parametrization
168     UInt_t fMinNClustersTPC;          // Minimum TPC clusters cut
169     UInt_t fMinNClustersTPCPID;       // Minimum TPC PID clusters cut
170     Float_t fClusterRatioTPC;         // Ratio of findable vs. found clusters in TPC
171     UChar_t fMinTrackletsTRD;         // Min. Number of Tracklets inside TRD
172     Float_t fMaxChi2TRD;              // Max chi2 TRD
173     UChar_t fMinNbITScls;             // Min. Number of ITS clusters
174     Bool_t  fTRDtrackletsExact;       // Require exact number of tracklets
175     UChar_t fPixelITS;                // Cut on ITS Pixels
176     UChar_t fDriftITS;                // Cut on ITS Drift
177     UChar_t fTPCclusterDef;           // TPC cluster definition Bitmap
178     UChar_t fTPCclusterRatioDef;      // TPC cluster ratio definition Bitmap
179     Double_t  fFractionTPCShared;     // Cut on fraction of shared clusters
180     Bool_t fAbsHFEImpactParamNsigmaR; // flag to use abs ip cut
181     Double_t fTOFsignalDx;            // TOF signal dx
182     Double_t fTOFsignalDz;            // TOF signal dz
183
184     Bool_t  fCheck;                     // check
185     TList *fQAlist;                     //! Directory for QA histograms
186     Int_t   fDebugLevel;                // Debug Level
187   
188     ClassDef(AliHFEextraCuts, 5)      // Additional cuts implemented by the ALICE HFE group
189 };
190
191 //__________________________________________________________
192 void AliHFEextraCuts::SetClusterRatioTPC(Double_t ratio, ETPCclrDef_t def) {
193   SETBIT(fRequirements, kClusterRatioTPC);
194   SETBIT(fTPCclusterRatioDef, def);
195   fClusterRatioTPC = ratio; 
196 }
197
198 //__________________________________________________________
199 void AliHFEextraCuts::SetRequireITSpixel(ITSPixel_t pixel) {
200   SETBIT(fRequirements, kPixelITS);
201   fPixelITS = pixel; 
202 }
203
204 //__________________________________________________________
205 void AliHFEextraCuts::SetRequireITSdrift(ITSDrift_t drift) {
206   SETBIT(fRequirements, kDriftITS);
207   fDriftITS = drift; 
208 }
209
210 //__________________________________________________________
211 void AliHFEextraCuts::SetMinImpactParamR(Double_t impactParam){
212   SETBIT(fRequirements, kMinImpactParamR);
213   fImpactParamCut[0] = impactParam;
214 }
215
216 //__________________________________________________________
217 void AliHFEextraCuts::SetMaxImpactParamR(Double_t impactParam){
218   SETBIT(fRequirements, kMaxImpactParamR);
219   fImpactParamCut[2] = impactParam;
220 }
221
222 //__________________________________________________________
223 void AliHFEextraCuts::SetMinImpactParamZ(Double_t impactParam){
224   SETBIT(fRequirements, kMinImpactParamZ);
225   fImpactParamCut[1] = impactParam;
226 }
227
228 //__________________________________________________________
229 void AliHFEextraCuts::SetMaxImpactParamZ(Double_t impactParam){
230   SETBIT(fRequirements, kMaxImpactParamZ);
231   fImpactParamCut[3] = impactParam;
232 }
233
234 //__________________________________________________________
235 void AliHFEextraCuts::SetMinHFEImpactParamR(Float_t ipcutParam[4], Bool_t isSigmacut, Bool_t isabs){
236   if(isSigmacut) SETBIT(fRequirements, kMinHFEImpactParamNsigmaR);
237   else SETBIT(fRequirements, kMinHFEImpactParamR);
238   fIPcutParam[0]=ipcutParam[0];
239   fIPcutParam[1]=ipcutParam[1];
240   fIPcutParam[2]=ipcutParam[2];
241   fIPcutParam[3]=ipcutParam[3];
242   fAbsHFEImpactParamNsigmaR = isabs;
243 }
244
245 //__________________________________________________________
246 void AliHFEextraCuts::SetMinTrackletsTRD(Int_t minTracklets, Bool_t exact){
247   SETBIT(fRequirements, kMinTrackletsTRD);
248   fMinTrackletsTRD = minTracklets;
249   fTRDtrackletsExact = exact;
250 }
251
252 //__________________________________________________________
253 void AliHFEextraCuts::SetMaxChi2TRD(Float_t maxchi2){
254   SETBIT(fRequirements, kMaxTRDChi2);
255   fMaxChi2TRD = maxchi2;
256 }
257
258
259 //__________________________________________________________
260 void AliHFEextraCuts::SetMinNClustersTPC(Int_t minClusters, ETPCclusterDef_t tpcdef){
261   SETBIT(fRequirements, kMinNClustersTPC);
262   SETBIT(fTPCclusterDef, tpcdef);
263   fMinNClustersTPC = minClusters;
264 }
265 #endif