]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TPC/AliTPCcalibResidualPID.h
Updates for the centralized automatic QA (Ionut)
[u/mrichter/AliRoot.git] / PWGPP / TPC / AliTPCcalibResidualPID.h
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: Yvonne Pachmayer <pachmay@physi.uni-heidelberg.de>             *
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 // The task:
17 // stores TPC PID quantities in a THnSparse
18 //
19 //  Author:
20 //  Yvonne Pachmayer <pachmay@physi.uni-heidelberg.de>
21 //
22
23 #ifndef ALITPCCALIBRESIDUALPID_H
24 #define ALITPCCALIBRESIDUALPID_H
25 #include "AliAnalysisTaskSE.h"
26
27 #include <TTreeStream.h>
28 #include "AliInputEventHandler.h"
29
30 class TArrayF;
31 template <class X>
32 class THnSparseT;
33 typedef class THnSparseT<TArrayF> THnSparseF;
34 class TFile;
35 class TGraphErrors;
36 class AliESDEvent;
37 class AliMCEvent;
38 class AliESDtrackCuts;
39 class AliPIDResponse;
40 class AliESD;
41 class AliAnalysisTask;
42 class AliESDInputHandler;
43 class AliESDv0KineCuts;
44 class AliAnalysisManager;
45 class AliCentrality;
46 class TTree;
47 class TSystem;
48 class TStyle;
49 class TROOT;
50 class Riostream;
51 class TChain;
52 class TH2;
53 class TF1;
54 class TH1;
55 class TObjArray;
56
57
58 class AliTPCcalibResidualPID : public AliAnalysisTaskSE {
59  public:
60   enum FitType { kAleph = 0, kLund = 1, kSaturatedLund = 2, kAlephWithAdditionalParam = 3 };
61   enum kParticle { kElectron = 0, kPion, kKaon, kProton };
62   AliTPCcalibResidualPID();
63   AliTPCcalibResidualPID(const char *name);
64   virtual ~AliTPCcalibResidualPID();
65   virtual void   UserCreateOutputObjects();
66   virtual void   UserExec(Option_t *);
67   virtual void   Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0);
68   virtual void   Terminate(const Option_t*);
69   Int_t          CompareFloat(Float_t f1=1, Float_t f2=0) const;
70   //setter
71   virtual void   SetESDtrackCuts(AliESDtrackCuts * trackCuts){fESDtrackCuts = trackCuts;};
72   virtual void   SetESDtrackCutsV0(AliESDtrackCuts * trackCutsV0){fESDtrackCutsV0 = trackCutsV0;};
73   virtual void   SetProduceTPCsignalTHnSparse(Int_t producetpcsignal){fProduceTPCSignalSparse = producetpcsignal;};
74   virtual void   SetProducePIDqa(Int_t produceGlobal){fProduceGlobal = produceGlobal;};
75   virtual void   SetProduceAllPadsPID(Int_t produceAllpadTypes){fProduceAllPadTypes = produceAllpadTypes;};
76   virtual void   SetProduceShortPadsPID(Int_t produceShortpads){fProduceShortPads = produceShortpads;};
77   virtual void   SetProduceMediumPadsPID(Int_t produceMediumpads){fProduceMediumPads = produceMediumpads;};
78   virtual void   SetProduceLongPadsPID(Int_t produceLongpads){fProduceLongPads = produceLongpads;};
79   virtual void   SetProduceOrocPID(Int_t produceOroc){fProduceOroc = produceOroc;};
80   
81   virtual Bool_t GetVertexIsOk(AliVEvent* event) const;
82   
83   virtual Bool_t GetUseTPCCutMIGeo() const { return fUseTPCCutMIGeo; };
84   virtual void SetUseTPCCutMIGeo(Bool_t newValue) { fUseTPCCutMIGeo = newValue; };
85   
86   virtual Bool_t GetIsPbpOrpPb() const { return fIsPbpOrpPb; };
87   virtual void SetIsPbpOrpPb(Bool_t newValue) { fIsPbpOrpPb = newValue; };
88   
89   Double_t GetZvtxCutEvent() const { return fZvtxCutEvent; };
90   virtual void SetZvtxCutEvent(Double_t newValue) { fZvtxCutEvent = newValue; };
91   
92   Bool_t GetCorrectdEdxEtaDependence() const { return fCorrectdEdxEtaDependence; };
93   virtual void SetCorrectdEdxEtaDependence(Bool_t flag) { fCorrectdEdxEtaDependence = flag; };
94   
95   Bool_t GetCorrectdEdxMultiplicityDependence() const { return fCorrectdEdxMultiplicityDependence; };
96   virtual void SetCorrectdEdxMultiplicityDependence(Bool_t flag) { fCorrectdEdxMultiplicityDependence = flag; };
97   
98   Bool_t GetCutOnProdRadiusForV0el() const { return fCutOnProdRadiusForV0el; };
99   virtual void SetCutOnProdRadiusForV0el(Bool_t flag) { fCutOnProdRadiusForV0el = flag; };
100   
101   virtual Char_t GetV0tag(Int_t trackIndex) const;
102
103   Bool_t GetUseMCinfo() const { return fUseMCinfo; };
104   virtual void SetUseMCinfo(Bool_t flag) { fUseMCinfo = flag; };
105   
106   Bool_t GetWriteAdditionalOutput() const { return fWriteAdditionalOutput; };
107   virtual void   SetWriteAdditionalOutput(Bool_t flag = kTRUE) { fWriteAdditionalOutput = flag; };
108
109   
110   virtual Int_t GetV0motherIndex(Int_t trackIndex) const;
111   virtual Int_t GetV0motherPDG(Int_t trackIndex) const;
112   
113   //
114   // static functions for postprocessing
115   //
116   static Double_t* ExtractResidualPID(THnSparseF * histPidQA,
117                                       const Bool_t useV0s = kTRUE,
118                                       const Char_t * outFile = "out.root",
119                                       const Char_t * type    = "MC",
120                                       const Char_t * period  = "LHC10H8",
121                                       const Char_t * pass    = "PASS1",
122                                       const Char_t * system  = "PBPB",
123                                       const Double_t * initialParameters = 0x0,
124                                       const Char_t * dedxtype= "",
125                                       FitType = kSaturatedLund);
126   static  TObjArray * GetResidualGraphs(THnSparseF * histPidQA, const Char_t * system, const Bool_t useV0s);
127   static  TObjArray * GetResidualGraphsMC(THnSparseF * histPidQA, const Char_t * system);
128   static  TObjArray * GetSeparation(THnSparseF * histPidQA, Int_t kParticle1, Int_t kParticle2);
129   static  TObjArray * GetResponseFunctions(TF1* parametrisation, TObjArray* inputGraphs, const Char_t * type, const Char_t * period, const Char_t * pass, const Char_t * system, const Char_t * dedxtype);
130   static  TF1*        FitBB(TObjArray* inputGraphs, Bool_t isMC, Bool_t isPPb, const Bool_t useV0s,
131                             const Double_t * initialParameters = 0x0, FitType = kSaturatedLund);
132   static Int_t MergeGraphErrors(TGraphErrors* mergedGraph, TCollection* li);
133   
134   static Double_t GetCutGeo() { return fgCutGeo; };
135   static Double_t GetCutNcr() { return fgCutNcr; };
136   static Double_t GetCutNcl() { return fgCutNcl; };
137   
138   static void SetCutGeo(Double_t value) { fgCutGeo = value; };
139   static void SetCutNcr(Double_t value) { fgCutNcr = value; };
140   static void SetCutNcl(Double_t value) { fgCutNcl = value; };
141   
142   static Bool_t TPCCutMIGeo(const AliVTrack* track, const AliVEvent* evt, TTreeStream* streamer = 0x0);
143   static Bool_t TPCCutMIGeo(const AliVTrack* track, const AliInputEventHandler* evtHandler, TTreeStream* streamer = 0x0)
144     { if (!evtHandler) return kFALSE; return TPCCutMIGeo(track, evtHandler->GetEvent(), streamer); };
145
146   protected:
147   static Double_t fgCutGeo;  // Cut variable for TPCCutMIGeo concerning geometry
148   static Double_t fgCutNcr;  // Cut variable for TPCCutMIGeo concerning num crossed rows
149   static Double_t fgCutNcl;  // Cut variable for TPCCutMIGeo concerning num clusters
150   
151   static Double_t Lund(Double_t* xx, Double_t* par);
152   static Double_t SaturatedLund(Double_t* xx, Double_t* par);
153   
154   void  BinLogAxis(const THnSparseF *h, Int_t axisNumber);
155
156   static void FitSlicesY(TH2 *hist, Double_t heightFractionForRange, Int_t cutThreshold, TString fitOption, TObjArray *arr);
157
158   void FillV0PIDlist(AliESDEvent* esdEvent = 0x0);
159   void ClearV0PIDlist();
160   
161   private:
162   //
163   //
164   AliESDEvent *fESD;                   //! ESD object
165   AliMCEvent  *fMC;                    //! MC object
166   TObjArray * fOutputContainer;        //! output data container
167   AliESDtrackCuts * fESDtrackCuts;     // basic cut variables for all non-V0 tracks
168   AliESDtrackCuts * fESDtrackCutsV0;   // basic cut variables for all V0 tracks
169   AliPIDResponse* fPIDResponse;        //! PID handling
170   //
171   
172   Short_t fNumEtaCorrReqErrorsIssued;  // Number of times the error about eta correction issues have been displayed
173   Short_t fNumMultCorrReqErrorsIssued; // Number of times the error about multiplicity correction issues have been displayed
174   
175   Bool_t fUseTPCCutMIGeo;   // Use geometrical cut for TPC 
176   
177   Bool_t fUseMCinfo;         // Use MC info, if available
178   
179   Bool_t fIsPbpOrpPb;      // Pbp/pPb collision or something else?
180   Double_t fZvtxCutEvent;  // Vertex z cut for the event (cm)
181   
182   AliESDv0KineCuts *fV0KineCuts;       //! ESD V0 kine cuts
183   Bool_t fCutOnProdRadiusForV0el;      // Cut on production radius for V0 electrons
184   Int_t fNumTagsStored;     // Number of entries of fV0tags
185   Char_t* fV0tags;         //! Pointer to array with tags for identified particles from V0 decays
186   Int_t* fV0motherIndex;   //! Pointer to array with index of the mother V0
187   Int_t* fV0motherPDG;     //! Pointer to array with pdg of the mother V0
188
189   Bool_t fProduceAllPadTypes, fProduceGlobal, fProduceShortPads, fProduceMediumPads, fProduceLongPads,fProduceOroc;
190   THnSparseF * fHistPidQA;             //! histogram for the QA of the PID
191   THnSparseF * fHistPidQAshort;        //! histogram for the QA of the PID short pads
192   THnSparseF * fHistPidQAmedium;       //! histogram for the QA of the PID med pads
193   THnSparseF * fHistPidQAlong;         //! histogram for the QA of the PID long pads
194   THnSparseF * fHistPidQAoroc;         //! histogram for the QA of the PID full oroc
195   //
196   Bool_t fProduceTPCSignalSparse;      //for setter
197   Bool_t fCorrectdEdxEtaDependence;    // Correct eta dependence for fHistPidQA (NOTE: Not done for the pad-specific THnSparses)
198   Bool_t fCorrectdEdxMultiplicityDependence; // Correct multiplicity dependence for fHistPidQA (NOTE: Not done for the pad-specific THnSparses)
199   THnSparseF * fThnspTpc;              //! thnsparse containing the data
200   //
201   //
202   
203   Bool_t fWriteAdditionalOutput; // Also fill histos/trees for QA etc. and write them
204   
205   // QA histos
206   TObjArray* fQAList;           //! Array with QA histos
207   TH1F* fhInvMassGamma;         //! Histogram with inv. mass of gamma
208   TH1F* fhInvMassK0s;           //! Histogram with inv. mass of K0s
209   TH1F* fhInvMassLambda;        //! Histogram with inv. mass of lambda
210   TH1F* fhInvMassAntiLambda;    //! Histogram with inv. mass of anti-lambda
211   
212   TH2F* fhArmenterosAll;        //! Histogram with armenteros plot for all V0s
213   TH2F* fhArmenterosGamma;      //! Histogram with armenteros plot for gamma
214   TH2F* fhArmenterosK0s;        //! Histogram with armenteros plot for K0s
215   TH2F* fhArmenterosLambda;     //! Histogram with armenteros plot for lambda
216   TH2F* fhArmenterosAntiLambda; //! Histogram with armenteros plot for anti-lambda
217   
218   // QA histos for shared clusters
219   THnSparseF* fHistSharedClusQAV0Pi;  //! Histogram with shared clusters QA for V0 pi
220   THnSparseF* fHistSharedClusQAV0Pr;  //! Histogram with shared clusters QA for V0 pr
221   THnSparseF* fHistSharedClusQAV0El;  //! Histogram with shared clusters QA for V0 el
222   
223   // TTree stuff for advanced studies (local track density, ...)
224   TTree* fTreeV0El;               //! Tree with V0 el and closest neighbour tracks and V0 sisters
225   TTree* fTreeV0Pi;               //! Tree with V0 pi and closest neighbour tracks and V0 sisters
226   TTree* fTreeV0Pr;               //! Tree with V0 pr and closest neighbour tracks and V0 sisters
227   Double_t fTree_dEdx_tr;         //! Tree: dEdx of track
228   Double_t fTree_dEdx_nb;         //! Tree: dEdx of neighbour
229   Double_t fTree_dEdx_vs;         //! Tree: dEdx of V0 sister
230   Double_t fTree_dEdxExpected_tr; //! Tree: dEdx_expected of track
231   Double_t fTree_p_TPC_tr;        //! Tree: TPC momentum of track
232   Double_t fTree_p_TPC_nb;        //! Tree: TPC momentum of neighbour
233   Double_t fTree_p_TPC_vs;        //! Tree: TPC momentum of V0 sister
234   Double_t fTree_BtimesChargeOverPt_tr; //! Tree: mag field times charge/pT of track
235   Double_t fTree_BtimesChargeOverPt_nb; //! Tree: mag field times charge/pT of neighbour
236   Double_t fTree_BtimesChargeOverPt_vs; //! Tree: mag field times charge/pT of V0 sister
237   Double_t fTree_tanTheta_tr;     //! Tree: tan(theta) of track
238   Double_t fTree_tanTheta_nb;     //! Tree: tan(theta) of neighbour
239   Double_t fTree_tanTheta_vs;     //! Tree: tan(theta) of V0 sister
240   Double_t fTree_distance_nb;     //! Tree: distance on TPC cylinder of track and neighbour
241   Double_t fTree_distance_vs;     //! Tree: distance on TPC cylinder of track and V0 sister
242   
243   AliTPCcalibResidualPID(const AliTPCcalibResidualPID&); // not implemented
244   AliTPCcalibResidualPID& operator=(const AliTPCcalibResidualPID&); // not implemented
245   
246   ClassDef(AliTPCcalibResidualPID, 5); 
247 };
248 #endif