]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/vertexingHF/charmFlow/AliAnalysisTaskFlowD2H.cxx
Added support for dylib in test mode
[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),
b9eaee3e 66 fSource(0), fDebugV2(kFALSE), fSwap(kFALSE), fMassBins(0), fMinMass(0.),
fc4003c2 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),
b9eaee3e 81 fSource(specie), fDebugV2(kFALSE), fSwap(kFALSE), fMassBins(0), fMinMass(0.),
fc4003c2 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();
d3e9f24a 128 cc->SetNbinsMult(500);
fc4003c2 129 cc->SetNbinsPt(24/fPtBinWidth);
d3e9f24a 130 cc->SetNbinsPhi(360);
131 cc->SetNbinsEta(90);
132 cc->SetNbinsQ(100);
fc4003c2 133 cc->SetNbinsMass( fMassBins );
d3e9f24a 134 cc->SetMultMin(0);
135 cc->SetMultMax(500);
fc4003c2 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) );
d3e9f24a 226 fTPCEvent->SetNumberOfPOIs(fTPCEvent->GetNumberOfPOIs()+1);
227 fVZEEvent->SetNumberOfPOIs(fVZEEvent->GetNumberOfPOIs()+1);
fc4003c2 228 }
229 if(fDebugV2) printf("TPCevent %d | VZEevent %d\n", fTPCEvent->NumberOfTracks(), fVZEEvent->NumberOfTracks() );
a8f6c03f 230
fc4003c2 231 PostData(1,fHList);
232 PostData(2,fTPCEvent);
233 PostData(3,fVZEEvent);
a8f6c03f 234}
235//______________________________________________________________________________
fcfcc352 236void AliAnalysisTaskFlowD2H::FillD0toKpi(const AliAODEvent *theAOD)
a8f6c03f 237{
8dda6917 238 // Fill D0->Kpi histos
a8f6c03f 239 TList *listHF = (TList*) theAOD->GetList();
240 if(!listHF) return;
241 TClonesArray *listDzero = (TClonesArray*) listHF->FindObject("D0toKpi");
242 if(!listDzero) return;
243 int nEntries = listDzero->GetEntriesFast();
244 if( !nEntries ) return;
fcfcc352 245 fEvent->Fill( 2 ); // EVERYTHING OKAY
246
a8f6c03f 247 AliRDHFCutsD0toKpi *fCutsD0toKpi = (AliRDHFCutsD0toKpi*) fCutsPOI;
8dda6917 248 if (fDebugV2) printf(" ᶫ%d candidates found. Looping...\n", nEntries);
fcfcc352 249 Int_t nIDs[2];
a8f6c03f 250 for( int iEntry=0; iEntry!=nEntries; ++iEntry ) {
8dda6917 251 AliAODRecoDecayHF2Prong *d0cand = (AliAODRecoDecayHF2Prong*) listDzero->UncheckedAt( iEntry );
252 if( !d0cand ) continue;
fcfcc352 253 // APPLYING CUTS
8dda6917 254 if( !d0cand->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts) ) continue;
255 if( !fCutsD0toKpi->IsInFiducialAcceptance(d0cand->Pt(),d0cand->Y(421)) )continue;
fcfcc352 256 Int_t topCut = fCutsD0toKpi->IsSelected( d0cand, AliRDHFCuts::kAll, NULL );
257 if(!topCut) continue;
450c0ff6 258 Double_t massD0=topCut>1?d0cand->InvMassD0bar():d0cand->InvMassD0();
b9eaee3e 259 if((fSwap)&&(topCut==3)) {
260 massD0=d0cand->InvMassD0();
261 }
262
fcfcc352 263 // TO HANDLE AUTOCORRELATIONS
264 nIDs[0] = ( (AliAODTrack*)d0cand->GetDaughter(0) )->GetID();
265 nIDs[1] = ( (AliAODTrack*)d0cand->GetDaughter(1) )->GetID();
450c0ff6 266 // ADDING TRACK
267 MakeTrack(massD0, d0cand->Pt(), d0cand->Phi(), d0cand->Eta(), 2, nIDs);
fcfcc352 268 if(fDebugV2) printf(" ᶫInjecting D0 candidate\n");
a8f6c03f 269 }
270}
271//______________________________________________________________________________
fcfcc352 272void AliAnalysisTaskFlowD2H::FillDStartoKpipi(const AliAODEvent *theAOD )
a8f6c03f 273{
fcfcc352 274 // Fills D* to Kpipi
a8f6c03f 275 TList *listHF = (TList*) theAOD->GetList();
276 if(!listHF) return;
277 TClonesArray *listDstar = (TClonesArray*) listHF->FindObject("Dstar");
278 if(!listDstar) return;
279 int nEntries = listDstar->GetEntriesFast();
280 if( !nEntries ) return;
fcfcc352 281 fEvent->Fill( 2 ); // EVERYTHING OKAY
282
a8f6c03f 283 AliRDHFCutsDStartoKpipi *fCutsDStartoKpipi = (AliRDHFCutsDStartoKpipi*) fCutsPOI;
8dda6917 284 if (fDebugV2) printf(" ᶫ%d candidates found. Looping...\n", nEntries);
fcfcc352 285 Int_t nIDs[3];
a8f6c03f 286 for( int iEntry=0; iEntry!=nEntries; ++iEntry ) {
8dda6917 287 AliAODRecoCascadeHF *dst = (AliAODRecoCascadeHF*) listDstar->UncheckedAt( iEntry );
288 if( !dst ) continue;
fcfcc352 289 AliAODRecoDecayHF2Prong *d0cand = (AliAODRecoDecayHF2Prong*)dst->Get2Prong();
290 if(!d0cand) continue;
291 if( !d0cand->GetDaughter(0) ) continue;
292 if( !d0cand->GetDaughter(1) ) continue;
293 if( !dst->GetBachelor() ) continue;
294 // APPLYING CUTS
8dda6917 295 if( !dst->HasSelectionBit(AliRDHFCuts::kDstarCuts) ) continue;
296 if( !fCutsDStartoKpipi->IsInFiducialAcceptance(dst->Pt(),dst->YDstar()) )continue;
fcfcc352 297 Int_t topCut=0;
e079069f 298 topCut = fCutsDStartoKpipi->IsSelected( dst, AliRDHFCuts::kAll );
fcfcc352 299 if(!topCut) continue;
8dda6917 300 Double_t massDS=dst->DeltaInvMass();
fcfcc352 301 // TO HANDLE AUTOCORRELATIONS
8dda6917 302 nIDs[0] = ((AliAODTrack*)d0cand->GetDaughter(0))->GetID();
f9507b4d 303 nIDs[1] = ((AliAODTrack*)d0cand->GetDaughter(1))->GetID();
8dda6917 304 nIDs[2] = ((AliAODTrack*)dst->GetBachelor() )->GetID();
fcfcc352 305 // ADDING TRACK
306 MakeTrack(massDS, dst->Pt(), dst->Phi(), dst->Eta(), 3, nIDs);
307 if(fDebugV2) printf(" ᶫInjecting DStar candidate %d\n",iEntry);
a8f6c03f 308 }
309}
310//______________________________________________________________________________
fcfcc352 311void AliAnalysisTaskFlowD2H::FillDplustoKpipi(const AliAODEvent *theAOD )
a8f6c03f 312{
fcfcc352 313 // Fill D+ to Kpipi
a8f6c03f 314 TList *listHF = (TList*) theAOD->GetList();
315 if(!listHF) return;
316 TClonesArray *listDplus = (TClonesArray*) listHF->FindObject("Charm3Prong");
317 if(!listDplus) return;
318 int nEntries = listDplus->GetEntriesFast();
319 if( !nEntries ) return;
fcfcc352 320 fEvent->Fill( 2 ); // EVERYTHING OKAY
321
a8f6c03f 322 AliRDHFCutsDplustoKpipi *fCutsDStartoKpipi = (AliRDHFCutsDplustoKpipi*) fCutsPOI;
8dda6917 323 if (fDebugV2) printf(" ᶫ%d candidates found. Looping...\n", nEntries);
fcfcc352 324 Int_t nIDs[3];
a8f6c03f 325 for( int iEntry=0; iEntry!=nEntries; ++iEntry ) {
8dda6917 326 AliAODRecoDecayHF3Prong *dplu = (AliAODRecoDecayHF3Prong*) listDplus->UncheckedAt( iEntry );
327 if( !dplu ) continue;
fcfcc352 328 // APPLYING CUTS
8dda6917 329 if( !dplu->HasSelectionBit(AliRDHFCuts::kDplusCuts) ) continue;
330 if( !fCutsDStartoKpipi->IsInFiducialAcceptance(dplu->Pt(),dplu->YDplus()) )continue;
fcfcc352 331 Int_t topCut = fCutsDStartoKpipi->IsSelected( dplu, AliRDHFCuts::kAll );
332 if(!topCut) continue;
8dda6917 333 Double_t massDp=dplu->InvMassDplus();
fcfcc352 334 // TO HANDLE AUTOCORRELATIONS
8dda6917 335 nIDs[0] = ((AliAODTrack*)dplu->GetDaughter(0))->GetID();
336 nIDs[1] = ((AliAODTrack*)dplu->GetDaughter(1))->GetID();
337 nIDs[2] = ((AliAODTrack*)dplu->GetDaughter(2))->GetID();
fcfcc352 338 // ADDING TRACK
339 MakeTrack(massDp, dplu->Pt(), dplu->Phi(), dplu->Eta(), 3, nIDs);
340 if(fDebugV2) printf(" ᶫInjecting Dplus candidate %d\n",iEntry);
a8f6c03f 341 }
342}
fcfcc352 343//_______________________________________________________________________________
344void AliAnalysisTaskFlowD2H::MakeTrack( Double_t mass, Double_t pt, Double_t phi,
345 Double_t eta, Int_t nDau, const Int_t *iID ) {
8dda6917 346 // create track for flow tasks
fcfcc352 347 Bool_t overwrite = kTRUE;
348 AliFlowCandidateTrack *oTrack = (static_cast<AliFlowCandidateTrack*> (fCandidates->At( fCandidates->GetLast()+1 )));
349 if( !oTrack ) { // creates new
350 oTrack = new AliFlowCandidateTrack();
351 overwrite = kFALSE;
352 } else { // overwrites
353 oTrack->ClearMe();
354 }
355 oTrack->SetMass(mass);
356 oTrack->SetPt(pt);
357 oTrack->SetPhi(phi);
358 oTrack->SetEta(eta);
a8f6c03f 359 for(Int_t iDau=0; iDau!=nDau; ++iDau)
fcfcc352 360 oTrack->AddDaughter(iID[iDau]);
361 oTrack->SetForPOISelection(kTRUE);
362 oTrack->SetForRPSelection(kFALSE);
363 if(overwrite) {
364 fCandidates->SetLast( fCandidates->GetLast()+1 );
365 } else {
366 fCandidates->AddLast(oTrack);
367 }
368 return;
a8f6c03f 369}
fc4003c2 370
371void AliAnalysisTaskFlowD2H::SetCommonConstants(Int_t massBins, Double_t minMass, Double_t maxMass, Int_t ptWidth) {
372 fMassBins = massBins;
373 fMinMass = minMass;
374 fMaxMass = maxMass;
375 fPtBinWidth = ptWidth;
376}
dffffe9e 377
378//=======================================================================
379void AliAnalysisTaskFlowD2H::Terminate(Option_t *)
380{
381 //terminate
382}