modified for AOD
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / AddTaskBalanceTriggered.C
CommitLineData
f8b2d882 1// now in options\r
2\r
3//PID config\r
4Bool_t kUseNSigmaPID = kFALSE;\r
5Double_t nSigmaMax = 3.0;\r
6Bool_t kUseBayesianPID = kTRUE;\r
7Double_t gMinAcceptedProbability = 0.7;\r
8\r
9//_________________________________________________________//\r
10AliAnalysisTaskTriggeredBF *AddTaskBalanceTriggered(Double_t centrMin=0.,\r
11 Double_t centrMax=100.,\r
12 Bool_t gRunShuffling=kFALSE,\r
845fdeca 13 Bool_t gRunMixing=kFALSE,\r
f8b2d882 14 TString centralityEstimator="V0M",\r
15 Double_t vertexZ=10.,\r
16 Double_t DCAxy=-1,\r
17 Double_t DCAz=-1,\r
18 Double_t ptMin=0.15,\r
19 Double_t ptMax=20,\r
20 Double_t etaMin=-0.8,\r
21 Double_t etaMax=0.8,\r
22 Double_t maxTPCchi2 = -1, \r
23 Int_t minNClustersTPC = -1,\r
24 Bool_t kUsePID = kFALSE,\r
25 Int_t AODfilterBit = 128,\r
26 Bool_t bCentralTrigger = kFALSE,\r
27 TString fileNameBase="AnalysisResults") {\r
28\r
29 // Creates a balance function analysis task and adds it to the analysis manager.\r
30 // Get the pointer to the existing analysis manager via the static access method.\r
31 TString centralityName("");\r
32 centralityName+=Form("%.0f",centrMin);\r
33 centralityName+="-";\r
34 centralityName+=Form("%.0f",centrMax);\r
35 centralityName+="_";\r
36 centralityName+=Form("%s",centralityEstimator.Data());\r
37 centralityName+="_";\r
38 centralityName+=Form("vZ%.1f",vertexZ);\r
39 centralityName+="_";\r
40 centralityName+=Form("DCAxy%.1f",DCAxy);\r
41 centralityName+="_";\r
42 centralityName+=Form("DCAz%.1f",DCAz);\r
43 centralityName+="_Pt";\r
44 centralityName+=Form("%.1f",ptMin);\r
45 centralityName+="-";\r
46 centralityName+=Form("%.1f",ptMax);\r
47 centralityName+="_Eta";\r
48 centralityName+=Form("%.1f",etaMin);\r
49 centralityName+="-";\r
50 centralityName+=Form("%.1f",etaMax);\r
51 centralityName+="_Chi";\r
52 centralityName+=Form("%.1f",maxTPCchi2);\r
53 centralityName+="_nClus";\r
54 centralityName+=Form("%d",minNClustersTPC);\r
55 centralityName+="_Bit";\r
56 centralityName+=Form("%d",AODfilterBit);\r
57 if(bCentralTrigger) centralityName+="_withCentralTrigger";\r
58\r
59\r
60\r
61 TString outputFileName(fileNameBase);\r
62 outputFileName.Append(".root");\r
63\r
64 //===========================================================================\r
65 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
66 if (!mgr) {\r
67 ::Error("AddTaskTriggeredBF", "No analysis manager to connect to.");\r
68 return NULL;\r
69 }\r
70\r
71 // Check the analysis type using the event handlers connected to the analysis manager.\r
72 //===========================================================================\r
73 if (!mgr->GetInputEventHandler()) {\r
74 ::Error("AddTaskTriggeredBF", "This task requires an input event handler");\r
75 return NULL;\r
76 }\r
77 TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"\r
78 if(dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC";\r
79\r
80 // setup the balance function objects\r
81 AliBalanceTriggered *bf = 0; // Balance Function object\r
82 AliBalanceTriggered *bfs = 0; // shuffled Balance function object\r
845fdeca 83 AliBalanceTriggered *bfm = 0; // mixing Balance function object\r
f8b2d882 84 \r
85 if (analysisType=="AOD"){\r
86 \r
87 bf = new AliBalanceTriggered();\r
88 bf->SetAnalysisLevel(analysisType);\r
f8b2d882 89 bf->InitHistograms();\r
90 \r
91 if(gRunShuffling){\r
92 bfs = new AliBalanceTriggered();\r
93 bfs->SetAnalysisLevel(analysisType);\r
f8b2d882 94 bfs->InitHistograms();\r
95 }\r
845fdeca 96 if(gRunMixing){\r
97 bfm = new AliBalanceTriggered();\r
98 bfm->SetAnalysisLevel(analysisType);\r
99 bfm->InitHistograms();\r
85379419 100 bfm->SetMixingTracks(50000)\r
845fdeca 101 }\r
f8b2d882 102 }\r
103 else{\r
104 ::Error("AddTaskTriggeredBF", "analysis type NOT supported.");\r
105 return NULL;\r
106 }\r
107\r
108 // Create the task, add it to manager and configure it.\r
109 //===========================================================================\r
110 AliAnalysisTaskTriggeredBF *taskTriggeredBF = new AliAnalysisTaskTriggeredBF("TaskTriggeredBF");\r
111 taskTriggeredBF->SetAnalysisObject(bf);\r
112 if(gRunShuffling) taskTriggeredBF->SetShufflingObject(bfs);\r
845fdeca 113 if(gRunMixing) taskTriggeredBF->SetMixingObject(bfm);\r
f8b2d882 114\r
115 taskTriggeredBF->SetCentralityPercentileRange(centrMin,centrMax);\r
116 if(analysisType == "AOD") {\r
117 // pt and eta cut (pt_min, pt_max, eta_min, eta_max)\r
118 taskTriggeredBF->SetAODtrackCutBit(AODfilterBit);\r
119 taskTriggeredBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);\r
120 \r
121 // set extra DCA cuts (-1 no extra cut)\r
122 taskTriggeredBF->SetExtraDCACutsAOD(DCAxy,DCAz);\r
123 \r
124 // set extra TPC chi2 / nr of clusters cut\r
125 taskTriggeredBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);\r
126 \r
127 }\r
128\r
129 // offline trigger selection (AliVEvent.h)\r
130 // taskTriggeredBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) \r
131 // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))\r
132 // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation\r
133 if(bCentralTrigger) taskTriggeredBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);\r
134 else taskTriggeredBF->SelectCollisionCandidates(AliVEvent::kMB);\r
135\r
136 // centrality estimator (default = V0M)\r
137 taskTriggeredBF->SetCentralityEstimator(centralityEstimator);\r
138 \r
139 // vertex cut (x,y,z)\r
140 taskTriggeredBF->SetVertexDiamond(.3,.3,vertexZ);\r
141 \r
142 //bf->PrintAnalysisSettings();\r
143 mgr->AddTask(taskTriggeredBF);\r
144 \r
145 // Create ONLY the output containers for the data produced by the task.\r
146 // Get and connect other common input/output containers via the manager as below\r
147 //==============================================================================\r
148 TString outputFileName = AliAnalysisManager::GetCommonFileName();\r
bf7a73c8 149 outputFileName += ":PWGCFEbyE.outputBalanceFunctionTriggeredAnalysis";\r
f8b2d882 150 AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQA_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
151 AliAnalysisDataContainer *coutTriggeredBF = mgr->CreateContainer(Form("listTriggeredBF_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
152 if(gRunShuffling) AliAnalysisDataContainer *coutTriggeredBFS = mgr->CreateContainer(Form("listTriggeredBFShuffled_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
85379419 153 if(gRunMixing) AliAnalysisDataContainer *coutTriggeredBFM = mgr->CreateContainer(Form("listTriggeredBFMixed_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
f8b2d882 154\r
155 mgr->ConnectInput(taskTriggeredBF, 0, mgr->GetCommonInputContainer());\r
156 mgr->ConnectOutput(taskTriggeredBF, 1, coutQA);\r
157 mgr->ConnectOutput(taskTriggeredBF, 2, coutTriggeredBF);\r
158 if(gRunShuffling) mgr->ConnectOutput(taskTriggeredBF, 3, coutTriggeredBFS);\r
85379419 159 if(gRunMixing) mgr->ConnectOutput(taskTriggeredBF, 4, coutTriggeredBFM);\r
f8b2d882 160\r
161 return taskTriggeredBF;\r
162}\r