create general emcal task lib
[u/mrichter/AliRoot.git] / PWG / EMCAL / macros / AddTaskEmcalPhysicsSelection.C
CommitLineData
f71e445a 1// $Id$
2
a55e4f1d 3AliEmcalPhysicsSelectionTask* AddTaskEmcalPhysicsSelection(
a6eee76f 4 Bool_t exFOnly,
2e998475 5 Bool_t wHistos = kTRUE,
6 UInt_t triggers = 0,
7 Double_t minE = -1,
1dc3ded9 8 Double_t minPt = -1,
9 Double_t vz = -1,
10 Bool_t vzdiff = kFALSE,
11 Double_t cmin = -1,
6a7fb48f 12 Double_t cmax = -1,
13 Double_t minCellTrackScale = -1,
14 Double_t maxCellTrackScale = -1
89d0bb11 15)
f71e445a 16{
17 // Add EMCAL physics selection task.
18
f71e445a 19 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
20 if (!mgr) {
a6eee76f 21 ::Error("AddTaskEmcalPhysicsSelection", "No analysis manager found.");
f71e445a 22 return 0;
23 }
a6eee76f 24
25 if (!mgr->GetInputEventHandler()) {
26 ::Error("AddTaskEmcalPhysicsSelection", "This task requires an input event handler");
27 return NULL;
28 }
29
27fde6c7 30 Bool_t isMC = (mgr->GetMCtruthEventHandler()) ? kTRUE:kFALSE;
a6eee76f 31 AliEmcalPhysicsSelectionTask *pseltask = new AliEmcalPhysicsSelectionTask("EmcalPSel");
32 pseltask->SetDoWriteHistos(wHistos);
6a7fb48f 33 AliEmcalPhysicsSelection *physSel = static_cast<AliEmcalPhysicsSelection*>(pseltask->GetPhysicsSelection());
2e998475 34 if (physSel) {
35 physSel->SetSkipFastOnly(exFOnly);
36 if (isMC)
37 physSel->SetAnalyzeMC();
38 physSel->SetClusMinE(minE);
39 physSel->SetTrackMinPt(minPt);
40 physSel->SetTriggers(triggers);
1dc3ded9 41 physSel->SetCentRange(cmin,cmax);
42 physSel->SetZVertex(vz);
43 physSel->SetCheckZvertexDiff(vzdiff);
6a7fb48f 44 physSel->SetCellTrackScale(minCellTrackScale,maxCellTrackScale);
2e998475 45 } else {
46 ::Error("AddTaskEmcalPhysicsSelection", "No AliEmcalPhysicsSelection object found.");
47 }
48
f71e445a 49 mgr->AddTask(pseltask);
50
51 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
a6eee76f 52 AliAnalysisDataContainer *coutput = mgr->CreateContainer("cstatsout",
53 TList::Class(),
54 AliAnalysisManager::kOutputContainer,
55 "EventStat_temp.root");
56
57 mgr->ConnectInput(pseltask, 0, cinput);
58 mgr->ConnectOutput(pseltask, 1, coutput);
59
27fde6c7 60 return pseltask;
f71e445a 61}