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