changes from gsi. Using mult if no centrality. testfilterbit 128
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliAnalysisTaskGammaConversion.h
1 #ifndef ALIANALYSISTASKGAMMACONVERSION_H
2 #define ALIANALYSISTASKGAMMACONVERSION_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 ////////////////////////////////////////////////
8 //--------------------------------------------- 
9 // Class used to do analysis on conversion pairs
10 //---------------------------------------------
11 ////////////////////////////////////////////////
12
13 #include "AliAnalysisTaskSE.h"
14 #include <vector>
15 #include "AliV0Reader.h"
16 #include "AliGammaConversionBGHandler.h"
17 #include "TRandom3.h"
18 #include "TF1.h"
19 #include "TTreeStream.h"
20 #include "AliMultiplicity.h"
21 //#include "AliCFManager.h"  // for CF
22 //#include "AliCFContainer.h"   // for CF
23 #include "AliAODConversionMother.h"
24
25
26 class AliAODPWG4Particle;
27 class AliAODConversionPhoton;
28 class AliAODConversionMother;
29 class AliKFConversionPhoton;
30 class AliKFConversionMother;
31 class TNtuple;
32 class AliGammaConversionHistograms;
33 class AliESDv0;
34 class AliV0;
35 class AliKFParticle;
36 class AliKFVertex;
37 class AliESDInputHandler;
38 class AliESDEvent;
39 class AliAODEvent;
40 class AliMCEvent;
41 class TList;
42 class AliStack;
43 class AliESDtrackCuts;
44 class AliTriggerAnalysis;
45 class AliCFManager; // for CF
46 class AliCFContainer; // for CF
47 class TRandom3;
48 class TF1;
49
50 class AliAnalysisTaskGammaConversion : public AliAnalysisTaskSE
51 {
52         
53 public:
54         typedef enum { kProcSD, kProcDD, kProcND, kProcUnknown, kNProcs } ProcType_t; 
55         AliAnalysisTaskGammaConversion();
56         AliAnalysisTaskGammaConversion(const char* name);
57         virtual ~AliAnalysisTaskGammaConversion() ;// virtual destructor
58                         
59         // Implementation of interface methods
60         virtual void UserCreateOutputObjects();
61         virtual void Init();
62         virtual void LocalInit() {Init();}
63         virtual void UserExec(Option_t *option);
64         virtual void Terminate(Option_t *option);
65         //virtual void ConnectInputData(Option_t * option);
66         void CheckMesonProcessTypeEventQuality(Int_t evtQ);
67         Int_t GetProcessType(const AliMCEvent * mcEvt) ;
68         void ProcessMCData();
69         void ProcessV0sNoCut();
70         void ProcessV0s();
71         void ProcessGammasForNeutralMesonAnalysis();
72         void ProcessGammasForOmegaMesonAnalysis();
73     Bool_t DoEventSelection();
74     Bool_t CheckMCEvent();
75   //  void ProcessConvPHOSGammasForNeutralMesonAnalysis();
76         //  void RecalculateV0ForGamma();
77         // for CF
78         void SetCFManager(AliCFManager * const io) {fCFManager = io;};
79         AliCFManager *GetCFManager() const {return fCFManager;}
80                         
81                         
82         // AOD
83         TString GetAODBranchName() const {return  fAODBranchName;}
84         void SetAODBranchName(TString name)  {fAODBranchName = name ;}  
85         void SetForceAOD(Bool_t forceAOD ) { fKFForceAOD = forceAOD; }
86         void FillAODWithConversionGammas();
87         void AddGammaToAOD(AliKFConversionPhoton * kfParticle);
88     void PostAODEvent();
89         // void AddPionToAOD(AliKFConversionMother * kfParticle);
90         // void AddOmegaToAOD(AliKFParticle * kfParticle, Int_t daughter1, Int_t daughter2);
91         void TagDaughter(Int_t gammaIndex);
92
93         // end AOD
94                         
95         static Bool_t IsGoodImpPar(const AliESDtrack *const track);
96                 
97         // for GammaJetAnalysis
98         void ProcessGammasForGammaJetAnalysis();
99         void CreateListOfChargedParticles();
100         Double_t GetMinimumDistanceToCharge(Int_t indexHighestPtGamma);
101         void CalculateJetCone(Int_t gammaIndex);
102         Int_t GetIndexHighestPtGamma();
103         void SetESDtrackCuts();
104         // end of Gamma Jet
105                         
106         void SetMinPtForGammaJet(Double_t minPtForGammaJet){fMinPtForGammaJet=minPtForGammaJet;}
107         void SetMinIsoConeSize(Double_t minIsoConeSize){fMinIsoConeSize=minIsoConeSize;}
108         void SetMinPtIsoCone(Double_t minPtIsoCone){fMinPtIsoCone=minPtIsoCone;}
109         void SetMinPtGamChargedCorr(Double_t minPtGamChargedCorr){fMinPtGamChargedCorr=minPtGamChargedCorr;}
110         void SetMinPtJetCone(Double_t minPtJetCone){fMinPtJetCone=minPtJetCone;}
111
112         void SetLowPtMapping(Double_t lowPtMapping){fLowPtMapping=lowPtMapping;}
113         void SetHighPtMapping(Double_t highPtMapping){fHighPtMapping=highPtMapping;}
114
115                         
116         void SetHistograms(AliGammaConversionHistograms *const histograms){fHistograms=histograms;}
117         void SetTriggerCINT1B(Bool_t flag){fTriggerCINT1B=flag;}
118         void SetDoMCTruth(Bool_t flag){fDoMCTruth=flag;}
119         void SetDoNeutralMeson(Bool_t flag){fDoNeutralMeson=flag;}
120         void SetDoOmegaMeson(Bool_t flag){fDoOmegaMeson=flag;}
121         void SetDoNeutralMesonV0MCCheck(Bool_t flag){fDoNeutralMesonV0MCCheck=flag;}
122         void SetDoJet(Bool_t flag){fDoJet=flag;}
123         void SetDoChic(Bool_t flag){fDoChic=flag;}
124         void SetDoHadInt(Bool_t flag){fDoHadInt=flag;}
125         void SetRecalculateV0ForGamma(Bool_t flag){fRecalculateV0ForGamma=flag;}                
126
127         void SetElectronMass(Double_t electronMass){fElectronMass = electronMass;}
128         void SetGammaMass(Double_t gammaMass){fGammaMass = gammaMass;}
129         void SetGammaWidth(Double_t gammaWidth){fGammaWidth = gammaWidth;}
130         void SetPi0Mass(Double_t pi0Mass){fPi0Mass = pi0Mass;}
131         void SetPi0Width(Double_t pi0Width){fPi0Width = pi0Width;}
132         void SetEtaMass(Double_t etaMass){fEtaMass = etaMass;}
133         void SetEtaWidth(Double_t etaWidth){fEtaWidth = etaWidth;}
134         void SetMinOpeningAngleGhostCut(Double_t ghostCut){fMinOpeningAngleGhostCut = ghostCut;}
135         void SetV0Reader(AliV0Reader* const reader){fV0Reader=reader; fV0Reader->SetESDtrackCuts(fEsdTrackCuts);}
136         void SetCalculateBackground(Bool_t bg){fCalculateBackground=bg;}
137         void CalculateBackground();
138         void SetWriteNtuple(Bool_t writeNtuple){fWriteNtuple = writeNtuple;}
139         void FillNtuple();
140         Double_t GetMCOpeningAngle(const TParticle* const daughter0,const TParticle* const daughter1) const;
141         void CheckV0Efficiency();
142         void SetDeltaAODFileName(TString fn) { fKFDeltaAODFileName = fn; };
143     void SetCreateAOD(Bool_t doAod) { fKFCreateAOD = doAod; };
144     void SetExchangeAOD(Bool_t xchAOD) { fKFExchangeAOD = xchAOD; };
145         TString GetDeltaAODFileName() const { return fKFDeltaAODFileName; };
146         //////////////////Chi_c Analysis////////////////////////////
147         void GetPID(const AliESDtrack *track, Stat_t &pid, Stat_t &weight);     
148         double GetSigmaToVertex(const AliESDtrack* t);
149         void ElectronBackground(TString hBg, TClonesArray e);
150         void FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos);
151         void FillElectronInvMass(TString histoName, TClonesArray const negativeElectron, TClonesArray const positiveElectron);
152         void FillGammaElectronInvMass(TString histoMass,TString histoDiff, TClonesArray const fKFGammas, TClonesArray const tlVeNeg,TClonesArray const tlVePos);
153         void CleanWithAngleCuts(TClonesArray const negativeElectrons, TClonesArray const positiveElectrons, TClonesArray const gammas);
154         TClonesArray GetTLorentzVector(TClonesArray* esdTrack); 
155         void ProcessGammaElectronsForChicAnalysis();
156         void ProcessHadronicInteraction(AliESDEvent *event);
157         Bool_t CheckLooper(Int_t index, AliESDEvent *event);
158         Bool_t CheckV0(Int_t index, AliESDEvent *event);
159         ///////////////////////////////////////////////////////////////
160
161         void SetDoCF(Bool_t flag){fDoCF = flag;}
162
163         void SetUseChargedTracksMultiplicityForBG(Bool_t flag){fUseTrackMultiplicityForBG = flag;}              
164
165         void SetMoveParticleAccordingToVertex(Bool_t flag){fMoveParticleAccordingToVertex = flag;}
166
167         void MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex);
168
169         void SetApplyChi2Cut(Bool_t flag){fApplyChi2Cut = flag;}
170
171         void SetDoRotation(Bool_t flag){fDoRotation = flag;}
172
173         void SetPMDegreesBG(Int_t deg){fNDegreesPMBackground=deg;}
174
175         void SetNumberOfRotationsBG(Int_t nRot){fNRandomEventsForBG=nRot;}
176
177         void RotateKFParticle(AliKFParticle * kfParticle,Double_t angle);
178
179         void SetCheckBGProbability(Bool_t flag){fCheckBGProbability = flag;}
180
181         void SetRemovePileUp(Bool_t removePileUp) { fRemovePileUp = removePileUp; }
182
183         void SetSelectV0AND(Bool_t selectV0AND) { fSelectV0AND = selectV0AND; }
184         void SetUseMultiplicity(Int_t useMultiplicity) {fUseMultiplicity=useMultiplicity;}
185         void SetUseMultiplicityBin(Int_t useMultiplicityBin) {fUseMultiplicityBin=useMultiplicityBin;}
186         void SetUseHBTMultiplicity(Int_t useHBTMultiplicity) {fUseHBTMultiplicity=useHBTMultiplicity;}
187         void SetUseHBTMultiplicityBin(Int_t useHBTMultiplicityBin) {fUseHBTMultiplicityBin=useHBTMultiplicityBin;}
188
189         Int_t CalculateMultiplicityBin();
190         void SetUseCentrality(Int_t useCentrality) {fUseCentrality=useCentrality;}
191         void SetUseCentralityBin(Int_t useCentralityBin) {fUseCentralityBin=useCentralityBin;}
192
193         void SetMaxChi2HadIntCut(Float_t chi2HadInt){fMaxChi2HadInt = chi2HadInt; }
194         void SetMaxErr2DHadIntCut(Float_t err2DHadInt){fMaxErr2DHadInt =err2DHadInt ;}
195         void SetMinPtHadIntCut(Float_t ptMinHadInt){fPtMinHadInt =ptMinHadInt ;}
196         
197
198
199
200  private:
201         AliAnalysisTaskGammaConversion(const AliAnalysisTaskGammaConversion&); // Not implemented
202         AliAnalysisTaskGammaConversion& operator=(const AliAnalysisTaskGammaConversion&); // Not implemented
203   
204         TTreeSRedirector *fpcstream;
205                                 
206   // for CF
207  enum{
208                 kStepGenerated = 0,
209                 kStepReconstructable = 1, 
210                 kStepGetOnFly = 2,
211                 kStepLikeSign = 3,
212                 kStepTPCRefit = 4,
213                 kStepKinks = 5,
214                 kStepdEdxElectronSelection = 6,
215                 kStepdEdxPpionRejection = 7,
216                 kStepNContributors = 8,
217                 kStepTPCPID = 9,
218                 kStepR = 10,
219                 kStepLine = 11,
220                 kStepZ = 12,
221                 kStepMinClsTPC = 13,
222                 kStepSinglePt = 14,
223                 kStepNDF = 15,
224                 kStepChi2 = 16,
225                 kStepEta = 17,
226                 kStepPt = 18,
227                 kStepTrueGamma = 19
228         };
229         
230         AliV0Reader* fV0Reader; // The V0 reader object 
231                         
232         AliStack * fStack; // pointer to the MC particle stack
233         AliMCEventHandler *fMCTruth; // for CF   pointer to MCTruth
234         AliMCEvent *fGCMCEvent;  // for CF    pointer to the MC Event
235         AliESDEvent* fESDEvent; //pointer to the ESDEvent
236         TList * fOutputContainer; // Histogram container
237         AliCFManager *fCFManager;  // for CF
238         //  AliCFContainer *container;   // for CF
239
240                         
241                         
242         AliGammaConversionHistograms *fHistograms; // Pointer to the histogram handling class
243         Bool_t fTriggerCINT1B; //Flag to select trigger CINT1B
244         Bool_t fDoMCTruth; // Flag to switch on/off MC truth 
245         Bool_t fDoNeutralMeson; // flag
246         Bool_t fDoOmegaMeson; // flag
247         Bool_t fDoJet; // flag
248         Bool_t fDoChic; // flag
249         Bool_t fDoHadInt; // flag
250                 
251         Bool_t fRecalculateV0ForGamma;//flag
252                         
253         TClonesArray * fKFReconstructedGammasTClone; //! transient
254         TClonesArray * fKFReconstructedPi0sTClone; //! transient
255         TClonesArray * fKFRecalculatedGammasTClone; //! transient
256         TClonesArray * fCurrentEventPosElectronTClone; //! transient
257         TClonesArray * fCurrentEventNegElectronTClone; //! transient
258         TClonesArray * fKFReconstructedGammasCutTClone; //! transient
259         TClonesArray * fPreviousEventTLVNegElectronTClone; //! transient
260         TClonesArray * fPreviousEventTLVPosElectronTClone; //! transient
261                         
262         //  vector<AliKFParticle> fKFReconstructedGammas; // vector containing all reconstructed gammas
263                         
264         //  AliESDpid * fESDpid; // esd pid
265
266
267         ///////Chi_c Analysis///////////////////////////
268         //  vector<AliESDtrack*> fCurrentEventPosElectron;       // comment here
269         //  vector<AliESDtrack*> fCurrentEventNegElectron;       // comment here
270         //  vector<AliKFParticle> fKFReconstructedGammasCut;     // comment here
271         //  vector<TLorentzVector> fPreviousEventTLVNegElectron; // comment here
272         //  vector<TLorentzVector> fPreviousEventTLVPosElectron; // comment here
273         //////////////////////////////////////////////////      
274                         
275         //mass defines
276         Double_t fElectronMass; //electron mass
277         Double_t fGammaMass;    //gamma mass
278         Double_t fPi0Mass;      //pi0mass
279         Double_t fEtaMass;      //eta mass
280                         
281         // width defines
282         Double_t fGammaWidth; //gamma width cut
283         Double_t fPi0Width;   // pi0 width cut
284         Double_t fEtaWidth;   // eta width cut
285                         
286         Double_t fMinOpeningAngleGhostCut; // minimum angle cut
287                         
288         AliESDtrackCuts* fEsdTrackCuts;           // Object containing the parameters of the esd track cuts
289                         
290         Bool_t fCalculateBackground; //flag to set backgrount calculation on/off
291         Bool_t fWriteNtuple;         // flag to set if writing to ntuple on/off
292         TNtuple *fGammaNtuple;       // Ntuple for gamma values
293         TNtuple *fNeutralMesonNtuple;// NTuple for mesons
294                         
295         Int_t fTotalNumberOfAddedNtupleEntries; // number of added ntuple entries
296                         
297         TClonesArray* fChargedParticles;  //! transient
298         vector<Int_t> fChargedParticlesId;  //! transient
299                         
300         Double_t fGammaPtHighest;  //! transient
301         Double_t fMinPtForGammaJet;  //! transient
302         Double_t fMinIsoConeSize; //! transient
303         Double_t fMinPtIsoCone; //! transient
304         Double_t fMinPtGamChargedCorr; //! transient
305         Double_t fMinPtJetCone; //! transient
306         Int_t    fLeadingChargedIndex; //! transient
307         Double_t fLowPtMapping; //! transient
308         Double_t fHighPtMapping; //! transient
309         Bool_t fDoCF; //! transient
310                         
311         TClonesArray * fAODGamma; //TClonesArray for gammas to put in AOD
312         //TClonesArray * fAODPi0; //TTClonesArray for Pi0s to put in AOD
313         //TClonesArray * fAODOmega; //TTClonesArray for omegas to put in AOD
314         TString fAODBranchName; // New AOD branch name
315         Bool_t fKFCreateAOD; //Create the AOD tclones? (regardless if storing or not)
316         Bool_t fKFExchangeAOD; //Create the AOD tclones? (regardless if storing or not)
317         Bool_t fKFForceAOD;  //Set the Analysis Manager FillAOD variable to true every event
318         TString fKFDeltaAODFileName; //! File name for delta AOD (if any)
319         Bool_t fDoNeutralMesonV0MCCheck; //flag
320         Bool_t fUseTrackMultiplicityForBG; //flag
321         Bool_t fMoveParticleAccordingToVertex; //flag
322         Bool_t fApplyChi2Cut; //flag
323         Int_t fNRandomEventsForBG; //number of random events to use in rotation method
324         Int_t fNDegreesPMBackground; // number of degree window to rotate particles for rotation method
325         Bool_t fDoRotation; //flag
326         Bool_t fCheckBGProbability; //flag
327         //  vector<Int_t>fKFReconstructedGammasV0Index; // index of the reconstructed v0s
328         Bool_t fRemovePileUp;                 // Remove Pile Up
329         Bool_t fSelectV0AND;                 // Select V0AND
330         AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation
331         Int_t fMultiplicity;
332         Int_t fUseMultiplicity;
333         Int_t fUseMultiplicityBin;
334         Int_t fUseHBTMultiplicity;
335         Int_t fUseHBTMultiplicityBin;
336         Int_t fUseCentrality;
337         Int_t fUseCentralityBin;
338         TRandom3 fRandom;
339         Float_t fMaxChi2HadInt;         
340         Float_t fMaxErr2DHadInt;                
341         Float_t fPtMinHadInt;
342
343         ClassDef(AliAnalysisTaskGammaConversion, 22); // Analysis task for gamma conversions
344 };
345
346 #endif //ALIANALYSISTASKGAMMA_H