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