1 ///////////////////////////////////////////////////////////////////
3 // AddTaskFlowTPCEMCalQCSP macro //
4 // Author: Andrea Dubla, Utrecht University, 2012 //
6 ///////////////////////////////////////////////////////////////////
7 class AliAnalysisDataContainer;
8 class AliFlowTrackCuts;
9 class AliFlowTrackSimpleCuts;
10 class AliFlowEventCuts;
11 class AliFlowEventSimpleCuts;
12 class AliAnalysisDataContainer;
13 class AliHFEextraCuts;
15 AliAnalysisTaskFlowTPCEMCalQCSP* AddTaskFlowTPCEMCalQCSP(
16 TString uniqueID = "",
33 AliHFEextraCuts::ITSPixel_t pixel,
34 Bool_t Weight = kFALSE,
35 Bool_t withmultetacorrection=kFALSE,
37 Bool_t PhotonicElectronDCA = kFALSE,
38 Int_t TPCClusterforAsso = 80,
39 Bool_t AssoITSref = kTRUE,
40 Double_t ptminassocut = 0.3,
41 Bool_t purity = kTRUE,
42 Bool_t SideBandsFlow = kFALSE,
43 Bool_t Phi_minus_psi = kFALSE,
44 const char *Cent = "V0M",
45 Bool_t QC = kTRUE, // use qc2 and qc4
46 Bool_t SP_TPC = kTRUE, //use tpc sp method
47 Bool_t VZERO_SP = kFALSE, // use vzero sp method
48 Bool_t BaseH = kFALSE, // base histo
50 Bool_t shrinkSP = kTRUE,
51 Bool_t debug = kFALSE,
52 Int_t RPFilterBit = 1,
53 Bool_t op_ang = kFALSE,
54 Double_t op_angle_cut=3.
61 if(debug) cout << " === Adding Task ElectFlow === " << endl;
62 TString fileName = AliAnalysisManager::GetCommonFileName();
63 fileName += ":ElectroID_";
65 if(debug) cout << " --> Reconstruction data container: " << fileName << endl;
66 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
68 if(debug) cout << " Fatal error: no analysis manager found! " << endl;
71 if (!mgr->GetInputEventHandler()) {
72 if(debug) cout << " Fatal error: no imput event handler found!" << endl;
77 AliAnalysisTaskFlowTPCEMCalQCSP *taskHFE = ConfigHFEemcalMod(kFALSE, minTPCCluster, pixel, withmultetacorrection); //kTRUE if MC
79 if(debug) cout << " === AliAnalysisElectronFlow === " << taskHFE << endl;
81 if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl;
84 taskHFE->SetTrigger(Trigger);
85 taskHFE->SetEPWeight(Weight);
88 TString histoflatname = "alien:///alice/cern.ch/user/a/adubla/CentrDistrBins005.root";
89 if(Trigger==0 || Trigger==4){
90 TFile *fFlat=TFile::Open(histoflatname.Data());
91 TCanvas *c=fFlat->Get("cintegral");
92 TH1F *hfl=(TH1F*)c->FindObject("hint");
93 taskHFE->SetHistoForCentralityFlattening(hfl,centrMin,centrMax,0.,0);
97 TString histoflatnameEP = "alien:///alice/cern.ch/user/a/adubla/EPVZero010_Smart.root";
99 TFile *fFlatEP=TFile::Open(histoflatnameEP,"READ");
100 TCanvas *cEP=fFlatEP->Get("c1_n7");
101 TH1D *hEPfl=(TH1D*)cEP->FindObject("EPVz");
102 taskHFE->SetHistoForEPFlattWeights(hEPfl);
107 // Set centrality percentiles and method V0M, FMD, TRK, TKL, CL0, CL1, V0MvsFMD, TKLvsV0M, ZEMvsZDC
108 taskHFE->SetCentralityParameters(centrMin, centrMax, Cent);
109 taskHFE->SetInvariantMassCut(InvmassCut);
110 taskHFE->SetIDCuts(minTPC, maxTPC, minEovP, maxEovP, minM20, maxM20, minM02, maxM02, Dispersion);
111 taskHFE->SetFlowSideBands(SideBandsFlow);
112 taskHFE->Setphiminuspsi(Phi_minus_psi);
113 taskHFE->SetPurity(purity);
114 taskHFE->SetpTCuttrack(pTCut);
115 taskHFE->SelectPhotonicElectronMethod(PhotonicElectronDCA);
116 taskHFE->SetOpeningAngleflag(op_ang);
117 taskHFE->SetOpeningAngleCut(op_angle_cut);
118 taskHFE->SetAssoTPCCluster(TPCClusterforAsso);
119 taskHFE->SetAssoITSRefit(AssoITSref);
120 taskHFE->SetMultCorrelationCut(multCorrcut);
121 taskHFE->SetPtMinAssoCut(ptminassocut);
123 //set RP cuts for flow package analysis
124 cutsRP = new AliFlowTrackCuts(Form("RFPcuts%s",uniqueID));
126 if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl;
131 AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
132 cutsRP->SetParamType(rptype);
133 cutsRP->SetAODfilterBit(RPFilterBit);
134 cutsRP->SetPtRange(0.2, 5.0);
135 cutsRP->SetEtaRange(-0.7, 0.7);
136 cutsRP->SetMinNClustersTPC(70);
137 cutsRP->SetMinChi2PerClusterTPC(0.1);
138 cutsRP->SetMaxChi2PerClusterTPC(4.0);
139 cutsRP->SetRequireTPCRefit(kTRUE);
140 cutsRP->SetMaxDCAToVertexXY(0.3);
141 cutsRP->SetMaxDCAToVertexZ(0.3);
142 cutsRP->SetAcceptKinkDaughters(kFALSE);
143 cutsRP->SetMinimalTPCdedx(10.);
144 if(debug) cout << " --> kGlobal RP's " << cutsRP << endl;
146 if(VZERO_SP) { // use vzero sub analysis
147 cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks
148 SP_TPC = kFALSE; // disable other methods
150 if(debug) cout << " --> VZERO RP's " << cutsRP << endl;
153 AliFlowTrackSimpleCuts *POIfilterLeft = new AliFlowTrackSimpleCuts();
154 AliFlowTrackSimpleCuts *POIfilterRight = new AliFlowTrackSimpleCuts();
155 if(VZERO_SP || SP_TPC){
156 POIfilterLeft->SetEtaMin(-0.7);
157 POIfilterLeft->SetEtaMax(0.0);
158 POIfilterLeft->SetMassMin(263731); POIfilterLeft->SetMassMax(263733);
160 POIfilterRight->SetEtaMin(0.0);
161 POIfilterRight->SetEtaMax(0.7);
162 POIfilterRight->SetMassMin(263731); POIfilterRight->SetMassMax(263733);
166 AliFlowTrackSimpleCuts *POIfilterQC = new AliFlowTrackSimpleCuts();
168 POIfilterQC->SetEtaMin(-0.7);
169 POIfilterQC->SetEtaMax(0.7);
170 POIfilterQC->SetMassMin(263731); POIfilterQC->SetMassMax(263733);
176 AliFlowTrackSimpleCuts *POIfilterLeftH = new AliFlowTrackSimpleCuts();
177 AliFlowTrackSimpleCuts *POIfilterRightH = new AliFlowTrackSimpleCuts();
179 POIfilterLeftH->SetEtaMin(-0.7);
180 POIfilterLeftH->SetEtaMax(0.0);
181 POIfilterLeftH->SetMassMin(2636); POIfilterLeftH->SetMassMax(2638);
183 POIfilterRightH->SetEtaMin(0.0);
184 POIfilterRightH->SetEtaMax(0.7);
185 POIfilterRightH->SetMassMin(2636); POIfilterRightH->SetMassMax(2638);
189 AliFlowTrackSimpleCuts *POIfilterQCH = new AliFlowTrackSimpleCuts();
191 POIfilterQCH->SetEtaMin(-0.7);
192 POIfilterQCH->SetEtaMax(0.7);
193 POIfilterQCH->SetMassMin(2636); POIfilterQCH->SetMassMax(2638);
199 taskHFE->SetRPCuts(cutsRP);
202 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(Form("ccontainer0_%s",uniqueID.Data()),TList::Class(),AliAnalysisManager::kOutputContainer,fileName);
204 mgr->ConnectInput(taskHFE,0,mgr->GetCommonInputContainer());
205 mgr->ConnectOutput(taskHFE,1,coutput3);
208 if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl;
209 AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FlowContainer_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
210 mgr->ConnectOutput(taskHFE, 2, flowEvent);
211 if(debug) cout << " --> Created IO containers " << flowEvent << endl;
214 if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl;
215 AliAnalysisDataContainer *flowEventCont = mgr->CreateContainer(Form("FlowContainer_Cont_%s",uniqueID.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
216 mgr->ConnectOutput(taskHFE, 3, flowEventCont);
217 if(debug) cout << " --> Created IO containers " << flowEventCont << endl;
221 mgr->AddTask(taskHFE);
223 if (QC) { // add qc tasks
224 AddQCmethod(Form("QCTPCin_%s",uniqueID.Data()), harmonic, flowEvent, debug ,uniqueID, -0.7, -0.0, 0.0, 0.7,false,POIfilterQC, NUA, shrinkSP, BaseH);
225 if(debug) cout << " --> Hanging QC task ...succes! "<< endl;
227 if (SP_TPC) { // add sp subevent tasks
228 AddSPmethod(Form("SPTPCQa_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterRight, NUA,BaseH);
229 if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl;
230 AddSPmethod(Form("SPTPCQb_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, false, POIfilterLeft, NUA,BaseH);
231 if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl;
233 if (VZERO_SP) { // add sp subevent tasks
234 AddSPmethod(Form("SPVZEROQa_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterRight, NUA,BaseH);
235 if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl;
236 AddSPmethod(Form("SPVZEROQb_in_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEvent, false, shrinkSP, debug,uniqueID, true, POIfilterLeft, NUA,BaseH);
237 if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl;
240 //=========================================Flow event for elctronContamination==============================================================================================
242 if (QC) { // add qc tasks
243 AddQCmethod(Form("QCTPCCont_%s",uniqueID.Data()), harmonic, flowEventCont, debug ,uniqueID, -0.7, -0.0, 0.0, 0.7,false,POIfilterQCH, NUA, shrinkSP,BaseH);
244 if(debug) cout << " --> Hanging QC task ...succes! "<< endl;
246 if (SP_TPC) { // add sp subevent tasks
247 AddSPmethod(Form("SPTPCQa_Cont_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qa", harmonic, flowEventCont, false, shrinkSP, debug,uniqueID, false, POIfilterRightH, NUA,BaseH);
248 if(debug) cout << " --> Hanging SP Qa task ... succes!" << endl;
249 AddSPmethod(Form("SPTPCQb_Cont_%s", uniqueID.Data()), -0.7, -.0, .0, +0.7, "Qb", harmonic, flowEventCont, false, shrinkSP, debug,uniqueID, false, POIfilterLeftH, NUA,BaseH);
250 if(debug) cout << " --> Hanging SP Qb task ... succes!"<< endl;
253 //==========================================================================================================================================================================
260 //_____________________________________________________________________________
263 //_____________________________________________________________________________
264 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, Bool_t kNUA, Bool_t kBaseH)
266 // add sp task and invm filter tasks
267 if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl;
268 TString fileName = AliAnalysisManager::GetCommonFileName();
269 (bEP) ? fileName+=":EP" : fileName+=":SP";
271 // fileName+="_SUBEVENTS";
272 // if(debug) cout << " --> Setting up subevent analysis <-- " << endl;
274 if(debug) cout << " --> fileName " << fileName << endl;
275 TString myFolder = fileName;
276 if(debug) cout << " --> myFolder " << myFolder << endl;
278 (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector);
279 if(debug) cout << " myNameSP " << myNameSP << endl;
280 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
281 AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s",myNameSP.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
282 AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), NULL, POIfilter);
283 tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB);
284 if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10);
285 mgr->AddTask(tskFilter);
286 mgr->ConnectInput(tskFilter, 0, flowEvent);
287 mgr->ConnectOutput(tskFilter, 1, flowEventOut);
288 AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
289 AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE);
290 tskSP->SetApplyCorrectionForNUA(kNUA);
291 tskSP->SetHarmonic(harmonic);
292 tskSP->SetTotalQvector(Qvector);
293 if (bEP) tskSP->SetBehaveAsEP();
294 if (shrink)tskSP->SetBookOnlyBasicCCH(kBaseH);
296 mgr->ConnectInput(tskSP, 0, flowEventOut);
297 mgr->ConnectOutput(tskSP, 1, outSP);
299 //_____________________________________________________________________________
300 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, Bool_t kNUA, bool shrink = false, Bool_t kBaseH)
302 // add qc task and invm filter tasks
303 if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", IO ****** " << flowEvent << endl;
304 TString fileName = AliAnalysisManager::GetCommonFileName();
306 if(debug) cout << " --> Common filename: " << fileName << endl;
307 TString myFolder = Form("v%d", harmonic);
308 if(debug) cout << " --> myFolder: " << myFolder << endl;
309 TString myName = Form("%s", name);
310 if(debug) cout << " --> myName: " << myName << endl;
311 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
312 AliAnalysisDataContainer *flowEventOut = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
313 AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), NULL, POIfilter);
314 tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB);
315 // if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10);
316 mgr->AddTask(tskFilter);
317 mgr->ConnectInput(tskFilter, 0, flowEvent);
318 mgr->ConnectOutput(tskFilter, 1, flowEventOut);
320 AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
321 AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE);
322 tskQC->SetApplyCorrectionForNUA(kNUA);
323 tskQC->SetHarmonic(harmonic);
324 if (shrink)tskQC->SetBookOnlyBasicCCH(kBaseH);
326 mgr->ConnectInput(tskQC, 0, flowEventOut);
327 mgr->ConnectOutput(tskQC, 1, outQC);
329 //_____________________________________________________________________________
332 //_____________________________________________________________________________
334 AliAnalysisTaskFlowTPCEMCalQCSP* ConfigHFEemcalMod(Bool_t useMC,Int_t minTPCCulster,AliHFEextraCuts::ITSPixel_t pixel, Bool_t withmultetacorrection1){
336 // HFE standard task configuration
339 Bool_t kAnalyseTaggedTracks = kTRUE;
341 AliHFEcuts *hfecuts = new AliHFEcuts("hfeCutsEMCAL","HFE Standard Cuts"); //TODO....change the cuts values to PbPb
342 // hfecuts->CreateStandardCuts();
343 hfecuts->SetMinNClustersTPC(minTPCCulster);
344 hfecuts->SetMinNClustersITS(3);
345 hfecuts->SetMinNTrackletsTRD(0);
346 hfecuts->SetMinRatioTPCclusters(0.6);
348 // hfecuts->SetEtaRange(-0.9,0.9);
349 // hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
350 hfecuts->SetRequireITSPixel();
351 hfecuts->SetCutITSpixel(pixel);//kAny
352 hfecuts->SetMaxChi2perClusterITS(-1);
353 hfecuts->SetMaxChi2perClusterTPC(3.5);
354 hfecuts->SetCheckITSLayerStatus(kFALSE); // shud be put back
355 // hfecuts->UnsetVertexRequirement();
356 hfecuts->SetVertexRange(10.);
357 hfecuts->SetRequireSigmaToVertex();
358 //hfecuts->SetSigmaToVertex(10);
359 hfecuts->SetTOFPIDStep(kFALSE);
360 // hfecuts->SetQAOn();
361 hfecuts->SetPtRange(0, 30);
363 AliAnalysisTaskFlowTPCEMCalQCSP *task = new AliAnalysisTaskFlowTPCEMCalQCSP("HFE_Flow_TPCEMCal");
364 printf("task ------------------------ %p\n ", task);
367 task->SetHFECuts(hfecuts);
369 // task->SetInvariantMassCut(0.05);
370 // task->SetRejectKinkMother(kTRUE);
371 // task->SetRemovePileUp(kTRUE);
374 AliHFEpid *pid = task->GetPID();
375 if(useMC) pid->SetHasMCData(kTRUE);
376 pid->AddDetector("TPC", 0);
377 pid->AddDetector("EMCAL", 1);
380 if(withmultetacorrection1) {
381 AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTPCpid);
383 // task->GetPIDQAManager()->SetFillMultiplicity();
384 TF1 *etaCorrMean = GetEtaCorrectionEMCal("LHC11h_etaCorrMean");
385 TF1 *etaCorrWdth = GetEtaCorrectionEMCal("LHC11h_etaCorrWidth");
386 if(etaCorrMean && etaCorrWdth && withmultetacorrection1){
387 tpcpid->SetEtaCorrections(etaCorrMean, etaCorrWdth);
388 printf("TPC dE/dx Eta correction %p %p\n",etaCorrMean,etaCorrWdth);
390 TF1 *centCorrMean = GetCentralityCorrectionEMCal("LHC11h_multCorrMean");
391 TF1 *centCorrWdth = GetCentralityCorrectionEMCal("LHC11h_multCorrWidth");
392 if(centCorrMean && centCorrWdth && withmultetacorrection1){
393 tpcpid->SetCentralityCorrections(centCorrMean, centCorrWdth);
394 printf("TPC dE/dx multiplicity correction %p %p\n",centCorrMean,centCorrWdth);
396 task->SetMultCorrectionTheo(withmultetacorrection1);
397 task->SetTPCPID(tpcpid);
403 printf("*************************************\n");
404 printf("Configuring standard Task:\n");
405 // task->PrintStatus();
407 printf("*************************************\n");
412 //_____________________________________________________________________________
413 //_____________________________________________________________________________
414 TF1* GetCentralityCorrectionEMCal(TString listname="LHC11h"){
416 TString etaMap="$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/CentCorrMapsTPC.root";
418 if (gSystem->AccessPathName(gSystem->ExpandPathName(etaMap.Data()))){
419 Error("ConfigHFEpbpb","Eta map not found: %s",etaMap.Data());
423 TFile f(etaMap.Data());
424 if (!f.IsOpen()) return 0;
426 TList *keys=f.GetListOfKeys();
428 for (Int_t i=0; i<keys->GetEntries(); ++i){
429 TString kName=keys->At(i)->GetName();
431 if (reg.MatchB(listname)){
432 printf("Using Eta Correction Function: %s\n",kName.Data());
433 return (TF1*)f.Get(kName.Data());
438 //_____________________________________________________________________________
439 TF1* GetEtaCorrectionEMCal(TString listname="LHC11h"){
441 TString etaMap="$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/EtaCorrMapsTPC.root";
443 if (gSystem->AccessPathName(gSystem->ExpandPathName(etaMap.Data()))){
444 Error("ConfigHFEpbpb","Eta map not found: %s",etaMap.Data());
448 TFile f(etaMap.Data());
449 if (!f.IsOpen()) return 0;
451 TList *keys=f.GetListOfKeys();
453 for (Int_t i=0; i<keys->GetEntries(); ++i){
454 TString kName=keys->At(i)->GetName();
456 if (reg.MatchB(listname)){
457 printf("Using Eta Correction Function: %s\n",kName.Data());
458 return (TF1*)f.Get(kName.Data());
463 //_____________________________________________________________________________