Bug in array initialization corrected
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskJets.C
CommitLineData
0651dd18 1AliJetReader *CreateJetReader(Char_t *jr); // Common config\r
2AliJetFinder *CreateJetFinder(Char_t *jf);\r
3\r
4AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf); // for the new AF\r
5AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf,AliAnalysisManager* mgr,AliAnalysisDataContainer *cinput); // for the old AF\r
6\r
672f1183 7AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf)\r
8{\r
0651dd18 9 // Creates a jet finder task, configures it and adds it to the analysis manager.\r
672f1183 10\r
11 // Get the pointer to the existing analysis manager via the static access method.\r
12 //==============================================================================\r
13 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
14 if (!mgr) {\r
15 ::Error("AddTaskJets", "No analysis manager to connect to.");\r
16 return NULL;\r
17 } \r
18 \r
19 // Check the analysis type using the event handlers connected to the analysis manager.\r
20 //==============================================================================\r
21 if (!mgr->GetInputEventHandler()) {\r
22 ::Error("AddTaskJets", "This task requires an input event handler");\r
23 return NULL;\r
24 }\r
25\r
26 // Create the task and configure it.\r
27 //===========================================================================\r
28 AliAnalysisTaskJets *jetana;\r
0651dd18 29 AliJetReader *er = CreateJetReader(jr);\r
672f1183 30 // Define jet header and jet finder\r
0651dd18 31 AliJetFinder *jetFinder = CreateJetFinder(jf);\r
32\r
672f1183 33 if (jetFinder){\r
672f1183 34 if (er) jetFinder->SetJetReader(er);\r
35 }\r
36\r
37 jetana = new AliAnalysisTaskJets(Form("JetAnalysis%s%s",jr,jf));\r
38 AliAnalysisDataContainer *cout_jet = mgr->CreateContainer(Form("jethist%s%s",jr,jf), TList::Class(),\r
39 AliAnalysisManager::kOutputContainer, Form("jethist%s_%s.root",jr,jf));\r
40 // Connect jet finder to task.\r
41 jetana->SetJetFinder(jetFinder);\r
42 jetana->SetConfigFile("");\r
43 jetana->SetDebugLevel(10);\r
44 mgr->AddTask(jetana);\r
45\r
46 // Create ONLY the output containers for the data produced by the task.\r
47 // Get and connect other common input/output containers via the manager as below\r
48 //==============================================================================\r
49 mgr->ConnectInput (jetana, 0, mgr->GetCommonInputContainer());\r
50// AOD output slot will be used in a different way in future\r
51 mgr->ConnectOutput (jetana, 0, mgr->GetCommonOutputContainer());\r
52 mgr->ConnectOutput (jetana, 1, cout_jet);\r
53 \r
54 return jetana;\r
55}\r
0651dd18 56\r
57AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf,AliAnalysisManager* mgr,AliAnalysisDataContainer *cinput)\r
58{\r
59 // This is only for running on PROOF with the old root version 5-22-00 \r
60 // and the older version of the AF\r
61\r
62 // Creates a jet fider task, configures it and adds it to the analysis manager.\r
63 // Get the pointer to the existing analysis manager via the static access method.\r
64 //==============================================================================\r
65\r
66 if (!mgr) {\r
67 ::Error("AddTaskJets", "No analysis manager to connect to.");\r
68 return NULL;\r
69 } \r
70 \r
71 // Check the analysis type using the event handlers connected to the analysis manager.\r
72 //==============================================================================\r
73 if (!mgr->GetInputEventHandler()) {\r
74 ::Error("AddTaskJets", "This task requires an input event handler");\r
75 return NULL;\r
76 }\r
77\r
78 // Create the task and configure it.\r
79 //===========================================================================\r
80 AliAnalysisTaskJets *jetana;\r
81 AliJetReader *er = CreateJetReader(jr);\r
82\r
83 // Define jet header and jet finder\r
84 AliJetFinder *jetFinder = CreateJetFinder(jf);\r
85\r
86 if (jetFinder){\r
87 if (er) jetFinder->SetJetReader(er);\r
88 }\r
89\r
90 jetana = new AliAnalysisTaskJets(Form("JetAnalysis%s%s",jr,jf));\r
91 AliAnalysisDataContainer *cout_jet = mgr->CreateContainer(Form("jethist%s%s",jr,jf), TList::Class(),AliAnalysisManager::kOutputContainer, Form("jethist%s_%s.root",jr,jf));\r
92 // Connect jet finder to task.\r
93 jetana->SetJetFinder(jetFinder);\r
94 jetana->SetConfigFile("");\r
95 jetana->SetDebugLevel(10);\r
96 mgr->AddTask(jetana);\r
97\r
98 // Create the output containers for the data produced by the task.\r
99 //==============================================================================\r
100 // AOD output slot will be used in a different way in future\r
101 // we need to have different names for each usage\r
102 c_aodjet = mgr->CreateContainer(Form("cAODjet%s%s",jr,jf), TTree::Class(),\r
103 AliAnalysisManager::kExchangeContainer);\r
104 // Connect to data containers\r
105 mgr->ConnectInput (jetana,0, cinput );\r
106 mgr->ConnectOutput (jetana,0, c_aodjet );\r
107 mgr->ConnectOutput (jetana, 1, cout_jet);\r
108 \r
109 return jetana;\r
110}\r
111\r
112AliJetFinder *CreateJetFinder(Char_t *jf){\r
113\r
114 switch (jf) {\r
115 case "CDF":\r
116 AliCdfJetHeader *jh = new AliCdfJetHeader();\r
117 jh->SetRadius(0.7);\r
118 \r
119 jetFinder = new AliCdfJetFinder();\r
120 jetFinder->SetOutputFile("jets.root");\r
121 if (jh) jetFinder->SetJetHeader(jh);\r
122 break;\r
123\r
124 case "DA":\r
125 AliDAJetHeader *jh=new AliDAJetHeader();\r
126 jh->SetComment("DA jet code with default parameters");\r
127 jh->SelectJets(kTRUE);\r
128 jh->SetNclust(10);\r
129 \r
130 jetFinder = new AliDAJetFinder();\r
131 if (jh) jetFinder->SetJetHeader(jh);\r
132 break;\r
133\r
134\r
135 case "Fastjet":\r
136 AliFastJetHeader *jh = new AliFastJetHeader();\r
137 jh->SetRparam(0.7); // setup parameters \r
138\r
139 jetFinder = new AliFastJetFinder();\r
140 jetFinder->SetOutputFile("jets.root");\r
141 if (jh) jetFinder->SetJetHeader(jh);\r
142 break;\r
143\r
144 case "UA1":\r
145 AliUA1JetHeaderV1 *jh=new AliUA1JetHeaderV1();\r
146 jh->SetComment("UA1 jet code with default parameters");\r
147 jh->BackgMode(2);\r
148 jh->SetRadius(1.0);\r
149 jh->SetEtSeed(4.);\r
150 jh->SetLegoNbinPhi(432);\r
151 jh->SetLegoNbinEta(274);\r
152 jh->SetLegoEtaMin(-2);\r
153 jh->SetLegoEtaMax(+2);\r
154 jh->SetJetEtaMax(0.5);\r
155 jh->SetJetEtaMin(-0.5);\r
156 jh->SetMinJetEt(10.);\r
157\r
158 jetFinder = new AliUA1JetFinderV1();\r
159 if (jh) jetFinder->SetJetHeader(jh);\r
160 break;\r
161\r
162 case default:\r
163 ::Error("AddTaskJets", "Wrong jet finder selected\n");\r
164 return 0;\r
165 }\r
166\r
167 return jetFinder;\r
168\r
169}\r
170\r
171AliJetReader *CreateJetReader(Char_t *jr){\r
172 AliJetReader *er = 0;\r
173\r
174 switch (jr) {\r
175 case "MC":\r
176 AliJetKineReaderHeader *jrh = new AliJetKineReaderHeader();\r
177 jrh->SetComment("MC full Kinematics");\r
178 jrh->SetFastSimTPC(kFALSE);\r
179 jrh->SetFastSimEMCAL(kFALSE);\r
180 jrh->SetPtCut(0.);\r
181 jrh->SetFiducialEta(-2.1,2.1); // to take all MC particles default is 0 .9 \r
182 // Define reader and set its header \r
183 er = new AliJetKineReader();\r
184 er->SetReaderHeader(jrh);\r
185 break;\r
186\r
187 case "ESD":\r
188 AliJetESDReaderHeader *jrh = new AliJetESDReaderHeader();\r
189 jrh->SetComment("Testing");\r
190 jrh->SetFirstEvent(0);\r
191 jrh->SetLastEvent(1000);\r
192 jrh->SetPtCut(0.);\r
193 jrh->SetReadSignalOnly(kFALSE);\r
194 // Define reader and set its header \r
195 er = new AliJetESDReader();\r
196 er->SetReaderHeader(jrh);\r
197 break;\r
198\r
199 case "AOD":\r
200 AliJetAODReaderHeader *jrh = new AliJetAODReaderHeader();\r
201 jrh->SetComment("AOD Reader");\r
202 jrh->SetPtCut(0.);\r
203 jrh->SetTestFilterMask(1<<0);\r
204 // Define reader and set its header\r
205 er = new AliJetAODReader();\r
206 er->SetReaderHeader(jrh);\r
207 break;\r
208\r
209 default:\r
210 ::Error("AddTaskJets", "Wrong jet reader selected\n");\r
211 return 0;\r
212 }\r
213\r
214 return er;\r
215\r
216}\r