Use new profiling tools in local mode, set proper name for tasks when running with...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskJetCluster.C
1 AliAnalysisTaskJetCluster *AddTaskJetCluster(char* bRec = "AOD",char* bGen = "",UInt_t filterMask = 16, Int_t iPhysicsSelection = 1,Char_t *jf = "KT", Float_t radius = 0.4);\r
2 \r
3 \r
4 AliAnalysisTaskJetCluster *AddTaskJetClusterDelta(UInt_t filterMask = 16,Bool_t kUseAODMC = kFALSE,Int_t iPhysicsSelection = 1,Char_t *jf = "KT", UInt_t iFlag){\r
5   AliAnalysisTaskJetCluster *js = 0;\r
6   if(kUseAODMC){\r
7     if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.00001);\r
8     if(iFlag&(2<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.1);\r
9     if(iFlag&(3<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.2);\r
10     if(iFlag&(4<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.4);\r
11     if(iFlag&(5<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.6);\r
12     if(iFlag&(6<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.8);\r
13     if(iFlag&(7<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,1.0);\r
14   }\r
15   else{\r
16     if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.00001);\r
17     if(iFlag&(2<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.1);\r
18     if(iFlag&(3<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.2);\r
19     //    if(iFlag&(4<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.4);\r
20     if(iFlag&(5<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.6);\r
21     if(iFlag&(6<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.8);\r
22     if(iFlag&(7<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,1.0);\r
23   }\r
24   \r
25   return js;\r
26 }\r
27 \r
28 \r
29 AliAnalysisTaskJetCluster *AddTaskJetCluster(char* bRec,char* bGen ,UInt_t filterMask,Int_t iPhysicsSelection,Char_t *jf,Float_t radius)\r
30 {\r
31 // Creates a jet fider task, configures it and adds it to the analysis manager.\r
32 \r
33    // Get the pointer to the existing analysis manager via the static access method.\r
34    //==============================================================================\r
35    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
36    if (!mgr) {\r
37       ::Error("AddTaskJetCluster", "No analysis manager to connect to.");\r
38       return NULL;\r
39    }  \r
40    \r
41    // Check the analysis type using the event handlers connected to the analysis manager.\r
42    //==============================================================================\r
43    if (!mgr->GetInputEventHandler()) {\r
44      ::Error("AddTaskJetCluster", "This task requires an input event handler");\r
45       return NULL;\r
46    }\r
47 \r
48    TString type = mgr->GetInputEventHandler()->GetDataType();\r
49    TString typeRec(bRec);\r
50    TString typeGen(bGen);\r
51    typeGen.ToUpper();\r
52    typeRec.ToUpper();\r
53    // Create the task and configure it.\r
54    //===========================================================================\r
55 \r
56 \r
57    char *cRadius = "";\r
58    if(radius>0)cRadius = Form("%02d",(int)((radius+0.01)*10.));\r
59 \r
60    \r
61    AliAnalysisTaskJetCluster* pwg4spec = new  AliAnalysisTaskJetCluster(Form("JetCluster_%s_%s",jf,cRadius));\r
62       \r
63    // or a config file\r
64    // pwg4spec->SetAnalysisType(AliAnalysisTaskJetCluster::kAnaMC);\r
65    // if(iAODanalysis)pwg4spec->SetAODInput(kTRUE);\r
66    // pwg4spec->SetDebugLevel(11); \r
67    pwg4spec->SetFilterMask(filterMask); \r
68    //   pwg4spec->SetUseGlobalSelection(kTRUE); \r
69 \r
70    if(type == "AOD"){\r
71      // Assume all jet are produced already\r
72      pwg4spec->SetAODJetInput(kTRUE);\r
73      pwg4spec->SetAODTrackInput(kTRUE);\r
74      pwg4spec->SetAODMCInput(kTRUE);\r
75    }\r
76 \r
77    if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
78      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
79    }\r
80    else if (typeRec.Contains("AODMC2")){\r
81      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
82    }\r
83    else if (typeRec.Contains("AODMC")){\r
84      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
85    }\r
86    else if (typeRec.Contains("AOD")) {\r
87      pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAOD);\r
88    }\r
89 \r
90    if(typeGen.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
91      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
92    }\r
93    else if (typeGen.Contains("AODMC2")){\r
94      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
95    }\r
96    else if (typeGen.Contains("AODMC")){\r
97      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
98    }\r
99    else if (typeGen.Contains("AOD")) {\r
100      pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAOD);\r
101    }\r
102 \r
103 \r
104 \r
105    pwg4spec->SetRparam(radius);\r
106 \r
107    switch (jf) {\r
108    case "ANTIKT":\r
109      pwg4spec->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh\r
110      break;\r
111    case "CA":\r
112      pwg4spec->SetAlgorithm(1); // kt from fastjet/JetDefinition.hh\r
113      break;\r
114    case "KT":\r
115      pwg4spec->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh\r
116      break;\r
117    default:\r
118      ::Error("AddTaskJetCluster", "Wrong jet finder selected\n");\r
119      return 0;\r
120    }\r
121 \r
122    \r
123    if(iPhysicsSelection)pwg4spec->SelectCollisionCandidates();\r
124 \r
125    mgr->AddTask(pwg4spec);\r
126      \r
127    // Create ONLY the output containers for the data produced by the task.\r
128    // Get and connect other common input/output containers via the manager as below\r
129    //==============================================================================\r
130    AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer(Form("pwg4cluster_%s_%s_%s_%s",bRec,bGen,jf,cRadius), TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:PWG4_cluster_%s_%s_%s_%s",AliAnalysisManager::GetCommonFileName(),bRec,bGen,jf,cRadius));\r
131 \r
132    mgr->ConnectInput  (pwg4spec, 0, mgr->GetCommonInputContainer());\r
133    mgr->ConnectOutput (pwg4spec, 0, mgr->GetCommonOutputContainer());\r
134    mgr->ConnectOutput (pwg4spec,  1, coutput1_Spec );\r
135    \r
136    return pwg4spec;\r
137 }\r