]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetTasks/AliAnalysisTaskJetCorrections.cxx
comment out documentation lines
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalysisTaskJetCorrections.cxx
CommitLineData
95392a57 1#include <TROOT.h>
2#include <TSystem.h>
3#include <TInterpreter.h>
4#include <TChain.h>
5#include <TFile.h>
6#include <TH1F.h>
7#include <TH1.h>
8#include <TH2.h>
9#include <TH2F.h>
10#include <TH3F.h>
11#include <TList.h>
12#include <TTree.h>
13#include <TBranch.h>
14#include <TLorentzVector.h>
15#include <TClonesArray.h>
16#include <TObjArray.h>
17#include <TRefArray.h>
18#include <TArrayD.h>
19#include <fstream>
20#include <TVector3.h>
21#include <TVectorD.h>
22#include <TMatrixDSym.h>
23#include <TMatrixDSymEigen.h>
24#include <TStyle.h>
25#include <TProfile.h>
26#include "TDatabasePDG.h"
27
28#include "AliAnalysisTaskJetCorrections.h"
29#include "AliAnalysisManager.h"
30#include "AliJetFinder.h"
31#include "AliJetReader.h"
32#include "AliJetHeader.h"
33#include "AliJetReaderHeader.h"
34#include "AliUA1JetHeaderV1.h"
35#include "AliESDEvent.h"
36#include "AliAODEvent.h"
37#include "AliAODVertex.h"
38#include "AliAODHandler.h"
39#include "AliAODTrack.h"
40#include "AliAODJet.h"
41#include "AliMCEventHandler.h"
42#include "AliMCEvent.h"
43#include "AliStack.h"
44#include "AliGenPythiaEventHeader.h"
45#include "AliJetKineReaderHeader.h"
46#include "AliGenCocktailEventHeader.h"
47#include "AliAODPid.h"
48#include "AliExternalTrackParam.h"
49
50#include "AliAnalysisTaskJetSpectrum.h"
51#include "AliAnalysisTaskThreeJets.h"
52
53#include "AliAnalysisHelperJetTasks.h"
54
55
56ClassImp(AliAnalysisTaskJetCorrections)
57
58 AliAnalysisTaskJetCorrections::AliAnalysisTaskJetCorrections() : AliAnalysisTaskSE(),
59
60 fAOD(0x0),
61
62 fBranchRec(""),
63 fBranchGen(""),
64
65 fUseAODInput(kFALSE),
66
67 fR(0x0),
68 fList(0x0),
69
70 fGlobVar(1),
71 fXsection(1),
72
73 fhEGen(0x0),
74 fhERec(0x0),
75
76 fhEGenRest(0x0),
77 fhERecRest(0x0),
78
79 fhEsumGenRest(0x0),
80 fhEsumRecRest(0x0),
81
82 fhE2vsE1Gen(0x0),
83 fhE2vsE1Rec(0x0),
84 fhE2E1vsEsumGen(0x0),
85 fhE2E1vsEsumRec(0x0),
86 fhE2E1vsE1Gen(0x0),
87 fhE2E1vsE1Rec(0x0),
88 fhE2E1vsdPhiGen(0x0),
89 fhE2E1vsdPhiRec(0x0),
90
91 fhTrackBalance2(0x0),
92 fhTrackBalance3(0x0),
93
94 fhEt1Et22(0x0),
95 fhEt1Et23(0x0)
96
97{
98
99 for (Int_t i = 0; i < 3; i++)
100 {
101 fhECorrJet10[i] = 0;
102 fhECorrJet05[i] = 0;
103 fhECorrJet01[i] = 0;
104 fhECorrJet001[i] = 0;
105 fhdEvsErec10[i] = 0;
106 fhdEvsErec05[i] = 0;
107 fhdEvsErec01[i] = 0;
108 fhdEvsErec001[i] = 0;
109 fhdPhidEta10[i] = 0;
110 fhdPhidEta05[i] = 0;
111 fhdPhidEta01[i] = 0;
112 fhdPhidEta001[i] = 0;
113 fhdPhidEtaPt10[i] = 0;
114 fhdPhidEtaPt05[i] = 0;
115 fhdPhidEtaPt01[i] = 0;
116 fhdPhidEtaPt001[i] = 0;
117 }
118}
119
120AliAnalysisTaskJetCorrections::AliAnalysisTaskJetCorrections(const char * name):
121 AliAnalysisTaskSE(name),
122
123 fAOD(0x0),
124
125 fBranchRec(""),
126 fBranchGen(""),
127
128 fUseAODInput(kFALSE),
129
130 fR(0x0),
131 fList(0x0),
132
133 fGlobVar(1),
134 fXsection(1),
135
136 fhEGen(0x0),
137 fhERec(0x0),
138
139 fhEGenRest(0x0),
140 fhERecRest(0x0),
141
142 fhEsumGenRest(0x0),
143 fhEsumRecRest(0x0),
144
145 fhE2vsE1Gen(0x0),
146 fhE2vsE1Rec(0x0),
147 fhE2E1vsEsumGen(0x0),
148 fhE2E1vsEsumRec(0x0),
149 fhE2E1vsE1Gen(0x0),
150 fhE2E1vsE1Rec(0x0),
151 fhE2E1vsdPhiGen(0x0),
152 fhE2E1vsdPhiRec(0x0),
153
154 fhTrackBalance2(0x0),
155 fhTrackBalance3(0x0),
156
157 fhEt1Et22(0x0),
158 fhEt1Et23(0x0)
159{
160 for (Int_t i = 0; i < 3; i++)
161 {
162 fhECorrJet10[i] = 0;
163 fhECorrJet05[i] = 0;
164 fhECorrJet01[i] = 0;
165 fhECorrJet001[i] = 0;
166 fhdEvsErec10[i] = 0;
167 fhdEvsErec05[i] = 0;
168 fhdEvsErec01[i] = 0;
169 fhdEvsErec001[i] = 0;
170 fhdPhidEta10[i] = 0;
171 fhdPhidEta05[i] = 0;
172 fhdPhidEta01[i] = 0;
173 fhdPhidEta001[i] = 0;
174 fhdPhidEtaPt10[i] = 0;
175 fhdPhidEtaPt05[i] = 0;
176 fhdPhidEtaPt01[i] = 0;
177 fhdPhidEtaPt001[i] = 0;
178 }
179 DefineOutput(1, TList::Class());
180}
181
182
183
184Bool_t AliAnalysisTaskJetCorrections::Notify()
185{
186 //
187 // Implemented Notify() to read the cross sections
188 // and number of trials from pyxsec.root
189 //
190 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
191 UInt_t ntrials = 0;
192 if(tree){
193 TFile *curfile = tree->GetCurrentFile();
194 if (!curfile) {
195 Error("Notify","No current file");
196 return kFALSE;
197 }
198
199 TString fileName(curfile->GetName());
200 if(fileName.Contains("AliESDs.root")){
201 fileName.ReplaceAll("AliESDs.root", "pyxsec.root");
202 }
203 else if(fileName.Contains("AliAOD.root")){
204 fileName.ReplaceAll("AliAOD.root", "pyxsec.root");
205 }
206 else if(fileName.Contains("galice.root")){
207 // for running with galice and kinematics alone...
208 fileName.ReplaceAll("galice.root", "pyxsec.root");
209 }
210 TFile *fxsec = TFile::Open(fileName.Data());
211 if(!fxsec){
212 Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,fileName.Data());
213 // no a severe condition
214 return kTRUE;
215 }
216 TTree *xtree = (TTree*)fxsec->Get("Xsection");
217 if(!xtree){
218 Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
219 }
220 xtree->SetBranchAddress("xsection",&fXsection);
221 xtree->SetBranchAddress("ntrials",&ntrials);
222 xtree->GetEntry(0);
223 }
224
225 return kTRUE;
226}
227
228
229//___________________________________________________________________________________________________________________________________
230void AliAnalysisTaskJetCorrections::UserCreateOutputObjects()
231{
232 //
233 // Create the output container
234 //
235 Printf("Analysing event %s :: # %5d\n", gSystem->pwd(), (Int_t) fEntry);
236
237 if(fUseAODInput){
238 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
239 if(!fAOD){
240 Printf("%s:%d AODEvent not found in Input Manager %d",(char*)__FILE__,__LINE__,fUseAODInput);
241 return;
242 }
243 }
244 else{
245 // assume that the AOD is in the general output...
246 fAOD = AODEvent();
247 if(!fAOD){
248 Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
249 return;
250 }
251 }
252
253 printf("AnalysisTaskJetSpectrum::UserCreateOutputObjects() \n");
254
255 fList = new TList();
256
257 fhEGen = new TH1F("EGen", "", 100, 0, 200);
258 fhEGen->Sumw2();
259 fList->Add(fhEGen);
260
261 fhERec = new TH1F("ERec", "", 100, 0, 200);
262 fhERec->Sumw2();
263 fList->Add(fhERec);
264
265 fhEGenRest = new TH1F("EGenRest", "", 100, 0, 200);
266 fhEGenRest->Sumw2();
267 fList->Add(fhEGenRest);
268
269 fhERecRest = new TH1F("ERecRest", "", 100, 0, 200);
270 fhERecRest->Sumw2();
271 fList->Add(fhERecRest);
272
273 fhEsumGenRest = new TH1F("EsumGenRest", "", 100, 0, 200);
274 fhEsumGenRest->Sumw2();
275 fList->Add(fhEsumGenRest);
276
277 fhEsumRecRest = new TH1F("EsumRecRest", "", 100, 0, 200);
278 fhEsumRecRest->Sumw2();
279 fList->Add(fhEsumRecRest);
280
281 fhE2vsE1Gen = new TH2F("E2vsE1Gen", "", 100, 0, 200, 100, 0, 200);
282 fhE2vsE1Gen->Sumw2();
283 fList->Add(fhE2vsE1Gen);
284
285 fhE2vsE1Rec = new TH2F("E2vsE1Rec", "", 100, 0, 200, 100, 0, 200);
286 fhE2vsE1Rec->Sumw2();
287 fList->Add(fhE2vsE1Rec);
288
289 fhE2E1vsEsumGen = new TH2F("E2E1vsEsumGen", "", 100, 0, 200, 25, 0, 1);
290 fhE2E1vsEsumGen->Sumw2();
291 fList->Add(fhE2E1vsEsumGen);
292
293 fhE2E1vsEsumRec = new TH2F("E2E1vsEsumRec", "", 100, 0, 200, 25, 0, 1);
294 fhE2E1vsEsumRec->Sumw2();
295 fList->Add(fhE2E1vsEsumRec);
296
297 fhE2E1vsE1Gen = new TH2F("E2E1vsE1Gen", "", 100, 0, 200, 25, 0, 1);
298 fhE2E1vsE1Gen->Sumw2();
299 fList->Add(fhE2E1vsE1Gen);
300
301 fhE2E1vsE1Rec = new TH2F("E2E1vsE1Rec", "", 100, 0, 200, 25, 0, 1);
302 fhE2E1vsE1Rec->Sumw2();
303 fList->Add(fhE2E1vsE1Rec);
304
305 fhE2E1vsdPhiGen = new TH2F("E2E1vsdPhiGen", "", 64, -3.20, 3.20, 25, 0, 1);
306 fList->Add(fhE2E1vsdPhiGen);
307
308 fhE2E1vsdPhiRec = new TH2F("E2E1vsdPhiRec", "", 64, -3.20, 3.20, 25, 0, 1);
309 fList->Add(fhE2E1vsdPhiRec);
310
311 fhTrackBalance2 = new TH2F("TrackBalance2", "", 60, 0, 30, 60, 0, 30);
312 fhTrackBalance2->Sumw2();
313 fList->Add(fhTrackBalance2);
314
315 fhTrackBalance3 = new TH2F("TrackBalance3", "", 60, 0, 30, 60, 0, 30);
316 fhTrackBalance3->Sumw2();
317 fList->Add(fhTrackBalance3);
318
319 fhEt1Et22 = new TH2F("Et1Et22", "", 100, 0, 50, 100, 0, 50);
320 fhEt1Et22->Sumw2();
321 fList->Add(fhEt1Et22);
322
323 fhEt1Et23 = new TH2F("Et1Et23", "", 100, 0, 50, 100, 0, 50);
324 fhEt1Et23->Sumw2();
325 fList->Add(fhEt1Et23);
326
327 for(Int_t i = 0; i < 3; i++)
328 {
329 fhECorrJet10[i] = new TProfile(Form("ECorrJet10%d", i+1), "", 100, 0, 200, 0, 10);
330 fhECorrJet10[i]->SetXTitle("E_{rec} [GeV]");
331 fhECorrJet10[i]->SetYTitle("C=E_{gen}/E_{rec}");
332 fhECorrJet10[i]->Sumw2();
333
334 fhECorrJet05[i] = new TProfile(Form("ECorrJet05%d", i+1), "", 100, 0, 200, 0, 10);
335 fhECorrJet05[i]->SetXTitle("E_{rec} [GeV]");
336 fhECorrJet05[i]->SetYTitle("C=E_{gen}/E_{rec}");
337 fhECorrJet05[i]->Sumw2();
338
339 fhECorrJet01[i] = new TProfile(Form("ECorrJet01%d", i+1), "", 100, 0, 200, 0, 10);
340 fhECorrJet01[i]->SetXTitle("E_{rec} [GeV]");
341 fhECorrJet01[i]->SetYTitle("C=E_{gen}/E_{rec}");
342 fhECorrJet01[i]->Sumw2();
343
344 fhECorrJet001[i] = new TProfile(Form("ECorrJet001%d", i+1), "", 100, 0, 200, 0, 10);
345 fhECorrJet001[i]->SetXTitle("E_{rec} [GeV]");
346 fhECorrJet001[i]->SetYTitle("C=E_{gen}/E_{rec}");
347 fhECorrJet001[i]->Sumw2();
348
349 fhdEvsErec10[i] = new TProfile(Form("dEvsErec10_%d", i+1),"", 100, 0, 200, -1, 10);
350 fhdEvsErec10[i]->SetYTitle("|E_{rec}-E_{rec}|/E_{rec}");
351 fhdEvsErec10[i]->SetXTitle("E_{rec} [GeV]");
352 fhdEvsErec10[i]->Sumw2();
353
354 fhdEvsErec05[i] = new TProfile(Form("dEvsErec05_%d", i+1),"", 100, 0, 200, -1, 10);
355 fhdEvsErec05[i]->SetYTitle("|E_{rec}-E_{rec}|/E_{rec}");
356 fhdEvsErec05[i]->SetXTitle("E_{rec} [GeV]");
357 fhdEvsErec05[i]->Sumw2();
358
359 fhdEvsErec01[i] = new TProfile(Form("dEvsErec01_%d", i+1),"", 100, 0, 200, -1, 10);
360 fhdEvsErec01[i]->SetYTitle("|E_{rec}-E_{rec}|/E_{rec}");
361 fhdEvsErec01[i]->SetXTitle("E_{rec} [GeV]");
362 fhdEvsErec01[i]->Sumw2();
363
364 fhdEvsErec001[i] = new TProfile(Form("dEvsErec001_%d", i+1),"", 100, 0, 200, -1, 10);
365 fhdEvsErec001[i]->SetYTitle("|E_{rec}-E_{rec}|/E_{rec}");
366 fhdEvsErec001[i]->SetXTitle("E_{rec} [GeV]");
367 fhdEvsErec001[i]->Sumw2();
368
369 fhdPhidEta10[i] = new TH2F(Form("dPhidEta10_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
370 fhdPhidEta10[i]->SetXTitle("#phi [rad]");
371 fhdPhidEta10[i]->SetYTitle("#eta");
372 fhdPhidEta10[i]->Sumw2();
373
374 fhdPhidEta05[i] = new TH2F(Form("dPhidEta05_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
375 fhdPhidEta05[i]->SetXTitle("#phi [rad]");
376 fhdPhidEta05[i]->SetYTitle("#eta");
377 fhdPhidEta05[i]->Sumw2();
378
379 fhdPhidEta01[i] = new TH2F(Form("dPhidEta01_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
380 fhdPhidEta01[i]->SetXTitle("#phi [rad]");
381 fhdPhidEta01[i]->SetYTitle("#eta");
382 fhdPhidEta01[i]->Sumw2();
383
384 fhdPhidEta001[i] = new TH2F(Form("dPhidEta001_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
385 fhdPhidEta001[i]->SetXTitle("#phi [rad]");
386 fhdPhidEta001[i]->SetYTitle("#eta");
387 fhdPhidEta001[i]->Sumw2();
388
389 fhdPhidEtaPt10[i] = new TH2F(Form("dPhidEtaPt10_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
390 fhdPhidEtaPt10[i]->SetXTitle("#phi [rad]");
391 fhdPhidEtaPt10[i]->SetYTitle("#eta");
392 fhdPhidEtaPt10[i]->Sumw2();
393
394 fhdPhidEtaPt05[i] = new TH2F(Form("dPhidEtaPt05_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
395 fhdPhidEtaPt05[i]->SetXTitle("#phi [rad]");
396 fhdPhidEtaPt05[i]->SetYTitle("#eta");
397 fhdPhidEtaPt05[i]->Sumw2();
398
399 fhdPhidEtaPt01[i] = new TH2F(Form("dPhidEtaPt01_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
400 fhdPhidEtaPt01[i]->SetXTitle("#phi [rad]");
401 fhdPhidEtaPt01[i]->SetYTitle("#eta");
402 fhdPhidEtaPt01[i]->Sumw2();
403
404 fhdPhidEtaPt001[i] = new TH2F(Form("dPhidEtaPt001_%d", i+1), "", 63, (-1)*TMath::Pi(), TMath::Pi(), 18, -0.9, 0.9);
405 fhdPhidEtaPt001[i]->SetXTitle("#phi [rad]");
406 fhdPhidEtaPt001[i]->SetYTitle("#eta");
407 fhdPhidEtaPt001[i]->Sumw2();
408
409 fList->Add(fhECorrJet10[i]);
410 fList->Add(fhECorrJet05[i]);
411 fList->Add(fhECorrJet01[i]);
412 fList->Add(fhECorrJet001[i]);
413 fList->Add(fhdEvsErec10[i]);
414 fList->Add(fhdEvsErec05[i]);
415 fList->Add(fhdEvsErec01[i]);
416 fList->Add(fhdEvsErec001[i]);
417 fList->Add(fhdPhidEta10[i]);
418 fList->Add(fhdPhidEta05[i]);
419 fList->Add(fhdPhidEta01[i]);
420 fList->Add(fhdPhidEta001[i]);
421 fList->Add(fhdPhidEtaPt10[i]);
422 fList->Add(fhdPhidEtaPt05[i]);
423 fList->Add(fhdPhidEtaPt01[i]);
424 fList->Add(fhdPhidEtaPt001[i]);
425 }
426
427 Printf("UserCreateOutputObjects finished\n");
428}
429
430//__________________________________________________________________________________________________________________________________________
431void AliAnalysisTaskJetCorrections::Init()
432{
433 printf("AliAnalysisJetCut::Init() \n");
434}
435
436//____________________________________________________________________________________________________________________________________________
437void AliAnalysisTaskJetCorrections::UserExec(Option_t * )
438{
439// if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) fEntry);
440
441
442 //create an AOD handler
443 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
444
445 if(!aodH)
446 {
447 Printf("%s:%d no output aodHandler found Jet",(char*)__FILE__,__LINE__);
448 return;
449 }
450
451 AliMCEvent* mcEvent =MCEvent();
452 if(!mcEvent){
453 Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
454 return;
455 }
456
457 if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
458
459 //primary vertex
460 AliAODVertex * pvtx = dynamic_cast<AliAODVertex*>(fAOD->GetPrimaryVertex());
461 if(!pvtx) return;
462
463 AliAODJet genJets[kMaxJets];
464 Int_t nGenJets = 0;
465
466 AliAODJet recJets[kMaxJets];
467 Int_t nRecJets = 0;
468
469 //array of reconstructed jets from the AOD input
470 TClonesArray *aodRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchRec.Data()));
471 if(!aodRecJets){
472 Printf("%s:%d no reconstructed Jet array with name %s in AOD",(char*)__FILE__,__LINE__,fBranchRec.Data());
473 return;
474 }
475
476 // reconstructed jets
477 nRecJets = aodRecJets->GetEntries();
478 nRecJets = TMath::Min(nRecJets, kMaxJets);
479
480 for(int ir = 0;ir < nRecJets;++ir)
481 {
482 AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodRecJets->At(ir));
483 if(!tmp)continue;
484 recJets[ir] = *tmp;
485 }
486
487 // If we set a second branch for the input jets fetch this
488 TClonesArray * aodGenJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchGen.Data()));
489
490 if(!aodGenJets)
491 {
492 printf("NO MC jets branch with name %s Found \n",fBranchGen.Data());
493 return;
494 }
495
496 // //Generated jets
497 nGenJets = aodGenJets->GetEntries();
498 nGenJets = TMath::Min(nGenJets, kMaxJets);
499
500 for(Int_t ig =0 ; ig < nGenJets; ++ig)
501 {
502 AliAODJet * tmp = dynamic_cast<AliAODJet*>(aodGenJets->At(ig));
503 if(!tmp)continue;
504 genJets[ig] = * tmp;
505 }
506
507 Double_t eRec[kMaxJets];
508 Double_t eGen[kMaxJets];
509
510 Double_t eRecRest[kMaxJets];
511 Double_t eGenRest[kMaxJets];
512
513// AliAODJet jetRec[kMaxJets];
514 AliAODJet jetGen[kMaxJets];
515
516 Int_t idxRec[kMaxJets];
517 Int_t idxGen[kMaxJets];
518
519// Double_t EsumRec = 0;
520 // Double_t EsumGen =0;
521
522 TLorentzVector vRec[kMaxJets];
523 TLorentzVector vGen[kMaxJets];
524
525 TLorentzVector vsumRec;
526 TLorentzVector vsumGen;
527
528 TVector3 pRec[kMaxJets];
529 TVector3 pGen[kMaxJets];
530
531 // HISTOS FOR MC
532 Int_t nGenSel = 0;
533 Int_t counter = 0;
534 Int_t tag = 0;
535
536 AliAODJet selJets[kMaxJets];
537
538 // loop for applying the separation cut
539 for(Int_t i = 0; i < nGenJets; i++)
540 {
541 if(nGenJets == 1)
542 {
543 selJets[nGenSel] = genJets[i];
544 nGenSel++;
545 }
546 else
547 {
548 counter = 0;
549 tag = 0;
550 for(Int_t j = 0; j < nGenJets; j++)
551 {
552 if(i!=j)
553 {
554 Double_t dRij = genJets[i].DeltaR(&genJets[j]);
555 counter++;
556 if(dRij > 2*fR) tag++;
557 }
558 }
559 if(counter!=0)
560 {
561 if(tag/counter == 1)
562 {
563 selJets[nGenSel] = genJets[i];
564 nGenSel++;
565 }
566 }
567 }
568 }
569
570 for (Int_t gj = 0; gj < nGenSel; gj++)
571 {
572 eGen[gj] = selJets[gj].E();
573 fhEGen->Fill(eGen[gj], fXsection);
574 }
575
576 TMath::Sort(nGenSel, eGen, idxGen);
577 for (Int_t ig = 0; ig < nGenSel; ig++)
578 jetGen[ig] = selJets[idxGen[ig]];
579
580 //rest frame MC jets
581 for (Int_t i = 0; i < nGenSel; ++i)
582 {
583 vGen[i].SetPxPyPzE(jetGen[i].Px(), jetGen[i].Py(), jetGen[i].Pz(), jetGen[i].E());
584 pGen[i].SetXYZ(vGen[i].Px(), vGen[i].Py(), vGen[i].Pz());
585 vsumGen += vGen[i];
586 }
587
588 if(nGenSel > 1 && pGen[0].DeltaPhi(pGen[1]) > 2.8)
589 {
590 fhE2vsE1Gen->Fill(jetGen[0].E(), jetGen[1].E(), fXsection);
591 fhE2E1vsEsumGen->Fill(jetGen[0].E()+jetGen[1].E(), TMath::Abs(jetGen[0].E()-jetGen[1].E())/jetGen[0].E(), fXsection);
592 fhE2E1vsE1Gen->Fill(jetGen[0].E(), TMath::Abs(jetGen[0].E()-jetGen[1].E())/jetGen[0].E(), fXsection);
593 Double_t deltaPhi = (jetGen[0].Phi()-jetGen[1].Phi());
594 if(deltaPhi > TMath::Pi()) deltaPhi = deltaPhi - 2.*TMath::Pi();
595 if(deltaPhi < (-1.*TMath::Pi())) deltaPhi = deltaPhi + 2.*TMath::Pi();
596 fhE2E1vsdPhiGen->Fill(deltaPhi, TMath::Abs(jetGen[0].E()-jetGen[1].E())/jetGen[0].E(), fXsection);
597 }
598
599 Double_t fPxGen = vsumGen.Px();
600 Double_t fPyGen = vsumGen.Py();
601 Double_t fPzGen = vsumGen.Pz();
602 Double_t fEGen = vsumGen.E();
603
604 Double_t eSumGenRest = 0;
605 for (Int_t j = 0; j < nGenSel; j++)
606 {
607 vGen[j].Boost(-fPxGen/fEGen, -fPyGen/fEGen, -fPzGen/fEGen);
608 eGenRest[j] = vGen[j].E();
609 if(nGenSel > 1)
610 fhEGenRest->Fill(eGenRest[j], fXsection);
611 eSumGenRest += eGenRest[j];
612 }
613
614 if(nGenSel > 1)
615 fhEsumGenRest->Fill(eSumGenRest, fXsection);
616
617 //END VARIABLES FOR MC JETS ---------------
618 // }
619
620 //AOD JET VARIABLES
621 Int_t nRecSel = 0;
622 Int_t counter1 = 0;
623 Int_t tag1 = 0;
624
625 AliAODJet recSelJets[kMaxJets];
626
627 for(Int_t i = 0; i < nRecJets; i++)
628 {
629 if(nRecJets == 1)
630 {
631 recSelJets[nRecSel] = recJets[i];
632 nRecSel++;
633 }
634 else
635 {
636 counter1 = 0;
637 tag1 = 0;
638 for(Int_t j = 0; j < nRecJets; j++)
639 {
640 if(i!=j)
641 {
642 Double_t dRij = recJets[i].DeltaR(&recJets[j]);
643 counter1++;
644 if(dRij > 2*fR) tag1++;
645 }
646 }
647 if(counter1!=0)
648 {
649 if(tag1/counter1 == 1)
650 {
651 recSelJets[nRecSel] = recJets[i];
652 nRecSel++;
653 }
654 }
655 }
656 }
657
658 if(nRecSel == 0) return;
659 Printf("******NUMBER OF JETS AFTER DELTA R CUT : %d **********\n", nRecSel);
660 //sort rec/gen jets by energy in C.M.S
661 AliAODJet jetRecTmp[kMaxJets];
662 Int_t nAccJets = 0;
663 Double_t jetTrackPt[kTracks];
664 TLorentzVector jetTrackTmp[kTracks];
665 Int_t nTracks = 0;
666 for (Int_t rj = 0; rj < nRecSel; rj++)
667 {
668 TRefArray * jetTracksAOD = dynamic_cast<TRefArray*>(recSelJets[rj].GetRefTracks());
669 if(!jetTracksAOD) continue;
670 if(jetTracksAOD->GetEntries() < 3) continue;
671 Int_t nJetTracks = 0;
672 for(Int_t j = 0; j < jetTracksAOD->GetEntries(); j++)
673 {
674 AliAODTrack * track = dynamic_cast<AliAODTrack*>(jetTracksAOD->At(j));
675 if(!track) continue;
676 Double_t cv[21];
677 track->GetCovarianceXYZPxPyPz(cv);
678 if(cv[14] > 1000.) continue;
679 jetTrackPt[nTracks] = track->Pt();
680 jetTrackTmp[nTracks].SetPxPyPzE(track->Px(),track->Py(),track->Pz(),track->E());
681 nTracks++;
682 nJetTracks++;
683 }
684 if(nJetTracks < 4) continue;
685 jetRecTmp[nAccJets] = recSelJets[rj];
686 eRec[nAccJets] = recSelJets[rj].E();
687 fhERec->Fill(eRec[nAccJets], fXsection);
688 nAccJets++;
689 }
690
691 if(nAccJets == 0) return;
692 if(nTracks == 0) return;
693
694 Printf(" ************ Number of accepted jets : %d ************ \n", nAccJets);
695
696 AliAODJet jetRecAcc[kMaxJets];
697 TMath::Sort(nAccJets, eRec, idxRec);
698 for (Int_t rj = 0; rj < nAccJets; rj++)
699 jetRecAcc[rj] = jetRecTmp[idxRec[rj]];
700
701 //rest frame for reconstructed jets
702 for (Int_t i = 0; i < nAccJets; i++)
703 {
704 vRec[i].SetPxPyPzE(jetRecAcc[i].Px(), jetRecAcc[i].Py(), jetRecAcc[i].Pz(), jetRecAcc[i].E());
705 pRec[i].SetXYZ(vRec[i].Px(), vRec[i].Py(), vRec[i].Pz());
706 vsumRec += vRec[i];
707 }
708
709 //check balance of two leading hadrons, deltaPhi > 2.
710 Int_t idxTrack[kTracks];
711 TMath::Sort(nTracks, jetTrackPt, idxTrack);
712
713 TLorentzVector jetTrack[kTracks];
714 for(Int_t iTr = 0; iTr < nTracks; iTr++)
715 jetTrack[iTr] = jetTrackTmp[idxTrack[iTr]];
716
717 Int_t n = 1;
718 while(jetTrack[0].DeltaPhi(jetTrack[n]) < 2.8)
719 n++;
720
721 Double_t et1 = 0;
722 Double_t et2 = 0;
723 for(Int_t iTr = 0; iTr < nTracks; iTr++)
724 {
725 if(TMath::Abs(jetTrack[0].DeltaPhi(jetTrack[iTr]) < 1.) && iTr != 0)
726 et1 += jetTrack[iTr].Et();
727
728 if(TMath::Abs(jetTrack[n].DeltaPhi(jetTrack[iTr]) < 1.) && iTr != n)
729 et2 += jetTrack[iTr].Et();
730 }
731
732 if(nAccJets == 2)
733 {
734 fhTrackBalance2->Fill(jetTrack[0].Et(), jetTrack[n].Et());
735 fhEt1Et22->Fill(et1, et2);
736 }
737 if(nAccJets == 3)
738 {
739 fhTrackBalance3->Fill(jetTrack[0].Et(), jetTrack[n].Et());
740 fhEt1Et23->Fill(et1, et2);
741 }
742
743 if(nAccJets > 1 && pRec[0].DeltaPhi(pRec[1]) > 2.8)
744 {
745 fhE2vsE1Rec->Fill(jetRecAcc[0].E(), jetRecAcc[1].E(), fXsection);
746 fhE2E1vsEsumRec->Fill(jetRecAcc[0].E()+jetRecAcc[1].E(), TMath::Abs(jetRecAcc[0].E()-jetRecAcc[1].E())/jetRecAcc[0].E(), fXsection);
747 fhE2E1vsE1Rec->Fill(jetRecAcc[0].E(), TMath::Abs(jetRecAcc[0].E()-jetRecAcc[1].E())/jetRecAcc[0].E(), fXsection);
748 Double_t deltaPhi = (jetRecAcc[0].Phi()-jetRecAcc[1].Phi());
749 if(deltaPhi > TMath::Pi()) deltaPhi = deltaPhi - 2.*TMath::Pi();
750 if(deltaPhi < (-1.*TMath::Pi())) deltaPhi = deltaPhi + 2.*TMath::Pi();
751 fhE2E1vsdPhiRec->Fill(-1*deltaPhi, TMath::Abs(jetRecAcc[0].E()-jetRecAcc[1].E())/jetRecAcc[0].E(), fXsection);
752 }
753
754 Double_t fPx = vsumRec.Px();
755 Double_t fPy = vsumRec.Py();
756 Double_t fPz = vsumRec.Pz();
757 Double_t fE = vsumRec.E();
758
759 Double_t eSumRecRest = 0;
760 for (Int_t j = 0; j < nAccJets; j++)
761 {
762 vRec[j].Boost(-fPx/fE, -fPy/fE, -fPz/fE);
763 eRecRest[j] = vRec[j].E();
764 if(nAccJets > 1)
765 fhERecRest->Fill(eRecRest[j], fXsection);
766 eSumRecRest += eRecRest[j];
767 }
768 if(nAccJets > 1)
769 fhEsumRecRest->Fill(eSumRecRest, fXsection);
770
771 // Relate the jets
772 Int_t iGenIndex[kMaxJets]; // Index of the generated jet for i-th rec -1 if none
773 Int_t iRecIndex[kMaxJets]; // Index of the rec jet for i-th gen -1 if none
774
775 for(int i = 0;i<kMaxJets;++i){
776 iGenIndex[i] = iRecIndex[i] = -1;
777 }
778 Double_t dR = 1.4;
779 if(nAccJets == nGenSel)
780 {
781 AliAnalysisHelperJetTasks::GetClosestJets(jetGen,nGenSel,jetRecAcc,nAccJets,
782 iGenIndex,iRecIndex,0);
783
784 for(int ir = 0;ir < nAccJets;ir++){
785 Int_t ig = iGenIndex[ir];
786 if(ig>=0&&ig<nGenSel){
787 Double_t dPhi = TMath::Abs(jetRecAcc[ir].Phi()-jetGen[ig].Phi());
788 if(dPhi > TMath::Pi()) dPhi = dPhi - 2.*TMath::Pi();
789 if(dPhi < (-1.*TMath::Pi())) dPhi = dPhi + 2.*TMath::Pi();
790 Double_t sigma = TMath::Abs(jetGen[ig].E()-jetRecAcc[ir].E())/jetGen[ig].E();
791 dR = jetRecAcc[ir].DeltaR(&jetGen[ig]);
792 if(dR < 2*fR && dR >= fR)
793 {
794 switch(nAccJets)
795 {
796 case 1:
797 {
798 fhdEvsErec10[0]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
799 fhECorrJet10[0]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
800 for(Int_t iTr = 0; iTr < nTracks; iTr++)
801 {
802 fhdPhidEtaPt10[0]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
803 fhdPhidEta10[0]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
804 }
805 }
806 break;
807 case 2:
808 {
809 fhdEvsErec10[1]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
810 fhECorrJet10[1]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
811 for(Int_t iTr = 0; iTr < nTracks; iTr++)
812 {
813 fhdPhidEtaPt10[1]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
814 fhdPhidEta10[1]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
815 }
816 }
817 break;
818 case 3:
819 {
820 fhdEvsErec10[2]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
821 fhECorrJet10[2]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
822 for(Int_t iTr = 0; iTr < nTracks; iTr++)
823 {
824 fhdPhidEtaPt10[2]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
825 fhdPhidEta10[2]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
826 }
827 }
828 break;
829 }
830 }
831 if(dR < fR && dR >= 0.1)
832 {
833 switch(nAccJets)
834 {
835 case 1:
836 {
837 fhdEvsErec05[0]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
838 fhECorrJet05[0]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
839 for(Int_t iTr = 0; iTr < nTracks; iTr++)
840 {
841 fhdPhidEtaPt05[0]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
842 fhdPhidEta05[0]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
843 }
844 }
845 break;
846 case 2:
847 {
848 fhdEvsErec05[1]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
849 fhECorrJet05[1]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
850 for(Int_t iTr = 0; iTr < nTracks; iTr++)
851 {
852 fhdPhidEtaPt05[1]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
853 fhdPhidEta05[1]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
854 }
855 }
856 break;
857 case 3:
858 {
859 fhdEvsErec05[2]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
860 fhECorrJet05[2]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
861 for(Int_t iTr = 0; iTr < nTracks; iTr++)
862 {
863 fhdPhidEtaPt05[2]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
864 fhdPhidEta05[2]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
865 }
866 }
867 break;
868 }
869 }
870 if(dR < 0.1 && dR >= 0.01)
871 {
872 switch(nAccJets)
873 {
874 case 1:
875 {
876 fhdEvsErec01[0]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
877 fhECorrJet01[0]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
878 for(Int_t iTr = 0; iTr < nTracks; iTr++)
879 {
880 fhdPhidEtaPt01[0]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
881 fhdPhidEta01[0]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
882 }
883 }
884 break;
885 case 2:
886 {
887 fhdEvsErec01[1]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
888 fhECorrJet01[1]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
889 for(Int_t iTr = 0; iTr < nTracks; iTr++)
890 {
891 fhdPhidEtaPt01[1]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
892 fhdPhidEta01[1]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
893 }
894 }
895 break;
896 case 3:
897 {
898 fhdEvsErec01[2]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
899 fhECorrJet01[2]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
900 for(Int_t iTr = 0; iTr < nTracks; iTr++)
901 {
902 fhdPhidEtaPt01[2]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
903 fhdPhidEta01[2]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
904 }
905 }
906 break;
907 }
908 }
909 if(dR > 0.01) continue;
910 switch(nAccJets)
911 {
912 case 1:
913 {
914 fhECorrJet001[0]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
915 fhdEvsErec001[0]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
916 for(Int_t iTr = 0; iTr < nTracks; iTr++)
917 {
918 fhdPhidEtaPt001[0]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
919 fhdPhidEta001[0]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
920 }
921 }
922 break;
923 case 2:
924 {
925 fhECorrJet001[1]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
926 fhdEvsErec001[1]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
927 for(Int_t iTr = 0; iTr < nTracks; iTr++)
928 {
929 fhdPhidEtaPt001[1]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
930 fhdPhidEta001[1]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
931 }
932 }
933 break;
934 case 3:
935 {
936 fhECorrJet001[2]->Fill(jetRecAcc[ir].E(), jetGen[ig].E()/jetRecAcc[ir].E(), fXsection);
937 fhdEvsErec001[2]->Fill(jetRecAcc[ir].E(), sigma, fXsection);
938 for(Int_t iTr = 0; iTr < nTracks; iTr++)
939 {
940 fhdPhidEtaPt001[2]->Fill(jetTrack[iTr].Phi(), jetTrack[iTr].Eta(), jetTrack[iTr].Pt());
941 fhdPhidEta001[2]->Fill(jetTrack[iTr].Phi(), jetTrack[ir].Eta());
942 }
943 }
944 break;
945 }
946 }
947 }
948 // loop over reconstructed jets
949 }
950
951 Printf("%s:%d",(char*)__FILE__,__LINE__);
952
953 PostData(1, fList);
954
955 Printf("%s:%d Data Posted",(char*)__FILE__,__LINE__);
956
957}
958
959
960//__________________________________________________________________________________________________________________________________________________
961void AliAnalysisTaskJetCorrections::Terminate(Option_t *)
962{
963 printf("AnalysisJetCorrelation::Terminate()");
964
965}
966
967//_______________________________________User defined functions_____________________________________________________________________________________
968void AliAnalysisTaskJetCorrections::GetThrustAxis(TVector3 &n01, TVector3 * pTrack, Int_t &nTracks)
969{
970 TVector3 psum;
971 Double_t psum1 = 0;
972 Double_t psum2 = 0;
973 Double_t thrust[kTracks];
974 Double_t th = -3;
975
976 for(Int_t j = 0; j < nTracks; j++)
977 {
978 psum.SetXYZ(0., 0., 0.);
979 psum1 = 0;
980 psum2 = 0;
981 for(Int_t i = 0; i < nTracks; i++)
982 {
983 psum1 += (TMath::Abs(n01.Dot(pTrack[i])));
984 psum2 += pTrack[i].Mag();
985
986 if (n01.Dot(pTrack[i]) > 0) psum += pTrack[i];
987 if (n01.Dot(pTrack[i]) < 0) psum -= pTrack[i];
988 }
989
990 thrust[j] = psum1/psum2;
991
992 if(th == thrust[j])
993 break;
994
995 th = thrust[j];
996
997 n01 = psum.Unit();
998 }
999}
1000//______________________________________________________________________________________________________
1001
1002