AliPhysics  master (3d17d9d)
AddTaskDplus.C
Go to the documentation of this file.
1 AliAnalysisTaskSEDplus *AddTaskDplus(Int_t system=AliAnalysisTaskSEDplus::kpp,
2  Float_t minC=0, Float_t maxC=100,
3  Bool_t storeTree=0,
4  Int_t doSparse=0,/*0=cutvar=kFALSE && imppar=kFALSE, 1=cutvar=kTRUE && imppar=kFALSE*/
5  /*2=cutvar=kFALSE && imppar=kTRUE, 3=cutvar=kTRUE && imppar=kTRUE*/
6  Bool_t doTrackVarSparse=kFALSE,
7  Bool_t readMC=kFALSE,
8  TString finDirname="Loose",
9  TString filename="",
10  TString finAnObjname="AnalysisCuts",
11  Int_t etaRange=0,
12  Bool_t cutsDistr=kFALSE,
13  Int_t trackletsmin=-1,
14  Int_t trackletsmax=-1)
15 {
16  //
17  // Test macro for the AliAnalysisTaskSE for D+ candidates
18 
19  //Invariant mass histogram and
20  // association with MC truth (using MC info in AOD)
21  // R. Bala, bala@to.infn.it
22  // Get the pointer to the existing analysis manager via the static access method.
23  //==============================================================================
24  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
25  if (!mgr) {
26  ::Error("AddTaskDplus", "No analysis manager to connect to.");
27  }
28 
29  Bool_t stdcuts=kFALSE;
30  TFile* filecuts;
31  if( filename.EqualTo("") ) {
32  stdcuts=kTRUE;
33  } else {
34  filecuts=TFile::Open(filename.Data());
35  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
36  ::Fatal("AddTaskDplus", "Input file not found : check your cut object");
37  }
38  }
39 
40 
41  //Analysis Task
42 
43 
45  if(stdcuts) {
46  if(system==0) analysiscuts->SetStandardCutsPP2010();
47  else if(system==1){
48  analysiscuts->SetStandardCutsPbPb2011();
49  analysiscuts->SetMinCentrality(minC);
50  analysiscuts->SetMaxCentrality(maxC);
51  // analysiscuts->SetUseAOD049(kTRUE);
53  }
54  }
55  else analysiscuts = (AliRDHFCutsDplustoKpipi*)filecuts->Get(finAnObjname);
56 
57 
58  AliAnalysisTaskSEDplus *dplusTask = new AliAnalysisTaskSEDplus("DplusAnalysis",analysiscuts,storeTree);
59  dplusTask->SetReadMC(readMC);
60  dplusTask->SetDoLikeSign(kFALSE);
61  dplusTask->SetDebugLevel(0);
62  dplusTask->SetMassLimits(0.2);
63  dplusTask->SetUseBit(kTRUE);
64  dplusTask->SetCutsDistr(cutsDistr);
65  dplusTask->SetSystem(system);
66  if(system == AliAnalysisTaskSEDplus::kPbPb) {
67  dplusTask->SetKeepOnlyBkgFromHIJING(kTRUE);
68  }
69  if(doSparse==0) {
70  dplusTask->SetDoCutVarsSparses(kFALSE);
71  dplusTask->SetDoImpactParameterHistos(kFALSE);
72  }
73  else if(doSparse==1) {
74  dplusTask->SetDoCutVarsSparses(kTRUE);
75  dplusTask->SetDoImpactParameterHistos(kFALSE);
76  }
77  else if(doSparse==2) {
78  dplusTask->SetDoCutVarsSparses(kFALSE);
79  dplusTask->SetDoImpactParameterHistos(kTRUE);
80  }
81  else if(doSparse==3){
82  dplusTask->SetDoCutVarsSparses(kTRUE);
83  dplusTask->SetDoImpactParameterHistos(kTRUE);
84  }
85  else {
86  cerr << "The doSparse flag can only be 0,1,2,3!" << endl;
87  }
88 
89  if((doSparse==1 || doSparse==3) && readMC)
90  dplusTask->SetDoMCAcceptanceHistos(kTRUE);
91  if (doTrackVarSparse)
92  dplusTask->SetDoTrackVarHistos(kTRUE);
93  if(etaRange==1) dplusTask->SetUseOnlyPositiveEta();
94  if(etaRange==-1) dplusTask->SetUseOnlyNegativeEta();
95  if(trackletsmin>=0 && trackletsmax>=0 && trackletsmax>trackletsmin) dplusTask->SetCutOnNtracklets(kTRUE,trackletsmin,trackletsmax);
96  mgr->AddTask(dplusTask);
97 
98  // Create containers for input/output
99 
100  TString inname = "cinputDplus";
101  TString outname = "coutputDplus";
102  TString cutsname = "coutputDplusCuts";
103  TString normname = "coutputDplusNorm";
104  TString treename = "coutputDplus2";
105  inname += finDirname.Data();
106  outname += finDirname.Data();
107  cutsname += finDirname.Data();
108  normname += finDirname.Data();
109  treename += finDirname.Data();
110  TString centr=Form("%.0f%.0f",analysiscuts->GetMinCentrality(),analysiscuts->GetMaxCentrality());
111  inname += centr;
112  outname += centr;
113  cutsname += centr;
114  normname += centr;
115  treename += centr;
116 
117 
118  AliAnalysisDataContainer *cinputDplus = mgr->CreateContainer(inname,TChain::Class(),
119  AliAnalysisManager::kInputContainer);
120  TString outputfile = AliAnalysisManager::GetCommonFileName();
121  outputfile += ":PWG3_D2H_InvMassDplus";
122 
123  AliAnalysisDataContainer *coutputDplusCuts = mgr->CreateContainer(cutsname,TList::Class(),
124  AliAnalysisManager::kOutputContainer,
125  outputfile.Data());
126 
127  AliAnalysisDataContainer *coutputDplus = mgr->CreateContainer(outname,TList::Class(),
128  AliAnalysisManager::kOutputContainer,
129  outputfile.Data());
130  AliAnalysisDataContainer *coutputDplusNorm = mgr->CreateContainer(normname,AliNormalizationCounter::Class(),
131  AliAnalysisManager::kOutputContainer,
132  outputfile.Data());
133  AliAnalysisDataContainer *coutputDplus2 = 0x0;
134  if(storeTree){
135  coutputDplus2 = mgr->CreateContainer(treename,TTree::Class(),
136  AliAnalysisManager::kOutputContainer,
137  outputfile.Data());
138 
139  coutputDplus2->SetSpecialOutput();
140  }
141  mgr->ConnectInput(dplusTask,0,mgr->GetCommonInputContainer());
142 
143  mgr->ConnectOutput(dplusTask,1,coutputDplus);
144 
145  mgr->ConnectOutput(dplusTask,2,coutputDplusCuts);
146 
147  mgr->ConnectOutput(dplusTask,3,coutputDplusNorm);
148  if(storeTree){
149  mgr->ConnectOutput(dplusTask,4,coutputDplus2);
150  }
151 
152  return dplusTask;
153 }
Float_t GetMaxCentrality() const
Definition: AliRDHFCuts.h:299
const char * filename
Definition: TestFCM.C:1
AliAnalysisTaskSEDplus * AddTaskDplus(Int_t system=AliAnalysisTaskSEDplus::kpp, Float_t minC=0, Float_t maxC=100, Bool_t storeTree=0, Int_t doSparse=0, Bool_t doTrackVarSparse=kFALSE, Bool_t readMC=kFALSE, TString finDirname="Loose", TString filename="", TString finAnObjname="AnalysisCuts", Int_t etaRange=0, Bool_t cutsDistr=kFALSE, Int_t trackletsmin=-1, Int_t trackletsmax=-1)
Definition: AddTaskDplus.C:1
void SetUseCentrality(Int_t flag=1)
Float_t GetMinCentrality() const
Definition: AliRDHFCuts.h:298
Class for cuts on AOD reconstructed D+->Kpipi.
int Int_t
Definition: External.C:63
void SetMinCentrality(Float_t minCentrality=0.)
Definition: AliRDHFCuts.h:54
float Float_t
Definition: External.C:68
void SetMaxCentrality(Float_t maxCentrality=100.)
Definition: AliRDHFCuts.h:55
bool Bool_t
Definition: External.C:53