Enable writing of a AOD cluster branch (of tpe AliAODJet) with track references,...
[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
8facb838 6 if(kUseAODMC&&false){// do not use the MC info yet\r
ef0bb91e 7 if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.00001);\r
9cb44fa6 8 if(iFlag&(1<<1))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.1);\r
9 if(iFlag&(1<<2))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.2);\r
10 if(iFlag&(1<<4))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.4);\r
11 if(iFlag&(1<<6))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.6);\r
12 if(iFlag&(1<<8))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,0.8);\r
13 if(iFlag&(1<<10))js = AddTaskJetCluster("AOD","AODMC",filterMask,iPhysicsSelection,jf,1.0);\r
ef0bb91e 14 }\r
15 else{\r
16 if(iFlag&(1<<0))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.00001);\r
9cb44fa6 17 if(iFlag&(1<<1))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.1);\r
18 if(iFlag&(1<<2))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.2);\r
19 if(iFlag&(1<<4))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.4);\r
20 if(iFlag&(1<<6))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.6);\r
21 if(iFlag&(1<<8))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,0.8);\r
22 if(iFlag&(1<<10))js = AddTaskJetCluster("AOD","",filterMask,iPhysicsSelection,jf,1.0);\r
ef0bb91e 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
4a6f59cb 55\r
56\r
57 char *cRadius = "";\r
58 if(radius>0)cRadius = Form("%02d",(int)((radius+0.01)*10.));\r
59\r
ef0bb91e 60 \r
4a6f59cb 61 AliAnalysisTaskJetCluster* pwg4spec = new AliAnalysisTaskJetCluster(Form("JetCluster_%s_%s",jf,cRadius));\r
ef0bb91e 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
ef0bb91e 72 pwg4spec->SetAODTrackInput(kTRUE);\r
73 pwg4spec->SetAODMCInput(kTRUE);\r
74 }\r
75\r
76 if(typeRec.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
77 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
78 }\r
79 else if (typeRec.Contains("AODMC2")){\r
80 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
81 }\r
82 else if (typeRec.Contains("AODMC")){\r
83 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
84 }\r
85 else if (typeRec.Contains("AOD")) {\r
86 pwg4spec->SetTrackTypeRec(AliAnalysisTaskJetCluster::kTrackAOD);\r
54424110 87 pwg4spec->SetTrackPtCut(0.15);\r
ef0bb91e 88 }\r
89\r
54424110 90\r
ef0bb91e 91 if(typeGen.Contains("AODMC2b")){// work down from the top AODMC2b -> AODMC2 -> AODMC -> AOD\r
92 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCChargedAcceptance);\r
93 }\r
94 else if (typeGen.Contains("AODMC2")){\r
95 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCCharged);\r
96 }\r
97 else if (typeGen.Contains("AODMC")){\r
98 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAODMCAll);\r
99 }\r
100 else if (typeGen.Contains("AOD")) {\r
101 pwg4spec->SetTrackTypeGen(AliAnalysisTaskJetCluster::kTrackAOD);\r
102 }\r
103\r
ef0bb91e 104\r
105\r
106 pwg4spec->SetRparam(radius);\r
107\r
108 switch (jf) {\r
109 case "ANTIKT":\r
110 pwg4spec->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh\r
111 break;\r
112 case "CA":\r
0971dabc 113 pwg4spec->SetAlgorithm(1); // CA from fastjet/JetDefinition.hh\r
ef0bb91e 114 break;\r
115 case "KT":\r
116 pwg4spec->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh\r
117 break;\r
118 default:\r
119 ::Error("AddTaskJetCluster", "Wrong jet finder selected\n");\r
120 return 0;\r
121 }\r
122\r
123 \r
54424110 124 if(TMath::Abs(radius-0.4)<0.01){\r
125 pwg4spec->SetJetOutputBranch(Form("clusters%s_%s%s",bRec,jf,cRadius));\r
126 pwg4spec->SetJetOutputMinPt(1); // store only jets / clusters above a certain threshold\r
127 }\r
128\r
ef0bb91e 129 if(iPhysicsSelection)pwg4spec->SelectCollisionCandidates();\r
130\r
131 mgr->AddTask(pwg4spec);\r
132 \r
133 // Create ONLY the output containers for the data produced by the task.\r
134 // Get and connect other common input/output containers via the manager as below\r
135 //==============================================================================\r
136 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
137\r
138 mgr->ConnectInput (pwg4spec, 0, mgr->GetCommonInputContainer());\r
139 mgr->ConnectOutput (pwg4spec, 0, mgr->GetCommonOutputContainer());\r
140 mgr->ConnectOutput (pwg4spec, 1, coutput1_Spec );\r
141 \r
142 return pwg4spec;\r
143}\r