]>
Commit | Line | Data |
---|---|---|
48a61f36 | 1 | // Dihadron correlations task - simple task to read ESD or AOD input, |
2 | // calculate same- and mixed-event correlations, and fill THnSparse | |
3 | // output. -A. Adare, Apr 2011 | |
4 | ||
b3b66a56 | 5 | #include <TAxis.h> |
6 | #include <TCanvas.h> | |
7 | #include <TChain.h> | |
8 | #include <TFormula.h> | |
9 | #include <TH1.h> | |
10 | #include <TH2.h> | |
11 | #include <TH3.h> | |
12 | #include <THn.h> | |
13 | #include <TProfile2D.h> | |
14 | #include <TROOT.h> | |
15 | #include <TTree.h> | |
16 | #include "AliAnalysisUtils.h" | |
48a61f36 | 17 | #include "AliAODEvent.h" |
18 | #include "AliAODInputHandler.h" | |
19 | #include "AliAnalysisManager.h" | |
20 | #include "AliAnalysisTask.h" | |
21 | #include "AliCentrality.h" | |
22 | #include "AliDhcTask.h" | |
23 | #include "AliESDEvent.h" | |
24 | #include "AliESDInputHandler.h" | |
beb13b6c | 25 | #include "AliESDMuonTrack.h" |
b3b66a56 | 26 | #include "AliESDtrackCuts.h" |
8433ff41 | 27 | #include "AliPool.h" |
48a61f36 | 28 | #include "AliVParticle.h" |
29 | ||
c64cb1f6 | 30 | using std::cout; |
31 | using std::endl; | |
32 | ||
48a61f36 | 33 | ClassImp(AliDhcTask) |
34 | ||
beb13b6c | 35 | //________________________________________________________________________ |
36 | AliDhcTask::AliDhcTask() | |
37 | : AliAnalysisTaskSE(), fVerbosity(0), fEtaMax(1), fZVtxMax(10), fPtMin(0.25), fPtMax(15), | |
38 | fTrackDepth(1000), fPoolSize(200), fTracksName(), fDoWeights(kFALSE), fFillMuons(kFALSE), | |
d7149d30 | 39 | fPtTACrit(kTRUE), fAllTAHists(kFALSE), fMixInEtaT(kFALSE), |
b3b66a56 | 40 | fEtaTLo(-1.0), fEtaTHi(1.0), fEtaALo(-1.0), fEtaAHi(1.0), fOmitFirstEv(kTRUE), |
98880cdf | 41 | fDoFillSame(kFALSE), fDoMassCut(kFALSE), fClassName(), |
beb13b6c | 42 | fESD(0x0), fAOD(0x0), fOutputList(0x0), fHEvt(0x0), fHTrk(0x0), |
43 | fHPtAss(0x0), fHPtTrg(0x0), fHPtTrgEvt(0x0), | |
44 | fHPtTrgNorm1S(0x0), fHPtTrgNorm1M(0x0), fHPtTrgNorm2S(0x0), fHPtTrgNorm2M(0x0), | |
98880cdf | 45 | fHCent(0x0), fHZvtx(0x0), fNbins(0), fHSs(0x0), fHMs(0x0), fHPts(0x0), fHSMass(0x0), fHMMass(0x0), |
426408af | 46 | fHQAT(0x0), fHQAA(0x0), fHQATCorr(0x0), fHQAACorr(0x0), fHPtCentT(0x0), fHPtCentA(0x0), |
380fb711 | 47 | fIndex(0x0), |
beb13b6c | 48 | fCentrality(99), fZVertex(99), fEsdTPCOnly(0), fPoolMgr(0), |
49 | fCentMethod("V0M"), fNBdeta(20), fNBdphi(36), | |
50 | fBPtT(0x0), fBPtA(0x0), fBCent(0x0), fBZvtx(0x0), | |
51 | fMixBCent(0x0), fMixBZvtx(0x0), | |
b3b66a56 | 52 | fHEffT(0x0), fHEffA(0x0), fUtils(0x0) |
beb13b6c | 53 | { |
54 | ||
55 | } | |
56 | ||
48a61f36 | 57 | //________________________________________________________________________ |
eee08176 | 58 | AliDhcTask::AliDhcTask(const char *name, Bool_t def) |
42036329 | 59 | : AliAnalysisTaskSE(name), fVerbosity(0), fEtaMax(1), fZVtxMax(10), fPtMin(0.25), fPtMax(15), |
beb13b6c | 60 | fTrackDepth(1000), fPoolSize(200), fTracksName(), fDoWeights(kFALSE), fFillMuons(kFALSE), |
d7149d30 | 61 | fPtTACrit(kTRUE), fAllTAHists(kFALSE), fMixInEtaT(kFALSE), |
b3b66a56 | 62 | fEtaTLo(-1.0), fEtaTHi(1.0), fEtaALo(-1.0), fEtaAHi(1.0), fOmitFirstEv(kTRUE), |
98880cdf | 63 | fDoFillSame(kFALSE), fDoMassCut(kFALSE), fClassName(), |
beb13b6c | 64 | fESD(0x0), fAOD(0x0), fOutputList(0x0), fHEvt(0x0), fHTrk(0x0), |
65 | fHPtAss(0x0), fHPtTrg(0x0), fHPtTrgEvt(0x0), | |
66 | fHPtTrgNorm1S(0x0), fHPtTrgNorm1M(0x0), fHPtTrgNorm2S(0x0), fHPtTrgNorm2M(0x0), | |
98880cdf | 67 | fHCent(0x0), fHZvtx(0x0), fNbins(0), fHSs(0x0), fHMs(0x0), fHPts(0x0), fHSMass(0x0), fHMMass(0x0), |
426408af | 68 | fHQAT(0x0), fHQAA(0x0), fHQATCorr(0x0), fHQAACorr(0x0), fHPtCentT(0x0), fHPtCentA(0x0), |
380fb711 | 69 | fIndex(0x0), |
8a9d3e12 | 70 | fCentrality(99), fZVertex(99), fEsdTPCOnly(0), fPoolMgr(0), |
d688e049 | 71 | fCentMethod("V0M"), fNBdeta(20), fNBdphi(36), |
72 | fBPtT(0x0), fBPtA(0x0), fBCent(0x0), fBZvtx(0x0), | |
beb13b6c | 73 | fMixBCent(0x0), fMixBZvtx(0x0), |
b3b66a56 | 74 | fHEffT(0x0), fHEffA(0x0), fUtils(0x0) |
48a61f36 | 75 | { |
76 | // Constructor | |
77 | ||
78 | // Define input and output slots here | |
79 | // Input slot #0 works with a TChain | |
80 | DefineInput(0, TChain::Class()); | |
81 | // Output slot #0 id reserved by the base class for AOD | |
82 | // Output slot #1 writes into a TH1 container | |
83 | DefineOutput(1, TList::Class()); | |
84 | ||
48a61f36 | 85 | fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.,SPDVertex.,TPCVertex.,Tracks " |
86 | "AOD:header,tracks,vertices,"; | |
d688e049 | 87 | |
eee08176 | 88 | if (def) { |
89 | Double_t ptt[4] = {0.25, 1.0, 2.0, 15.0}; | |
90 | fBPtT = new TAxis(3,ptt); | |
91 | Double_t pta[4] = {0.25, 1.0, 2.0, 15.0}; | |
92 | fBPtA = new TAxis(3,pta); | |
93 | Double_t cent[2] = {-100.0, 100.0}; | |
94 | fBCent = new TAxis(1,cent); | |
95 | Double_t zvtx[2] = {-10, 10}; | |
96 | fBZvtx = new TAxis(1,zvtx); | |
97 | Double_t centmix[2] = {-100.0, 100.0}; | |
98 | fMixBCent = new TAxis(1,centmix); | |
99 | Double_t zvtxmix[9] = {-10,-6,-4,-2,0,2,4,6,10}; | |
100 | fMixBZvtx = new TAxis(8,zvtxmix); | |
101 | } | |
48a61f36 | 102 | } |
103 | ||
104 | //________________________________________________________________________ | |
105 | void AliDhcTask::UserCreateOutputObjects() | |
106 | { | |
107 | // Create histograms | |
108 | // Called once (per slave on PROOF!) | |
d7149d30 | 109 | PrintDhcSettings(); |
48a61f36 | 110 | |
48a61f36 | 111 | fOutputList = new TList(); |
112 | fOutputList->SetOwner(1); | |
113 | ||
b3b66a56 | 114 | fUtils = new AliAnalysisUtils(); |
48a61f36 | 115 | |
8433ff41 | 116 | BookHistos(); |
117 | InitEventMixer(); | |
48a61f36 | 118 | PostData(1, fOutputList); |
119 | } | |
120 | ||
d7149d30 | 121 | //________________________________________________________________________ |
122 | void AliDhcTask::PrintDhcSettings() | |
123 | { | |
124 | AliInfo(Form("Dhc Task %s settings",fName.Data())); | |
125 | AliInfo(Form(" centrality estimator %s", fCentMethod.Data())); | |
126 | AliInfo(Form(" using tracks named %s", fTracksName.Data())); | |
127 | AliInfo(Form(" efficiency correct triggers? %d", fHEffT!=0)); | |
e5da1e91 | 128 | if (fHEffT!=0) { |
129 | AliInfo(Form(" %d dimensions (t)", fHEffT->GetNdimensions())); | |
130 | } | |
d7149d30 | 131 | AliInfo(Form(" efficiency correct associates? %d", fHEffA!=0)); |
e5da1e91 | 132 | if (fHEffA!=0) { |
133 | AliInfo(Form(" %d dimensions (a)", fHEffA->GetNdimensions())); | |
134 | } | |
d7149d30 | 135 | AliInfo(Form(" fill muons? %d", fFillMuons)); |
136 | AliInfo(Form(" use pTT > pTA criterion? %d", fPtTACrit)); | |
137 | AliInfo(Form(" create all pTT, pTA hists? %d", fAllTAHists)); | |
138 | AliInfo(Form(" Mix in eta_T bins instead of z_vertex? %d", fMixInEtaT)); | |
139 | AliInfo(Form(" trigger eta range %f .. %f", fEtaTLo, fEtaTHi)); | |
140 | AliInfo(Form(" associate eta range %f .. %f", fEtaALo, fEtaAHi)); | |
98880cdf | 141 | AliInfo(Form(" fill same event in any case? %d", fDoFillSame)); |
b3b66a56 | 142 | AliInfo(Form(" do invariant mass cut? %d", fDoMassCut)); |
143 | AliInfo(Form(" omit first event? %d\n", fOmitFirstEv)); | |
d7149d30 | 144 | } |
145 | ||
48a61f36 | 146 | //________________________________________________________________________ |
147 | void AliDhcTask::BookHistos() | |
148 | { | |
8433ff41 | 149 | // Book histograms. |
150 | ||
d688e049 | 151 | if (fVerbosity > 1) { |
8a9d3e12 | 152 | AliInfo(Form("Number of pt(t) bins: %d", fBPtT->GetNbins())); |
153 | for (Int_t i=1; i<=fBPtT->GetNbins(); i++) { | |
154 | AliInfo(Form("pt(t) bin %d, %f to %f", i, fBPtT->GetBinLowEdge(i), fBPtT->GetBinUpEdge(i))); | |
155 | } | |
d688e049 | 156 | AliInfo(Form("Number of pt(a) bins: %d", fBPtA->GetNbins())); |
157 | for (Int_t i=1; i<=fBPtA->GetNbins(); i++) { | |
158 | AliInfo(Form("pt(a) bin %d, %f to %f", i, fBPtA->GetBinLowEdge(i), fBPtA->GetBinUpEdge(i))); | |
159 | } | |
160 | } | |
48a61f36 | 161 | |
d688e049 | 162 | Int_t nPtAssc=fBPtA->GetNbins(); |
163 | Int_t nPtTrig=fBPtT->GetNbins(); | |
164 | Int_t nCent=fBCent->GetNbins(); | |
165 | Int_t nZvtx=fBZvtx->GetNbins(); | |
166 | Double_t ptt[nPtTrig+1]; | |
167 | ptt[0] = fBPtT->GetBinLowEdge(1); | |
168 | for (Int_t i=1; i<=nPtTrig; i++) { | |
169 | ptt[i] = fBPtT->GetBinUpEdge(i); | |
170 | } | |
171 | Double_t pta[nPtAssc+1]; | |
172 | pta[0] = fBPtA->GetBinLowEdge(1); | |
173 | for (Int_t i=1; i<=nPtAssc; i++) { | |
174 | pta[i] = fBPtA->GetBinUpEdge(i); | |
175 | } | |
176 | Double_t cent[nCent+1]; | |
177 | cent[0] = fBCent->GetBinLowEdge(1); | |
178 | for (Int_t i=1; i<=nCent; i++) { | |
179 | cent[i] = fBCent->GetBinUpEdge(i); | |
180 | } | |
181 | Double_t zvtx[nZvtx+1]; | |
182 | zvtx[0] = fBZvtx->GetBinLowEdge(1); | |
183 | for (Int_t i=1; i<=nZvtx; i++) { | |
184 | zvtx[i] = fBZvtx->GetBinUpEdge(i); | |
185 | } | |
380fb711 | 186 | |
8a9d3e12 | 187 | fHEvt = new TH2F("fHEvt", "Event-level variables; Zvtx; Cent", nZvtx, zvtx, nCent, cent); |
8433ff41 | 188 | fOutputList->Add(fHEvt); |
380fb711 | 189 | fHTrk = new TH2F("fHTrk", "Track-level variables", |
190 | 100, 0, TMath::TwoPi(), 100, -fEtaMax, +fEtaMax); | |
8433ff41 | 191 | fOutputList->Add(fHTrk); |
192 | ||
8433ff41 | 193 | fHPtAss = new TH1F("fHPtAss","PtAssoc;P_{T} (GeV/c) [GeV/c]",nPtAssc,pta); |
194 | fOutputList->Add(fHPtAss); | |
195 | fHPtTrg = new TH1F("fHPtTrg","PtTrig;P_{T} (GeV/c) [GeV/c]",nPtTrig,ptt); | |
196 | fOutputList->Add(fHPtTrg); | |
beb13b6c | 197 | fHPtTrgEvt = new TH1F("fHPtTrgEvt","PtTrig;P_{T} (GeV/c) [GeV/c]",nPtTrig,ptt); |
198 | fHPtTrgNorm1S = new TH3F("fHPtTrgNorm1S","PtTrig;P_{T} (GeV/c) [GeV/c];centrality;z_{vtx}",nPtTrig,ptt,nCent,cent,nZvtx,zvtx); | |
199 | fOutputList->Add(fHPtTrgNorm1S); | |
200 | fHPtTrgNorm1M = (TH3*) fHPtTrgNorm1S->Clone("fHPtTrgNorm1M"); | |
201 | fOutputList->Add(fHPtTrgNorm1M); | |
202 | fHPtTrgNorm2S = (TH3*) fHPtTrgNorm1S->Clone("fHPtTrgNorm2S"); | |
203 | fOutputList->Add(fHPtTrgNorm2S); | |
204 | fHPtTrgNorm2M = (TH3*) fHPtTrgNorm1S->Clone("fHPtTrgNorm2M"); | |
205 | fOutputList->Add(fHPtTrgNorm2M); | |
380fb711 | 206 | |
8433ff41 | 207 | fHCent = new TH1F("fHCent","Cent;bins",nCent,cent); |
208 | fOutputList->Add(fHCent); | |
209 | fHZvtx = new TH1F("fHZvtx","Zvertex;bins",nZvtx,zvtx); | |
210 | fOutputList->Add(fHZvtx); | |
380fb711 | 211 | |
212 | fHQAT = new TH3F("fHQAT","QA trigger;p_{T} (GeV/c);#eta;#phi", | |
213 | 100,0.0,10.0, | |
214 | 40,fEtaTLo,fEtaTHi, | |
215 | 36,0.0,TMath::TwoPi()); | |
216 | fOutputList->Add(fHQAT); | |
380fb711 | 217 | fHQAA = new TH3F("fHQAA","QA associated;p_{T} (GeV/c);#eta;#phi", |
218 | 100,0.0,10.0, | |
219 | 40,fEtaALo,fEtaAHi, | |
220 | 36,0.0,TMath::TwoPi()); | |
221 | fOutputList->Add(fHQAA); | |
426408af | 222 | fHQATCorr = (TH3 *) fHQAT->Clone("fHQATCorr"); |
223 | fOutputList->Add(fHQATCorr); | |
224 | fHQAACorr = (TH3 *) fHQAA->Clone("fHQAACorr"); | |
225 | fOutputList->Add(fHQAACorr); | |
8433ff41 | 226 | |
d7149d30 | 227 | fHPtCentT = new TH2F("fHPtCentT",Form("trigger particles;p_{T} (GeV/c);centrality (%s)",fCentMethod.Data()), |
228 | 100,0.0,10.0, | |
229 | 100,cent[0],cent[nCent]); | |
230 | fOutputList->Add(fHPtCentT); | |
231 | fHPtCentA = new TH2F("fHPtCentA",Form("associated particles;p_{T} (GeV/c);centrality (%s)",fCentMethod.Data()), | |
232 | 100,0.0,10.0, | |
233 | 100,cent[0],cent[nCent]); | |
234 | fOutputList->Add(fHPtCentA); | |
235 | ||
98880cdf | 236 | fNbins = nPtTrig*nPtAssc*nCent*nZvtx; |
237 | fHSs = new TH2*[fNbins]; | |
238 | fHMs = new TH2*[fNbins]; | |
239 | fHPts = new TH1*[fNbins]; | |
240 | fHSMass = new TH1*[fNbins]; | |
241 | fHMMass = new TH1*[fNbins]; | |
242 | ||
8433ff41 | 243 | fIndex = new TFormula("GlobIndex","(t-1)*[0]*[1]*[2]+(z-1)*[0]*[1]+(x-1)*[0]+(y-1)+0*[4]"); |
244 | fIndex->SetParameters(nPtTrig,nPtAssc,nZvtx,nCent); | |
245 | fIndex->SetParNames("NTrigBins","NAssocBins", "NZvertexBins", "NCentBins"); | |
eee08176 | 246 | fOutputList->Add(fIndex); |
380fb711 | 247 | |
8433ff41 | 248 | Int_t count = 0; |
249 | for (Int_t c=1; c<=nCent; ++c) { | |
250 | for (Int_t z=1; z<=nZvtx; ++z) { | |
251 | for (Int_t t=1; t<=nPtTrig; ++t) { | |
380fb711 | 252 | for (Int_t a=1; a<=nPtAssc; ++a) { |
98880cdf | 253 | fHSs[count] = 0; |
254 | fHMs[count] = 0; | |
255 | fHPts[count] = 0; | |
256 | fHSMass[count] = 0; | |
257 | fHMMass[count] = 0; | |
e47b8f11 | 258 | if ((a>t)&&!fAllTAHists) { |
380fb711 | 259 | ++count; |
260 | continue; | |
261 | } | |
98880cdf | 262 | if (z==1 && t==1 && a==1) { |
263 | TString title(Form("cen=%d (%.1f to %.1f)", | |
264 | c, fBCent->GetBinLowEdge(c), fBCent->GetBinUpEdge(c))); | |
265 | fHSMass[count] = new TH1F(Form("hSMass%d",count), Form("Mass Same Event %s;m (GeV)",title.Data()), 10000, 0,10); | |
266 | fOutputList->Add(fHSMass[count]); | |
267 | fHMMass[count] = new TH1F(Form("hMMass%d",count), Form("Mass Mixed Event %s;m (GeV)",title.Data()), 10000, 0,10); | |
268 | fOutputList->Add(fHMMass[count]); | |
269 | } | |
8a9d3e12 | 270 | if (t==1 && a==1) { |
271 | TString title(Form("cen=%d (%.1f to %.1f), zVtx=%d (%.1f to %.1f)", | |
380fb711 | 272 | c, fBCent->GetBinLowEdge(c), fBCent->GetBinUpEdge(c), |
8a9d3e12 | 273 | z, fBZvtx->GetBinLowEdge(z), fBZvtx->GetBinUpEdge(z))); |
274 | fHPts[count] = new TH1F(Form("hPt%d",count), Form("Ptdist %s;p_{T} (GeV/c)",title.Data()), 200,0,20); | |
275 | fOutputList->Add(fHPts[count]); | |
276 | } | |
380fb711 | 277 | TString title(Form("cen=%d (%.1f to %.1f), zVtx=%d (%.1f to %.1f), trig=%d (%.1f to %.1f), assoc=%d (%.1f to %.1f)", |
278 | c, fBCent->GetBinLowEdge(c), fBCent->GetBinUpEdge(c), | |
8a9d3e12 | 279 | z, fBZvtx->GetBinLowEdge(z), fBZvtx->GetBinUpEdge(z), |
380fb711 | 280 | t, fBPtT->GetBinLowEdge(t), fBPtT->GetBinUpEdge(t), |
8a9d3e12 | 281 | a, fBPtA->GetBinLowEdge(a), fBPtA->GetBinUpEdge(a))); |
380fb711 | 282 | fHSs[count] = new TH2F(Form("hS%d",count), Form("Signal %s;#Delta #varphi;#Delta #eta",title.Data()), |
283 | fNBdphi,-0.5*TMath::Pi(),1.5*TMath::Pi(),fNBdeta,-2*fEtaMax,2*fEtaMax); | |
284 | fHMs[count] = new TH2F(Form("hM%d",count), Form("Mixed %s;#Delta #varphi;#Delta #eta",title.Data()), | |
285 | fNBdphi,-0.5*TMath::Pi(),1.5*TMath::Pi(),fNBdeta,-2*fEtaMax,2*fEtaMax); | |
286 | fOutputList->Add(fHSs[count]); | |
287 | fOutputList->Add(fHMs[count]); | |
8a9d3e12 | 288 | Int_t tcount = (Int_t)fIndex->Eval(t,a,z,c); |
380fb711 | 289 | if (fVerbosity>5) |
290 | cout << count << " " << tcount << ": " << title << endl; | |
8a9d3e12 | 291 | if (count != tcount) |
292 | AliFatal(Form("Index mismatch: %d %d", count, tcount)); | |
380fb711 | 293 | ++count; |
294 | } | |
8433ff41 | 295 | } |
296 | } | |
297 | } | |
48a61f36 | 298 | } |
299 | ||
beb13b6c | 300 | //________________________________________________________________________ |
b422cf0d | 301 | void AliDhcTask::SetAnaMode(Int_t iAna) |
beb13b6c | 302 | { |
303 | if (iAna==kHH) { | |
304 | SetFillMuons(kFALSE); | |
f45f3950 | 305 | fEtaTLo = -1.6; |
306 | fEtaTHi = +1.6; | |
307 | fEtaALo = -1.6; | |
308 | fEtaAHi = +1.6; | |
beb13b6c | 309 | } else if (iAna==kMuH) { |
310 | SetFillMuons(kTRUE); | |
311 | fEtaTLo = -5.0; | |
f45f3950 | 312 | fEtaTHi = -2.0; |
313 | fEtaALo = -1.6; | |
314 | fEtaAHi = +1.6; | |
beb13b6c | 315 | } else if (iAna==kHMu) { |
316 | SetFillMuons(kTRUE); | |
f45f3950 | 317 | fEtaTLo = -1.6; |
318 | fEtaTHi = +1.6; | |
beb13b6c | 319 | fEtaALo = -5.0; |
f45f3950 | 320 | fEtaAHi = -2.0; |
beb13b6c | 321 | } else if (iAna==kMuMu) { |
322 | SetFillMuons(kTRUE); | |
323 | fEtaTLo = -5.0; | |
f45f3950 | 324 | fEtaTHi = -2.0; |
beb13b6c | 325 | fEtaALo = -5.0; |
f45f3950 | 326 | fEtaAHi = -2.0; |
beb13b6c | 327 | } else if (iAna==kPSide) { |
328 | SetFillMuons(kFALSE); | |
f45f3950 | 329 | fEtaTLo = -1.6; |
beb13b6c | 330 | fEtaTHi = -0.465; |
f45f3950 | 331 | fEtaALo = -1.6; |
332 | fEtaAHi = +1.6; | |
beb13b6c | 333 | } else if (iAna==kASide) { |
334 | SetFillMuons(kFALSE); | |
f45f3950 | 335 | fEtaTLo = +0.465; |
336 | fEtaTHi = +1.6; | |
337 | fEtaALo = -1.6; | |
338 | fEtaAHi = +1.6; | |
beb13b6c | 339 | } else { |
340 | AliInfo(Form("Unrecognized analysis option: %d", iAna)); | |
341 | } | |
342 | } | |
343 | ||
48a61f36 | 344 | //________________________________________________________________________ |
345 | void AliDhcTask::InitEventMixer() | |
346 | { | |
347 | // The effective pool size in events is set by trackDepth, so more | |
348 | // low-mult events are required to maintain the threshold than | |
349 | // high-mult events. Centrality pools are indep. of data histogram | |
350 | // binning, no need to match. | |
351 | ||
48a61f36 | 352 | // Centrality pools |
d688e049 | 353 | Int_t nCentBins=fMixBCent->GetNbins(); |
354 | Double_t centBins[nCentBins+1]; | |
355 | centBins[0] = fMixBCent->GetBinLowEdge(1); | |
356 | for (Int_t i=1; i<=nCentBins; i++) { | |
357 | centBins[i] = fMixBCent->GetBinUpEdge(i); | |
358 | } | |
48a61f36 | 359 | |
360 | // Z-vertex pools | |
d688e049 | 361 | Int_t nZvtxBins=fMixBZvtx->GetNbins(); |
362 | Double_t zvtxbin[nZvtxBins+1]; | |
363 | zvtxbin[0] = fMixBZvtx->GetBinLowEdge(1); | |
364 | for (Int_t i=1; i<=nZvtxBins; i++) { | |
365 | zvtxbin[i] = fMixBZvtx->GetBinUpEdge(i); | |
366 | } | |
8433ff41 | 367 | |
368 | fPoolMgr = new AliEvtPoolManager(); | |
d688e049 | 369 | fPoolMgr->SetTargetTrackDepth(fTrackDepth); |
8433ff41 | 370 | if (fVerbosity>4) |
371 | fPoolMgr->SetDebug(1); | |
d688e049 | 372 | fPoolMgr->InitEventPools(fPoolSize, nCentBins, centBins, nZvtxBins, zvtxbin); |
48a61f36 | 373 | } |
374 | ||
375 | //________________________________________________________________________ | |
376 | void AliDhcTask::UserExec(Option_t *) | |
377 | { | |
378 | // Main loop, called for each event. | |
48a61f36 | 379 | |
380 | LoadBranches(); | |
381 | ||
b3b66a56 | 382 | if (fOmitFirstEv) { |
383 | if (fUtils->IsFirstEventInChunk(InputEvent())) | |
384 | return; | |
385 | } | |
386 | ||
48a61f36 | 387 | // Get event pointers, check for signs of life |
b3b66a56 | 388 | Int_t dType = -1; // Will be set to kESD or kAOD. |
48a61f36 | 389 | fESD = dynamic_cast<AliESDEvent*>(InputEvent()); |
390 | fAOD = dynamic_cast<AliAODEvent*>(InputEvent()); | |
391 | if (fESD) | |
392 | dType = kESD; | |
393 | else if (fAOD) | |
394 | dType = kAOD; | |
395 | else { | |
396 | AliError("Neither fESD nor fAOD available"); | |
397 | return; | |
398 | } | |
399 | ||
5a6df06d | 400 | if (fClassName.Length()>0) { |
401 | TString cls; | |
402 | if (fESD) | |
403 | cls = fESD->GetFiredTriggerClasses(); | |
404 | else | |
405 | cls = fAOD->GetFiredTriggerClasses(); | |
406 | if (!cls.Contains(fClassName)) | |
407 | return; | |
408 | } | |
409 | ||
d688e049 | 410 | Bool_t mcgen = 0; |
411 | if (fTracksName.Contains("Gen")) | |
412 | mcgen = 1; | |
413 | ||
48a61f36 | 414 | // Centrality, vertex, other event variables... |
d688e049 | 415 | if (mcgen) { |
416 | fZVertex = 0; | |
417 | TList *list = InputEvent()->GetList(); | |
beb13b6c | 418 | TClonesArray *tcaTracks = 0; |
419 | if (list) | |
420 | tcaTracks = dynamic_cast<TClonesArray*>(list->FindObject(fTracksName)); | |
d688e049 | 421 | if (tcaTracks) |
422 | fCentrality = tcaTracks->GetEntries(); | |
423 | } else { | |
424 | if (dType == kESD) { | |
b3b66a56 | 425 | const AliESDVertex* vertex = fESD->GetPrimaryVertex(); |
426 | fZVertex = vertex->GetZ(); | |
427 | if (!VertexOk()) { | |
d688e049 | 428 | if (fVerbosity > 1) |
429 | AliInfo(Form("Event REJECTED (ESD vertex not OK). z = %.1f", fZVertex)); | |
430 | return; | |
431 | } | |
d688e049 | 432 | if(fESD->GetCentrality()) { |
433 | fCentrality = | |
434 | fESD->GetCentrality()->GetCentralityPercentile(fCentMethod); | |
435 | } | |
eee08176 | 436 | } else if (dType == kAOD) { |
d688e049 | 437 | const AliAODVertex* vertex = fAOD->GetPrimaryVertex(); |
438 | fZVertex = vertex->GetZ(); | |
b3b66a56 | 439 | if (!VertexOk()) { |
d688e049 | 440 | if (fVerbosity > 1) |
441 | Info("Exec()", "Event REJECTED (AOD vertex not OK). z = %.1f", fZVertex); | |
442 | return; | |
443 | } | |
444 | const AliCentrality *aodCent = fAOD->GetHeader()->GetCentralityP(); | |
445 | if (aodCent) { | |
446 | fCentrality = aodCent->GetCentralityPercentile(fCentMethod); | |
447 | } | |
48a61f36 | 448 | } |
449 | } | |
d688e049 | 450 | |
eee08176 | 451 | // Fill event histogram |
48a61f36 | 452 | fHEvt->Fill(fZVertex, fCentrality); |
d688e049 | 453 | if (fCentrality > fBCent->GetXmax() || fCentrality < fBCent->GetXmin()) { |
9370528f | 454 | if (fVerbosity > 1) |
455 | AliInfo(Form("Event REJECTED (centrality out of range). fCentrality = %.1f", fCentrality)); | |
48a61f36 | 456 | return; |
457 | } | |
458 | ||
b3b66a56 | 459 | // Get pool containing tracks from other events like this one |
460 | AliEvtPool* pool = fPoolMgr->GetEventPool(fCentrality, fZVertex); | |
461 | if (!pool) { | |
462 | AliWarning(Form("No pool found. Centrality %f, ZVertex %f", | |
463 | fCentrality, fZVertex)); | |
464 | return; | |
465 | } | |
466 | ||
48a61f36 | 467 | // Get array of selected tracks |
b3b66a56 | 468 | MiniEvent* sTracks = new MiniEvent(0); // deleted by pool mgr. |
48a61f36 | 469 | if (dType == kESD) { |
f6701c6e | 470 | GetESDTracks(sTracks); |
eee08176 | 471 | } else if (dType == kAOD) { |
f6701c6e | 472 | GetAODTracks(sTracks); |
48a61f36 | 473 | } |
474 | ||
b3b66a56 | 475 | if (sTracks->size()==0) { |
476 | AliWarning(Form("Track array empty")); | |
477 | delete sTracks; | |
48a61f36 | 478 | return; |
479 | } | |
480 | ||
481 | if (!pool->IsReady()) { | |
482 | pool->UpdatePool(sTracks); | |
eee08176 | 483 | if (fDoFillSame) { // fill same event right away if requested |
484 | Correlate(*sTracks, *sTracks, kSameEvt); | |
485 | } | |
48a61f36 | 486 | return; |
487 | } | |
488 | ||
489 | if (pool->IsFirstReady()) { | |
490 | // recover events missed before the pool is ready | |
491 | Int_t nEvs = pool->GetCurrentNEvents(); | |
492 | if (nEvs>1) { | |
493 | for (Int_t i=0; i<nEvs; ++i) { | |
494 | MiniEvent* evI = pool->GetEvent(i); | |
495 | for (Int_t j=0; j<nEvs; ++j) { | |
496 | MiniEvent* evJ = pool->GetEvent(j); | |
eee08176 | 497 | if ((i==j) && !fDoFillSame) { |
498 | Correlate(*evI, *evJ, kSameEvt); | |
48a61f36 | 499 | } else { |
d688e049 | 500 | Correlate(*evI, *evJ, kDiffEvt); |
48a61f36 | 501 | } |
502 | } | |
503 | } | |
504 | } | |
505 | } else { /* standard case: same event, then mix*/ | |
506 | Correlate(*sTracks, *sTracks, kSameEvt); | |
507 | Int_t nMix = pool->GetCurrentNEvents(); | |
508 | for (Int_t jMix=0; jMix<nMix; ++jMix) { | |
509 | MiniEvent* bgTracks = pool->GetEvent(jMix); | |
d688e049 | 510 | Correlate(*sTracks, *bgTracks, kDiffEvt); |
48a61f36 | 511 | } |
512 | } | |
513 | ||
48a61f36 | 514 | pool->UpdatePool(sTracks); |
515 | PostData(1, fOutputList); | |
48a61f36 | 516 | } |
517 | ||
518 | //________________________________________________________________________ | |
f6701c6e | 519 | void AliDhcTask::GetESDTracks(MiniEvent* miniEvt) |
48a61f36 | 520 | { |
521 | // Loop twice: 1. Count sel. tracks. 2. Fill vector. | |
522 | ||
d688e049 | 523 | if (fTracksName.IsNull()) { |
524 | const AliESDVertex *vtxSPD = fESD->GetPrimaryVertexSPD(); | |
525 | if (!vtxSPD) | |
526 | return; | |
527 | ||
528 | Int_t nTrax = fESD->GetNumberOfTracks(); | |
529 | if (fVerbosity > 2) | |
530 | AliInfo(Form("%d tracks in event",nTrax)); | |
531 | ||
532 | // Loop 1. | |
533 | Int_t nSelTrax = 0; | |
534 | TObjArray arr(nTrax); | |
535 | arr.SetOwner(1); | |
536 | ||
b3b66a56 | 537 | if (!fEsdTPCOnly) { |
538 | fEsdTPCOnly = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); | |
539 | //fEsdTPCOnly->SetMinNClustersTPC(70); | |
540 | fEsdTPCOnly->SetMinNCrossedRowsTPC(70); | |
541 | fEsdTPCOnly->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8); | |
542 | } | |
543 | ||
d688e049 | 544 | for (Int_t i = 0; i < nTrax; ++i) { |
545 | AliESDtrack* esdtrack = fESD->GetTrack(i); | |
546 | if (!esdtrack) { | |
547 | AliError(Form("Couldn't get ESD track %d\n", i)); | |
548 | continue; | |
549 | } | |
8a9d3e12 | 550 | Bool_t trkOK = fEsdTPCOnly->AcceptTrack(esdtrack); |
d688e049 | 551 | if (!trkOK) |
552 | continue; | |
553 | Double_t pt = esdtrack->Pt(); | |
554 | Bool_t ptOK = pt >= fPtMin && pt < fPtMax; | |
555 | if (!ptOK) | |
556 | continue; | |
557 | Double_t eta = esdtrack->Eta(); | |
558 | if (TMath::Abs(eta) > fEtaMax) | |
559 | continue; | |
560 | ||
561 | // create a tpc only track | |
562 | AliESDtrack *newtrack = AliESDtrackCuts::GetTPCOnlyTrack(fESD,esdtrack->GetID()); | |
563 | if(!newtrack) | |
564 | continue; | |
565 | if (newtrack->Pt()<=0) { | |
566 | delete newtrack; | |
567 | continue; | |
568 | } | |
8433ff41 | 569 | |
d688e049 | 570 | AliExternalTrackParam exParam; |
571 | Bool_t relate = newtrack->RelateToVertexTPC(vtxSPD,fESD->GetMagneticField(),kVeryBig,&exParam); | |
572 | if (!relate) { | |
573 | delete newtrack; | |
574 | continue; | |
575 | } | |
8433ff41 | 576 | |
d688e049 | 577 | // set the constraint parameters to the track |
578 | newtrack->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance()); | |
8433ff41 | 579 | |
d688e049 | 580 | pt = newtrack->Pt(); |
581 | ptOK = pt >= fPtMin && pt < fPtMax; | |
582 | if (!ptOK) { | |
583 | delete newtrack; | |
584 | continue; | |
585 | } | |
586 | eta = esdtrack->Eta(); | |
587 | if (TMath::Abs(eta) > fEtaMax) { | |
588 | delete newtrack; | |
589 | continue; | |
590 | } | |
591 | arr.Add(newtrack); | |
592 | nSelTrax++; | |
8433ff41 | 593 | } |
beb13b6c | 594 | |
595 | for(Int_t itrack = 0; itrack < nSelTrax; itrack++) { | |
596 | AliVTrack *esdtrack = static_cast<AliESDtrack*>(arr.At(itrack)); | |
597 | if(!esdtrack) { | |
598 | AliError(Form("ERROR: Could not retrieve esdtrack %d",itrack)); | |
599 | continue; | |
600 | } | |
601 | Double_t pt = esdtrack->Pt(); | |
602 | Double_t eta = esdtrack->Eta(); | |
603 | Double_t phi = esdtrack->Phi(); | |
604 | Int_t sign = esdtrack->Charge() > 0 ? 1 : -1; | |
605 | miniEvt->push_back(AliMiniTrack(pt, eta, phi, sign)); | |
606 | } | |
b673a083 | 607 | } else { |
608 | TList *list = InputEvent()->GetList(); | |
609 | TClonesArray *tcaTracks = dynamic_cast<TClonesArray*>(list->FindObject(fTracksName)); | |
f018e7c8 | 610 | |
b673a083 | 611 | if(!tcaTracks){ |
612 | AliError("Ptr to tcaTracks zero"); | |
613 | return; | |
614 | } | |
f018e7c8 | 615 | |
b673a083 | 616 | const Int_t ntracks = tcaTracks->GetEntries(); |
617 | if (miniEvt) | |
618 | miniEvt->reserve(ntracks); | |
619 | else { | |
620 | AliError("Ptr to miniEvt zero"); | |
621 | return; | |
622 | } | |
48a61f36 | 623 | |
b673a083 | 624 | for (Int_t itrack = 0; itrack < ntracks; itrack++) { |
625 | AliVTrack *vtrack = static_cast<AliVTrack*>(tcaTracks->At(itrack)); | |
626 | if (!vtrack) { | |
627 | AliError(Form("ERROR: Could not retrieve track %d",itrack)); | |
628 | continue; | |
629 | } | |
630 | Double_t pt = vtrack->Pt(); | |
631 | Double_t eta = vtrack->Eta(); | |
632 | Double_t phi = vtrack->Phi(); | |
633 | Int_t sign = vtrack->Charge() > 0 ? 1 : -1; | |
634 | miniEvt->push_back(AliMiniTrack(pt, eta, phi, sign)); | |
48a61f36 | 635 | } |
48a61f36 | 636 | } |
beb13b6c | 637 | |
638 | if (fFillMuons) { | |
beb13b6c | 639 | // count good muons |
640 | Int_t nGoodMuons = 0; | |
641 | for (Int_t iMu = 0; iMu<fESD->GetNumberOfMuonTracks(); iMu++) { | |
642 | AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iMu); | |
b673a083 | 643 | if (muonTrack) { |
beb13b6c | 644 | if (IsGoodMUONtrack(*muonTrack)) nGoodMuons++; |
645 | } | |
646 | } | |
647 | miniEvt->reserve(miniEvt->size()+nGoodMuons); | |
648 | // fill them into the mini event | |
649 | for (Int_t iMu = 0; iMu<fESD->GetNumberOfMuonTracks(); iMu++) { | |
650 | AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iMu); | |
b673a083 | 651 | if (muonTrack) { |
652 | if (!IsGoodMUONtrack(*muonTrack)) | |
653 | continue; | |
654 | Double_t ptMu = muonTrack->Pt(); | |
655 | Double_t etaMu = muonTrack->Eta(); | |
656 | Double_t phiMu = muonTrack->Phi(); | |
b422cf0d | 657 | Int_t signMu = muonTrack->Charge() > 0 ? 1 : -1; |
beb13b6c | 658 | miniEvt->push_back(AliMiniTrack(ptMu, etaMu, phiMu, signMu)); |
659 | } | |
660 | } | |
661 | } | |
48a61f36 | 662 | } |
663 | ||
664 | //________________________________________________________________________ | |
f6701c6e | 665 | void AliDhcTask::GetAODTracks(MiniEvent* miniEvt) |
48a61f36 | 666 | { |
667 | // Loop twice: 1. Count sel. tracks. 2. Fill vector. | |
668 | ||
b673a083 | 669 | if (fTracksName.IsNull()) { |
670 | Int_t nTrax = fAOD->GetNumberOfTracks(); | |
671 | Int_t nSelTrax = 0; | |
48a61f36 | 672 | |
b673a083 | 673 | if (fVerbosity > 2) |
674 | AliInfo(Form("%d tracks in event",nTrax)); | |
48a61f36 | 675 | |
b673a083 | 676 | // Loop 1. |
677 | for (Int_t i = 0; i < nTrax; ++i) { | |
678 | AliAODTrack* aodtrack = fAOD->GetTrack(i); | |
679 | if (!aodtrack) { | |
680 | AliError(Form("Couldn't get AOD track %d\n", i)); | |
681 | continue; | |
682 | } | |
683 | // See $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C | |
684 | UInt_t tpcOnly = 1 << 7; | |
685 | Bool_t trkOK = aodtrack->TestFilterBit(tpcOnly); | |
686 | if (!trkOK) | |
687 | continue; | |
688 | Double_t pt = aodtrack->Pt(); | |
689 | Bool_t ptOK = pt >= fPtMin && pt < fPtMax; | |
690 | if (!ptOK) | |
691 | continue; | |
692 | Double_t eta = aodtrack->Eta(); | |
693 | if (TMath::Abs(eta) > fEtaMax) | |
694 | continue; | |
695 | nSelTrax++; | |
48a61f36 | 696 | } |
48a61f36 | 697 | |
b673a083 | 698 | if (miniEvt) |
699 | miniEvt->reserve(nSelTrax); | |
700 | else { | |
701 | AliError("!miniEvt"); | |
702 | return; | |
48a61f36 | 703 | } |
b673a083 | 704 | |
705 | // Loop 2. | |
706 | for (Int_t i = 0; i < nTrax; ++i) { | |
707 | AliAODTrack* aodtrack = fAOD->GetTrack(i); | |
708 | if (!aodtrack) { | |
709 | AliError(Form("Couldn't get AOD track %d\n", i)); | |
710 | continue; | |
711 | } | |
48a61f36 | 712 | |
b673a083 | 713 | // See $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C |
714 | UInt_t tpcOnly = 1 << 7; | |
715 | Bool_t trkOK = aodtrack->TestFilterBit(tpcOnly); | |
716 | if (!trkOK) | |
717 | continue; | |
718 | Double_t pt = aodtrack->Pt(); | |
719 | Bool_t ptOK = pt >= fPtMin && pt < fPtMax; | |
720 | if (!ptOK) | |
721 | continue; | |
722 | Double_t eta = aodtrack->Eta(); | |
723 | if (TMath::Abs(eta) > fEtaMax) | |
724 | continue; | |
725 | ||
726 | Double_t phi = aodtrack->Phi(); | |
727 | Int_t sign = aodtrack->Charge() > 0 ? 1 : -1; | |
728 | miniEvt->push_back(AliMiniTrack(pt, eta, phi, sign)); | |
729 | } | |
730 | } else { | |
731 | TList *list = InputEvent()->GetList(); | |
732 | TClonesArray *tcaTracks = dynamic_cast<TClonesArray*>(list->FindObject(fTracksName)); | |
733 | ||
734 | if (!tcaTracks){ | |
735 | AliError("Ptr to tcaTracks zero"); | |
736 | return; | |
737 | } | |
738 | ||
739 | const Int_t ntracks = tcaTracks->GetEntries(); | |
740 | if (miniEvt) | |
741 | miniEvt->reserve(ntracks); | |
742 | else { | |
743 | AliError("Ptr to miniEvt zero"); | |
744 | return; | |
745 | } | |
746 | ||
747 | for (Int_t itrack = 0; itrack < ntracks; itrack++) { | |
748 | AliVTrack *vtrack = static_cast<AliVTrack*>(tcaTracks->At(itrack)); | |
749 | if (!vtrack) { | |
750 | AliError(Form("ERROR: Could not retrieve vtrack %d",itrack)); | |
751 | continue; | |
752 | } | |
753 | Double_t pt = vtrack->Pt(); | |
754 | Double_t eta = vtrack->Eta(); | |
f45f3950 | 755 | if (TMath::Abs(eta) > fEtaMax) |
756 | continue; | |
b673a083 | 757 | Double_t phi = vtrack->Phi(); |
758 | Int_t sign = vtrack->Charge() > 0 ? 1 : -1; | |
759 | miniEvt->push_back(AliMiniTrack(pt, eta, phi, sign)); | |
760 | } | |
761 | } | |
48a61f36 | 762 | |
b673a083 | 763 | if (fFillMuons) { |
764 | // count good muons | |
765 | Int_t nGoodMuons = 0; | |
766 | for (Int_t iMu = 0; iMu<fAOD->GetNumberOfTracks(); iMu++) { | |
767 | AliAODTrack* muonTrack = fAOD->GetTrack(iMu); | |
768 | if(muonTrack) { | |
769 | if (IsGoodMUONtrack(*muonTrack)) | |
770 | nGoodMuons++; | |
771 | } | |
772 | } | |
773 | miniEvt->reserve(miniEvt->size()+nGoodMuons); | |
774 | // fill them into the mini event | |
775 | for (Int_t iMu = 0; iMu<fAOD->GetNumberOfTracks(); iMu++) { | |
776 | AliAODTrack* muonTrack = fAOD->GetTrack(iMu); | |
777 | if (muonTrack) { | |
778 | if (!IsGoodMUONtrack(*muonTrack)) | |
779 | continue; | |
780 | Double_t ptMu = muonTrack->Pt(); | |
781 | Double_t etaMu = muonTrack->Eta(); | |
782 | Double_t phiMu = muonTrack->Phi(); | |
b422cf0d | 783 | Int_t signMu = muonTrack->Charge() > 0 ? 1 : -1; |
b673a083 | 784 | miniEvt->push_back(AliMiniTrack(ptMu, etaMu, phiMu, signMu)); |
785 | } | |
786 | } | |
48a61f36 | 787 | } |
48a61f36 | 788 | } |
789 | ||
790 | //________________________________________________________________________ | |
791 | Double_t AliDhcTask::DeltaPhi(Double_t phia, Double_t phib, | |
792 | Double_t rangeMin, Double_t rangeMax) const | |
793 | { | |
794 | Double_t dphi = -999; | |
795 | Double_t pi = TMath::Pi(); | |
796 | ||
797 | if (phia < 0) phia += 2*pi; | |
798 | else if (phia > 2*pi) phia -= 2*pi; | |
799 | if (phib < 0) phib += 2*pi; | |
800 | else if (phib > 2*pi) phib -= 2*pi; | |
801 | dphi = phib - phia; | |
802 | if (dphi < rangeMin) dphi += 2*pi; | |
803 | else if (dphi > rangeMax) dphi -= 2*pi; | |
804 | ||
805 | return dphi; | |
806 | } | |
807 | ||
808 | //________________________________________________________________________ | |
d688e049 | 809 | Int_t AliDhcTask::Correlate(const MiniEvent &evt1, const MiniEvent &evt2, Int_t pairing) |
48a61f36 | 810 | { |
811 | // Triggered angular correlations. If pairing is kSameEvt, particles | |
812 | // within evt1 are correlated. If kDiffEvt, correlate triggers from | |
813 | // evt1 with partners from evt2. | |
8433ff41 | 814 | |
815 | Int_t cbin = fHCent->FindBin(fCentrality); | |
816 | if (fHCent->IsBinOverflow(cbin) || | |
817 | fHCent->IsBinUnderflow(cbin)) | |
818 | return 0; | |
819 | ||
820 | Int_t zbin = fHZvtx->FindBin(fZVertex); | |
821 | if (fHZvtx->IsBinOverflow(zbin) || | |
822 | fHZvtx->IsBinUnderflow(zbin)) | |
823 | return 0; | |
824 | ||
48a61f36 | 825 | Int_t iMax = evt1.size(); |
826 | Int_t jMax = evt2.size(); | |
827 | ||
8433ff41 | 828 | TH2 **hist = fHMs; |
829 | if (pairing == kSameEvt) { | |
830 | hist = fHSs; | |
b673a083 | 831 | fHCent->Fill(fCentrality); |
832 | fHZvtx->Fill(fZVertex); | |
8433ff41 | 833 | } |
834 | ||
835 | Int_t nZvtx = fHZvtx->GetNbinsX(); | |
836 | Int_t nPtTrig = fHPtTrg->GetNbinsX(); | |
837 | Int_t nPtAssc = fHPtAss->GetNbinsX(); | |
838 | ||
839 | Int_t globIndex = (cbin-1)*nZvtx*nPtTrig*nPtAssc+(zbin-1)*nPtTrig*nPtAssc; | |
98880cdf | 840 | Int_t ptindex = (Int_t)fIndex->Eval(1,1,zbin,cbin); |
841 | Int_t mindex = (Int_t)fIndex->Eval(1,1,1,cbin); | |
48a61f36 | 842 | |
8a9d3e12 | 843 | |
beb13b6c | 844 | fHPtTrgEvt->Reset(); |
383b3bca | 845 | for (Int_t i=0; i<iMax; ++i) { |
846 | const AliMiniTrack &a(evt1.at(i)); | |
847 | Float_t pta = a.Pt(); | |
beb13b6c | 848 | fHPtTrgEvt->Fill(pta); |
383b3bca | 849 | if (pairing == kSameEvt) { |
8a9d3e12 | 850 | fHPts[ptindex]->Fill(pta); |
d688e049 | 851 | } |
852 | } | |
73a051c1 | 853 | |
beb13b6c | 854 | Bool_t bCountTrg; // only count the trigger if an associated particle is found |
48a61f36 | 855 | |
beb13b6c | 856 | for (Int_t i=0; i<iMax; ++i) { |
48a61f36 | 857 | // Trigger particles |
8433ff41 | 858 | const AliMiniTrack &a(evt1.at(i)); |
859 | ||
860 | Float_t pta = a.Pt(); | |
beb13b6c | 861 | Float_t etaa = a.Eta(); |
7e990b20 | 862 | Float_t phia = a.Phi(); |
e5da1e91 | 863 | Int_t sgna = a.Sign(); |
380fb711 | 864 | |
865 | // brief intermezzo in the trigger particle loop: do associated particle QA here in order to avoid double counting | |
866 | if (pairing == kSameEvt) { | |
867 | if (etaa>fEtaALo && etaa<fEtaAHi) { | |
868 | Int_t bbin = fHPtAss->FindBin(pta); | |
869 | if (!(fHPtAss->IsBinOverflow(bbin) || fHPtAss->IsBinUnderflow(bbin))) { | |
870 | fHQAA->Fill(pta,etaa,phia); // fill every associated particle once | |
426408af | 871 | Double_t aQAWght = 1.0; |
872 | if (fHEffA) { | |
873 | const Int_t nEffDimA = fHEffA->GetNdimensions(); | |
874 | Int_t effBinA[nEffDimA]; | |
875 | effBinA[0] = fHEffA->GetAxis(0)->FindBin(etaa); | |
876 | effBinA[1] = fHEffA->GetAxis(1)->FindBin(pta); | |
877 | effBinA[2] = fHEffA->GetAxis(2)->FindBin(fCentrality); | |
878 | effBinA[3] = fHEffA->GetAxis(3)->FindBin(fZVertex); | |
879 | if (nEffDimA>4) { | |
880 | effBinA[4] = fHEffA->GetAxis(4)->FindBin(phia); | |
881 | if (nEffDimA>5) { | |
882 | effBinA[5] = fHEffA->GetAxis(5)->FindBin(sgna); | |
883 | } | |
884 | } | |
885 | aQAWght = fHEffA->GetBinContent(effBinA); | |
886 | } | |
887 | fHQAACorr->Fill(pta,etaa,phia,aQAWght); // fill every associated particle once, this time weighted | |
d7149d30 | 888 | fHPtCentA->Fill(pta,fCentrality); |
380fb711 | 889 | } |
890 | } | |
891 | } | |
892 | ||
893 | // back to triggers | |
8433ff41 | 894 | Int_t abin = fHPtTrg->FindBin(pta); |
beb13b6c | 895 | if (fHPtTrg->IsBinOverflow(abin) || fHPtTrg->IsBinUnderflow(abin)) |
896 | continue; | |
897 | ||
898 | if (etaa<fEtaTLo || etaa>fEtaTHi) | |
8433ff41 | 899 | continue; |
48a61f36 | 900 | |
beb13b6c | 901 | // efficiency weighting |
beb13b6c | 902 | Double_t effWtT = 1.0; |
903 | if (fHEffT) { | |
904 | // trigger particle | |
7e990b20 | 905 | const Int_t nEffDimT = fHEffT->GetNdimensions(); |
906 | Int_t effBinT[nEffDimT]; | |
907 | effBinT[0] = fHEffT->GetAxis(0)->FindBin(etaa); | |
908 | effBinT[1] = fHEffT->GetAxis(1)->FindBin(pta); | |
909 | effBinT[2] = fHEffT->GetAxis(2)->FindBin(fCentrality); | |
910 | effBinT[3] = fHEffT->GetAxis(3)->FindBin(fZVertex); | |
911 | if (nEffDimT>4) { | |
912 | effBinT[4] = fHEffT->GetAxis(4)->FindBin(phia); | |
e5da1e91 | 913 | if (nEffDimT>5) { |
914 | effBinT[5] = fHEffT->GetAxis(5)->FindBin(sgna); | |
915 | } | |
7e990b20 | 916 | } |
917 | effWtT = fHEffT->GetBinContent(effBinT); | |
beb13b6c | 918 | } |
919 | ||
48a61f36 | 920 | if (pairing == kSameEvt) { |
7e990b20 | 921 | fHTrk->Fill(phia,etaa); |
380fb711 | 922 | fHQAT->Fill(pta,etaa,phia); |
426408af | 923 | fHQATCorr->Fill(pta,etaa,phia,effWtT); |
d7149d30 | 924 | fHPtCentT->Fill(pta,fCentrality); |
380fb711 | 925 | fHPtTrg->Fill(pta); |
beb13b6c | 926 | fHPtTrgNorm1S->Fill(pta,fCentrality,fZVertex,effWtT); |
927 | } else { | |
928 | fHPtTrgNorm1M->Fill(pta,fCentrality,fZVertex,effWtT); | |
48a61f36 | 929 | } |
beb13b6c | 930 | bCountTrg = kFALSE; |
48a61f36 | 931 | |
8433ff41 | 932 | for (Int_t j=0; j<jMax; ++j) { |
48a61f36 | 933 | // Associated particles |
934 | if (pairing == kSameEvt && i==j) | |
beb13b6c | 935 | continue; |
48a61f36 | 936 | |
8433ff41 | 937 | const AliMiniTrack &b(evt2.at(j)); |
48a61f36 | 938 | |
48a61f36 | 939 | Float_t ptb = b.Pt(); |
beb13b6c | 940 | Float_t etab = b.Eta(); |
7e990b20 | 941 | Float_t phib = b.Phi(); |
e5da1e91 | 942 | Int_t sgnb = b.Sign(); |
380fb711 | 943 | if (fPtTACrit&&(pta < ptb)) { |
b422cf0d | 944 | continue; |
945 | } | |
48a61f36 | 946 | |
73a051c1 | 947 | Int_t bbin = fHPtAss->FindBin(ptb); |
beb13b6c | 948 | if (fHPtAss->IsBinOverflow(bbin) || fHPtAss->IsBinUnderflow(bbin)) |
949 | continue; | |
950 | ||
951 | if (etab<fEtaALo || etab>fEtaAHi) | |
952 | continue; | |
8433ff41 | 953 | |
7e990b20 | 954 | Float_t dphi = DeltaPhi(phia, phib); |
beb13b6c | 955 | Float_t deta = etaa - etab; |
98880cdf | 956 | Float_t mass = 2*pta*ptb*(TMath::CosH(deta)-TMath::Cos(dphi)); |
e5da1e91 | 957 | Int_t q2 = sgna + sgnb; |
98880cdf | 958 | if ((q2==0) && fDoMassCut) { |
959 | if (mass>3.0 && mass<3.2) | |
960 | continue; | |
961 | if (mass>9.2&&mass<9.8) | |
962 | continue; | |
963 | } | |
48a61f36 | 964 | |
8433ff41 | 965 | Int_t index = globIndex+(abin-1)*nPtAssc+(bbin-1); |
8a9d3e12 | 966 | Double_t weight = 1.0; |
beb13b6c | 967 | // number of trigger weight event-by-event (CMS method) |
968 | if (fDoWeights) { | |
969 | Double_t nTrgs = fHPtTrgEvt->GetBinContent(abin); | |
970 | if (nTrgs==0.0) { | |
971 | AliError(Form("Trying to work with number of triggers weight = %f",nTrgs)); | |
972 | return 0; | |
973 | } | |
974 | weight *= 1./nTrgs; | |
975 | } | |
8a9d3e12 | 976 | |
beb13b6c | 977 | // efficiency weighting |
978 | if (fHEffT) { | |
979 | // trigger particle | |
980 | weight *= effWtT; | |
73a051c1 | 981 | } |
98880cdf | 982 | |
beb13b6c | 983 | if (fHEffA) { |
984 | // associated particle | |
7e990b20 | 985 | const Int_t nEffDimA = fHEffA->GetNdimensions(); |
986 | Int_t effBinA[nEffDimA]; | |
987 | effBinA[0] = fHEffA->GetAxis(0)->FindBin(etab); | |
988 | effBinA[1] = fHEffA->GetAxis(1)->FindBin(ptb); | |
989 | effBinA[2] = fHEffA->GetAxis(2)->FindBin(fCentrality); | |
990 | effBinA[3] = fHEffA->GetAxis(3)->FindBin(fZVertex); | |
991 | if (nEffDimA>4) { | |
992 | effBinA[4] = fHEffA->GetAxis(4)->FindBin(phib); | |
e5da1e91 | 993 | if (nEffDimA>5) { |
994 | effBinA[5] = fHEffA->GetAxis(5)->FindBin(sgnb); | |
995 | } | |
7e990b20 | 996 | } |
997 | weight *= fHEffA->GetBinContent(effBinA); | |
beb13b6c | 998 | } |
98880cdf | 999 | |
380fb711 | 1000 | if (hist[index]) { // check if this histogram exists, relevant in the fPtTACrit==kFALSE case |
1001 | hist[index]->Fill(dphi,deta,weight); | |
1002 | bCountTrg = kTRUE; | |
1003 | if (pairing == kSameEvt) { | |
1004 | fHPtAss->Fill(ptb); // fill every associated particle every time it is used | |
98880cdf | 1005 | if (q2==0) |
1006 | fHSMass[mindex]->Fill(mass); | |
1007 | } else { | |
1008 | if (q2==0) | |
1009 | fHMMass[mindex]->Fill(mass); | |
380fb711 | 1010 | } |
beb13b6c | 1011 | } |
1012 | } | |
1013 | if (bCountTrg) { | |
1014 | if (pairing == kSameEvt) { | |
1015 | fHPtTrgNorm2S->Fill(pta,fCentrality,fZVertex,effWtT); | |
1016 | } else { | |
1017 | fHPtTrgNorm2M->Fill(pta,fCentrality,fZVertex,effWtT); | |
8433ff41 | 1018 | } |
48a61f36 | 1019 | } |
1020 | } | |
1021 | ||
beb13b6c | 1022 | return 1; |
48a61f36 | 1023 | } |
1024 | ||
1025 | //________________________________________________________________________ | |
1026 | void AliDhcTask::Terminate(Option_t *) | |
1027 | { | |
1028 | // Draw result to the screen | |
1029 | // Called once at the end of the query | |
48a61f36 | 1030 | } |
1031 | ||
1032 | //________________________________________________________________________ | |
b3b66a56 | 1033 | Bool_t AliDhcTask::VertexOk() const |
48a61f36 | 1034 | { |
1035 | // Modified from AliAnalyseLeadingTrackUE::VertexSelection() | |
1036 | ||
1037 | Int_t nContributors = 0; | |
1038 | Double_t zVertex = 999; | |
1039 | TString name(""); | |
b3b66a56 | 1040 | |
1041 | Int_t runno = InputEvent()->GetRunNumber(); | |
1042 | if (runno>=176326 && runno<=197692) { // year 12 and 13 | |
1043 | if (!fUtils->IsVertexSelected2013pA(InputEvent())) | |
1044 | return 0; | |
1045 | } | |
1046 | ||
1047 | if (fESD) { | |
1048 | const AliESDVertex* vtx = fESD->GetPrimaryVertex(); | |
48a61f36 | 1049 | if (!vtx) |
1050 | return 0; | |
1051 | nContributors = vtx->GetNContributors(); | |
1052 | zVertex = vtx->GetZ(); | |
1053 | name = vtx->GetName(); | |
b3b66a56 | 1054 | } else { |
1055 | if (fAOD->GetNumberOfVertices() < 1) | |
48a61f36 | 1056 | return 0; |
b3b66a56 | 1057 | const AliAODVertex* vtx = fAOD->GetPrimaryVertex(); |
48a61f36 | 1058 | nContributors = vtx->GetNContributors(); |
1059 | zVertex = vtx->GetZ(); | |
1060 | name = vtx->GetName(); | |
1061 | } | |
1062 | ||
1063 | // Reject if TPC-only vertex | |
8433ff41 | 1064 | if (name.CompareTo("TPCVertex")==0) |
48a61f36 | 1065 | return kFALSE; |
1066 | ||
1067 | // Check # contributors and range... | |
1068 | if( nContributors < 1 || TMath::Abs(zVertex) > fZVtxMax ) { | |
1069 | return kFALSE; | |
1070 | } | |
1071 | ||
1072 | return kTRUE; | |
1073 | } | |
beb13b6c | 1074 | |
1075 | //________________________________________________________________________ | |
1076 | Bool_t AliDhcTask::IsGoodMUONtrack(AliESDMuonTrack &track) | |
1077 | { | |
b673a083 | 1078 | // Applying track cuts for MUON tracks |
1079 | ||
1080 | if (!track.ContainTrackerData()) | |
1081 | return kFALSE; | |
1082 | if (!track.ContainTriggerData()) | |
1083 | return kFALSE; | |
1084 | Double_t thetaTrackAbsEnd = TMath::ATan(track.GetRAtAbsorberEnd()/505.) * TMath::RadToDeg(); | |
1085 | if ((thetaTrackAbsEnd < 2.) || (thetaTrackAbsEnd > 10.)) | |
1086 | return kFALSE; | |
1087 | Double_t eta = track.Eta(); | |
1088 | if ((eta < -4.) || (eta > -2.5)) | |
1089 | return kFALSE; | |
1090 | if (track.GetMatchTrigger() < 0.5) | |
1091 | return kFALSE; | |
1092 | return kTRUE; | |
1093 | } | |
1094 | ||
1095 | //________________________________________________________________________ | |
1096 | Bool_t AliDhcTask::IsGoodMUONtrack(AliAODTrack &track) | |
1097 | { | |
1098 | // Applying track cuts for MUON tracks | |
1099 | ||
1100 | if (!track.IsMuonTrack()) | |
1101 | return kFALSE; | |
1102 | Double_t dThetaAbs = TMath::ATan(track.GetRAtAbsorberEnd()/505.)* TMath::RadToDeg(); | |
1103 | if ((dThetaAbs<2.) || (dThetaAbs>10.)) | |
1104 | return kFALSE; | |
1105 | Double_t dEta = track.Eta(); | |
3d3e51db | 1106 | if ((dEta<-4.) || (dEta>-2.5)) |
b673a083 | 1107 | return kFALSE; |
1108 | if (track.GetMatchTrigger()<0.5) | |
1109 | return kFALSE; | |
1110 | return kTRUE; | |
1111 | } | |
1112 | ||
1113 | //________________________________________________________________________ | |
1114 | AliDhcTask::~AliDhcTask() | |
1115 | { | |
1116 | //Destructor | |
1117 | if (fPoolMgr) | |
1118 | delete fPoolMgr; | |
beb13b6c | 1119 | } |