cda526070b8653314145c9e9393a75152ee0599e
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / AddTaskFlowTPCTOFQCSP.C
1 ///////////////////////////////////////////////////////////////////\r
2 //                                                               //            \r
3 // AddTaskFlowTPCTOFQCSP macro                                     //\r
4 // Author: Andrea Dubla, Utrecht University, 2012                //\r
5 //                                                               //\r
6 ///////////////////////////////////////////////////////////////////\r
7 class AliAnalysisDataContainer;\r
8 class AliFlowTrackCuts;\r
9 class AliFlowTrackSimpleCuts;\r
10 class AliFlowEventCuts;\r
11 class AliFlowEventSimpleCuts;\r
12 class AliAnalysisDataContainer;\r
13 class AliHFEextraCuts;\r
14 \r
15 AliAnalysisTaskFlowTPCTOFQCSP* AddTaskFlowTPCTOFQCSP(\r
16                                               TString uniqueID = "",\r
17                                               Float_t centrMin ,\r
18                                               Float_t centrMax ,\r
19                                               Double_t InvmassCut,\r
20                                               Bool_t op_ang = kTRUE,\r
21                                               Double_t op_angle_cut,\r
22                                               Int_t Trigger,\r
23                                               Double_t minTPCnsigma,\r
24                                               Double_t maxTPCnsigma,\r
25                                               Double_t minTOFnSigma,\r
26                                               Double_t maxTOFnSigma,\r
27                                               Int_t minTPCCluster,\r
28                                               Int_t TPCS,\r
29                                               Int_t Vz,\r
30                                               AliHFEextraCuts::ITSPixel_t pixel,\r
31                                               Bool_t PhiCut = kFALSE,\r
32                                               Bool_t QaPidSparse = kFALSE,\r
33                                               const char *Cent = "V0M",\r
34                                               Bool_t QC = kTRUE, // use qc2 and qc4\r
35                                               Bool_t SP_TPC = kTRUE, //use tpc sp method\r
36                                               Bool_t VZERO_SP = kFALSE, // use vzero sp method\r
37                                               Int_t harmonic = 2,\r
38                                               Bool_t shrinkSP = kTRUE,\r
39                                               Bool_t debug = kFALSE,\r
40                                               Int_t RPFilterBit = 1\r
41                                               )\r
42 \r
43 {\r
44 \r
45 \r
46 \r
47     if(debug) cout << " === Adding Task ElectFlow === " << endl;    \r
48     TString fileName = AliAnalysisManager::GetCommonFileName();\r
49     fileName += ":ElectroID_";\r
50     fileName += uniqueID;\r
51     if(debug) cout << "    --> Reconstruction data container: " << fileName << endl;\r
52     AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
53     if (!mgr) {\r
54         if(debug) cout << " Fatal error: no analysis manager found! " << endl;\r
55         return 0x0;\r
56     }\r
57     if (!mgr->GetInputEventHandler()) {\r
58         if(debug) cout << " Fatal error: no imput event handler found!" << endl;\r
59         return 0x0;\r
60     }\r
61 \r
62 //create a task\r
63   AliAnalysisTaskFlowTPCTOFQCSP *taskHFE = ConfigHFEStandardCuts(minTPCCluster, pixel);    //kTRUE if MC\r
64     \r
65   if(debug) cout << " === AliAnalysisTaskFlowTPCTOFQCSP === " << taskHFE << endl;\r
66   if(!taskHFE) {\r
67         if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl;\r
68         return 0x0;\r
69     }\r
70     \r
71 // Set centrality percentiles and method V0M, FMD, TRK, TKL, CL0, CL1, V0MvsFMD, TKLvsV0M, ZEMvsZDC\r
72   taskHFE->SetCentralityParameters(centrMin, centrMax, Cent);\r
73   taskHFE->SetInvariantMassCut(InvmassCut);\r
74   taskHFE->SetTrigger(Trigger);\r
75   taskHFE->SetTPCS(TPCS);\r
76   taskHFE->SetVz(Vz);\r
77   taskHFE->SetIDCuts(minTPCnsigma, maxTPCnsigma, minTOFnSigma, maxTOFnSigma);\r
78   taskHFE->SetQAPIDSparse(QaPidSparse);\r
79   taskHFE->SetPhiCut(PhiCut);\r
80   taskHFE->SetOpeningAngleflag(op_ang);\r
81   taskHFE->SetOpeningAngleCut(op_angle_cut);\r
82     \r
83     \r
84 //set RP cuts for flow package analysis\r
85   cutsRP = new AliFlowTrackCuts(Form("RFPcuts%s",uniqueID));\r
86     if(!cutsRP) {\r
87         if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl;\r
88         return 0x0;\r
89     }\r
90 \r
91     if(!VZERO_SP) {\r
92         AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;\r
93         cutsRP->SetParamType(rptype);\r
94         cutsRP->SetAODfilterBit(RPFilterBit);\r
95         cutsRP->SetPtRange(0.2, 5.0);\r
96         cutsRP->SetEtaRange(-0.8, 0.8);\r
97         cutsRP->SetMinNClustersTPC(70);\r
98         cutsRP->SetMinChi2PerClusterTPC(0.1);\r
99         cutsRP->SetMaxChi2PerClusterTPC(4.0);\r
100         cutsRP->SetRequireTPCRefit(kTRUE);\r
101         cutsRP->SetMaxDCAToVertexXY(0.3);\r
102         cutsRP->SetMaxDCAToVertexZ(0.3);\r
103         cutsRP->SetAcceptKinkDaughters(kFALSE);\r
104         cutsRP->SetMinimalTPCdedx(10.);\r
105         if(debug) cout << "    --> kGlobal RP's " << cutsRP << endl;\r
106     }\r
107     if(VZERO_SP) { // use vzero sub analysis\r
108         cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks\r
109         SP_TPC = kFALSE; // disable other methods\r
110         QC = kFALSE;\r
111         if(debug) cout << "    --> VZERO RP's " << cutsRP << endl;\r
112     }\r
113 \r
114     AliFlowTrackSimpleCuts *POIfilterLeft = new AliFlowTrackSimpleCuts();\r
115     AliFlowTrackSimpleCuts *POIfilterRight = new AliFlowTrackSimpleCuts();\r
116     if(SP_TPC){\r
117         POIfilterLeft->SetEtaMin(-0.8);\r
118         POIfilterLeft->SetEtaMax(0.0);\r
119         POIfilterLeft->SetMassMin(263731); POIfilterLeft->SetMassMax(263733);\r
120 \r
121         POIfilterRight->SetEtaMin(0.0);\r
122         POIfilterRight->SetEtaMax(0.8);\r
123         POIfilterRight->SetMassMin(263731); POIfilterRight->SetMassMax(263733);\r
124     }\r
125 \r
126     \r
127     AliFlowTrackSimpleCuts *POIfilterVZERO = new AliFlowTrackSimpleCuts();\r
128     if(VZERO_SP || QC){\r
129         POIfilterVZERO->SetEtaMin(-0.8);\r
130         POIfilterVZERO->SetEtaMax(0.8);\r
131         POIfilterVZERO->SetMassMin(263731); POIfilterVZERO->SetMassMax(263733);\r
132  \r
133     }\r
134  \r
135     \r
136     taskHFE->SetRPCuts(cutsRP);\r
137  \r
138  \r
139  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(Form("ccontainer0_%s",uniqueID.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,fileName);\r
140   \r
141  mgr->ConnectInput(taskHFE,0,mgr->GetCommonInputContainer());\r
142  mgr->ConnectOutput(taskHFE,1,coutput3);\r
143     \r
144  \r
145     if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl;\r
146     AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FlowContainer_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);\r
147     mgr->ConnectOutput(taskHFE, 2, flowEvent);\r
148     if(debug) cout << "    --> Created IO containers " << flowEvent << endl;   \r
149     \r
150     \r
151   mgr->AddTask(taskHFE);\r
152     \r
153     if (QC) {  // add qc tasks\r
154         TPCTOF::AddQCmethod(Form("QCTPCin_%s",uniqueID.Data()), harmonic, flowEvent,  debug ,uniqueID, -0.8, -0.0, 0.0, 0.8,false,POIfilterVZERO);\r
155         if(debug) cout << "    --> Hanging QC task ...succes! "<< endl;\r
156     }   \r
157     if (SP_TPC) {  // add sp subevent tasks\r
158         TPCTOF::AddSPmethod(Form("SPTPCQa_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterRight);\r
159         if(debug) cout << "    --> Hanging SP Qa task ... succes!" << endl;\r
160         TPCTOF::AddSPmethod(Form("SPTPCQb_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qb", harmonic, flowEvent,  false, shrinkSP, debug,uniqueID, false, POIfilterLeft);\r
161         if(debug) cout << "    --> Hanging SP Qb task ... succes!"<< endl;\r
162     }\r
163     if (VZERO_SP) {  // add sp subevent tasks\r
164         TPCTOF::AddSPmethod(Form("SPVZEROQa_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterVZERO);\r
165         if(debug) cout << "    --> Hanging SP Qa task ... succes!" << endl;\r
166         TPCTOF::AddSPmethod(Form("SPVZEROQb_in_%s", uniqueID.Data()), -0.8, -.0, .0, +0.8, "Qb", harmonic, flowEvent,  false, shrinkSP, debug,uniqueID, true, POIfilterVZERO);\r
167         if(debug) cout << "    --> Hanging SP Qb task ... succes!"<< endl;\r
168     }\r
169 \r
170 \r
171     \r
172 return taskHFE;\r
173 \r
174 }\r
175 \r
176 //_____________________________________________________________________________\r
177 //_____________________________________________________________________________\r
178                     \r
179 AliAnalysisTaskFlowTPCTOFQCSP* ConfigHFEStandardCuts(Int_t minTPCCulster,AliHFEextraCuts::ITSPixel_t pixel){\r
180     //\r
181     // HFE standard task configuration\r
182     //\r
183     \r
184     Bool_t kAnalyseTaggedTracks = kTRUE;\r
185     \r
186     AliHFEcuts *hfecuts = new AliHFEcuts("hfeCuts","HFE Standard Cuts");  //TODO....change the cuts values to PbPb\r
187     //  hfecuts->CreateStandardCuts();\r
188     hfecuts->SetMinNClustersTPC(minTPCCulster);\r
189     hfecuts->SetMinNClustersITS(3);\r
190     hfecuts->SetMinNTrackletsTRD(0);\r
191     hfecuts->SetMinRatioTPCclusters(0.6);\r
192     \r
193     //   hfecuts->SetEtaRange(-0.9,0.9);\r
194     //   hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);\r
195     hfecuts->SetRequireITSPixel();\r
196     hfecuts->SetCutITSpixel(pixel);//kAny\r
197     hfecuts->SetMaxChi2perClusterITS(-1);\r
198     hfecuts->SetMaxChi2perClusterTPC(3.5);\r
199     hfecuts->SetCheckITSLayerStatus(kFALSE); // shud be put back\r
200     //  hfecuts->UnsetVertexRequirement();\r
201     hfecuts->SetVertexRange(10.);\r
202     hfecuts->SetRequireSigmaToVertex();\r
203     //hfecuts->SetSigmaToVertex(10);\r
204     hfecuts->SetTOFPIDStep(kFALSE);\r
205     //  hfecuts->SetQAOn();\r
206     hfecuts->SetPtRange(0, 30);\r
207     \r
208     AliAnalysisTaskFlowTPCTOFQCSP *task = new AliAnalysisTaskFlowTPCTOFQCSP("HFE_Flow_TPCTOF");\r
209     printf("*************************************************************");\r
210     printf("task -------------------------------------------- %p\n ", task);\r
211     printf("*************************************************************\n");\r
212 \r
213     \r
214     task->SetHFECuts(hfecuts);\r
215     \r
216     //   task->SetInvariantMassCut(0.05);\r
217     //  task->SetRejectKinkMother(kTRUE);\r
218     //  task->SetRemovePileUp(kTRUE);\r
219     \r
220     // Define PID\r
221  //   AliHFEpid *pid = task->GetPID();\r
222  //   if(useMC) pid->SetHasMCData(kTRUE);\r
223  //   pid->AddDetector("TPC", 0);\r
224    // pid->AddDetector("EMCAL", 1);\r
225     \r
226  //   printf("*************************************\n");\r
227  //   printf("Configuring standard Task:\n");\r
228     //  task->PrintStatus();\r
229   //  pid->PrintStatus();\r
230   //  printf("*************************************\n");\r
231     return task;\r
232     \r
233     \r
234 }\r
235 \r
236 //_____________________________________________________________________________\r
237 \r
238 namespace TPCTOF{\r
239     //_____________________________________________________________________________\r
240     void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, bool bEP, bool shrink = false, bool debug, TString uniqueID,Bool_t VZERO_SP = kFALSE,  AliFlowTrackSimpleCuts* POIfilter)\r
241     {\r
242         // add sp task and invm filter tasks\r
243         if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl;\r
244         TString fileName = AliAnalysisManager::GetCommonFileName();\r
245         (bEP) ? fileName+=":EP_tpctof" : fileName+=":SP_tpctof";\r
246         //          if(etagap) {\r
247         //            fileName+="_SUBEVENTS";\r
248         //          if(debug) cout << "    --> Setting up subevent analysis <-- " << endl;\r
249         //    }\r
250         if(debug) cout << "    --> fileName " << fileName << endl;\r
251         TString myFolder = fileName;\r
252         if(debug) cout << "    --> myFolder " << myFolder << endl;\r
253         TString myNameSP;\r
254         (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector);\r
255         if(debug) cout << " myNameSP " << myNameSP << endl;\r
256         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
257         AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s",myNameSP.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);\r
258         AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), NULL, POIfilter);\r
259         tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB);\r
260         if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10);\r
261         mgr->AddTask(tskFilter);\r
262         mgr->ConnectInput(tskFilter, 0, flowEvent);\r
263         mgr->ConnectOutput(tskFilter, 1, flowEventOut);\r
264         AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);\r
265         AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE);\r
266         tskSP->SetApplyCorrectionForNUA(kTRUE);\r
267         tskSP->SetHarmonic(harmonic);\r
268         tskSP->SetTotalQvector(Qvector);\r
269         if (bEP) tskSP->SetBehaveAsEP();\r
270         if (shrink) tskSP->SetBookOnlyBasicCCH(kTRUE);\r
271         mgr->AddTask(tskSP);\r
272         mgr->ConnectInput(tskSP, 0, flowEventOut);\r
273         mgr->ConnectOutput(tskSP, 1, outSP);\r
274     }\r
275     //_____________________________________________________________________________\r
276     void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, Bool_t debug, TString uniqueID,double minEtaA, double maxEtaA, double minEtaB, double maxEtaB,Bool_t VZERO_SP = kFALSE,  AliFlowTrackSimpleCuts* POIfilter)\r
277     {\r
278         // add qc task and invm filter tasks\r
279         if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", IO ****** " << flowEvent << endl;\r
280         TString fileName = AliAnalysisManager::GetCommonFileName();\r
281         fileName+=":QC_tpctof";\r
282         if(debug) cout << "    --> Common filename: " << fileName << endl;\r
283         TString myFolder = Form("v%d", harmonic);\r
284         if(debug) cout << "    --> myFolder: " << myFolder << endl;\r
285         TString myName = Form("%s", name);\r
286         if(debug) cout << "    --> myName: " << myName << endl;\r
287         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
288         AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);\r
289         AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), NULL, POIfilter);\r
290         tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB);\r
291         //    if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10);\r
292         mgr->AddTask(tskFilter);\r
293         mgr->ConnectInput(tskFilter, 0, flowEvent);\r
294         mgr->ConnectOutput(tskFilter, 1, flowEventOut);\r
295         \r
296         AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);\r
297         AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE);\r
298         tskQC->SetApplyCorrectionForNUA(kTRUE);\r
299         tskQC->SetHarmonic(harmonic);\r
300         tskQC->SetBookOnlyBasicCCH(kTRUE);\r
301         mgr->AddTask(tskQC);\r
302         mgr->ConnectInput(tskQC, 0, flowEventOut);\r
303         mgr->ConnectOutput(tskQC, 1, outQC);\r
304     }\r
305     //_____________________________________________________________________________\r
306 }\r
307 \r
308 \r
309 \r