]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/vertexingHF/charmFlow/AliAnalysisTaskFlowD2H.cxx
Revert wrong commit
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / charmFlow / AliAnalysisTaskFlowD2H.cxx
CommitLineData
a8f6c03f 1/**************************************************************************
2* Copyright(c) 1998-2008,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// FlowD2H main task:
fc4003c2 18// >> Select candidates and passes flowevents to the daughter tasks.
a8f6c03f 19// >> The POIcuts are polymorphic based on the AliRDHFCuts class allowing the
20// use of all charmed candidates reconstructed in the central barrel.
21// Author: Carlos Perez (cperez@cern.ch)
22//==============================================================================
23
f829c4f7 24/* $Id$ */
25
a8f6c03f 26#include "TChain.h"
a8f6c03f 27
28#include "AliAnalysisTaskSE.h"
29#include "AliAnalysisManager.h"
30
31#include "AliCentrality.h"
32
33#include "AliAODEvent.h"
34#include "AliAODInputHandler.h"
35#include "AliAODTrack.h"
36
a8f6c03f 37#include "AliRDHFCuts.h"
fcfcc352 38
a8f6c03f 39#include "AliRDHFCutsD0toKpi.h"
40#include "AliRDHFCutsDStartoKpipi.h"
41#include "AliRDHFCutsDplustoKpipi.h"
42
43#include "AliAODRecoDecayHF2Prong.h"
44#include "AliAODRecoDecayHF3Prong.h"
45#include "AliAODRecoCascadeHF.h"
46
fcfcc352 47#include "TMath.h"
48
fc4003c2 49#include "AliFlowCommonConstants.h"
50#include "AliFlowEvent.h"
51#include "AliFlowTrackCuts.h"
fcfcc352 52#include "AliFlowCandidateTrack.h"
53
54#include "TObjArray.h"
55#include "TList.h"
56#include "TH1D.h"
57
a8f6c03f 58#include "AliAnalysisTaskFlowD2H.h"
59
60ClassImp(AliAnalysisTaskFlowD2H)
61
62//_____________________________________________________________________________
63AliAnalysisTaskFlowD2H::AliAnalysisTaskFlowD2H() :
fc4003c2 64 AliAnalysisTaskSE(), fTPCEvent(NULL), fVZEEvent(NULL),
65 fCutsTPC(NULL), fCutsVZE(NULL), fNoPOIs(NULL), fCutsPOI(NULL),
66 fSource(0), fDebugV2(kFALSE), fMassBins(0), fMinMass(0.),
67 fMaxMass(0.), fPtBinWidth(0), fHList(NULL), fEvent(NULL),
68 fCC(NULL), fRFPMTPC(NULL), fRFPPhiTPC(NULL), fCandidates(NULL)
a8f6c03f 69{
70// Default constructor
a8f6c03f 71}
72
73//_____________________________________________________________________________
fc4003c2 74AliAnalysisTaskFlowD2H::AliAnalysisTaskFlowD2H(const char *name,
75 AliFlowTrackCuts *cutsTPC,
76 AliFlowTrackCuts *cutsVZE,
fcfcc352 77 AliRDHFCuts *cutsPOIs,
78 Int_t specie) :
fc4003c2 79 AliAnalysisTaskSE(name), fTPCEvent(NULL), fVZEEvent(NULL),
80 fCutsTPC(cutsTPC), fCutsVZE(cutsVZE), fNoPOIs(NULL), fCutsPOI(cutsPOIs),
81 fSource(specie), fDebugV2(kFALSE), fMassBins(0), fMinMass(0.),
82 fMaxMass(0.), fPtBinWidth(0), fHList(NULL), fEvent(NULL),
83 fCC(NULL), fRFPMTPC(NULL), fRFPPhiTPC(NULL), fCandidates(NULL)
a8f6c03f 84{
85// Standard constructor
a8f6c03f 86 DefineInput( 0,TChain::Class());
87 DefineOutput(1,TList::Class());
fc4003c2 88 DefineOutput(2,AliFlowEventSimple::Class());
89 DefineOutput(3,AliFlowEventSimple::Class());
a8f6c03f 90}
91
92//_____________________________________________________________________________
8dda6917 93AliAnalysisTaskFlowD2H::~AliAnalysisTaskFlowD2H(){
94 // delete objects
fc4003c2 95 if(fTPCEvent) delete fTPCEvent;
96 if(fVZEEvent) delete fVZEEvent;
97 if(fCutsTPC) delete fCutsTPC;
98 if(fCutsVZE) delete fCutsVZE;
99 if(fNoPOIs) delete fNoPOIs;
fcfcc352 100 if(fCutsPOI) delete fCutsPOI;
101 if(fHList) delete fHList;
102 if(fCandidates) delete fCandidates;
a8f6c03f 103}
104
105//_____________________________________________________________________________
8dda6917 106void AliAnalysisTaskFlowD2H::UserCreateOutputObjects(){
107 // Define output objects + parameters
108 if(fDebugV2)
a8f6c03f 109 printf("DEBUGGER: Creating output\n");
110 fHList = new TList();
111 fHList->SetOwner();
fcfcc352 112 fEvent = new TH1D("Events","Events",3,0,3);
113 fEvent->GetXaxis()->SetBinLabel(1,"REACHED");
114 fEvent->GetXaxis()->SetBinLabel(2,"SELECTED");
115 fEvent->GetXaxis()->SetBinLabel(3,"DELTA AOD REACHED");
116 fHList->Add( fEvent );
fc4003c2 117 fCC = new TH1D("CentralityClass","Centrality Class",50,0,100);
118 fHList->Add( fCC );
119 fRFPMTPC = new TH1D("RFPMultiplicityTPC","RFP Multiplicity TPC",300,0,3000);
120 fHList->Add( fRFPMTPC );
121 fRFPPhiTPC = new TH1D("RFPPhiTPC","RFP Phi TPC",180,0,TMath::TwoPi());
122 fHList->Add( fRFPPhiTPC );
a8f6c03f 123
fc4003c2 124 fCandidates = new TObjArray(100);
fcfcc352 125 fCandidates->SetOwner();
a8f6c03f 126
fc4003c2 127 AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster();
128 cc->SetNbinsMult(1);
129 cc->SetNbinsPt(24/fPtBinWidth);
130 cc->SetNbinsPhi(1);
131 cc->SetNbinsEta(15);
132 cc->SetNbinsQ(1);
133 cc->SetNbinsMass( fMassBins );
134 cc->SetMultMin(1);
135 cc->SetMultMax(2);
136 cc->SetPtMin(0);
137 cc->SetPtMax(24);
138 cc->SetPhiMin(0);
139 cc->SetPhiMax(TMath::TwoPi());
140 cc->SetEtaMin(-3.9);
141 cc->SetEtaMax(+5.1);
142 cc->SetQMin(0);
143 cc->SetQMax(1);
144 cc->SetMassMin( fMinMass );
145 cc->SetMassMax( fMaxMass );
146
147 fTPCEvent = new AliFlowEvent(3000);
148 fVZEEvent = new AliFlowEvent(170);
149
150 fNoPOIs = new AliFlowTrackCuts( "noPOIs" );
151 fNoPOIs->SetParamType(AliFlowTrackCuts::kGlobal);
152 fNoPOIs->SetPtRange(+1,-1);
153
fcfcc352 154 PostData(1,fHList);
fc4003c2 155 PostData(2,fTPCEvent);
156 PostData(3,fVZEEvent);
a8f6c03f 157}
158//_____________________________________________________________________________
159void AliAnalysisTaskFlowD2H::UserExec(Option_t *)
160{
8dda6917 161 // Do analysis + fIll histograms
a8f6c03f 162 AliAODEvent *fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
163
fcfcc352 164 if(!fAOD) return;
165 fEvent->Fill( 0 );
166
fc4003c2 167 // floweventcuts::isselected() and alirdhfcuts::iseventselected() cut on the same
168 // values in the same way BUT the latter also loads the PIDresponse object from the
169 // event header!!!
170 // if(!fEventCuts->IsSelected(fAOD)) return;
171 if(!fCutsPOI->IsEventSelected(fAOD)) return;
fcfcc352 172 fEvent->Fill( 1 );
a8f6c03f 173
fc4003c2 174 fCC->Fill( fCutsPOI->GetCentrality(fAOD) );
175
176 fCutsTPC->SetEvent( fAOD, MCEvent() );
177 fCutsVZE->SetEvent( fAOD, MCEvent() );
178 fNoPOIs->SetEvent( fAOD, MCEvent() );
179 fTPCEvent->Fill( fCutsTPC, fNoPOIs );
180 fVZEEvent->Fill( fCutsVZE, fNoPOIs );
181
182 Int_t rfps = fTPCEvent->GetNumberOfRPs();
183 fRFPMTPC->Fill( rfps );
184 for(int iRPs=0; iRPs!=rfps; ++iRPs ) {
185 AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(fTPCEvent->GetTrack( iRPs ));
186 if (!iRP) continue;
187 fRFPPhiTPC->Fill( iRP->Phi() );
188 }
189
8dda6917 190 if (fDebugV2) printf("Event selected\n");
fcfcc352 191 fCandidates->SetLast(-1); // resets the array
a8f6c03f 192
193 switch (fSource) {
194 case (AliRDHFCuts::kD0toKpiCuts):
fcfcc352 195 FillD0toKpi(fAOD); break;
a8f6c03f 196 case (AliRDHFCuts::kDstarCuts):
fcfcc352 197 FillDStartoKpipi(fAOD); break;
a8f6c03f 198 case (AliRDHFCuts::kDplusCuts):
fcfcc352 199 FillDplustoKpipi(fAOD); break;
a8f6c03f 200 }
201
fc4003c2 202 if(fDebugV2) printf("TPCevent %d | VZEevent %d\n", fTPCEvent->NumberOfTracks(), fVZEEvent->NumberOfTracks() );
203 //inject candidates
204 if (fDebugV2) printf("I received %d candidates\n",fCandidates->GetEntriesFast());
205 for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) {
206 AliFlowCandidateTrack *cand = dynamic_cast<AliFlowCandidateTrack*>(fCandidates->At(iCand));
207 if (!cand) continue;
208 if (fDebugV2) printf(" >Checking at candidate %d with %d daughters: mass %f\n",iCand,cand->GetNDaughters(),cand->Mass());
209 for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) {
210 if(fDebugV2) printf(" >Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau));
211 for(int iRPs=0; iRPs!=fTPCEvent->NumberOfTracks(); ++iRPs ) {
212 AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(fTPCEvent->GetTrack( iRPs ));
213 if (!iRP) continue;
214 if( !iRP->InRPSelection() ) continue;
215 if( cand->GetIDDaughter(iDau) == iRP->GetID() ) {
216 if(fDebugV2) printf(" was in RP set");
217 iRP->SetForRPSelection(kFALSE);
218 fTPCEvent->SetNumberOfRPs( fTPCEvent->GetNumberOfRPs() -1 );
219 }
220 }
221 if(fDebugV2) printf("\n");
222 }
223 cand->SetForPOISelection(kTRUE);
224 fTPCEvent->InsertTrack( ((AliFlowTrack*) cand) );
225 fVZEEvent->InsertTrack( ((AliFlowTrack*) cand) );
226 }
227 if(fDebugV2) printf("TPCevent %d | VZEevent %d\n", fTPCEvent->NumberOfTracks(), fVZEEvent->NumberOfTracks() );
a8f6c03f 228
fc4003c2 229 PostData(1,fHList);
230 PostData(2,fTPCEvent);
231 PostData(3,fVZEEvent);
a8f6c03f 232}
233//______________________________________________________________________________
fcfcc352 234void AliAnalysisTaskFlowD2H::FillD0toKpi(const AliAODEvent *theAOD)
a8f6c03f 235{
8dda6917 236 // Fill D0->Kpi histos
a8f6c03f 237 TList *listHF = (TList*) theAOD->GetList();
238 if(!listHF) return;
239 TClonesArray *listDzero = (TClonesArray*) listHF->FindObject("D0toKpi");
240 if(!listDzero) return;
241 int nEntries = listDzero->GetEntriesFast();
242 if( !nEntries ) return;
fcfcc352 243 fEvent->Fill( 2 ); // EVERYTHING OKAY
244
a8f6c03f 245 AliRDHFCutsD0toKpi *fCutsD0toKpi = (AliRDHFCutsD0toKpi*) fCutsPOI;
8dda6917 246 if (fDebugV2) printf(" ᶫ%d candidates found. Looping...\n", nEntries);
fcfcc352 247 Int_t nIDs[2];
a8f6c03f 248 for( int iEntry=0; iEntry!=nEntries; ++iEntry ) {
8dda6917 249 AliAODRecoDecayHF2Prong *d0cand = (AliAODRecoDecayHF2Prong*) listDzero->UncheckedAt( iEntry );
250 if( !d0cand ) continue;
fcfcc352 251 // APPLYING CUTS
8dda6917 252 if( !d0cand->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts) ) continue;
253 if( !fCutsD0toKpi->IsInFiducialAcceptance(d0cand->Pt(),d0cand->Y(421)) )continue;
fcfcc352 254 Int_t topCut = fCutsD0toKpi->IsSelected( d0cand, AliRDHFCuts::kAll, NULL );
255 if(!topCut) continue;
450c0ff6 256 Double_t massD0=topCut>1?d0cand->InvMassD0bar():d0cand->InvMassD0();
fcfcc352 257 // TO HANDLE AUTOCORRELATIONS
258 nIDs[0] = ( (AliAODTrack*)d0cand->GetDaughter(0) )->GetID();
259 nIDs[1] = ( (AliAODTrack*)d0cand->GetDaughter(1) )->GetID();
450c0ff6 260 // ADDING TRACK
261 MakeTrack(massD0, d0cand->Pt(), d0cand->Phi(), d0cand->Eta(), 2, nIDs);
fcfcc352 262 if(fDebugV2) printf(" ᶫInjecting D0 candidate\n");
a8f6c03f 263 }
264}
265//______________________________________________________________________________
fcfcc352 266void AliAnalysisTaskFlowD2H::FillDStartoKpipi(const AliAODEvent *theAOD )
a8f6c03f 267{
fcfcc352 268 // Fills D* to Kpipi
a8f6c03f 269 TList *listHF = (TList*) theAOD->GetList();
270 if(!listHF) return;
271 TClonesArray *listDstar = (TClonesArray*) listHF->FindObject("Dstar");
272 if(!listDstar) return;
273 int nEntries = listDstar->GetEntriesFast();
274 if( !nEntries ) return;
fcfcc352 275 fEvent->Fill( 2 ); // EVERYTHING OKAY
276
a8f6c03f 277 AliRDHFCutsDStartoKpipi *fCutsDStartoKpipi = (AliRDHFCutsDStartoKpipi*) fCutsPOI;
8dda6917 278 if (fDebugV2) printf(" ᶫ%d candidates found. Looping...\n", nEntries);
fcfcc352 279 Int_t nIDs[3];
a8f6c03f 280 for( int iEntry=0; iEntry!=nEntries; ++iEntry ) {
8dda6917 281 AliAODRecoCascadeHF *dst = (AliAODRecoCascadeHF*) listDstar->UncheckedAt( iEntry );
282 if( !dst ) continue;
fcfcc352 283 AliAODRecoDecayHF2Prong *d0cand = (AliAODRecoDecayHF2Prong*)dst->Get2Prong();
284 if(!d0cand) continue;
285 if( !d0cand->GetDaughter(0) ) continue;
286 if( !d0cand->GetDaughter(1) ) continue;
287 if( !dst->GetBachelor() ) continue;
288 // APPLYING CUTS
8dda6917 289 if( !dst->HasSelectionBit(AliRDHFCuts::kDstarCuts) ) continue;
290 if( !fCutsDStartoKpipi->IsInFiducialAcceptance(dst->Pt(),dst->YDstar()) )continue;
fcfcc352 291 Int_t topCut=0;
292 if(dst->Pt() > 5) {
293 fCutsDStartoKpipi->SetUsePID(kFALSE);
294 topCut = fCutsDStartoKpipi->IsSelected( dst, AliRDHFCuts::kAll );
295 fCutsDStartoKpipi->SetUsePID(kTRUE);
296 } else topCut = fCutsDStartoKpipi->IsSelected( dst, AliRDHFCuts::kAll );
297 if(!topCut) continue;
8dda6917 298 Double_t massDS=dst->DeltaInvMass();
fcfcc352 299 // TO HANDLE AUTOCORRELATIONS
8dda6917 300 nIDs[0] = ((AliAODTrack*)d0cand->GetDaughter(0))->GetID();
f9507b4d 301 nIDs[1] = ((AliAODTrack*)d0cand->GetDaughter(1))->GetID();
8dda6917 302 nIDs[2] = ((AliAODTrack*)dst->GetBachelor() )->GetID();
fcfcc352 303 // ADDING TRACK
304 MakeTrack(massDS, dst->Pt(), dst->Phi(), dst->Eta(), 3, nIDs);
305 if(fDebugV2) printf(" ᶫInjecting DStar candidate %d\n",iEntry);
a8f6c03f 306 }
307}
308//______________________________________________________________________________
fcfcc352 309void AliAnalysisTaskFlowD2H::FillDplustoKpipi(const AliAODEvent *theAOD )
a8f6c03f 310{
fcfcc352 311 // Fill D+ to Kpipi
a8f6c03f 312 TList *listHF = (TList*) theAOD->GetList();
313 if(!listHF) return;
314 TClonesArray *listDplus = (TClonesArray*) listHF->FindObject("Charm3Prong");
315 if(!listDplus) return;
316 int nEntries = listDplus->GetEntriesFast();
317 if( !nEntries ) return;
fcfcc352 318 fEvent->Fill( 2 ); // EVERYTHING OKAY
319
a8f6c03f 320 AliRDHFCutsDplustoKpipi *fCutsDStartoKpipi = (AliRDHFCutsDplustoKpipi*) fCutsPOI;
8dda6917 321 if (fDebugV2) printf(" ᶫ%d candidates found. Looping...\n", nEntries);
fcfcc352 322 Int_t nIDs[3];
a8f6c03f 323 for( int iEntry=0; iEntry!=nEntries; ++iEntry ) {
8dda6917 324 AliAODRecoDecayHF3Prong *dplu = (AliAODRecoDecayHF3Prong*) listDplus->UncheckedAt( iEntry );
325 if( !dplu ) continue;
fcfcc352 326 // APPLYING CUTS
8dda6917 327 if( !dplu->HasSelectionBit(AliRDHFCuts::kDplusCuts) ) continue;
328 if( !fCutsDStartoKpipi->IsInFiducialAcceptance(dplu->Pt(),dplu->YDplus()) )continue;
fcfcc352 329 Int_t topCut = fCutsDStartoKpipi->IsSelected( dplu, AliRDHFCuts::kAll );
330 if(!topCut) continue;
8dda6917 331 Double_t massDp=dplu->InvMassDplus();
fcfcc352 332 // TO HANDLE AUTOCORRELATIONS
8dda6917 333 nIDs[0] = ((AliAODTrack*)dplu->GetDaughter(0))->GetID();
334 nIDs[1] = ((AliAODTrack*)dplu->GetDaughter(1))->GetID();
335 nIDs[2] = ((AliAODTrack*)dplu->GetDaughter(2))->GetID();
fcfcc352 336 // ADDING TRACK
337 MakeTrack(massDp, dplu->Pt(), dplu->Phi(), dplu->Eta(), 3, nIDs);
338 if(fDebugV2) printf(" ᶫInjecting Dplus candidate %d\n",iEntry);
a8f6c03f 339 }
340}
fcfcc352 341//_______________________________________________________________________________
342void AliAnalysisTaskFlowD2H::MakeTrack( Double_t mass, Double_t pt, Double_t phi,
343 Double_t eta, Int_t nDau, const Int_t *iID ) {
8dda6917 344 // create track for flow tasks
fcfcc352 345 Bool_t overwrite = kTRUE;
346 AliFlowCandidateTrack *oTrack = (static_cast<AliFlowCandidateTrack*> (fCandidates->At( fCandidates->GetLast()+1 )));
347 if( !oTrack ) { // creates new
348 oTrack = new AliFlowCandidateTrack();
349 overwrite = kFALSE;
350 } else { // overwrites
351 oTrack->ClearMe();
352 }
353 oTrack->SetMass(mass);
354 oTrack->SetPt(pt);
355 oTrack->SetPhi(phi);
356 oTrack->SetEta(eta);
a8f6c03f 357 for(Int_t iDau=0; iDau!=nDau; ++iDau)
fcfcc352 358 oTrack->AddDaughter(iID[iDau]);
359 oTrack->SetForPOISelection(kTRUE);
360 oTrack->SetForRPSelection(kFALSE);
361 if(overwrite) {
362 fCandidates->SetLast( fCandidates->GetLast()+1 );
363 } else {
364 fCandidates->AddLast(oTrack);
365 }
366 return;
a8f6c03f 367}
fc4003c2 368
369void AliAnalysisTaskFlowD2H::SetCommonConstants(Int_t massBins, Double_t minMass, Double_t maxMass, Int_t ptWidth) {
370 fMassBins = massBins;
371 fMinMass = minMass;
372 fMaxMass = maxMass;
373 fPtBinWidth = ptWidth;
374}