]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
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 | // | |
17 | // Base class for DStar - Hadron Correlations Analysis | |
18 | // | |
19 | //----------------------------------------------------------------------- | |
20 | // | |
21 | // | |
22 | // Author S.Bjelogrlic | |
23 | // Utrecht University | |
24 | // sandro.bjelogrlic@cern.ch | |
25 | // | |
26 | //----------------------------------------------------------------------- | |
27 | ||
28 | /* $Id$ */ | |
29 | ||
30 | #include <TDatabasePDG.h> | |
31 | #include <TParticle.h> | |
32 | #include <TVector3.h> | |
33 | #include <TChain.h> | |
34 | #include "TROOT.h" | |
35 | ||
36 | #include "AliAnalysisTaskDStarCorrelations.h" | |
37 | #include "AliRDHFCutsDStartoKpipi.h" | |
38 | #include "AliHFAssociatedTrackCuts.h" | |
39 | #include "AliAODRecoDecay.h" | |
40 | #include "AliAODRecoCascadeHF.h" | |
41 | #include "AliAODRecoDecayHF2Prong.h" | |
42 | #include "AliAODPidHF.h" | |
43 | #include "AliEventPoolManager.h" | |
44 | #include "AliVParticle.h" | |
45 | #include "AliAnalysisManager.h" | |
46 | #include "AliAODInputHandler.h" | |
47 | #include "AliAODHandler.h" | |
48 | #include "AliESDtrack.h" | |
49 | #include "AliAODMCParticle.h" | |
50 | #include "AliNormalizationCounter.h" | |
51 | #include "AliReducedParticle.h" | |
52 | ||
53 | ||
54 | ||
55 | ClassImp(AliAnalysisTaskDStarCorrelations) | |
56 | ||
57 | ||
58 | //__________________________________________________________________________ | |
59 | AliAnalysisTaskDStarCorrelations::AliAnalysisTaskDStarCorrelations() : | |
60 | AliAnalysisTaskSE(), | |
61 | fhandler(0x0), | |
62 | fPoolMgr(0x0), | |
63 | fmcArray(0x0), | |
64 | fCounter(0x0), | |
65 | fselect(0), | |
66 | fmontecarlo(kFALSE), | |
67 | fmixing(kFALSE), | |
68 | fEvents(0), | |
69 | fDebug(0), | |
70 | ||
71 | fOutput(0x0), | |
72 | fCuts(0), | |
73 | fCuts2(0) | |
74 | { | |
75 | // default constructor | |
76 | } | |
77 | ||
78 | //__________________________________________________________________________ | |
79 | AliAnalysisTaskDStarCorrelations::AliAnalysisTaskDStarCorrelations(const Char_t* name,AliRDHFCutsDStartoKpipi* cuts, AliHFAssociatedTrackCuts *AsscCuts) : | |
80 | AliAnalysisTaskSE(name), | |
81 | ||
82 | fhandler(0x0), | |
83 | fPoolMgr(0x0), | |
84 | fmcArray(0x0), | |
85 | fCounter(0x0), | |
86 | fselect(0), | |
87 | fmontecarlo(kFALSE), | |
88 | fmixing(kFALSE), | |
89 | fEvents(0), | |
90 | fDebug(0), | |
91 | ||
92 | fOutput(0x0), | |
93 | fCuts(0), | |
94 | fCuts2(AsscCuts) | |
95 | { | |
96 | fCuts=cuts; | |
97 | Info("AliAnalysisTaskDStarCorrelations","Calling Constructor"); | |
98 | DefineInput(0, TChain::Class()); | |
99 | DefineOutput(1,TList::Class()); // histos from data | |
100 | DefineOutput(2,AliRDHFCutsDStartoKpipi::Class()); // my cuts | |
101 | DefineOutput(3,AliNormalizationCounter::Class()); // normalization | |
102 | DefineOutput(4,AliHFAssociatedTrackCuts::Class()); // my cuts | |
103 | } | |
104 | ||
105 | //__________________________________________________________________________ | |
106 | ||
107 | AliAnalysisTaskDStarCorrelations::~AliAnalysisTaskDStarCorrelations() { | |
108 | // | |
109 | // destructor | |
110 | // | |
111 | ||
112 | Info("AliAnalysisTaskDStarCorrelations","Calling Destructor"); | |
113 | ||
114 | if(fhandler) {delete fhandler; fhandler = 0;} | |
115 | if(fPoolMgr) {delete fPoolMgr; fPoolMgr = 0;} | |
116 | if(fmcArray) {delete fmcArray; fmcArray = 0;} | |
117 | if(fCounter) {delete fCounter; fCounter = 0;} | |
118 | if(fOutput) {delete fOutput; fOutput = 0;} | |
119 | if(fCuts) {delete fCuts; fCuts = 0;} | |
120 | if(fCuts2) {delete fCuts2; fCuts2=0;} | |
121 | ||
122 | } | |
123 | ||
124 | //___________________________________________________________ | |
125 | void AliAnalysisTaskDStarCorrelations::Init(){ | |
126 | // | |
127 | // Initialization | |
128 | // | |
129 | if(fDebug > 1) printf("AliAnalysisTaskDStarCorrelations::Init() \n"); | |
130 | ||
131 | AliRDHFCutsDStartoKpipi* copyfCuts=new AliRDHFCutsDStartoKpipi(*fCuts); | |
132 | // Post the D* cuts | |
133 | PostData(2,copyfCuts); | |
134 | ||
135 | // Post the hadron cuts | |
136 | PostData(4,fCuts2); | |
137 | ||
138 | return; | |
139 | } | |
140 | ||
141 | ||
142 | //_________________________________________________ | |
143 | void AliAnalysisTaskDStarCorrelations::UserCreateOutputObjects(){ | |
144 | Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName()); | |
145 | ||
146 | //slot #1 | |
147 | //OpenFile(0); | |
148 | fOutput = new TList(); | |
149 | fOutput->SetOwner(); | |
150 | ||
151 | // define histograms | |
152 | DefineHistoForAnalysis(); | |
153 | ||
154 | fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(3)->GetContainer()->GetName())); | |
155 | fCounter->Init(); | |
156 | ||
157 | ||
158 | // definition of the Pool Manager for Event Mixing | |
159 | ||
160 | Int_t MaxNofEvents = 200; | |
161 | Int_t MinNofTracks = 1000; | |
162 | ||
163 | Int_t NofMultiplicityBins = 5; | |
164 | Double_t MBins[]={0,20,40,60,80,500}; | |
165 | Double_t * MultiplicityBins = MBins; | |
166 | ||
167 | Int_t NofZVrtxBins = 5; | |
168 | Double_t ZBins[]={-10,-5,-2.5,2.5,5,10}; | |
169 | Double_t *ZVrtxBins = ZBins; | |
170 | ||
171 | ||
172 | fPoolMgr = new AliEventPoolManager(MaxNofEvents, MinNofTracks, NofMultiplicityBins, MultiplicityBins, NofZVrtxBins, ZVrtxBins); | |
173 | ||
174 | ||
175 | } | |
176 | //_________________________________________________ | |
177 | void AliAnalysisTaskDStarCorrelations::UserExec(Option_t *){ | |
178 | ||
179 | cout << " " << endl; | |
180 | cout << "=================================================================================" << endl; | |
181 | ||
182 | if(fselect==1) cout << "TASK::Correlation with hadrons "<< endl; | |
183 | if(fselect==2) cout << "TASK::Correlation with kaons "<< endl; | |
184 | if(fselect==3) cout << "TASK::Correlation with kzeros "<< endl; | |
185 | ||
186 | if (!fInputEvent) { | |
187 | Error("UserExec","NO EVENT FOUND!"); | |
188 | return; | |
189 | } | |
190 | ||
191 | AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent); | |
192 | Double_t pi = TMath::Pi(); | |
193 | ||
194 | fEvents++; // event counter | |
195 | ((TH1D*)fOutput->FindObject("NofEvents"))->Fill(0); | |
196 | ||
197 | fmcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName())); | |
198 | ||
199 | // initialize the pool for event mixing | |
200 | Int_t multiplicity = aodEvent->GetNTracks(); | |
201 | AliAODVertex *vtx = aodEvent->GetPrimaryVertex(); | |
202 | Double_t zvertex = vtx->GetZ(); | |
203 | Double_t multip = multiplicity; | |
204 | ||
205 | if(TMath::Abs(zvertex)>=10 || multip>500 || multip == 0) { | |
206 | AliInfo(Form("Event with Zvertex = %.2f cm and multiplicity = %.0f out of pool bounds, SKIPPING",zvertex,multip)); | |
207 | return; | |
208 | } | |
209 | ||
210 | ||
211 | AliEventPool* pool = fPoolMgr->GetEventPool(multip, zvertex); | |
212 | if (!pool) AliFatal(Form("No pool found for multiplicity = %f, zVtx = %f cm", multip, zvertex)); | |
213 | ||
214 | ||
215 | ||
216 | // D* reconstruction | |
217 | ||
218 | TClonesArray *arrayDStartoD0pi=0; | |
219 | ||
220 | ||
221 | if(!aodEvent && AODEvent() && IsStandardAOD()) { | |
222 | // In case there is an AOD handler writing a standard AOD, use the AOD | |
223 | // event in memory rather than the input (ESD) event. | |
224 | aodEvent = dynamic_cast<AliAODEvent*> (AODEvent()); | |
225 | // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root) | |
226 | // have to taken from the AOD event hold by the AliAODExtension | |
227 | AliAODHandler* aodHandler = (AliAODHandler*) | |
228 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); | |
229 | if(aodHandler->GetExtensions()) { | |
230 | AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root"); | |
231 | AliAODEvent *aodFromExt = ext->GetAOD(); | |
232 | arrayDStartoD0pi=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar"); | |
233 | } | |
234 | } else { | |
235 | arrayDStartoD0pi=(TClonesArray*)aodEvent->GetList()->FindObject("Dstar"); | |
236 | } | |
237 | ||
238 | if(!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField())<0.001) return; | |
239 | ||
240 | // initialize variables you will need for the D* | |
241 | ||
242 | Double_t ptDStar;// | |
243 | Double_t phiDStar;// | |
244 | Double_t etaDStar;// | |
245 | Bool_t isInPeak, isInSideBand, isDStarMCtag; | |
246 | Double_t invMassDZero; | |
247 | Double_t deltainvMDStar; | |
248 | ||
249 | ||
250 | Double_t mPDGD0=TDatabasePDG::Instance()->GetParticle(421)->Mass(); | |
251 | Double_t mPDGDstar=TDatabasePDG::Instance()->GetParticle(413)->Mass(); | |
252 | ||
253 | ||
254 | ||
255 | if(fselect ==3){// check the K0 invariant mass | |
256 | TObjArray * fillkzerospectra = AcceptAndReduceKZero(aodEvent, 0,0); | |
257 | delete fillkzerospectra; | |
258 | } | |
259 | ||
260 | //MC tagging for DStar | |
261 | //D* and D0 prongs needed to MatchToMC method | |
262 | Int_t pdgDgDStartoD0pi[2]={421,211}; | |
263 | Int_t pdgDgD0toKpi[2]={321,211}; | |
264 | ||
265 | //loop on D* candidates | |
266 | for (Int_t iDStartoD0pi = 0; iDStartoD0pi<arrayDStartoD0pi->GetEntriesFast(); iDStartoD0pi++) { | |
267 | isInPeak = kFALSE; | |
268 | isInSideBand = kFALSE; | |
269 | isDStarMCtag = kFALSE; | |
270 | ptDStar = -123.4; | |
271 | phiDStar = -999; | |
272 | etaDStar = -56.; | |
273 | invMassDZero = - 999; | |
274 | deltainvMDStar = -998; | |
275 | ||
276 | ||
277 | ||
278 | AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)arrayDStartoD0pi->At(iDStartoD0pi); | |
279 | if(!dstarD0pi->GetSecondaryVtx()) continue; | |
280 | AliAODRecoDecayHF2Prong* theD0particle = (AliAODRecoDecayHF2Prong*)dstarD0pi->Get2Prong(); | |
281 | if (!theD0particle) continue; | |
282 | ||
283 | // track quality cuts | |
284 | Int_t isTkSelected = fCuts->IsSelected(dstarD0pi,AliRDHFCuts::kTracks); // quality cuts on tracks | |
285 | // region of interest + topological cuts + PID | |
286 | Int_t isSelected=fCuts->IsSelected(dstarD0pi,AliRDHFCuts::kCandidate); //selected | |
287 | ||
288 | //apply selections | |
289 | if(!isTkSelected) continue; | |
290 | if(!isSelected) continue; | |
291 | if(!fCuts->IsInFiducialAcceptance(dstarD0pi->Pt(),dstarD0pi->YDstar())) continue; | |
292 | ||
293 | if(fmontecarlo){ | |
294 | // find associated MC particle for D* ->D0toKpi | |
295 | Int_t mcLabelDStar = dstarD0pi->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,fmcArray); | |
296 | if(mcLabelDStar>=0) isDStarMCtag = kTRUE; | |
297 | } | |
298 | ||
299 | ptDStar = dstarD0pi->Pt(); | |
300 | phiDStar = dstarD0pi->Phi(); | |
301 | etaDStar = dstarD0pi->Eta(); | |
302 | ||
303 | Int_t ptbin=fCuts->PtBin(dstarD0pi->Pt()); | |
304 | ||
305 | Double_t dmDStarWindow =0.0019;// 0.0019 = 3 sigma | |
306 | Double_t mD0Window=0.074; | |
307 | ||
308 | if (ptbin==1) mD0Window = 0.026; //0.5-1 | |
309 | if (ptbin==2) mD0Window = 0.022; //1-2 | |
310 | if (ptbin==3) mD0Window = 0.024; //2-3 | |
311 | if (ptbin==4) mD0Window = 0.032; | |
312 | if (ptbin==5) mD0Window = 0.032; | |
313 | if (ptbin==6) mD0Window = 0.036; | |
314 | if (ptbin==7) mD0Window = 0.036; | |
315 | if (ptbin==8) mD0Window = 0.036; | |
316 | if (ptbin==9) mD0Window = 0.058; | |
317 | if (ptbin==10) mD0Window = 0.058; | |
318 | if (ptbin>10) mD0Window = 0.074; | |
319 | ||
320 | ||
321 | invMassDZero = dstarD0pi->InvMassD0(); | |
322 | ((TH2F*)fOutput->FindObject("D0InvMass"))->Fill(ptDStar,invMassDZero); | |
323 | ||
324 | deltainvMDStar = dstarD0pi->DeltaInvMass(); | |
325 | ||
326 | ||
327 | ||
328 | //good candidates | |
329 | if (TMath::Abs(invMassDZero-mPDGD0)<mD0Window){ | |
330 | ||
331 | ((TH2F*)fOutput->FindObject("DeltaInvMass"))->Fill(ptDStar,deltainvMDStar); | |
332 | if(TMath::Abs(deltainvMDStar-(mPDGDstar-mPDGD0))<dmDStarWindow){ // is in DStar peak region? | |
333 | ||
334 | ((TH1F*)fOutput->FindObject("RecoPtDStar"))->Fill(ptDStar); | |
335 | isInPeak = kTRUE; | |
336 | } | |
337 | }// end if good candidates | |
338 | ||
339 | //sidebands | |
340 | if (TMath::Abs(invMassDZero-mPDGD0)>1.3*mD0Window && TMath::Abs(invMassDZero-mPDGD0)<4.*mD0Window ){ | |
341 | ((TH2F*)fOutput->FindObject("bkgDeltaInvMass"))->Fill(ptDStar,deltainvMDStar); | |
342 | ((TH2F*)fOutput->FindObject("D0InvMassinSB"))->Fill(ptDStar,invMassDZero); | |
343 | ||
344 | if(TMath::Abs(deltainvMDStar-(mPDGDstar-mPDGD0))<dmDStarWindow){ // is in DStar peak region? | |
345 | ((TH1F*)fOutput->FindObject("RecoPtBkg"))->Fill(ptDStar); | |
346 | isInSideBand = kTRUE; | |
347 | } | |
348 | ||
349 | }//end if sidebands | |
350 | ||
351 | ||
352 | ||
353 | if(!isInPeak && !isInSideBand) continue; // skip if it is not side band or peak event - SAVE CPU TIME | |
354 | ||
355 | ||
356 | Int_t trackiddaugh0 = ((AliAODTrack*)theD0particle->GetDaughter(0))->GetID(); | |
357 | Int_t trackiddaugh1 = ((AliAODTrack*)theD0particle->GetDaughter(1))->GetID(); | |
358 | Int_t trackidsoftPi = ((AliAODTrack*)dstarD0pi->GetBachelor())->GetID(); | |
359 | ||
360 | ptDStar = dstarD0pi->Pt(); | |
361 | phiDStar = dstarD0pi->Phi(); | |
362 | etaDStar = dstarD0pi->Eta(); | |
363 | ||
364 | if(!fmixing){ // analysis on Single Event | |
365 | ||
366 | TObjArray* selectedtracks = new TObjArray(); | |
367 | if(fselect==1 || fselect ==2) selectedtracks = AcceptAndReduceTracks(aodEvent); | |
368 | if(fselect==3) {cout << " 2 "<< endl; selectedtracks = AcceptAndReduceKZero(aodEvent,iDStartoD0pi,1);} | |
369 | Int_t noftracks = selectedtracks->GetEntriesFast(); | |
370 | Int_t counterPeak =0; | |
371 | Int_t counterSB = 0; | |
372 | ||
373 | for(Int_t i =0; i<noftracks; i++){ // loop on tracks/k0 candidates in aod event | |
374 | ||
375 | AliReducedParticle *redpart = (AliReducedParticle*)selectedtracks->At(i); | |
376 | Double_t phiHad=redpart->Phi(); | |
377 | ||
378 | Double_t ptHad=redpart->Pt(); | |
379 | Double_t etaHad=redpart->Eta(); | |
380 | ||
381 | Int_t label = redpart->GetLabel(); | |
382 | ||
383 | Int_t trackid = redpart->GetID(); | |
384 | ||
385 | ||
386 | // check that the track is not a D* daughter | |
387 | if(trackid == trackiddaugh0) continue; | |
388 | if(trackid == trackiddaugh1) continue; | |
389 | if(trackid == trackidsoftPi) continue; | |
390 | ||
391 | if(fmontecarlo && isDStarMCtag){ // check correlations of MC tagged DStars in MonteCarlo | |
392 | ||
393 | Int_t PartSource = fCuts2->IsMCpartFromHF(label,fmcArray); // check source of associated particle (hadron/kaon/K0) | |
394 | ||
395 | FillMCTagCorrelations(ptDStar,phiDStar,etaDStar,ptHad,phiHad,etaHad,PartSource); | |
396 | } | |
397 | if(isInPeak) { | |
398 | FillCorrelations(ptDStar,phiDStar,etaDStar,phiHad,etaHad);// function for correlations | |
399 | counterPeak++; | |
400 | if (phiDStar > 1.5*pi) phiDStar = phiDStar - 2*pi; | |
401 | if (phiDStar < -0.5*pi) phiDStar = phiDStar + 2*pi; | |
402 | ||
403 | ((TH1F*)fOutput->FindObject("PhiTrigger"))->Fill(phiDStar); | |
404 | ||
405 | ||
406 | ||
407 | if (phiHad > 1.5*pi) phiHad = phiHad - 2*pi; | |
408 | if (phiHad < -0.5*pi) phiHad = phiHad + 2*pi; | |
409 | ((TH1F*)fOutput->FindObject("PhiPart"))->Fill(phiHad); | |
410 | ||
411 | } | |
412 | cout << "fill6" << endl; | |
413 | if(isInSideBand) { | |
414 | ||
415 | FillSideBandCorrelations(ptDStar,phiDStar,etaDStar,phiHad,etaHad); // function for sidebands | |
416 | if (phiDStar > 1.5*pi) phiDStar = phiDStar - 2*pi; | |
417 | if (phiDStar < -0.5*pi) phiDStar = phiDStar + 2*pi; | |
418 | ((TH1F*)fOutput->FindObject("PhiSideBand"))->Fill(phiDStar); | |
419 | ||
420 | counterSB++; | |
421 | } | |
422 | cout << "fill7" << endl; | |
423 | } // end loop on tracks | |
424 | ||
425 | if(counterPeak) ((TH1D*)fOutput->FindObject("NofTracksInPeak"))->Fill(counterPeak); | |
426 | if(counterSB) ((TH1D*)fOutput->FindObject("NofTracksInSB"))->Fill(counterSB); | |
427 | ||
428 | ||
429 | ||
430 | ||
431 | } // end if SE Analysis | |
432 | ||
433 | if(fmixing) { // analysis on Mixed Events | |
434 | if (pool->IsReady()|| pool->GetCurrentNEvents()>=5){ // check if the pool is ready | |
435 | ||
436 | pool->PrintInfo(); | |
437 | ||
438 | Int_t multbinflag = pool->MultBinIndex(); | |
439 | Int_t zvtxflag = pool->ZvtxBinIndex(); | |
440 | ||
441 | if(isInPeak){ cout << "check 1" << endl; | |
442 | ((TH2I*)fOutput->FindObject("EventMixingCheck"))->Fill(multbinflag,zvtxflag); | |
443 | cout << "filling" << endl;} | |
444 | ||
445 | TObjArray* mixedtracks = new TObjArray(); | |
446 | ||
447 | for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++) {//loop over the events in the pool | |
448 | mixedtracks = pool->GetEvent(jMix); | |
449 | if(!mixedtracks) cout << "No Mixed tracks " << endl; | |
450 | Int_t jMax = mixedtracks->GetEntriesFast(); | |
451 | ||
452 | for(Int_t iMix =0; iMix<jMax; iMix++){ //loop on the tracks of the event | |
453 | AliVParticle *redpart = (AliVParticle*)mixedtracks->At(iMix); | |
454 | Double_t phiHad=redpart->Phi(); | |
455 | Double_t etaHad=redpart->Eta(); | |
456 | Double_t ptHad=redpart->Pt(); | |
457 | Int_t label = redpart->GetLabel(); | |
458 | ||
459 | ||
460 | if(fmontecarlo && isDStarMCtag){ // check correlations of MC tagged DStars in MonteCarlo | |
461 | ||
462 | Int_t PartSource = fCuts2->IsMCpartFromHF(label,fmcArray); // check source of associated particle (hadron/kaon/K0) | |
463 | ||
464 | FillMCTagCorrelations(ptDStar,phiDStar,etaDStar,ptHad,phiHad,etaHad,PartSource); | |
465 | } | |
466 | ||
467 | if(isInPeak) { | |
468 | FillCorrelations(ptDStar,phiDStar,etaDStar,phiHad,etaHad);// function for correlations | |
469 | ||
470 | if (phiDStar > 1.5*pi) phiDStar = phiDStar - 2*pi; | |
471 | if (phiDStar < -0.5*pi) phiDStar = phiDStar + 2*pi; | |
472 | ||
473 | ((TH1F*)fOutput->FindObject("PhiTrigger"))->Fill(phiDStar); | |
474 | if (phiHad > 1.5*pi) phiHad = phiHad - 2*pi; | |
475 | if (phiHad < -0.5*pi) phiHad = phiHad + 2*pi; | |
476 | ((TH1F*)fOutput->FindObject("PhiPart"))->Fill(phiHad); | |
477 | ||
478 | ||
479 | ||
480 | } | |
481 | ||
482 | if(isInSideBand) FillSideBandCorrelations(ptDStar,phiDStar,etaDStar,phiHad,etaHad); // function for sidebands | |
483 | ||
484 | } // end loop on tracks | |
485 | }// end loop on events in pool | |
486 | } // end if pool is ready | |
487 | ||
488 | } // end ME analysis | |
489 | ||
490 | }// end loop on D* candidates | |
491 | ||
492 | if(fmixing) { // update the pool for Event Mixing | |
493 | if(fselect==1 || fselect==2)pool->UpdatePool(AcceptAndReduceTracks(aodEvent)); // updating the pool for hadrons | |
494 | if(fselect==3) pool->UpdatePool(AcceptAndReduceKZero(aodEvent,0,0)); // updating the pool for K0s | |
495 | } | |
496 | //cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END OF THE EVENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; | |
497 | ||
498 | PostData(1,fOutput); // set the outputs | |
499 | PostData(3,fCounter); // set the outputs | |
500 | ||
501 | } //end the exec | |
502 | ||
503 | //________________________________________ terminate ___________________________ | |
504 | void AliAnalysisTaskDStarCorrelations::Terminate(Option_t*) | |
505 | { | |
506 | // The Terminate() function is the last function to be called during | |
507 | // a query. It always runs on the client, it can be used to present | |
508 | // the results graphically or save the results to file. | |
509 | ||
510 | AliAnalysisTaskSE::Terminate(); | |
511 | ||
512 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
513 | if (!fOutput) { | |
514 | printf("ERROR: fOutput not available\n"); | |
515 | return; | |
516 | } | |
517 | ||
518 | return; | |
519 | } | |
520 | ||
521 | ||
522 | //_____________________________________________________ | |
523 | TObjArray* AliAnalysisTaskDStarCorrelations::AcceptAndReduceTracks(AliAODEvent* inputEvent){ | |
524 | ||
525 | Int_t nTracks = inputEvent->GetNTracks(); | |
526 | AliAODVertex * vtx = inputEvent->GetPrimaryVertex(); | |
527 | Double_t Bz = inputEvent->GetMagneticField(); | |
528 | ||
529 | ||
530 | TObjArray* tracksClone = new TObjArray; | |
531 | tracksClone->SetOwner(kTRUE); | |
532 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) { | |
533 | AliAODTrack* track = inputEvent->GetTrack(iTrack); | |
534 | if (! track) continue; | |
535 | ||
536 | if(!fCuts2->IsHadronSelected(track,vtx,Bz)) continue; // apply selection of hadrons | |
537 | ||
538 | ||
539 | if(fselect ==2){ | |
540 | if(!fCuts2->CheckKaonCompatibility(track,fmontecarlo,fmcArray)) continue; // check if it is a Kaon - data and MC | |
541 | } | |
542 | ||
543 | AliVParticle * part = (AliVParticle*)track; | |
544 | tracksClone->Add(new AliReducedParticle(part->Eta(), part->Phi(), part->Pt(),track->GetLabel(),track->GetID())); | |
545 | ||
546 | } | |
547 | return tracksClone; | |
548 | } | |
549 | ||
550 | //_____________________________________________________ | |
551 | TObjArray* AliAnalysisTaskDStarCorrelations::AcceptAndReduceKZero(AliAODEvent* inputEvent, Int_t loopindex, Int_t plotassociation){ | |
552 | ||
553 | Int_t nOfVZeros = inputEvent->GetNumberOfV0s(); | |
554 | TObjArray* KZeroClone = new TObjArray; | |
555 | AliAODVertex *vertex1 = (AliAODVertex*)inputEvent->GetPrimaryVertex(); | |
556 | Int_t v0label = -1; | |
557 | Int_t pdgDgK0toPipi[2] = {211,211}; | |
558 | Double_t mPDGK0=TDatabasePDG::Instance()->GetParticle(310)->Mass(); | |
559 | const Int_t size = inputEvent->GetNumberOfV0s(); | |
560 | Int_t prevnegID[size]; | |
561 | Int_t prevposID[size]; | |
562 | for(Int_t iv0 =0; iv0< nOfVZeros; iv0++){// loop on all v0 candidates | |
563 | AliAODv0 *v0 = (static_cast<AliAODEvent*> (inputEvent))->GetV0(iv0); | |
564 | if(!v0) {cout << "is not a v0 at step " << iv0 << endl; continue;} | |
565 | ||
566 | if(!fCuts2->IsKZeroSelected(v0,vertex1)) continue; // check if it is a k0 | |
567 | ||
568 | // checks to avoid double counting | |
569 | Int_t negID = -999; | |
570 | Int_t posID = -998; | |
571 | //Int_t a = 0; | |
572 | prevnegID[iv0] = -997; | |
573 | prevposID[iv0]= -996; | |
574 | negID = v0->GetNegID(); | |
575 | posID = v0->GetPosID(); | |
576 | Bool_t DoubleCounting = kFALSE; | |
577 | ||
578 | for(Int_t k=0; k<iv0; k++){ | |
579 | if(((negID==prevnegID[k])&&(posID==prevposID[k]))||((negID==prevposID[k])&&(posID==prevnegID[k]))){ | |
580 | DoubleCounting = kTRUE; | |
581 | //a=k; | |
582 | break; | |
583 | }//end if | |
584 | } // end for | |
585 | ||
586 | if(DoubleCounting) {cout << "SKIPPING DOUBLE COUNTING" << endl;continue;} | |
587 | else{ prevposID[iv0] = posID; prevnegID[iv0] = negID;} | |
588 | ||
589 | if(fmontecarlo) v0label = v0->MatchToMC(310,fmcArray, 0, pdgDgK0toPipi); //match a K0 short | |
590 | Double_t k0pt = v0->Pt(); | |
591 | Double_t k0eta = v0->Eta(); | |
592 | Double_t k0Phi = v0->Phi(); | |
593 | Double_t k0InvMass = v0->MassK0Short(); | |
594 | ||
595 | if (loopindex == 0) { | |
596 | if(!plotassociation) ((TH2F*)fOutput->FindObject("KZeroSpectra"))->Fill(k0InvMass,k0pt); // spectra for all k0 | |
597 | if(plotassociation) ((TH2F*)fOutput->FindObject("KZeroSpectraifHF"))->Fill(k0InvMass,k0pt); // spectra for k0 in association with a D* | |
598 | } | |
599 | // if there are more D* candidates per event, loopindex == 0 makes sure you fill the mass spectra only once! | |
600 | ||
601 | if(TMath::Abs(k0InvMass-mPDGK0)>3*0.004) continue; // select candidates within 3 sigma | |
602 | KZeroClone->Add(new AliReducedParticle(k0eta , k0Phi, k0pt,v0label,0)); | |
603 | ||
604 | } | |
605 | ||
606 | return KZeroClone; | |
607 | } | |
608 | ||
609 | //_____________________________________________________ | |
610 | void AliAnalysisTaskDStarCorrelations::DefineHistoForAnalysis(){ | |
611 | ||
612 | Double_t Pi = TMath::Pi(); | |
613 | Int_t nbinscorr = 32; | |
614 | Double_t lowcorrbin = -0.5*Pi - Pi/32; // shift the bin by half the width so that at 0 is it the bin center | |
615 | Double_t upcorrbin = 1.5*Pi - Pi/32; | |
616 | ||
617 | // ========================= histograms for both Data and MonteCarlo | |
618 | ||
619 | ||
620 | TH1D * NofEvents = new TH1D("NofEvents","NofEvents",1,0,1); | |
621 | fOutput->Add(NofEvents); | |
622 | ||
623 | TH2F *D0InvMass = new TH2F("D0InvMass","K#pi invariant mass distribution",300,0,30,1500,0.5,3.5); | |
624 | fOutput->Add(D0InvMass); | |
625 | ||
626 | TH2F *D0InvMassinSB = new TH2F("D0InvMassinSB","K#pi invariant mass distribution in sb",300,0,30,1500,0.5,3.5); | |
627 | fOutput->Add(D0InvMassinSB); | |
628 | ||
629 | TH2F *DeltaInvMass = new TH2F("DeltaInvMass","K#pi#pi - K#pi invariant mass distribution",300,0,30,750,0.1,0.2); | |
630 | fOutput->Add(DeltaInvMass); | |
631 | ||
632 | TH2F *bkgDeltaInvMass = new TH2F("bkgDeltaInvMass","K#pi#pi - K#pi invariant mass distribution",300,0,30,750,0.1,0.2); | |
633 | fOutput->Add(bkgDeltaInvMass); | |
634 | ||
635 | TH1F *RecoPtDStar = new TH1F("RecoPtDStar","RECO DStar pt distribution",30,0,30); | |
636 | fOutput->Add(RecoPtDStar); | |
637 | ||
638 | TH1F *RecoPtBkg = new TH1F("RecoPtBkg","RECO pt distribution side bands",30,0,30); | |
639 | fOutput->Add(RecoPtBkg); | |
640 | ||
641 | TH2F *KZeroSpectra = new TH2F("KZeroSpectra","Spectra of K0s",500,0.3,0.8,250,0,25); | |
642 | if(fselect==3) fOutput->Add(KZeroSpectra); | |
643 | ||
644 | TH2F *KZeroSpectraifHF = new TH2F("KZeroSpectraifHF","Spectra of K0s in association with a D*",500,0.3,0.8,250,0,25); | |
645 | if(fselect==3) fOutput->Add(KZeroSpectraifHF); | |
646 | ||
647 | TH1D * NofTracksInPeak = new TH1D("NofTracksInPeak","NofTracksInPeak",500,0.5,500.5); | |
648 | fOutput->Add(NofTracksInPeak); | |
649 | ||
650 | TH1D * NofTracksInSB = new TH1D("NofTracksInSB","NofTracksInSB",500,0.5,500.5); | |
651 | fOutput->Add(NofTracksInSB); | |
652 | ||
653 | TH2I * EventMixingCheck = new TH2I("EventMixingCheck","EventMixingCheck",5,-0.5,4.5,7,-0.5,6.5); | |
654 | if(fmixing) fOutput->Add(EventMixingCheck); | |
655 | ||
656 | ||
657 | ||
658 | TH1F * MCSources = new TH1F("MCSources","Origin of associated particles in MC", 10, -0.5, 9.5); | |
659 | MCSources->GetXaxis()->SetBinLabel(1,"All "); | |
660 | MCSources->GetXaxis()->SetBinLabel(2," from Heavy flavour"); | |
661 | MCSources->GetXaxis()->SetBinLabel(3," from c->D"); | |
662 | MCSources->GetXaxis()->SetBinLabel(4," from b->D"); | |
663 | MCSources->GetXaxis()->SetBinLabel(5," from b->B"); | |
664 | if(fmontecarlo) fOutput->Add(MCSources); | |
665 | ||
666 | TH1F * PhiTrigger = new TH1F("PhiTrigger","#phi distribution of the trigger particle",36,-0.5*Pi,1.5*Pi); | |
667 | fOutput->Add(PhiTrigger); | |
668 | ||
669 | TH1F * PhiSideBand = new TH1F("PhiSideBand","#phi distribution of the sideband particle",36,-0.5*Pi,1.5*Pi); | |
670 | fOutput->Add(PhiSideBand); | |
671 | ||
672 | TH1F * PhiPart = new TH1F("PhiPart","#phi distribution of the associated particle",36,-0.5*Pi,1.5*Pi); | |
673 | fOutput->Add(PhiPart); | |
674 | ||
675 | ||
676 | //correlations histograms | |
677 | TString histoname1 = "DPhiDStar"; | |
678 | if(fselect==1) histoname1 += "Hadron"; | |
679 | if(fselect==2) histoname1 += "Kaon"; | |
680 | if(fselect==3) histoname1 += "KZero"; | |
681 | ||
682 | ||
683 | TH3D * DPhiDStar = new TH3D(histoname1.Data(),histoname1.Data(),nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
684 | ||
685 | TH3D * DPhiDStarKZero1 = new TH3D("DPhiDStarKZero1","DPhiDStarKZero1",nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
686 | ||
687 | //side band background histograms | |
688 | TString histoname2 = "bkg"; | |
689 | histoname2 += histoname1; | |
690 | TH3D * bkgDPhiDStar = new TH3D(histoname2.Data(),histoname2.Data(),nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
691 | TH3D * bkgDPhiDStarKZero1 = new TH3D("bkgDPhiDStarKZero1","bkgDPhiDStarKZero1",nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
692 | ||
693 | ||
694 | fOutput->Add(DPhiDStar); | |
695 | ||
696 | if(fselect==3){fOutput->Add(DPhiDStarKZero1);} | |
697 | ||
698 | fOutput->Add(bkgDPhiDStar); | |
699 | ||
700 | if(fselect==3){fOutput->Add(bkgDPhiDStarKZero1);} | |
701 | ||
702 | ||
703 | // ========================= histos for analysis on MC | |
704 | TString histoname3 = "MCTag"; | |
705 | histoname3 += histoname1; | |
706 | TH3D * MCTagDPhiDStar = new TH3D(histoname3.Data(),histoname3.Data(),nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
707 | ||
708 | TString histoname44 = "CharmDOrigin"; | |
709 | histoname44 += histoname1; | |
710 | histoname44 += "MC"; | |
711 | ||
712 | TH3D * CharmDOriginDPhiDStar = new TH3D(histoname44.Data(),histoname44.Data(),nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
713 | ||
714 | ||
715 | TString histoname54 = "BeautyDOrigin"; | |
716 | histoname54 += histoname1; | |
717 | histoname54 += "MC"; | |
718 | TH3D * BeautyDOriginDPhiDStar = new TH3D(histoname54.Data(),histoname54.Data(),nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
719 | ||
720 | TString histoname55 = "BeautyBOrigin"; | |
721 | histoname55 += histoname1; | |
722 | histoname55 += "MC"; | |
723 | TH3D * BeautyBOriginDPhiDStar = new TH3D(histoname55.Data(),histoname55.Data(),nbinscorr,lowcorrbin,upcorrbin,30,0,30,19,-0.95,0.95); | |
724 | ||
725 | if(fmontecarlo){ | |
726 | ||
727 | fOutput->Add(MCTagDPhiDStar); | |
728 | fOutput->Add(CharmDOriginDPhiDStar); | |
729 | fOutput->Add(BeautyDOriginDPhiDStar); | |
730 | fOutput->Add(BeautyBOriginDPhiDStar); | |
731 | ||
732 | } | |
733 | ||
734 | ||
735 | ||
736 | } | |
737 | ||
738 | ||
739 | //____________________________ Function for correlations ___________________________________________________ | |
740 | void AliAnalysisTaskDStarCorrelations::FillCorrelations(Double_t ptTrig, Double_t phiTrig, Double_t etaTrig, Double_t phiTrack, Double_t etaTrack){ | |
741 | Double_t pi = TMath::Pi(); | |
742 | Double_t deltaPhi, deltaEta; | |
743 | deltaPhi = phiTrig - phiTrack; | |
744 | deltaEta = etaTrig - etaTrack; | |
745 | // set correct Delta Phi range | |
746 | if (deltaPhi > 1.5*pi -pi/32) deltaPhi = deltaPhi - 2*pi; | |
747 | if (deltaPhi < -0.5*pi -pi/32) deltaPhi = deltaPhi + 2*pi; | |
748 | cout << "CRASH CHECK 1 " << endl; | |
749 | if(fselect==1) ((TH3D*)fOutput->FindObject("DPhiDStarHadron"))->Fill(deltaPhi,ptTrig,deltaEta); | |
750 | if(fselect==2) ((TH3D*)fOutput->FindObject("DPhiDStarKaon"))->Fill(deltaPhi,ptTrig,deltaEta); | |
751 | if(fselect==3) ((TH3D*)fOutput->FindObject("DPhiDStarKZero"))->Fill(deltaPhi,ptTrig,deltaEta); | |
752 | cout << "CRASH CHECK 2 " << endl; | |
753 | ||
754 | return; | |
755 | } | |
756 | ||
757 | //____________________________ Function for sidebands ___________________________________________________ | |
758 | void AliAnalysisTaskDStarCorrelations::FillSideBandCorrelations(Double_t ptTrig, Double_t phiTrig, Double_t etaTrig, Double_t phiTrack, Double_t etaTrack){ | |
759 | ||
760 | Double_t pi = TMath::Pi(); | |
761 | Double_t deltaPhi, deltaEta; | |
762 | deltaPhi = phiTrig - phiTrack; | |
763 | deltaEta = etaTrig - etaTrack; | |
764 | // set correct Delta Phi range | |
765 | if (deltaPhi > 1.5*pi -pi/32) deltaPhi = deltaPhi - 2*pi; | |
766 | if (deltaPhi < -0.5*pi -pi/32) deltaPhi = deltaPhi + 2*pi; | |
767 | cout << "CRASH CHECK bkg 1 " << endl; | |
768 | if(fselect==1) ((TH3D*)fOutput->FindObject("bkgDPhiDStarHadron"))->Fill(deltaPhi,ptTrig,deltaEta); | |
769 | if(fselect==2) ((TH3D*)fOutput->FindObject("bkgDPhiDStarKaon"))->Fill(deltaPhi,ptTrig,deltaEta); | |
770 | if(fselect==3) ((TH3D*)fOutput->FindObject("bkgDPhiDStarKZero"))->Fill(deltaPhi,ptTrig,deltaEta); | |
771 | cout << "CRASH CHECK bkg 2 " << endl; | |
772 | ||
773 | return; | |
774 | ||
775 | ||
776 | } | |
777 | ||
778 | //____________________________ Function for sidebands ___________________________________________________ | |
779 | void AliAnalysisTaskDStarCorrelations::FillMCTagCorrelations(Double_t ptTrig, Double_t phiTrig, Double_t etaTrig, Double_t ptTrack, Double_t phiTrack, Double_t etaTrack, Int_t mcSource){ | |
780 | Double_t deltaPhi = phiTrig - phiTrack; | |
781 | Double_t deltaEta = etaTrig - etaTrack; | |
782 | // set correct Delta Phi range | |
783 | ||
784 | Double_t pi = TMath::Pi(); | |
785 | ||
786 | if (deltaPhi > 1.5*pi -pi/32) deltaPhi = deltaPhi - 2*pi; | |
787 | if (deltaPhi < -0.5*pi -pi/32) deltaPhi = deltaPhi + 2*pi; | |
788 | cout << "fill1" << endl; | |
789 | if(fselect==1) ((TH3D*)fOutput->FindObject("MCTagDPhiDStarHadron"))->Fill(deltaPhi,ptTrig,deltaEta); | |
790 | if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutput->FindObject("MCTagDPhiDStarKaon"))->Fill(deltaPhi,ptTrig,deltaEta); | |
791 | if(fselect==3) ((TH3D*)fOutput->FindObject("MCTagDPhiDStarKZero"))->Fill(deltaPhi,ptTrig,deltaEta); | |
792 | ||
793 | ||
794 | ||
795 | ((TH1F*)fOutput->FindObject("MCSources"))->Fill(0); | |
796 | cout << "fill2" << endl; | |
797 | if (mcSource==44){ // is from charm ->D | |
798 | if(fselect==1) ((TH3D*)fOutput->FindObject("CharmDOriginDPhiDStarHadronMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
799 | if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutput->FindObject("CharmDOriginDPhiDStarKaonMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
800 | if(fselect==3) ((TH3D*)fOutput->FindObject("CharmDOriginDPhiDStarKZeroMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
801 | ||
802 | ||
803 | ((TH1F*)fOutput->FindObject("MCSources"))->Fill(1); | |
804 | ((TH1F*)fOutput->FindObject("MCSources"))->Fill(2); | |
805 | } | |
806 | cout << "fill3" << endl; | |
807 | if (mcSource==54){ // is from beauty -> D | |
808 | if(fselect==1) ((TH3D*)fOutput->FindObject("BeautyDOriginDPhiDStarHadronMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
809 | if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutput->FindObject("BeautyDOriginDPhiDStarKaonMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
810 | if(fselect==3) ((TH3D*)fOutput->FindObject("BeautyDOriginDPhiDStarKZeroMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
811 | if(fselect==3) ((TH1F*)fOutput->FindObject("MCSources"))->Fill(1); | |
812 | if(fselect==3) ((TH1F*)fOutput->FindObject("MCSources"))->Fill(3); | |
813 | } | |
814 | cout << "fill4" << endl; | |
815 | if (mcSource==55){ // is from beauty ->B | |
816 | if(fselect==1) ((TH3D*)fOutput->FindObject("BeautyBOriginDPhiDStarHadronMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
817 | if(fselect==2 && ptTrack <1.5) ((TH3D*)fOutput->FindObject("BeautyBOriginDPhiDStarKaonMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
818 | if(fselect==3) ((TH3D*)fOutput->FindObject("BeautyOriginBDPhiDStarKZeroMC"))->Fill(deltaPhi,ptTrig,deltaEta); | |
819 | if(fselect==3) ((TH1F*)fOutput->FindObject("MCSources"))->Fill(1); | |
820 | if(fselect==3) ((TH1F*)fOutput->FindObject("MCSources"))->Fill(4); | |
821 | } | |
822 | return; | |
823 | } | |
824 | ||
825 | ||
826 | ||
827 | ||
828 |