add tasks for jet like cluster analysis
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskJetCluster.C
CommitLineData
ef0bb91e 1AliAnalysisTaskJetCluster *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
4AliAnalysisTaskJetCluster *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
29AliAnalysisTaskJetCluster *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 AliAnalysisTaskJetCluster* pwg4spec = new AliAnalysisTaskJetCluster(Form("Jet Spectrum %s %s",bRec,bGen));\r
57 \r
58 // or a config file\r
59 // pwg4spec->SetAnalysisType(AliAnalysisTaskJetCluster::kAnaMC);\r
60 // if(iAODanalysis)pwg4spec->SetAODInput(kTRUE);\r
61 // pwg4spec->SetDebugLevel(11); \r
62 pwg4spec->SetFilterMask(filterMask); \r
63 // pwg4spec->SetUseGlobalSelection(kTRUE); \r
64\r
65 if(type == "AOD"){\r
66 // Assume all jet are produced already\r
67 pwg4spec->SetAODJetInput(kTRUE);\r
68 pwg4spec->SetAODTrackInput(kTRUE);\r
69 pwg4spec->SetAODMCInput(kTRUE);\r
70 }\r
71\r
72 if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
73 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
74 }\r
75 else if (typeRec.Contains("AODMC2")){\r
76 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
77 }\r
78 else if (typeRec.Contains("AODMC")){\r
79 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
80 }\r
81 else if (typeRec.Contains("AOD")) {\r
82 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAOD);\r
83 }\r
84\r
85 if(typeGen.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
86 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
87 }\r
88 else if (typeGen.Contains("AODMC2")){\r
89 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
90 }\r
91 else if (typeGen.Contains("AODMC")){\r
92 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
93 }\r
94 else if (typeGen.Contains("AOD")) {\r
95 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAOD);\r
96 }\r
97\r
98 char *cRadius = "";\r
99 if(radius>0)cRadius = Form("%02d",(int)((radius+0.01)*10.));\r
100\r
101\r
102\r
103 pwg4spec->SetRparam(radius);\r
104\r
105 switch (jf) {\r
106 case "ANTIKT":\r
107 pwg4spec->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh\r
108 break;\r
109 case "CA":\r
110 pwg4spec->SetAlgorithm(1); // kt from fastjet/JetDefinition.hh\r
111 break;\r
112 case "KT":\r
113 pwg4spec->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh\r
114 break;\r
115 default:\r
116 ::Error("AddTaskJetCluster", "Wrong jet finder selected\n");\r
117 return 0;\r
118 }\r
119\r
120 \r
121 if(iPhysicsSelection)pwg4spec->SelectCollisionCandidates();\r
122\r
123 mgr->AddTask(pwg4spec);\r
124 \r
125 // Create ONLY the output containers for the data produced by the task.\r
126 // Get and connect other common input/output containers via the manager as below\r
127 //==============================================================================\r
128 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
129\r
130 mgr->ConnectInput (pwg4spec, 0, mgr->GetCommonInputContainer());\r
131 mgr->ConnectOutput (pwg4spec, 0, mgr->GetCommonOutputContainer());\r
132 mgr->ConnectOutput (pwg4spec, 1, coutput1_Spec );\r
133 \r
134 return pwg4spec;\r
135}\r