]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/CaloTrackCorrBase/AliCaloPID.h
Add cut on distance to bad channel and EMCal border for selected second local maxima...
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliCaloPID.h
1 #ifndef ALICALOPID_H
2 #define ALICALOPID_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice     */
5
6 //_________________________________________________________________________
7 // Class for PID selection with calorimeters
8 // The Output of the main method GetIdentifiedParticleType is a PDG number identifying the cluster, 
9 // being kPhoton, kElectron, kPi0 ... as defined in the header file
10 //   - GetIdentifiedParticleType(const AliVCluster * cluster) 
11 //      Assignes a PID tag to the cluster, right now there is the possibility to : use bayesian weights from reco, 
12 //      recalculate them (EMCAL) or use other procedures not used in reco.
13 //      In order to recalculate Bayesian, it is necessary to load the EMCALUtils library
14 //      and do SwitchOnBayesianRecalculation().
15 //      To change the PID parameters from Low to High like the ones by default, use the constructor 
16 //      AliCaloPID(flux)
17 //      where flux is AliCaloPID::kLow or AliCaloPID::kHigh
18 //      If it is necessary to change the parameters use the constructor 
19 //      AliCaloPID(AliEMCALPIDUtils *utils) and set the parameters before.
20
21 //   - GetGetIdentifiedParticleTypeFromBayesian(const Double_t * pid, const Float_t energy)
22 //      Reads the PID weights array of the ESDs and depending on its magnitude identifies the particle, 
23 //      executed when bayesian is ON by GetIdentifiedParticleType(const AliVCluster * cluster) 
24 //   - SetPIDBits: Simple PID, depending on the thresholds fLOCut fTOFCut and even the
25 //     result of the PID bayesian a different PID bit is set. 
26 //
27 //
28 //*-- Author: Gustavo Conesa (INFN-LNF)
29
30 // --- ROOT system ---
31 #include <TObject.h> 
32 class TString ;
33 class TLorentzVector ;
34 #include <TFormula.h>
35 class TList;
36 class TH2F ;
37
38 //--- AliRoot system ---
39 class AliVCluster;
40 class AliVCaloCells;
41 class AliAODPWG4Particle;
42 class AliEMCALPIDUtils;
43 class AliCalorimeterUtils;
44 class AliVEvent;
45
46 class AliCaloPID : public TObject {
47         
48  public: 
49   
50   AliCaloPID() ; // ctor
51   AliCaloPID(const Int_t particleFlux) ; // ctor, to be used when recalculating bayesian PID
52   AliCaloPID(const TNamed * emcalpid) ; // ctor, to be used when recalculating bayesian PID and need different parameters
53   virtual ~AliCaloPID() ;//virtual dtor
54         
55   enum PidType 
56   {
57     kPhoton         = 22,
58     kPi0            = 111,
59     kEta            = 221, 
60     kElectron       = 11, 
61     kEleCon         =-11, 
62     kNeutralHadron  = 2112, 
63     kChargedHadron  = 211, 
64     kNeutralUnknown = 130, 
65     kChargedUnknown = 321
66   };
67   
68   enum TagType {kPi0Decay, kEtaDecay, kOtherDecay, kConversion, kNoTag = -1};
69   
70   // Main methods
71   
72   TList *   GetCreateOutputObjects();
73
74   void      InitParameters();
75   
76   Bool_t    IsInPi0SplitAsymmetryRange(const Float_t energy, const Float_t asy,  const Int_t nlm);
77
78   Bool_t    IsInPi0SplitMassRange     (const Float_t energy, const Float_t mass, const Int_t nlm);
79   
80   Bool_t    IsInPi0M02Range           (const Float_t energy, const Float_t m02,  const Int_t nlm);
81   Bool_t    IsInEtaM02Range           (const Float_t energy, const Float_t m02,  const Int_t nlm);
82   Bool_t    IsInConM02Range           (const Float_t energy, const Float_t m02,  const Int_t nlm);
83   
84   
85   Int_t     GetIdentifiedParticleTypeFromBayesWeights(const Bool_t isEMCAL, const Double_t * pid, const Float_t energy) ;
86
87   Int_t     GetIdentifiedParticleTypeFromClusterSplitting(AliVCluster * cluster, AliVCaloCells* cells, 
88                                                           AliCalorimeterUtils * caloutils,
89                                                           Double_t vertex[3], 
90                                                           Int_t & nLocMax, Double_t & mass, Double_t & angle,
91                                                           TLorentzVector & l1  , TLorentzVector & l2,
92                                                           Int_t   & absId1,   Int_t   & absId2,
93                                                           Float_t & distbad1, Float_t & distbad2,
94                                                           Bool_t  & fidcut1,  Bool_t  & fidcut2  ) ;
95   
96   Int_t     GetIdentifiedParticleType(const AliVCluster * cluster) ;
97   
98   TString   GetPIDParametersList();
99   
100   Bool_t    IsTrackMatched(AliVCluster * cluster, AliCalorimeterUtils* cu, AliVEvent* event) const ;    
101   
102   void      SetPIDBits(AliVCluster * cluster, AliAODPWG4Particle *aodph, 
103                        AliCalorimeterUtils* cu, AliVEvent* event);
104   
105   void      Print(const Option_t * opt)const;
106   
107   void      PrintClusterPIDWeights(const Double_t * pid) const;
108   
109   //Check if cluster photon-like. Uses photon cluster parameterization in real pp data 
110   //Returns distance in sigmas. Recommended cut 2.5
111   Float_t TestPHOSDispersion(const Double_t pt, const Double_t m20, const Double_t m02) const ; 
112   //Checks distance to the closest track. Takes into account 
113   //non-perpendicular incidence of tracks.
114   Float_t TestPHOSChargedVeto(const Double_t dx,  const Double_t dz, const Double_t ptTrack, 
115                               const Int_t chargeTrack, const Double_t mf) const ;
116   
117   // Setters, getters
118   
119   void    SetDebug(Int_t deb)                  { fDebug = deb                 ; }
120   Int_t   GetDebug()                     const { return fDebug                ; }       
121
122   enum    eventType{kLow,kHigh};
123   void    SetLowParticleFlux()                 { fParticleFlux        = kLow  ; }
124   void    SetHighParticleFlux()                { fParticleFlux        = kHigh ; }  
125   // not really used, only for bayesian recalculation in EMCAL, but could be useful in future
126   
127   // Bayesian
128   
129   void    SwitchOnBayesian()                   { fUseBayesianWeights  = kTRUE ; }
130   void    SwitchOffBayesian()                  { fUseBayesianWeights  = kFALSE; }
131   void    SwitchOnBayesianRecalculation()      { fRecalculateBayesian = kTRUE ; fUseBayesianWeights  = kTRUE ;} // EMCAL
132   void    SwitchOffBayesianRecalculation()     { fRecalculateBayesian = kFALSE; } // EMCAL
133   
134   AliEMCALPIDUtils * GetEMCALPIDUtils() ; 
135   
136   //Weight getters
137   Float_t GetEMCALPhotonWeight()         const { return fEMCALPhotonWeight    ; }
138   Float_t GetEMCALPi0Weight()            const { return fEMCALPi0Weight       ; }
139   Float_t GetEMCALElectronWeight()       const { return fEMCALElectronWeight  ; }
140   Float_t GetEMCALChargeWeight()         const { return fEMCALChargeWeight    ; }
141   Float_t GetEMCALNeutralWeight()        const { return fEMCALNeutralWeight   ; }
142   Float_t GetPHOSPhotonWeight()          const { return fPHOSPhotonWeight     ; }
143   Float_t GetPHOSPi0Weight()             const { return fPHOSPi0Weight        ; }
144   Float_t GetPHOSElectronWeight()        const { return fPHOSElectronWeight   ; }
145   Float_t GetPHOSChargeWeight()          const { return fPHOSChargeWeight     ; }
146   Float_t GetPHOSNeutralWeight()         const { return fPHOSNeutralWeight    ; }
147   
148   Bool_t  IsPHOSPIDWeightFormulaOn()     const { return fPHOSWeightFormula    ; } 
149
150   TFormula * GetPHOSPhotonWeightFormula()      { 
151     if(!fPHOSPhotonWeightFormula) 
152       fPHOSPhotonWeightFormula = new TFormula("phos_photon_weight",
153                                               fPHOSPhotonWeightFormulaExpression);
154     return fPHOSPhotonWeightFormula                                           ; } 
155   
156   TFormula * GetPHOSPi0WeightFormula()         { 
157     if(!fPHOSPi0WeightFormula) 
158       fPHOSPi0WeightFormula = new TFormula("phos_pi0_weight",
159                                            fPHOSPi0WeightFormulaExpression);
160     return fPHOSPi0WeightFormula                                              ; } 
161   
162   TString  GetPHOSPhotonWeightFormulaExpression() const { return fPHOSPhotonWeightFormulaExpression ; } 
163   TString  GetPHOSPi0WeightFormulaExpression()    const { return fPHOSPi0WeightFormulaExpression    ; } 
164   
165   //Weight setters
166   void    SetEMCALPhotonWeight  (Float_t  w)   { fEMCALPhotonWeight   = w     ; }
167   void    SetEMCALPi0Weight     (Float_t  w)   { fEMCALPi0Weight      = w     ; }
168   void    SetEMCALElectronWeight(Float_t  w)   { fEMCALElectronWeight = w     ; }
169   void    SetEMCALChargeWeight  (Float_t  w)   { fEMCALChargeWeight   = w     ; }
170   void    SetEMCALNeutralWeight (Float_t  w)   { fEMCALNeutralWeight  = w     ; }
171   void    SetPHOSPhotonWeight   (Float_t  w)   { fPHOSPhotonWeight    = w     ; }
172   void    SetPHOSPi0Weight      (Float_t  w)   { fPHOSPi0Weight       = w     ; }
173   void    SetPHOSElectronWeight (Float_t  w)   { fPHOSElectronWeight  = w     ; }
174   void    SetPHOSChargeWeight   (Float_t  w)   { fPHOSChargeWeight    = w     ; }
175   void    SetPHOSNeutralWeight  (Float_t  w)   { fPHOSNeutralWeight   = w     ; }
176   
177   void    UsePHOSPIDWeightFormula   (Bool_t ok )           { fPHOSWeightFormula                 = ok ; } 
178   void    SetPHOSPhotonWeightFormulaExpression(TString ph) { fPHOSPhotonWeightFormulaExpression = ph ; } 
179   void    SetPHOSPi0WeightFormulaExpression   (TString pi) { fPHOSPi0WeightFormulaExpression    = pi ; }
180   
181   //PID cuts 
182   
183   void    SetEMCALLambda0CutMax(Float_t lcut ) { fEMCALL0CutMax     = lcut    ; }
184   Float_t GetEMCALLambda0CutMax()        const { return fEMCALL0CutMax        ; }   
185   
186   void    SetEMCALLambda0CutMin(Float_t lcut ) { fEMCALL0CutMin     = lcut    ; }
187   Float_t GetEMCALLambda0CutMin()        const { return fEMCALL0CutMin        ; }   
188   
189   void    SetEMCALDEtaCut(Float_t dcut )       { fEMCALDEtaCut      = dcut    ; }
190   Float_t GetEMCALDEtaCut()              const { return fEMCALDEtaCut         ; }   
191   
192   void    SetEMCALDPhiCut(Float_t dcut )       { fEMCALDPhiCut      = dcut    ; }
193   Float_t GetEMCALDPhiCut()              const { return fEMCALDPhiCut         ; }   
194   
195   void    SetTOFCut(Float_t tcut )             { fTOFCut            = tcut    ; }
196   Float_t GetTOFCut()                    const { return fTOFCut               ; }   
197   
198   void    SetPHOSRCut(Float_t rcut )           { fPHOSRCut          = rcut    ; }
199   Float_t GetPHOSRCut()                  const { return fPHOSRCut             ; }   
200
201   void    SetPHOSDispersionCut(Float_t dcut )  { fPHOSDispersionCut = dcut    ; }
202   Float_t GetPHOSDispersionCut()         const { return fPHOSDispersionCut    ; }   
203   
204   // Cluster splitting analysis
205   
206   void    SwitchOnClusterSplittingPID()        { fDoClusterSplitting = kTRUE  ; }
207   void    SwitchOffClusterplittingPID()        { fDoClusterSplitting = kFALSE ; }
208   
209   void    SwitchOnSimpleSplitMassCut()         { fUseSimpleMassCut   = kTRUE  ; }
210   void    SwitchOffSimpleSplitMassCut()        { fUseSimpleMassCut   = kFALSE ; }
211
212   void    SwitchOnSimpleSplitM02Cut()          { fUseSimpleM02Cut    = kTRUE  ; }
213   void    SwitchOffSimpleSplitM02Cut()         { fUseSimpleM02Cut    = kFALSE ; }
214   
215   void    SwitchOnSplitAsymmetryCut()          { fUseSplitAsyCut     = kTRUE  ; }
216   void    SwitchOffSplitAsymmetryCut()         { fUseSplitAsyCut     = kFALSE ; }
217   
218   void    SwitchOnSplitShowerShapeCut()        { fUseSplitSSCut      = kTRUE  ; }
219   void    SwitchOffSplitShowerShapeCut()       { fUseSplitSSCut      = kFALSE ; }
220   
221   void    SetClusterSplittingM02Cut(Float_t min=0, Float_t max=100) 
222   { fSplitM02MinCut   = min ; fSplitM02MaxCut  = max ; }
223   
224   void    SetClusterSplittingMinNCells(Int_t cut)   { fSplitMinNCells = cut   ; }
225   
226   void    SetSplitEnergyFractionMinimum(Int_t i, Float_t min){ if (i < 3 && i >=0 ) fSplitEFracMin[i]  = min   ; }
227   Float_t GetSplitEnergyFractionMinimum(Int_t i) const       { if( i < 3 && i >=0 ) return fSplitEFracMin[i]   ;  else return 0 ; }
228   
229   Float_t GetPi0MinMass()                const { return fMassPi0Min           ; } // Simple cut case
230   Float_t GetEtaMinMass()                const { return fMassEtaMin           ; } // Simple cut case
231   Float_t GetPhotonMinMass()             const { return fMassPhoMin           ; }  
232   Float_t GetPi0MaxMass()                const { return fMassPi0Max           ; }
233   Float_t GetEtaMaxMass()                const { return fMassEtaMax           ; }
234   Float_t GetPhotonMaxMass()             const { return fMassPhoMax           ; }
235   
236   void    SetSplitWidthSigma(Float_t s)        { fSplitWidthSigma        = s  ; }
237   void    SetPi0MassWidthSelectionParameters    (Int_t iparam, Float_t param) { if(iparam < 7 ) fMassWidthPi0Param[iparam] = param ; }
238   void    SetM02MaximumSelectionParameters      (Int_t inlm, Int_t iparam, Float_t param)
239   { if(iparam < 6 && inlm < 2) fM02MaxParam[inlm][iparam] = param ; }
240   void    SetM02MinimumSelectionParameters      (Int_t inlm, Int_t iparam, Float_t param)
241   { if(iparam < 6 && inlm < 2) fM02MinParam[inlm][iparam] = param ; }
242   void    SetAsymmetryMinimumSelectionParameters(Int_t inlm, Int_t iparam, Float_t param)
243   { if(iparam < 6 && inlm < 2) fAsyMinParam[inlm][iparam] = param ; }
244
245   void    SetPi0MassRange(Float_t min, Float_t max)    { fMassPi0Min    = min ; fMassPi0Max = max ; } // Simple case
246   void    SetEtaMassRange(Float_t min, Float_t max)    { fMassEtaMin    = min ; fMassEtaMax = max ; }
247   void    SetPhotonMassRange(Float_t min, Float_t max) { fMassPhoMin    = min ; fMassPhoMax = max ; }
248     
249 private:
250   
251   Int_t     fDebug;                             // Debug level
252   Int_t     fParticleFlux;                      // Particle flux for setting PID parameters
253
254   // Bayesian
255   AliEMCALPIDUtils * fEMCALPIDUtils;            // Pointer to EMCALPID to redo the PID Bayesian calculation
256   Bool_t    fUseBayesianWeights;                // Select clusters based on weights calculated in reconstruction
257   Bool_t    fRecalculateBayesian;               // Recalculate PID bayesian or use simple PID?
258
259   Float_t   fEMCALPhotonWeight;                 // Bayesian PID weight for photons in EMCAL 
260   Float_t   fEMCALPi0Weight;                    // Bayesian PID weight for pi0 in EMCAL 
261   Float_t   fEMCALElectronWeight;               // Bayesian PID weight for electrons in EMCAL 
262   Float_t   fEMCALChargeWeight;                 // Bayesian PID weight for charged hadrons in EMCAL 
263   Float_t   fEMCALNeutralWeight;                // Bayesian PID weight for neutral hadrons in EMCAL 
264   Float_t   fPHOSPhotonWeight;                  // Bayesian PID weight for photons in PHOS 
265   Float_t   fPHOSPi0Weight;                     // Bayesian PID weight for pi0 in PHOS 
266   Float_t   fPHOSElectronWeight;                // Bayesian PID weight for electrons in PHOS 
267   Float_t   fPHOSChargeWeight;                  // Bayesian PID weight for charged hadrons in PHOS 
268   Float_t   fPHOSNeutralWeight;                 // Bayesian PID weight for neutral hadrons in PHOS 
269   
270   Bool_t    fPHOSWeightFormula ;                // Use parametrized weight threshold, function of energy
271   TFormula *fPHOSPhotonWeightFormula ;          // Formula for photon weight
272   TFormula *fPHOSPi0WeightFormula ;             // Formula for pi0 weight
273   TString   fPHOSPhotonWeightFormulaExpression; // Photon weight formula in string
274   TString   fPHOSPi0WeightFormulaExpression;    // Pi0 weight formula in string
275
276   // PID calculation
277   Float_t   fEMCALL0CutMax;                     // Max Cut on shower shape lambda0, used in PID evaluation, only EMCAL
278   Float_t   fEMCALL0CutMin;                     // Min Cut on shower shape lambda0, used in PID evaluation, only EMCAL
279   Float_t   fEMCALDEtaCut;                      // Track matching cut on Dz
280   Float_t   fEMCALDPhiCut;                      // Track matching cut on Dx
281
282   Float_t   fTOFCut;                            // Cut on TOF, used in PID evaluation
283   
284   Float_t   fPHOSDispersionCut;                 // Shower shape elipse radious cut
285   Float_t   fPHOSRCut;                          // Track-Cluster distance cut for track matching in PHOS  
286   
287   // Cluster splitting mass ranges
288   Bool_t    fDoClusterSplitting;                // Cluster splitting analysis
289   Bool_t    fUseSimpleMassCut;                  // Use simple min-max pi0 mass cut
290   Bool_t    fUseSimpleM02Cut;                   // Use simple min-max M02 cut
291   Bool_t    fUseSplitAsyCut ;                   // Remove splitted clusters with too large asymmetry
292   Bool_t    fUseSplitSSCut  ;                   // Remove splitted clusters out of shower shape band
293   Float_t   fSplitM02MaxCut ;                   // Study clusters with l0 smaller than cut
294   Float_t   fSplitM02MinCut ;                   // Study clusters with l0 larger than cut  // simple case
295   Int_t     fSplitMinNCells ;                   // Study clusters with ncells larger than cut  
296   Float_t   fMassEtaMin  ;                      // Min Eta mass
297   Float_t   fMassEtaMax  ;                      // Max Eta mass  
298   Float_t   fMassPi0Min  ;                      // Min Pi0 mass // simple cut case
299   Float_t   fMassPi0Max  ;                      // Min Pi0 mass // simple cut case
300   Float_t   fMassPhoMin  ;                      // Min Photon mass
301   Float_t   fMassPhoMax  ;                      // Min Photon mass
302   Float_t   fMassWidthPi0Param[7] ;             // 3 param for pol2 fit on width, 2 param for mass position NLM=1 and NLM>1 for pi0 selection
303   Float_t   fM02MinParam[2][6] ;                // 4 param for pol3 fit on M02 minimum for pi0 selection (maximum for conversions)
304   Float_t   fM02MaxParam[2][6] ;                // 4 param for pol3 fit on M02 maximum for pi0 selection
305   Float_t   fAsyMinParam[2][6] ;                // 4 param for pol3 fit on asymmetry minimum, for 2 cases, NLM=1 and NLM>=2
306   Float_t   fSplitEFracMin[3]  ;                // Do not use clusters with too large energy in cluster compared
307                                                 // to energy in splitted clusters, depeding on NLM
308   Float_t   fSplitWidthSigma;                   // Cut on mass+-width*fSplitWidthSigma
309
310
311   
312   AliCaloPID & operator = (const AliCaloPID & cpid) ; // cpy assignment
313   AliCaloPID(              const AliCaloPID & cpid) ; // cpy ctor
314   
315   ClassDef(AliCaloPID,18)
316   
317 } ;
318
319
320 #endif //ALICALOPID_H
321
322
323