Add fast merging option (Diego)
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectron.h
CommitLineData
b2a297fa 1#ifndef ALIDIELECTRON_H
2#define ALIDIELECTRON_H
3/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6//#####################################################
7//# #
8//# Class AliDielectron #
9//# Main Class for e+e- analysis #
10//# #
11//# by WooJin J. Park, GSI / W.J.Park@gsi.de #
12//# Ionut C. Arsene, GSI / I.C.Arsene@gsi.de #
13//# Magnus Mager, CERN / Magnus.Mager@cern.ch #
14//# Jens Wiechula, Uni HD / Jens.Wiechula@cern.ch #
15//# #
16//#####################################################
17
18
19#include <TNamed.h>
20#include <TObjArray.h>
21
22#include <AliAnalysisFilter.h>
23#include <AliKFParticle.h>
24
25#include "AliDielectronHistos.h"
b2a297fa 26
27class AliVEvent;
ba15fdfb 28class AliMCEvent;
b2a297fa 29class THashList;
30class AliDielectronCF;
572b0139 31class AliDielectronDebugTree;
2a14a7b1 32class AliDielectronTrackRotator;
ffbede40 33class AliDielectronPair;
ba15fdfb 34class AliDielectronSignalMC;
b2a297fa 35
36//________________________________________________________________
37class AliDielectron : public TNamed {
38
39public:
2a14a7b1 40 enum EPairType { kEv1PP=0, kEv1PM, kEv1MM,
41 kEv1PEv2P, kEv1MEv2P, kEv2PP,
42 kEv1PEv2M, kEv1MEv2M, kEv2PM,
43 kEv2MM, kEv1PMRot };
44 enum ELegType { kEv1P, kEv1M, kEv2P, kEv2M };
b2a297fa 45
46 AliDielectron();
47 AliDielectron(const char* name, const char* title);
48 virtual ~AliDielectron();
49
50 void Init();
51
52 void Process(AliVEvent *ev1, AliVEvent *ev2=0);
53
b2a297fa 54 const AliAnalysisFilter& GetEventFilter() const { return fEventFilter; }
55 const AliAnalysisFilter& GetTrackFilter() const { return fTrackFilter; }
56 const AliAnalysisFilter& GetPairFilter() const { return fPairFilter; }
57
61d106d3 58 AliAnalysisFilter& GetEventFilter() { return fEventFilter; }
59 AliAnalysisFilter& GetTrackFilter() { return fTrackFilter; }
60 AliAnalysisFilter& GetPairFilter() { return fPairFilter; }
61 AliAnalysisFilter& GetPairPreFilter() { return fPairPreFilter; }
62 AliAnalysisFilter& GetPairPreFilterLegs() { return fPairPreFilterLegs; }
63
8df8e382 64 void SetMotherPdg( Int_t pdgMother ) { fPdgMother=pdgMother; }
65 void SetLegPdg(Int_t pdgLeg1, Int_t pdgLeg2) { fPdgLeg1=pdgLeg1; fPdgLeg2=pdgLeg2; }
66 Int_t GetMotherPdg() const { return fPdgMother; }
67 Int_t GetLeg1Pdg() const { return fPdgLeg1; }
68 Int_t GetLeg2Pdg() const { return fPdgLeg2; }
554e40f8 69
70 void SetNoPairing(Bool_t noPairing=kTRUE) { fNoPairing=noPairing; }
b2a297fa 71 const TObjArray* GetTrackArray(Int_t i) const {return (i>=0&&i<4)?&fTracks[i]:0;}
72 const TObjArray* GetPairArray(Int_t i) const {return (i>=0&&i<10)?
73 static_cast<TObjArray*>(fPairCandidates->UncheckedAt(i)):0;}
74
75 TObjArray** GetPairArraysPointer() { return &fPairCandidates; }
76
77 void SetHistogramManager(AliDielectronHistos * const histos) { fHistos=histos; }
c8f0f810 78 AliDielectronHistos* GetHistoManager() const { return fHistos; }
b2a297fa 79 const THashList * GetHistogramList() const { return fHistos?fHistos->GetHistogramList():0x0; }
80
81 Bool_t HasCandidates() const { return GetPairArray(1)?GetPairArray(1)->GetEntriesFast()>0:0; }
fb7d2d99 82 Bool_t HasCandidatesLikeSign() const {
83 return (GetPairArray(0)&&GetPairArray(2)) ? (GetPairArray(0)->GetEntriesFast()>0 || GetPairArray(2)->GetEntriesFast()>0) : 0;
84 }
85
b2a297fa 86 void SetCFManagerPair(AliDielectronCF * const cf) { fCfManagerPair=cf; }
87 AliDielectronCF* GetCFManagerPair() const { return fCfManagerPair; }
572b0139 88
554e40f8 89 void SetPreFilterUnlikeOnly(Bool_t setValue=kTRUE){fPreFilterUnlikeOnly=setValue;};
ba15fdfb 90 void SetPreFilterAllSigns(Bool_t setValue=kTRUE){fPreFilterAllSigns=setValue;};
554e40f8 91
2a14a7b1 92 void SetTrackRotator(AliDielectronTrackRotator * const rot) { fTrackRotator=rot; }
93 AliDielectronTrackRotator* GetTrackRotator() const { return fTrackRotator; }
fb7d2d99 94
95 void SetHasMC(Bool_t hasMC) { fHasMC = hasMC; }
96 Bool_t GetHasMC() const { return fHasMC; }
ba15fdfb 97
98 void AddSignalMC(AliDielectronSignalMC* signal);
99
572b0139 100 void SetDebugTree(AliDielectronDebugTree * const tree) { fDebugTree=tree; }
c8f0f810 101
102 const TObjArray* GetMCSignals() const { return fSignalsMC; }
b2a297fa 103 static const char* TrackClassName(Int_t i) { return (i>=0&&i<4)?fgkTrackClassNames[i]:""; }
2a14a7b1 104 static const char* PairClassName(Int_t i) { return (i>=0&&i<11)?fgkPairClassNames[i]:""; }
572b0139 105
106 void SaveDebugTree();
b2a297fa 107
108private:
109
110
61d106d3 111 AliAnalysisFilter fEventFilter; // Event cuts
112 AliAnalysisFilter fTrackFilter; // leg cuts
113 AliAnalysisFilter fPairPreFilter; // pair prefilter cuts
114 AliAnalysisFilter fPairPreFilterLegs; // Leg filter after the pair prefilter cuts
115 AliAnalysisFilter fPairFilter; // pair cuts
b2a297fa 116
117 Int_t fPdgMother; // pdg code of mother tracks
8df8e382 118 Int_t fPdgLeg1; // pdg code leg1
119 Int_t fPdgLeg2; // pdg code leg2
554e40f8 120
ba15fdfb 121 TObjArray* fSignalsMC; // array of AliDielectronSignalMC
122
554e40f8 123 Bool_t fNoPairing; // if to skip pairing, can be used for track QA only
124
b2a297fa 125 AliDielectronHistos *fHistos; // Histogram manager
126 // Streaming and merging should be handled
127 // by the analysis framework
554e40f8 128
b2a297fa 129 TObjArray fTracks[4]; //! Selected track candidates
130 // 0: Event1, positive particles
131 // 1: Event1, negative particles
132 // 2: Event2, positive particles
133 // 3: Event2, negative particles
134
135 TObjArray *fPairCandidates; //! Pair candidate arrays
136 //TODO: better way to store it? TClonesArray?
137
138 AliDielectronCF *fCfManagerPair;//Correction Framework Manager for the Pair
2a14a7b1 139 AliDielectronTrackRotator *fTrackRotator; //Track rotator
572b0139 140 AliDielectronDebugTree *fDebugTree; // Debug tree output
554e40f8 141
142 Bool_t fPreFilterUnlikeOnly; //Apply PreFilter either in +- or to ++/--/+- individually
ba15fdfb 143 Bool_t fPreFilterAllSigns; //Apply PreFilter find in ++/--/+- and remove from all
fb7d2d99 144 Bool_t fHasMC; //If we run with MC, at the moment only needed in AOD
572b0139 145
b2a297fa 146 void FillTrackArrays(AliVEvent * const ev, Int_t eventNr=0);
61d106d3 147 void PairPreFilter(Int_t arr1, Int_t arr2, TObjArray &arrTracks1, TObjArray &arrTracks2);
b2a297fa 148 void FillPairArrays(Int_t arr1, Int_t arr2);
2a14a7b1 149 void FillPairArrayTR();
b2a297fa 150
151 Int_t GetPairIndex(Int_t arr1, Int_t arr2) const {return arr1>=arr2?arr1*(arr1+1)/2+arr2:arr2*(arr2+1)/2+arr1;}
152
153 void InitPairCandidateArrays();
154 void ClearArrays();
155
156 TObjArray* PairArray(Int_t i);
157
158 static const char* fgkTrackClassNames[4]; //Names for track arrays
2a14a7b1 159 static const char* fgkPairClassNames[11]; //Names for pair arrays
b2a297fa 160
161 void ProcessMC();
162
a655b716 163 void FillHistograms(const AliVEvent *ev);
ba15fdfb 164 void FillHistogramsMC(const AliMCEvent *ev);
ffbede40 165 void FillHistogramsPair(AliDielectronPair *pair,Bool_t fromPreFilter=kFALSE);
554e40f8 166 void FillHistogramsTracks(TObjArray **tracks);
167
572b0139 168 void FillDebugTree();
a655b716 169
b2a297fa 170 AliDielectron(const AliDielectron &c);
171 AliDielectron &operator=(const AliDielectron &c);
172
61d106d3 173 ClassDef(AliDielectron,4);
b2a297fa 174};
175
176inline void AliDielectron::InitPairCandidateArrays()
177{
178 //
179 // initialise all pair candidate arrays
180 //
181 fPairCandidates->SetOwner();
182 for (Int_t i=0;i<10;++i){
183 TObjArray *arr=new TObjArray;
184 fPairCandidates->AddAt(arr,i);
185 arr->SetOwner();
186 }
187}
188
189inline TObjArray* AliDielectron::PairArray(Int_t i)
190{
191 //
192 // for internal use only: unchecked return of track array for fast access
193 //
194 return static_cast<TObjArray*>(fPairCandidates->UncheckedAt(i));
195}
196
197inline void AliDielectron::ClearArrays()
198{
199 //
200 // Reset the Arrays
201 //
202 for (Int_t i=0;i<4;++i){
203 fTracks[i].Clear();
204 }
205 for (Int_t i=0;i<10;++i){
206 PairArray(i)->Delete();
207 }
208}
209
210#endif