coverity fixes
[u/mrichter/AliRoot.git] / PWGJE / UserTasks / AliAnalysisTaskJetHadronCorrelation.cxx
CommitLineData
32de1459 1//#include <string.h>
2//#include <TStyle.h>
3#include <list>
4#include <string>
5
6#include "TTree.h"
7#include "TCanvas.h"
8#include "AliAnalysisTask.h"
9#include "AliInputEventHandler.h"
10#include "AliESDtrack.h"
11#include "AliAODVertex.h"
12#include "AliAODCluster.h"
13
14#include <TROOT.h>
15#include <TRandom.h>
16#include <TSystem.h>
17#include <TInterpreter.h>
18#include <TChain.h>
19#include <TFile.h>
20#include <TKey.h>
21#include <TH1F.h>
22#include <TH2F.h>
23#include <TH3F.h>
24#include <TProfile.h>
25#include <TList.h>
26#include <TLorentzVector.h>
27#include <TClonesArray.h>
28#include <TRefArray.h>
29
30#include "TDatabasePDG.h"
31#include "AliAnalysisManager.h"
32#include "AliJetFinder.h"
33#include "AliJetHeader.h"
34#include "AliJetReader.h"
35#include "AliJetReaderHeader.h"
36#include "AliUA1JetHeaderV1.h"
37#include "AliSISConeJetHeader.h"
38#include "AliESDEvent.h"
39#include "AliAODEvent.h"
40#include "AliAODHandler.h"
1d478650 41#include "AliAODInputHandler.h"
32de1459 42#include "AliAODTrack.h"
43#include "AliAODJet.h"
44#include "AliAODJetEventBackground.h"
45#include "AliMCParticle.h"
46#include "AliAODMCParticle.h"
47#include "AliMCEventHandler.h"
48#include "AliMCEvent.h"
49#include "AliStack.h"
50
51#include "AliAODHeader.h"
52#include "AliAODMCHeader.h"
53//#include "AliGenPythiaEventHeader.h"
54#include "AliJetKineReaderHeader.h"
55#include "AliGenCocktailEventHeader.h"
56#include "AliInputEventHandler.h"
57#include "AliGenEventHeader.h"
58#include "AliGenDPMjetEventHeader.h"
59
60
61
62#include "AliAnalysisTaskJetHadronCorrelation.h"
63#include "AliAnalysisTaskPhiCorrelations.h"
64//#include "AliAnalysisHelperJetTasks.h"
65#include "AliPWG4HighPtQAMC.h"
66
67
68
69
c64cb1f6 70using std::cout;
71using std::endl;
72
32de1459 73ClassImp(AliAnalysisTaskJetHadronCorrelation)
74
75 //________________________________________________________________________
76 AliAnalysisTaskJetHadronCorrelation::AliAnalysisTaskJetHadronCorrelation():
77 AliAnalysisTaskSE(),
78 fUseAODInput(kFALSE),
79 fFillAOD(kFALSE),
80 fJetBranch("jets"),
81 fNonStdFile(""),
82 fAODIn(0x0),
83 fAODOut(0x0),
84 fAODExtension(0x0),
85 JFAlg("ANTIKT"),
86 Radius(0.4),
00a3f17b 87 Filtermask(272),
32de1459 88 BackM(0),
89 TrackPtcut(0.15),
90 SkipCone(0),
91 IsMC(kTRUE),
92 fxsec(0.),
93 ftrial(1.),
94 fJetRecEtaWindow(0.5), // eta window for rec jets
95 fMinJetPt(10),
96 fHistList(0x0), // Output list
97 fIfiles(0),
98 fH1Events(0x0),
99 fH1Xsec(0x0),
100 fH1Trials(0x0),
101 fH1JetAKT04_pt (0x0),
102 fH1leadJetAKT04_pt (0x0),
103 fH1leadJetAKT04_pt_dijet (0x0),
104 fH1subJetAKT04_pt_dijet (0x0),
105 fH2JetsJetAKT04_dphi (0x0),
106 fH2JetsJetAKT04_deta (0x0),
107 fH2JetsJetAKT04_Aj (0x0),
108 fH2JetsJetAKT04_pt (0x0),
109 fH1JetMCAKT04_pt (0x0),
110 fH1leadJetMCAKT04_pt (0x0),
111 fH1leadJetMCAKT04_pt_dijet (0x0),
112 fH1subJetMCAKT04_pt_dijet (0x0),
113 fH2JetsJetMCAKT04_dphi (0x0),
114 fH2JetsJetMCAKT04_deta (0x0),
115 fH2JetsJetMCAKT04_Aj (0x0),
116 fH2JetsJetMCAKT04_pt (0x0)
117
118
119{
120
121
122 if(IsMC){
123 for(int j=0;j<5;j++){
124 fH1AKT04_ndiJ_ediv[j]=0;
125 fH1leadJetMCAKT04_dphiResolution [j]=0;
126 fH1subJetMCAKT04_dphiResolution [j]=0;
127 for(int k=0;k<5;k++){
128 fH1JetHadronAKT04_dphi_ediv [j][k]=0;
129 fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]=0;
130 fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]=0;
131 }
132 }
133 }else{
134 for(int j=0;j<5;j++){
135 fH1AKT04_ndiJ_ediv[j]=0;
136 for(int k=0;k<5;k++){
137 fH1JetHadronAKT04_dphi_ediv [j][k]=0;
138 fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]=0;
139 fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]=0;
140 }
141 }
142 }
143
144
145 // Default constructor
146}
147
148//________________________________________________________________________
149AliAnalysisTaskJetHadronCorrelation::AliAnalysisTaskJetHadronCorrelation(const char *name):
150 AliAnalysisTaskSE(name),
151 fUseAODInput(kFALSE),
152 fFillAOD(kFALSE),
153 fJetBranch("jets"),
154 fNonStdFile(""),
155 fAODIn(0x0),
156 fAODOut(0x0),
157 fAODExtension(0x0),
158 JFAlg("ANTIKT"),
159 Radius(0.4),
00a3f17b 160 Filtermask(272),
32de1459 161 BackM(0),
162 TrackPtcut(0.15),
163 SkipCone(0),
164 IsMC(kTRUE),
165 fxsec(0.),
166 ftrial(1.),
167 fJetRecEtaWindow(0.5), // eta window for rec jets
168 fMinJetPt(10),
169 fHistList(0x0), // Output list
170 fIfiles(0),
171
172 fH1Events(0x0),
173 fH1Xsec(0x0),
174 fH1Trials(0x0),
175 fH1JetAKT04_pt (0x0),
176 fH1leadJetAKT04_pt (0x0),
177 fH1leadJetAKT04_pt_dijet (0x0),
178 fH1subJetAKT04_pt_dijet (0x0),
179 fH2JetsJetAKT04_dphi (0x0),
180 fH2JetsJetAKT04_deta (0x0),
181 fH2JetsJetAKT04_Aj (0x0),
182 fH2JetsJetAKT04_pt (0x0),
183 fH1JetMCAKT04_pt (0x0),
184 fH1leadJetMCAKT04_pt (0x0),
185 fH1leadJetMCAKT04_pt_dijet (0x0),
186 fH1subJetMCAKT04_pt_dijet (0x0),
187 fH2JetsJetMCAKT04_dphi (0x0),
188 fH2JetsJetMCAKT04_deta (0x0),
189 fH2JetsJetMCAKT04_Aj (0x0),
190 fH2JetsJetMCAKT04_pt (0x0)
191
192
193{
194 if(IsMC){
195 for(int j=0;j<5;j++){
196 fH1AKT04_ndiJ_ediv[j]=0;
197 fH1leadJetMCAKT04_dphiResolution [j]=0;
198 fH1subJetMCAKT04_dphiResolution [j]=0;
199 for(int k=0;k<5;k++){
200 fH1JetHadronAKT04_dphi_ediv [j][k]=0;
201 fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]=0;
202 fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]=0;
203 }
204 }
205 }else{
206 for(int j=0;j<5;j++){
207 fH1AKT04_ndiJ_ediv[j]=0;
208 for(int k=0;k<5;k++){
209 fH1JetHadronAKT04_dphi_ediv [j][k]=0;
210 fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]=0;
211 fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]=0;
212 }
213 }
214 }
215
216 // Default constructor
217
218 // Constructor
219
220 // Define input and output slots here
221 // Input slot #0 works with a TChain
222 DefineInput(0, TChain::Class());
223 // Output slot #0 id reserved by the base class for AOD
224 // Output slot #1 writes into a TH1 container
225 DefineOutput(1, TList::Class());
226
227}
228
229//________________________________________________________________________
230void AliAnalysisTaskJetHadronCorrelation::UserCreateOutputObjects()
231{
232 // Create histograms
233 // Called once
234
235
236 fHistList = new TList();fHistList->SetOwner(kTRUE); cout<<"TList is created for output "<<endl;
237 //if (!fHistList){ fHistList = new TList();fHistList->SetOwner(kTRUE); cout<<"TList is created for output "<<endl;}
238
239 Bool_t oldStatus = TH1::AddDirectoryStatus();
240 TH1::AddDirectory(kFALSE);
241
242 Float_t pi=TMath::Pi();
243 //gStyle->SetPalette(1);
244
245
246 char *histname;
247 if(IsMC){
248 fH1Xsec = new TProfile("Xsec" ,"Xsec" ,1,0,1);
249 fH1Trials = new TH1F ("Trials" ,"Trials" ,1,0,1);
250 fH1JetMCAKT04_pt = new TH1F("JetMCAKT04_pt" ,"JetMCAKT04_pt" ,400,0,400);
251 fH1leadJetMCAKT04_pt = new TH1F("leadJetMCAKT04_pt" ,"leadJetMCAKT04_pt" ,400,0,400);
252 fH1leadJetMCAKT04_pt_dijet = new TH1F("leadJetMCAKT04_pt_dijet","leadJetMCAKT04_pt_dijet",400,0,400);
253 fH1subJetMCAKT04_pt_dijet = new TH1F("subJetMCAKT04_pt_dijet" ,"subJetMCAKT04_pt_dijet" ,400,0,400);
254 fH1JetAKT04_pt = new TH1F("JetAKT04_pt" ,"JetAKT04_pt" ,400,0,400);
255 fH1leadJetAKT04_pt = new TH1F("leadJetAKT04_pt" ,"leadJetAKT04_pt" ,400,0,400);
256 fH1leadJetAKT04_pt_dijet = new TH1F("leadJetAKT04_pt_dijet" ,"leadJetAKT04_pt_dijet" ,400,0,400);
257 fH1subJetAKT04_pt_dijet = new TH1F("subJetAKT04_pt_dijet" ,"subJetAKT04_pt_dijet" ,400,0,400);
258 histname = Form("JetsJetMCAKT04_dphi");
259 fH2JetsJetMCAKT04_dphi = new TH2F(histname,histname,200,0,400,100,-2*pi,2*pi);
260 histname = Form("JetsJetMCAKT04_deta");
261 fH2JetsJetMCAKT04_deta = new TH2F(histname,histname,200,0,400,100,-1.5,1.5);
262 histname = Form("JetsJetMCAKT04_Aj");
263 fH2JetsJetMCAKT04_Aj = new TH2F(histname,histname,200,0,400,100,0,1.2);
264 histname = Form("JetsJetMCAKT04_pt");
265 fH2JetsJetMCAKT04_pt = new TH2F(histname,histname,200,0,400,200,0,400);
266 histname = Form("JetsJetAKT04_dphi");
267 fH2JetsJetAKT04_dphi = new TH2F(histname,histname,200,0,400,100,-2*pi,2*pi);
268 histname = Form("JetsJetAKT04_deta");
269 fH2JetsJetAKT04_deta = new TH2F(histname,histname,200,0,400,100,-1.5,1.5);
270 histname = Form("JetsJetAKT04_Aj");
271 fH2JetsJetAKT04_Aj = new TH2F(histname,histname,200,0,400,100,0,1.2);
272 histname = Form("JetsJetAKT04_pt");
273 fH2JetsJetAKT04_pt = new TH2F(histname,histname,200,0,400,200,0,400);
274 for(int j=0;j<5;j++){
275 histname = Form("AKT04_ndiJ_ediv%d",j);
276 fH1AKT04_ndiJ_ediv[j]= new TH1F(histname,histname,1,1,2);
277 histname = Form("leadJetMCAKT04_dphiResolution%d",j);
278 fH1leadJetMCAKT04_dphiResolution[j] = new TH1F(histname,histname,200,-2*pi,2*pi);
279 histname = Form("subJetMCAKT04_dphiResolution%d",j);
280 fH1subJetMCAKT04_dphiResolution[j] = new TH1F(histname,histname,200,-2*pi,2*pi);
281 for(int k=0;k<5;k++){
282 histname = Form("JetHadronAKT04_dphi_ediv%d%d",j,k);
00a3f17b 283 fH1JetHadronAKT04_dphi_ediv [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);
32de1459 284 histname = Form("JetHadronAKT04_dphi_tptweight_ediv%d%d",j,k);
00a3f17b 285 fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);
32de1459 286 histname = Form("JetHadronAKT04_dphi_tJptweight_ediv%d%d",j,k);
00a3f17b 287 fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);
32de1459 288 }
289 }
00a3f17b 290
32de1459 291 fHistList->Add(fH1Xsec);
292 fHistList->Add(fH1Trials);
293 fHistList->Add(fH1JetMCAKT04_pt );
294 fHistList->Add(fH1leadJetMCAKT04_pt );
295 fHistList->Add(fH1leadJetMCAKT04_pt_dijet);
296 fHistList->Add(fH1subJetMCAKT04_pt_dijet );
297 fHistList->Add(fH1JetAKT04_pt );
298 fHistList->Add(fH1leadJetAKT04_pt );
299 fHistList->Add(fH1leadJetAKT04_pt_dijet );
300 fHistList->Add(fH1subJetAKT04_pt_dijet );
301 fHistList->Add(fH2JetsJetMCAKT04_dphi);
302 fHistList->Add(fH2JetsJetMCAKT04_deta);
303 fHistList->Add(fH2JetsJetMCAKT04_Aj );
304 fHistList->Add(fH2JetsJetMCAKT04_pt );
305 fHistList->Add(fH2JetsJetAKT04_dphi );
306 fHistList->Add(fH2JetsJetAKT04_deta );
307 fHistList->Add(fH2JetsJetAKT04_Aj );
308 fHistList->Add(fH2JetsJetAKT04_pt );
309 for(int j=0;j<5;j++){
310 fHistList->Add(fH1AKT04_ndiJ_ediv [j]);
311 fHistList->Add(fH1leadJetMCAKT04_dphiResolution [j]);
312 fHistList->Add(fH1subJetMCAKT04_dphiResolution [j]);
313 for(int k=0;k<5;k++){
314 fHistList->Add(fH1JetHadronAKT04_dphi_ediv [j][k]);
315 fHistList->Add(fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]);
316 fHistList->Add(fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]);
317 }
318 }
319 }
320 else{
321 fH1Events = new TH1F("Events" ,"Events" ,1,0,1);
322 fH1JetAKT04_pt = new TH1F("JetAKT04_pt" ,"JetAKT04_pt" ,400,0,400);
323 fH1leadJetAKT04_pt = new TH1F("leadJetAKT04_pt" ,"leadJetAKT04_pt" ,400,0,400);
324 fH1leadJetAKT04_pt_dijet = new TH1F("leadJetAKT04_pt_dijet" ,"leadJetAKT04_pt_dijet" ,400,0,400);
325 fH1subJetAKT04_pt_dijet = new TH1F("subJetAKT04_pt_dijet" ,"subJetAKT04_pt_dijet" ,400,0,400);
326 histname = Form("JetsJetAKT04_dphi");
327 fH2JetsJetAKT04_dphi = new TH2F(histname,histname,200,0,400,100,-2*pi,2*pi);
328 histname = Form("JetsJetAKT04_deta");
329 fH2JetsJetAKT04_deta = new TH2F(histname,histname,200,0,400,100,-1.5,1.5);
330 histname = Form("JetsJetAKT04_Aj");
331 fH2JetsJetAKT04_Aj = new TH2F(histname,histname,200,0,400,100,0,1.2);
332 histname = Form("JetsJetAKT04_pt");
333 fH2JetsJetAKT04_pt = new TH2F(histname,histname,200,0,400,200,0,400);
334 for(int j=0;j<5;j++){
335 histname = Form("AKT04_ndiJ_ediv%d",j);
336 fH1AKT04_ndiJ_ediv[j]= new TH1F(histname,histname,1,1,2);
337 for(int k=0;k<5;k++){
338 histname = Form("JetHadronAKT04_dphi_ediv%d%d",j,k);
00a3f17b 339 fH1JetHadronAKT04_dphi_ediv [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);
32de1459 340 histname = Form("JetHadronAKT04_dphi_tptweight_ediv%d%d",j,k);
00a3f17b 341 fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);
32de1459 342 histname = Form("JetHadronAKT04_dphi_tJptweight_ediv%d%d",j,k);
00a3f17b 343 fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);
32de1459 344 }
345 }
346 fHistList->Add(fH1Events);
347 fHistList->Add(fH1JetAKT04_pt );
348 fHistList->Add(fH1leadJetAKT04_pt );
349 fHistList->Add(fH1leadJetAKT04_pt_dijet);
350 fHistList->Add(fH1subJetAKT04_pt_dijet );
351 fHistList->Add(fH2JetsJetAKT04_dphi );
352 fHistList->Add(fH2JetsJetAKT04_deta );
353 fHistList->Add(fH2JetsJetAKT04_Aj );
354 fHistList->Add(fH2JetsJetAKT04_pt );
355 for(int j=0;j<5;j++){
356 fHistList->Add(fH1AKT04_ndiJ_ediv [j]);
357 for(int k=0;k<5;k++){
358 fHistList->Add(fH1JetHadronAKT04_dphi_ediv [j][k]);
359 fHistList->Add(fH1JetHadronAKT04_dphi_tptweight_ediv [j][k]);
360 fHistList->Add(fH1JetHadronAKT04_dphi_tJptweight_ediv [j][k]);
361 }
362 }
363 }
364
365
366
367 // =========== Switch on Sumw2 for all histos ===========
368 for (Int_t i=0; i<fHistList->GetEntries(); ++i)
369 {
370 TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));
371 if (h1)
372 {
373 h1->Sumw2();
374 continue;
375 }
376 THnSparse *hn = dynamic_cast<THnSparse*>(fHistList->At(i));
377 if(hn)hn->Sumw2();
378 }
379 TH1::AddDirectory(oldStatus);
380
381
382
383
384 PostData(1,fHistList);
385
386}
387
388//----------------------------------------------------------------------
389void AliAnalysisTaskJetHadronCorrelation::Init()
390{
391 // Initialization
392 if (fDebug) printf("AnalysisTaskJetHadronCorrelation::Init() \n");
393
394}
395
396Bool_t AliAnalysisTaskJetHadronCorrelation::Notify()
397{
398
399
400 fIfiles++;
401 fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
402 fAODOut = AODEvent();
403 if(fNonStdFile.Length()!=0){
404 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
405 fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0);
406 if(fAODExtension){
407 if(fDebug>1)Printf("AODExtension found for %s ",fNonStdFile.Data());
408 }
409 }
410
411 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
412 fxsec=0;
413 ftrial=1;
414
415 if(tree){
416 TFile *curfile = tree->GetCurrentFile();
417 if(!curfile){
418 Error("Notify","No current file");
419 return kFALSE;
420 }
421
422
423 if(IsMC){
424 AliPWG4HighPtQAMC::PythiaInfoFromFile(curfile->GetName(),fxsec,ftrial);
425 //cout<<" Xsec "<<fxsec<<" trial "<<ftrial<<endl;
426 fH1Xsec ->Fill(0.,fxsec);
427 fH1Trials->Fill(0.,ftrial);
32de1459 428 }
f4b5b842 429 //else fH1Events->Fill(0.,ftrial);
32de1459 430
431 }
432
433 printf("Reading File %s ",fInputHandler->GetTree()->GetCurrentFile()->GetName());
434 return kTRUE;
435}
436void AliAnalysisTaskJetHadronCorrelation::FinishTaskOutput()
437{
438}
439
440
441
442//________________________________________________________________________
443void AliAnalysisTaskJetHadronCorrelation::UserExec(Option_t *)
444{
445
446
447 // Main loop (called each event)
1d478650 448 // Execute analysis for current event
449
450 AliAODEvent *fAOD;
451 TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
452 if( handler && handler->InheritsFrom("AliAODInputHandler") ) {
453 fAOD = ((AliAODInputHandler*)handler)->GetEvent();
454 if(fUseAODInput) fAODIn = fAOD;
455 if (fDebug > 1) Printf("%s:%d AOD event from input", (char*)__FILE__,__LINE__);
456 }
457 else {
458 handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
459 if( handler && handler->InheritsFrom("AliAODHandler") ) {
460 fAOD = ((AliAODHandler*)handler)->GetAOD();
461 fAODIn = fAOD;
462 if (fDebug > 1) Printf("%s:%d AOD event from output", (char*)__FILE__,__LINE__);
463 }
464 }
465
466 if(!fAODIn && !fUseAODInput){ // case we have AOD in input & output and want jets from output
467 TObject* outHandler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
468 if( outHandler && outHandler->InheritsFrom("AliAODHandler") ) {
469 fAODIn = ((AliAODHandler*)outHandler)->GetAOD();
470 if (fDebug > 1) Printf("%s:%d jets from output AOD", (char*)__FILE__,__LINE__);
471 }
472 }
473
28c36b48 474 //if(fNonStdFile.Length()!=0){
475 // // case we have an AOD extension - fetch the jets from the extended output
476 // AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
477 // fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0);
478 // if(!fAODExtension){
479 // if(fDebug>1)Printf("AODExtension not found for %s",fNonStdFile.Data());
480 // }
481 //}
1d478650 482 //fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
483 if (!fAODIn) {
484 Printf("ERROR %s : fAODIn not available",(char*)__FILE__);
485 return;
486 }
487
488 AliInputEventHandler* inputHandler = (AliInputEventHandler*)
489 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
f4b5b842 490 if(!(inputHandler->IsEventSelected() & AliVEvent::kMB)){
491 if (fDebug > 1 ) Printf(" Trigger Selection: event REJECTED ... ");
492 return;
493 }
494 if(!IsMC)fH1Events->Fill(0);
32de1459 495
496 // start jet analysis
497
498 Double_t Jet_n [20];
499 Double_t Jet_pt [20][1000];
500 Double_t Jet_eta[20][1000];
501 Double_t Jet_phi[20][1000];
502 Double_t subJet_n [20];
503 Double_t subJet_pt [20][1000];
504 Double_t subJet_eta[20][1000];
505 Double_t subJet_phi[20][1000];
506 Double_t Track_n ;
507 Double_t Track_pt [1000];
508 Double_t Track_eta[1000];
509 Double_t Track_phi[1000];
510
511 Track_n=0;
512 for(int i=0;i<20;i++){
513 Jet_n[i]=0;
514 subJet_n[i]=0;
515 for(int j=0;j<1000;j++){
516 Jet_pt[i][j]=0.;
517 Jet_phi[i][j]=999.;
518 Jet_eta[i][j]=999.;
519 subJet_pt[i][j]=0.;
520 subJet_phi[i][j]=999.;
521 subJet_eta[i][j]=999.;
522 Track_pt [j]=0.;
523 Track_phi[j]=999.;
524 Track_eta[j]=999.;
525 }
526 }
527
32de1459 528 //////-----------------------------------------------------------------------------------
529
530
531 int nLJetAOD=999; double ptLJetAOD=0;double phiLJetAOD=999.;double etaLJetAOD=999.;int nsLJetAOD=900;double ptsLJetAOD=0;double phisLJetAOD=900.;double etasLJetAOD=900.;
532 int nLJetMC2=999; double ptLJetMC2=0;double phiLJetMC2=999.;double etaLJetMC2=999.;int nsLJetMC2=900;double ptsLJetMC2=0;double phisLJetMC2=900.;double etasLJetMC2=900.;
533 int nLJetMC =999; double ptLJetMC =0;double phiLJetMC =999.;double etaLJetMC =999.;int nsLJetMC =900;double ptsLJetMC =0;double phisLJetMC =900.;double etasLJetMC =900.;
534 bool findLJetAOD=false;bool findsLJetAOD=false;bool findsLJetAOD_temp=false;
535 bool findLJetMC2=false;bool findsLJetMC2=false;bool findsLJetMC2_temp=false;
536 bool findLJetMC =false;bool findsLJetMC =false;bool findsLJetMC_temp =false;
537 bool findsLJet=false;
538 int nLJet = 999;
539
540
541 TString cAdd = "";
542 cAdd += Form("%02d_",(int)((Radius+0.01)*10.));
543 cAdd += Form("B%d",(int)BackM);
544 cAdd += Form("_Filter%05d",Filtermask);
545 cAdd += Form("_Cut%05d",(int)(1000.*TrackPtcut));
546 cAdd += Form("_Skip%02d",SkipCone);
547 TString Branchname_gen,Branchname_gen2,Branchname_rec;
652845bc 548 //Branchname_gen = Form("clustersMCKINE_%s%s",JFAlg.Data(),cAdd.Data());
549 //Branchname_gen2 = Form("clustersMCKINE2_%s%s",JFAlg.Data(),cAdd.Data());
550 Branchname_gen = Form("clustersAODMC_%s%s",JFAlg.Data(),cAdd.Data());
551 Branchname_gen2 = Form("clustersAODMC2_%s%s",JFAlg.Data(),cAdd.Data());
32de1459 552 Branchname_rec = Form("clustersAOD_%s%s",JFAlg.Data(),cAdd.Data());
553
554
555 for(int algorithm=0;algorithm<3;algorithm++){
556 //for LHC11a1 LHC11a2
32de1459 557 if(algorithm==0)fJetBranch = Branchname_rec.Data();
558 if(algorithm==1)fJetBranch = Branchname_gen2.Data();
559 if(algorithm==2)fJetBranch = Branchname_gen.Data();
560
561 if((!IsMC&&(algorithm==1||algorithm==2)))continue;
562
563 TClonesArray* jets = dynamic_cast <TClonesArray*> (fAODIn->FindListObject(fJetBranch.Data()));
652845bc 564 if(!jets){
565 printf(" Tere are no Branch named %s \n",fJetBranch.Data());
566 continue;
567 }
32de1459 568 Int_t nj = jets->GetEntriesFast();
569 if (fDebug) printf("There are %5d jets in the event \n", nj);
570 AliAODJet* jetsAOD;
571 Jet_n[algorithm] = nj;
572 int nLjet_in05_pthdiv[20][20];
573 int nsLjet_in05_pthdiv[20][20];
574 for(int i=0;i<20;i++){
575 for(int j=0;j<20;j++){
576 nLjet_in05_pthdiv [i][j]=0;
577 nsLjet_in05_pthdiv[i][j]=0;
578 }
579 }
580 //Find Leading Jet -------------------------------------------------------
581 for(int njet =0;njet<nj;njet++){
582 jetsAOD = (AliAODJet*) (jets->At(njet));
583 Jet_pt [algorithm][njet] = jetsAOD->Pt();
584 Jet_phi [algorithm][njet] = jetsAOD->Phi();
585 Jet_eta [algorithm][njet] = jetsAOD->Eta();
586 //TRefArray *reftracks = jetsAOD->GetRefTracks();
587 double eta_cut_Jet=0.5;
588 if((TMath::Abs(Jet_eta[algorithm][njet])<eta_cut_Jet)&&(Jet_pt[algorithm][njet]>10.)){
589 if(algorithm==0){
590 fH1JetAKT04_pt->Fill(Jet_pt[algorithm][njet]);
591 if(Jet_pt[algorithm][njet]>ptLJetAOD){
592 findLJetAOD=true;
593 nLJetAOD=njet;ptLJetAOD=Jet_pt[algorithm][njet];phiLJetAOD=Jet_phi[algorithm][njet];etaLJetAOD=Jet_eta[algorithm][njet];
594 }
595 }
596 if(algorithm==1){
597 fH1JetMCAKT04_pt->Fill(Jet_pt[algorithm][njet]);
598 if(Jet_pt[algorithm][njet]>ptLJetMC2){
599 findLJetMC2=true;
600 nLJetMC2=njet;ptLJetMC2=Jet_pt[algorithm][njet];phiLJetMC2=Jet_phi[algorithm][njet];etaLJetMC2=Jet_eta[algorithm][njet];
601 }
602 }
603 if(algorithm==2){
604 if(Jet_pt[algorithm][njet]>ptLJetMC){
605 findLJetMC=true;
606 nLJetMC=njet;ptLJetMC=Jet_pt[algorithm][njet];phiLJetMC=Jet_phi[algorithm][njet];etaLJetMC=Jet_eta[algorithm][njet];
607 }
608 }
609 }
610 }//njet loop
611 //Leading Jet -----------------------------------------------------------
612
613 if(algorithm==0){nLJet=nLJetAOD;fH1leadJetAKT04_pt->Fill(Jet_pt[algorithm][nLJet]);}
614 if(algorithm==1){nLJet=nLJetMC2;fH1leadJetMCAKT04_pt->Fill(Jet_pt[algorithm][nLJet]);}
615 if(algorithm==2){nLJet=nLJetMC2;}
616
617 if(nj<2)continue;
618 //Find Sub leading Jet ==================================================
619 for(int njet=0;njet<nj;njet++){
620 if(njet==nLJet)continue;
621 jetsAOD = (AliAODJet *)jets->At(njet);
622 subJet_pt [algorithm][njet] = jetsAOD->Pt();
623 subJet_phi[algorithm][njet] = jetsAOD->Phi();
624 subJet_eta[algorithm][njet] = jetsAOD->Eta();
625 double eta_cut_Jet=0.5;
626 if((TMath::Abs(subJet_eta[algorithm][njet])<eta_cut_Jet) && (subJet_pt[algorithm][njet]>10.)){
627 if(subJet_pt[algorithm][njet]>ptsLJetAOD&&algorithm==0){
628 findsLJetAOD_temp=true;
629 nsLJetAOD=njet;ptsLJetAOD=Jet_pt[algorithm][njet];phisLJetAOD=Jet_phi[algorithm][njet];etasLJetAOD=Jet_eta[algorithm][njet];
630 }
631 if(subJet_pt[algorithm][njet]>ptsLJetMC2 &&algorithm==1){
632 findsLJetMC2_temp=true;
633 nsLJetMC2=njet;ptsLJetMC2=Jet_pt[algorithm][njet];phisLJetMC2=Jet_phi[algorithm][njet];etasLJetMC2=Jet_eta[algorithm][njet];
634 }
635 if(subJet_pt[algorithm][njet]>ptsLJetMC &&algorithm==2){
636 findsLJetMC_temp=true;
637 nsLJetMC =njet;ptsLJetMC =Jet_pt[algorithm][njet];phisLJetMC =Jet_phi[algorithm][njet];etasLJetMC =Jet_eta[algorithm][njet];
638 }
639 }
640 }
641 ////Sub leading Jet ======================================================
642
643 double Leading_pt=0.;double Leading_phi=999.;double Leading_eta=999.;double sLeading_pt=0.;double sLeading_phi=999.;double sLeading_eta=999.;
644 if(algorithm==0){Leading_pt=ptLJetAOD;Leading_phi=phiLJetAOD;Leading_eta=etaLJetAOD;sLeading_pt=ptsLJetAOD;sLeading_phi=phisLJetAOD;sLeading_eta=etasLJetAOD;}
645 if(algorithm==1){Leading_pt=ptLJetMC2;Leading_phi=phiLJetMC2;Leading_eta=etaLJetMC2;sLeading_pt=ptsLJetMC2;sLeading_phi=phisLJetMC2;sLeading_eta=etasLJetMC2;}
646 if(algorithm==2){Leading_pt=ptLJetMC ;Leading_phi=phiLJetMC ;Leading_eta=etaLJetMC ;sLeading_pt=ptsLJetMC ;sLeading_phi=phisLJetMC ;sLeading_eta=etasLJetMC ;}
647
648 ////Di-Jet event trigger +++++++++++++++++++++++++++++++++++++++++++++++
649 double DPhi = DeltaPhi(Leading_phi,sLeading_phi);
650 double DEta = Leading_eta-sLeading_eta;
651 if(algorithm==0){
652 fH2JetsJetAKT04_dphi->Fill(Leading_pt,DPhi);
653 fH2JetsJetAKT04_deta->Fill(Leading_pt,DEta);
654 }
655 if(algorithm==1){
656 fH2JetsJetMCAKT04_dphi->Fill(Leading_pt,DPhi);
657 fH2JetsJetMCAKT04_deta->Fill(Leading_pt,DEta);
658 }
659 if((TMath::Cos(DPhi)<-0.5)&&(Leading_pt>10.)&&(sLeading_pt>10.)){
660 if(algorithm==0)findsLJetAOD=true;
661 if(algorithm==1)findsLJetMC=true;
662
663 double Aj = (Leading_pt-sLeading_pt)/(Leading_pt+sLeading_pt);
664 if(algorithm==0){
665 fH1leadJetAKT04_pt_dijet->Fill(Leading_pt);
666 fH1subJetAKT04_pt_dijet ->Fill(sLeading_pt);
667 fH2JetsJetAKT04_Aj->Fill(Leading_pt,Aj);
668 fH2JetsJetAKT04_pt->Fill(Leading_pt,sLeading_pt);
669 }
670 if(algorithm==1){
671 fH1leadJetMCAKT04_pt_dijet->Fill(Leading_pt);
672 fH1subJetMCAKT04_pt_dijet ->Fill(sLeading_pt);
673 fH2JetsJetMCAKT04_Aj->Fill(Leading_pt,Aj);
674 fH2JetsJetMCAKT04_pt->Fill(Leading_pt,sLeading_pt);
675 }
28c36b48 676
32de1459 677 }
678 if(algorithm==0)findsLJet=findsLJetAOD;
679 if(algorithm==1)findsLJet=findsLJetMC2;
680 if(algorithm==2)findsLJet=findsLJetMC;
681 ////++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
682
00a3f17b 683 if(algorithm!=0)continue;
32de1459 684
685 if((findsLJet)&&(Leading_pt>10.)&&(sLeading_pt>10.)){
00a3f17b 686
687 for(int eb=0;eb<5;eb++){//count number of Di-Jet in pt bin
688 if(TMath::Abs(Leading_pt -20.*(eb+1))<10.){
689 if(algorithm==0)fH1AKT04_ndiJ_ediv[eb]->Fill(1);
690 }
691 }
692
693 TClonesArray* tracks = dynamic_cast <TClonesArray*> (fAODIn->GetTracks());
694 if(!tracks){
695 if (fDebug > 1) Printf("%s:%d could not get AODtracks", (char*)__FILE__,__LINE__);
696 continue;
697 }
698 Int_t nt = fAODIn->GetNumberOfTracks();
699
32de1459 700 AliAODTrack* trackAOD;
701 Track_n = nt;
00a3f17b 702 double eta_cut_Jet=0.5;
703 if(TMath::Abs(Leading_eta)<eta_cut_Jet){
704 for(int eb=0;eb<5;eb++){
705 if(TMath::Abs(Leading_pt -20.*(eb+1))<10.){
706 for(int ntrack =0;ntrack<nt;ntrack++){
707 trackAOD = (AliAODTrack*) (fAODIn->GetTrack(ntrack));
708 Bool_t bgoodT=false;
709 if(Filtermask!=768){
710 if(trackAOD->TestFilterMask(Filtermask))bgoodT=true;
711 }
712 else{
713 if(trackAOD->IsHybridGlobalConstrainedGlobal())bgoodT=true; //for hybrid Track cuts
714 }
715 if(!bgoodT)continue;
716 Track_pt [ntrack] = trackAOD->Pt();
717 Track_phi [ntrack] = trackAOD->Phi();
718 Track_eta [ntrack] = trackAOD->Eta();
719 double DelPhi = DeltaPhi(Leading_phi,Track_phi[ntrack]);
720 if(TMath::Abs(Track_eta[ntrack])<0.9){
721 for(int teb=0;teb<5;teb++){
722 if(teb==0){if(!(Track_pt[ntrack]>0.15))continue;}
723 if(teb==1){if(!((Track_pt[ntrack]<1.5)&&(Track_pt[ntrack]>0.15)))continue;}
724 if(teb==2){if(!((Track_pt[ntrack]<3.0)&&(Track_pt[ntrack]>1.5)))continue;}
725 if(teb==3){if(!((Track_pt[ntrack]<4.5)&&(Track_pt[ntrack]>3.0)))continue;}
726 if(teb==4){if(!(Track_pt[ntrack]>4.5))continue;}
727 if(algorithm==0){
728 fH1JetHadronAKT04_dphi_ediv [eb][teb]->Fill(DelPhi);
729 fH1JetHadronAKT04_dphi_tptweight_ediv [eb][teb]->Fill(DelPhi,Track_pt[ntrack]);
730 fH1JetHadronAKT04_dphi_tJptweight_ediv [eb][teb]->Fill(DelPhi,Track_pt[ntrack]/Leading_pt);
32de1459 731 }
732 }
00a3f17b 733 }
734 }//Track Loop
32de1459 735 }
00a3f17b 736 }
737 }//eta cut
32de1459 738 }// Di-Jet
739 }// algorithm LOOP
740 if(IsMC){
741 for(int eb=0;eb<5;eb++){
742 double DPhi;
743 if(TMath::Abs(ptLJetAOD -20.*(eb+1))<10.){
744 DPhi = DeltaPhi(phiLJetMC,phiLJetAOD);
745 fH1leadJetMCAKT04_dphiResolution[eb]->Fill(DPhi);
746 DPhi = DeltaPhi(phisLJetMC,phisLJetAOD);
747 fH1subJetMCAKT04_dphiResolution[eb]->Fill(DPhi);
748 }
749 }
750 }
751
32de1459 752 PostData(1, fHistList);
753 return;
754}
755
756//________________________________________________________________________
00a3f17b 757void AliAnalysisTaskJetHadronCorrelation::Terminate(Option_t *){
32de1459 758 // Terminate analysis
759 if (fDebug) printf("AnalysisTaskPt: Terminate() \n");
32de1459 760}
761
762
763Int_t AliAnalysisTaskJetHadronCorrelation::GetListOfJets(TList *list,TClonesArray* jarray,Int_t type){
764
765 if(fDebug>2)Printf("%s:%d Selecting jets with cuts %d",(char*)__FILE__,__LINE__,type);
766 Int_t iCount = 0;
767
768 if(!jarray){
769 Printf("%s:%d no Jet array",(char*)__FILE__,__LINE__);
770 return iCount;
771 }
772
773
774 for(int ij=0;ij<jarray->GetEntries();ij++){
775 AliAODJet* jet = (AliAODJet*)jarray->At(ij);
776 if(!jet)continue;
777 if(type==0){
778 // No cut at all, main purpose here is sorting
779 list->Add(jet);
780 iCount++;
781 }
782 else if(type == 1){
783 // eta cut
784 if(JetSelected(jet)){
785 list->Add(jet);
786 iCount++;
787 }
788 }
789 }
790
791 list->Sort();
792 return iCount;
793
794}
795
796
797
798Bool_t AliAnalysisTaskJetHadronCorrelation::JetSelected(AliAODJet *jet){
799 Bool_t selected = false;
800
801 if(!jet)return selected;
802
803 if(fabs(jet->Eta())<fJetRecEtaWindow&&jet->Pt()>fMinJetPt){
804 selected = kTRUE;
805 }
806 return selected;
807
808}
809
810
811Double_t AliAnalysisTaskJetHadronCorrelation::DeltaPhi(Double_t phi1,Double_t phi2){
812 Float_t pi=TMath::Pi();
813 Double_t dphi = phi1-phi2;
814 if (dphi<(-1./2*pi))dphi = dphi +2*pi;
815 else if(dphi>( 3./2*pi))dphi = dphi -2*pi;
816 return dphi;
817}
818
f4b5b842 819//Float_t AliAnalysisTaskJetHadronCorrelation::GetTotalEvents(const char* currFile){
820// Float_t totalevent;
821// //TString file_es(currFile);
822// //if(file_es.Contains("root_archive.zip#")){
823// // Ssiz_t pos1 = file_es.Index("root_archive",12,TString::kExact);
824// // Ssiz_t pos = file_es.Index("#",1,pos1,TString::kExact);
825// // file_es.Replace(pos+1,20,"");
826// //}
827// //else {
828// // // not an archive take the basename....
829// // file_es.ReplaceAll(gSystem->BaseName(file_es.Data()),"");
830// //}
831//
832// //TString cAdd = "";
833// //cAdd += Form("%02d_",(int)((Radius+0.01)*10.));
834// //cAdd += Form("B%d",(int)BackM);
835// //cAdd += Form("_Filter%05d",Filtermask);
836// //cAdd += Form("_Cut%05d",(int)(1000.*TrackPtcut));
837// //cAdd += Form("_Skip%02d",SkipCone);
838// //TString Dirname,Listname;
839// //Dirname = Form("PWG4_cluster_AOD__%s%s",JFAlg.Data(),cAdd.Data());
840// //Listname = Form("pwg4cluster_AOD__%s%s",JFAlg.Data(),cAdd.Data());
841//
842// //TFile *feventstat = TFile::Open(Form("%s%s",file_es.Data(),"JetTasksOutput.root"));
843// //gROOT->Cd(Dirname.Data());
844// //TList *templist = (TList*)gROOT->FindObject(Listname.Data());
845// //TH1F* temphist = (TH1F*)templist->FindObject("fh1Trials");
846// //totalevent = temphist->Integral();
847// ////cout<<temphist->Integral()<<endl;
848// //delete feventstat;
849// return totalevent;
850//
851//}
32de1459 852
853