Setter for the maxpt for the tight PID selection (Andrea)
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalysisTaskJetServices.cxx
CommitLineData
d3a3f33d 1
bf7b8731 2// **************************************
3// Task used for the correction of determiantion of reconstructed jet spectra
4// Compares input (gen) and output (rec) jets
5// *******************************************
6
7
8/**************************************************************************
9 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
10 * *
11 * Author: The ALICE Off-line Project. *
12 * Contributors are mentioned in the code where appropriate. *
13 * *
14 * Permission to use, copy, modify and distribute this software and its *
15 * documentation strictly for non-commercial purposes is hereby granted *
16 * without fee, provided that the above copyright notice appears in all *
17 * copies and that both the copyright notice and this permission notice *
18 * appear in the supporting documentation. The authors make no claims *
19 * about the suitability of this software for any purpose. It is *
20 * provided "as is" without express or implied warranty. *
21 **************************************************************************/
22
23
24#include <TROOT.h>
25#include <TRandom.h>
b1cd90b5 26#include <TString.h>
bf7b8731 27#include <TSystem.h>
28#include <TInterpreter.h>
29#include <TChain.h>
30#include <TFile.h>
31#include <TKey.h>
32#include <TH1F.h>
33#include <TH2F.h>
34#include <TH3F.h>
35#include <TProfile.h>
36#include <TList.h>
37#include <TLorentzVector.h>
40445651 38#include <TRandom3.h>
bf7b8731 39#include <TClonesArray.h>
c0997643 40#include "TDatabasePDG.h"
bf7b8731 41
42#include "AliAnalysisTaskJetServices.h"
b6dd6ad2 43#include "AliCentrality.h"
fe669ac6 44#include "AliAnalysisDataContainer.h"
45#include "AliAnalysisDataSlot.h"
bf7b8731 46#include "AliAnalysisManager.h"
47#include "AliJetFinder.h"
48#include "AliJetHeader.h"
49#include "AliJetReader.h"
50#include "AliJetReaderHeader.h"
51#include "AliUA1JetHeaderV1.h"
52#include "AliESDEvent.h"
53#include "AliAODEvent.h"
54#include "AliAODHandler.h"
55#include "AliAODTrack.h"
2eded560 56#include "AliAODVZERO.h"
bf7b8731 57#include "AliAODJet.h"
58#include "AliAODMCParticle.h"
59#include "AliMCEventHandler.h"
60#include "AliMCEvent.h"
61#include "AliStack.h"
62#include "AliGenPythiaEventHeader.h"
63#include "AliJetKineReaderHeader.h"
64#include "AliGenCocktailEventHeader.h"
65#include "AliInputEventHandler.h"
fe669ac6 66#include "AliPhysicsSelection.h"
3493c3a9 67#include "AliTriggerAnalysis.h"
bf7b8731 68
69#include "AliAnalysisHelperJetTasks.h"
70
71ClassImp(AliAnalysisTaskJetServices)
72
2eded560 73AliAODVZERO* AliAnalysisTaskJetServices::fgAODVZERO = NULL;
f4132e7d 74AliAODHeader* AliAnalysisTaskJetServices::fgAODHeader = NULL;
80a790fd 75TClonesArray* AliAnalysisTaskJetServices::fgAODVertices = NULL;
f4132e7d 76
40445651 77AliAnalysisTaskJetServices::AliAnalysisTaskJetServices():
78 AliAnalysisTaskSE(),
bf7b8731 79 fUseAODInput(kFALSE),
cc0649e4 80 fUsePhysicsSelection(kFALSE),
3493c3a9 81 fMC(kFALSE),
f4132e7d 82 fFilterAODCollisions(kFALSE),
39e7e8ab 83 fPhysicsSelectionFlag(AliVEvent::kMB),
f2dd0695 84 fSelectionInfoESD(0),
6d597ca2 85 fEventCutInfoESD(0),
40445651 86 fFilterMask(0),
2eded560 87 fRPMethod(0),
21df3cc7 88 fCollisionType(kPbPb),
bf7b8731 89 fAvgTrials(1),
c0997643 90 fVtxXMean(0),
91 fVtxYMean(0),
92 fVtxZMean(0),
93 fVtxRCut(1.),
94 fVtxZCut(8.),
df7848fc 95 fPtMinCosmic(5.),
96 fRIsolMinCosmic(3.),
97 fMaxCosmicAngle(0.01),
40445651 98 fCentrality(101),
99 fTrackRecEtaWindow(0.9),
100 fMinTrackPt(0.15),
101 fRPAngle(0),
2eded560 102 fPsiVZEROA(0),
103 fPsiVZEROC(0),
40445651 104 fRandomizer(0),
f4132e7d 105 fNonStdFile(""),
bf7b8731 106 fh1Xsec(0x0),
107 fh1Trials(0x0),
108 fh1PtHard(0x0),
109 fh1PtHardTrials(0x0),
f2dd0695 110 fh1SelectionInfoESD(0x0),
6d597ca2 111 fh1EventCutInfoESD(0),
742ee86c 112 fh1CentralityESD(0),
113 fh1Centrality(0),
40445651 114 fh1RP(0),
bf7b8731 115 fh2TriggerCount(0x0),
116 fh2ESDTriggerCount(0x0),
117 fh2TriggerVtx(0x0),
118 fh2ESDTriggerVtx(0x0),
b5a3f310 119 fh2ESDTriggerRun(0x0),
120 fh2VtxXY(0x0),
df7848fc 121 fh1NCosmicsPerEvent(0x0),
2eded560 122 fp1RPXA(0x0),
123 fp1RPYA(0x0),
124 fp1RPXC(0x0),
125 fp1RPYC(0x0),
126 fh2RPAC(0x0),
127 fh2RPAT(0x0),
128 fh2RPCT(0x0),
129 fh2XYA(0x0),
130 fh2XYC(0x0),
40445651 131 fh2RPCentrality(0x0),
2eded560 132 fh2RPACentrality(0x0),
133 fh2RPCCentrality(0x0),
3493c3a9 134 fTriggerAnalysis(0x0),
bf7b8731 135 fHistList(0x0)
136{
b5a3f310 137 fRunRange[0] = fRunRange[1] = 0;
bf7b8731 138}
139
140AliAnalysisTaskJetServices::AliAnalysisTaskJetServices(const char* name):
141 AliAnalysisTaskSE(name),
142 fUseAODInput(kFALSE),
cc0649e4 143 fUsePhysicsSelection(kFALSE),
3493c3a9 144 fMC(kFALSE),
f4132e7d 145 fFilterAODCollisions(kFALSE),
39e7e8ab 146 fPhysicsSelectionFlag(AliVEvent::kMB),
f2dd0695 147 fSelectionInfoESD(0),
6d597ca2 148 fEventCutInfoESD(0),
40445651 149 fFilterMask(0),
2eded560 150 fRPMethod(0),
21df3cc7 151 fCollisionType(kPbPb),
bf7b8731 152 fAvgTrials(1),
c0997643 153 fVtxXMean(0),
154 fVtxYMean(0),
155 fVtxZMean(0),
156 fVtxRCut(1.),
157 fVtxZCut(8.),
df7848fc 158 fPtMinCosmic(5.),
159 fRIsolMinCosmic(3.),
160 fMaxCosmicAngle(0.01),
40445651 161 fCentrality(101),
162 fTrackRecEtaWindow(0.9),
163 fMinTrackPt(0.15),
164 fRPAngle(0),
2eded560 165 fPsiVZEROA(0),
166 fPsiVZEROC(0),
40445651 167 fRandomizer(0),
f4132e7d 168 fNonStdFile(""),
bf7b8731 169 fh1Xsec(0x0),
170 fh1Trials(0x0),
171 fh1PtHard(0x0),
172 fh1PtHardTrials(0x0),
f2dd0695 173 fh1SelectionInfoESD(0x0),
6d597ca2 174 fh1EventCutInfoESD(0),
742ee86c 175 fh1CentralityESD(0),
176 fh1Centrality(0),
40445651 177 fh1RP(0),
bf7b8731 178 fh2TriggerCount(0x0),
179 fh2ESDTriggerCount(0x0),
180 fh2TriggerVtx(0x0),
181 fh2ESDTriggerVtx(0x0),
b5a3f310 182 fh2ESDTriggerRun(0x0),
183 fh2VtxXY(0x0),
df7848fc 184 fh1NCosmicsPerEvent(0x0),
2eded560 185 fp1RPXA(0x0),
186 fp1RPYA(0x0),
187 fp1RPXC(0x0),
188 fp1RPYC(0x0),
189 fh2RPAC(0x0),
190 fh2RPAT(0x0),
191 fh2RPCT(0x0),
192 fh2XYA(0x0),
193 fh2XYC(0x0),
40445651 194 fh2RPCentrality(0x0),
2eded560 195 fh2RPACentrality(0x0),
196 fh2RPCCentrality(0x0),
3493c3a9 197 fTriggerAnalysis(0x0),
bf7b8731 198 fHistList(0x0)
199{
b5a3f310 200 fRunRange[0] = fRunRange[1] = 0;
bf7b8731 201 DefineOutput(1,TList::Class());
202}
203
204
205
206Bool_t AliAnalysisTaskJetServices::Notify()
207{
208 //
209 // Implemented Notify() to read the cross sections
210 // and number of trials from pyxsec.root
211 //
212
213 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
214 Float_t xsection = 0;
215 Float_t ftrials = 1;
216
217 fAvgTrials = 1;
218 if(tree){
219 TFile *curfile = tree->GetCurrentFile();
220 if (!curfile) {
221 Error("Notify","No current file");
222 return kFALSE;
223 }
224 if(!fh1Xsec||!fh1Trials){
225 Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__);
226 return kFALSE;
227 }
228 AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
229 fh1Xsec->Fill("<#sigma>",xsection);
230 // construct a poor man average trials
231 Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
232 if(ftrials>=nEntries && nEntries>0.)fAvgTrials = ftrials/nEntries;
233 }
234 return kTRUE;
235}
236
237void AliAnalysisTaskJetServices::UserCreateOutputObjects()
238{
239
240 //
241 // Create the output container
242 //
243
40445651 244 fRandomizer = new TRandom3(0);
bf7b8731 245 if (fDebug > 1) printf("AnalysisTaskJetServices::UserCreateOutputObjects() \n");
246
247 OpenFile(1);
248 if(!fHistList)fHistList = new TList();
40440b28 249 fHistList->SetOwner();
250 PostData(1, fHistList); // post data in any case once
bf7b8731 251
252 Bool_t oldStatus = TH1::AddDirectoryStatus();
253 TH1::AddDirectory(kFALSE);
bf7b8731 254 fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1);
255 fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>");
256 fHistList->Add(fh1Xsec);
257
258 fh1Trials = new TH1F("fh1Trials","trials root file",1,0,1);
259 fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}");
260 fHistList->Add(fh1Trials);
261
262 const Int_t nBinPt = 100;
263 Double_t binLimitsPt[nBinPt+1];
264 for(Int_t iPt = 0;iPt <= nBinPt;iPt++){
265 if(iPt == 0){
266 binLimitsPt[iPt] = 0.0;
267 }
268 else {// 1.0
269 binLimitsPt[iPt] = binLimitsPt[iPt-1] + 2.5;
270 }
271 }
272
742ee86c 273
eb1739b7 274 fh1CentralityESD = new TH1F("fh1CentralityESD","cent",103,-1,102);
742ee86c 275 fHistList->Add(fh1CentralityESD);
276
eb1739b7 277 fh1Centrality = new TH1F("fh1Centrality","cent",103,-1,102);
742ee86c 278 fHistList->Add(fh1Centrality);
279
40445651 280 fh1RP = new TH1F("fh1RP","RP;#Psi",440, -1.*TMath::Pi(), 2.*TMath::Pi());
281 fHistList->Add(fh1RP);
282
d95fc15a 283 fh2TriggerCount = new TH2F("fh2TriggerCount",";Trigger No.;constrained;Count",6,-0.5,5.5,kConstraints,-0.5,kConstraints-0.5);
bf7b8731 284 fHistList->Add(fh2TriggerCount);
285
d95fc15a 286 fh2ESDTriggerCount = new TH2F("fh2ESDTriggerCount",";Trigger No.;constrained;Count",6,-0.5,5.5,kConstraints,-0.5,kConstraints-0.5);
bf7b8731 287 fHistList->Add(fh2ESDTriggerCount);
d95fc15a 288 const Int_t nBins = 6*kConstraints;
57ca1193 289 fh2TriggerVtx = new TH2F("fh2TriggerVtx",";Constraint No. * (trig no+1);Vtx (cm);Count",nBins,-0.5,nBins-0.5,400,-20.,20.);
bf7b8731 290 fHistList->Add(fh2TriggerVtx);
291
57ca1193 292 fh2ESDTriggerVtx = new TH2F("fh2ESDTriggerVtx",";Constraint No.* (trg no+1);Vtx (cm);Count",nBins,-0.5,nBins-0.5,400,-20.,20.);
bf7b8731 293 fHistList->Add(fh2ESDTriggerVtx);
294
295
296 fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",nBinPt,binLimitsPt);
297 fHistList->Add(fh1PtHard);
298 fh1PtHardTrials = new TH1F("fh1PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard}",nBinPt,binLimitsPt);
299 fHistList->Add(fh1PtHardTrials);
f2dd0695 300 fh1SelectionInfoESD = new TH1F("fh1SelectionInfoESD","Bit Masks that satisfy the selection info",
301 AliAnalysisHelperJetTasks::kTotalSelections,0.5,AliAnalysisHelperJetTasks::kTotalSelections+0.5);
f2dd0695 302 fHistList->Add(fh1SelectionInfoESD);
6d597ca2 303
304 fh1EventCutInfoESD = new TH1F("fh1EventCutInfoESD","Bit Masks that for the events after each step of cuts",
305 kTotalEventCuts,0.5,kTotalEventCuts+0.5);
306 fHistList->Add(fh1EventCutInfoESD);
307
b5a3f310 308 // 3 decisions, 0 trigger X, X + SPD vertex, X + SPD vertex in range
309 // 3 triggers BB BE/EB EE
310
f4132e7d 311 fh2ESDTriggerRun = new TH2F("fh2ESDTriggerRun","Eventclass vs run number:run;trigger",(Int_t)(1+fRunRange[1]-fRunRange[0]),fRunRange[0]-0.5,fRunRange[1]+0.5,10,-0.5,9.5);
b5a3f310 312 fHistList->Add(fh2ESDTriggerRun);
313
314 fh2VtxXY = new TH2F("fh2VtxXY","Beam Spot all INT triggered events;x (cm);y (cm)",160,-10,10,160,-10,10);
315 fHistList->Add(fh2VtxXY);
bf7b8731 316 // =========== Switch on Sumw2 for all histos ===========
317 for (Int_t i=0; i<fHistList->GetEntries(); ++i) {
318 TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));
319 if (h1){
320 h1->Sumw2();
321 continue;
322 }
323 THnSparse *hn = dynamic_cast<THnSparse*>(fHistList->At(i));
324 if(hn)hn->Sumw2();
325 }
326
df7848fc 327 fh1NCosmicsPerEvent = new TH1F("fh1NCosmicsPerEvent","Number of cosmic candidates per event",10,0.,10.);
2eded560 328 fHistList->Add(fh1NCosmicsPerEvent),
40445651 329
40445651 330
2eded560 331 fh2RPCentrality = new TH2F("fh2RPCentrality" ,"Reaction Plane Angle from tracks" , 20, 0.,100., 180, 0, TMath::Pi());
40445651 332 fHistList->Add(fh2RPCentrality);
333
40445651 334
2eded560 335 fh2RPACentrality = new TH2F("fh2RPACentrality" ,"Reaction Plane Angle from vzero A" , 20, 0.,100., 180, 0, TMath::Pi());
336 fHistList->Add(fh2RPACentrality);
40445651 337
2eded560 338 fh2RPCCentrality = new TH2F("fh2RPCCentrality" ,"Reaction Plane Angle from vzero C" , 20, 0.,100., 180, 0, TMath::Pi());
339 fHistList->Add(fh2RPCCentrality);
40445651 340
2eded560 341 fh2RPAC = new TH2F("fh2RPAC" ,"Reaction Plane Angle vzero a vs c" , 180, 0, TMath::Pi(), 180, 0, TMath::Pi());
342 fHistList->Add( fh2RPAC);
40445651 343
2eded560 344 fh2RPAT = new TH2F("fh2RPAT" ,"Reaction Plane Angle vzero a vs tracks" , 180, 0, TMath::Pi(), 180, 0, TMath::Pi());
345 fHistList->Add( fh2RPAT);
346
347 fh2RPCT = new TH2F("fh2RPCT" ,"Reaction Plane Angle vzero c vs tracks" , 180, 0, TMath::Pi(), 180, 0, TMath::Pi());
348 fHistList->Add( fh2RPCT);
349
350 fh2XYA = new TH2F("fh2XYA" ,"XY vzeroa ;X;Y;" ,100,-0.3,0.3,100,-0.3,0.3);
351 fHistList->Add(fh2XYA);
352 fh2XYC = new TH2F("fh2XYC" ,"XY vzeroc ;X;Y;" ,100,-0.3,0.3,100,-0.3,0.3);
353 fHistList->Add(fh2XYC);
354
355 // profiles for mean
356 fp1RPXA = new TProfile("fp1RPXA","mean vzeroa x vs run number;run;x",(Int_t)(1+fRunRange[1]-fRunRange[0]),fRunRange[0]-0.5,fRunRange[1]+0.5);
357 fHistList->Add(fp1RPXA);
358
359 fp1RPYA = new TProfile("fp1RPYA","mean vzeroa y vs run number;run;y",(Int_t)(1+fRunRange[1]-fRunRange[0]),fRunRange[0]-0.5,fRunRange[1]+0.5);
360 fHistList->Add(fp1RPYA);
361
362
363 fp1RPXC = new TProfile("fp1RPXC","mean vzeroc x vs run number;run;x",(Int_t)(1+fRunRange[1]-fRunRange[0]),fRunRange[0]-0.5,fRunRange[1]+0.5);
364 fHistList->Add(fp1RPXC);
365
366 fp1RPYC = new TProfile("fp1RPYC","mean vzeroa y vs run number;run;y",(Int_t)(1+fRunRange[1]-fRunRange[0]),fRunRange[0]-0.5,fRunRange[1]+0.5);
367 fHistList->Add(fp1RPYC);
df7848fc 368
bf7b8731 369
370 TH1::AddDirectory(oldStatus);
f4132e7d 371
372 // Add an AOD branch for replication
373 if(fNonStdFile.Length()){
374 if (fDebug > 1) AliInfo("Replicating header");
375 fgAODHeader = new AliAODHeader;
376 AddAODBranch("AliAODHeader",&fgAODHeader,fNonStdFile.Data());
2eded560 377 if (fDebug > 1) AliInfo("Replicating vzeros");
378 fgAODVZERO = new AliAODVZERO;
379 AddAODBranch("AliAODVZERO",&fgAODVZERO,fNonStdFile.Data());
070f06d2 380 if (fDebug > 1) AliInfo("Replicating primary vertices");
070f06d2 381 fgAODVertices = new TClonesArray("AliAODVertex",3);
80a790fd 382 fgAODVertices->SetName("vertices");
070f06d2 383 AddAODBranch("TClonesArray",&fgAODVertices,fNonStdFile.Data());
f4132e7d 384 }
bf7b8731 385}
386
387void AliAnalysisTaskJetServices::Init()
388{
389 //
390 // Initialization
391 //
bf7b8731 392 if (fDebug > 1) printf("AnalysisTaskJetServices::Init() \n");
393
394}
395
396void AliAnalysisTaskJetServices::UserExec(Option_t */*option*/)
397{
398
399 //
400 // Execute analysis for current event
401 //
402
403 AliAODEvent *aod = 0;
404 AliESDEvent *esd = 0;
f4132e7d 405
406
3493c3a9 407
bf7b8731 408 AliAnalysisHelperJetTasks::Selected(kTRUE,kFALSE); // set slection to false
f4132e7d 409 AliAnalysisHelperJetTasks::EventClass(kTRUE,0);
40445651 410 AliAnalysisHelperJetTasks::ReactionPlane(kTRUE,0); // set slection to false
f2dd0695 411 fSelectionInfoESD = 0; // reset
6d597ca2 412 fEventCutInfoESD = 0; // reset
f2dd0695 413 AliAnalysisHelperJetTasks::SelectInfo(kTRUE,fSelectionInfoESD); // set slection to false
414
bf7b8731 415
f4132e7d 416 static AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
417
418
419
bf7b8731 420 if(fUseAODInput){
421 aod = dynamic_cast<AliAODEvent*>(InputEvent());
422 if(!aod){
423 Printf("%s:%d AODEvent not found in Input Manager %d",(char*)__FILE__,__LINE__,fUseAODInput);
424 return;
425 }
426 // fethc the header
427 }
428 else{
429 // assume that the AOD is in the general output...
430 aod = AODEvent();
431 if(!aod){
432 Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
433 return;
434 }
435 esd = dynamic_cast<AliESDEvent*>(InputEvent());
436 }
ffab794c 437 if(aod&&fDebug>2){
438 aod->Print();
439 Printf("Vertices %d",aod->GetNumberOfVertices());
440 Printf("tracks %d",aod->GetNumberOfTracks());
441 Printf("jets %d",aod->GetNJets());
442 }
3493c3a9 443 fSelectionInfoESD |= kNoEventCut;
444 fEventCutInfoESD |= kNoEventCut;
6d597ca2 445
446 Bool_t esdVtxValid = false;
447 Bool_t esdVtxIn = false;
448 Bool_t aodVtxValid = false;
449 Bool_t aodVtxIn = false;
f2dd0695 450
b5a3f310 451 if(esd){
3493c3a9 452 // trigger analyisis
453 if(!fTriggerAnalysis){
454 fTriggerAnalysis = new AliTriggerAnalysis;
455 fTriggerAnalysis->SetAnalyzeMC(fMC);
456 fTriggerAnalysis->SetSPDGFOThreshhold(1);
457 }
458 // fTriggerAnalysis->FillTriggerClasses(esd);
459 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0A);
460 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0C);
461 Bool_t v0ABG = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0ABG);
462 Bool_t v0CBG = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0CBG);
463 Bool_t spdFO = fTriggerAnalysis->SPDFiredChips(esd, 0);;
464 if(v0A)fSelectionInfoESD |= AliAnalysisHelperJetTasks::kV0A;
465 if(v0C)fSelectionInfoESD |= AliAnalysisHelperJetTasks::kV0C;
466 if(!(v0ABG||v0CBG))fSelectionInfoESD |= AliAnalysisHelperJetTasks::kNoV0BG;
467 if(spdFO)fSelectionInfoESD |= AliAnalysisHelperJetTasks::kSPDFO;
b5a3f310 468 }
f4132e7d 469
c0997643 470 // Apply additional constraints
6d597ca2 471 Bool_t esdEventSelected = IsEventSelected(esd);
472 Bool_t esdEventPileUp = IsEventPileUp(esd);
473 Bool_t esdEventCosmic = IsEventCosmic(esd);
f2dd0695 474
6d597ca2 475 Bool_t aodEventSelected = IsEventSelected(aod);
f2dd0695 476
39e7e8ab 477 Bool_t physicsSelection = ((fInputHandler->IsEventSelected())&fPhysicsSelectionFlag);
20b170eb 478
f4132e7d 479
6d597ca2 480 fEventCutInfoESD |= kPhysicsSelectionCut; // other alreay set via IsEventSelected
481 fh1EventCutInfoESD->Fill(fEventCutInfoESD);
482
f2dd0695 483 if(esdEventSelected) fSelectionInfoESD |= AliAnalysisHelperJetTasks::kVertexIn;
484 if(esdEventPileUp) fSelectionInfoESD |= AliAnalysisHelperJetTasks::kIsPileUp;
485 if(esdEventCosmic) fSelectionInfoESD |= AliAnalysisHelperJetTasks::kIsCosmic;
486 if(physicsSelection) fSelectionInfoESD |= AliAnalysisHelperJetTasks::kPhysicsSelection;
487
488
489 // here we have all selection information, fill histogram
490 for(unsigned int i = 1;i<(UInt_t)fh1SelectionInfoESD->GetNbinsX();i++){
491 if((i&fSelectionInfoESD)==i)fh1SelectionInfoESD->Fill(i);
492 }
6d597ca2 493 AliAnalysisHelperJetTasks::SelectInfo(kTRUE,fSelectionInfoESD);
c0997643 494
495 if(esd&&aod&&fDebug){
496 if(esdEventSelected&&!aodEventSelected){
497 Printf("%s:%d Different Selection for ESD and AOD",(char*)__FILE__,__LINE__);
498 const AliESDVertex *vtxESD = esd->GetPrimaryVertex();
bf7b8731 499 const AliAODVertex *vtxAOD = aod->GetPrimaryVertex();
c0997643 500 Printf("ESD Vtx %s %s %d",vtxESD->GetName(),vtxESD->GetTitle(),vtxESD->GetNContributors());
501 vtxESD->Print();
502 Printf("AOD Vtx %s %s %d",vtxAOD->GetName(),vtxAOD->GetTitle(),vtxAOD->GetNContributors());
503 vtxAOD->Print();
bf7b8731 504 }
c0997643 505 }
506
507 // loop over all possible triggers for esd
508
aa3ba8d2 509 Float_t cent = 0;
21df3cc7 510 if(fCollisionType==kPbPb){
511 if(aod)cent = aod->GetHeader()->GetCentrality();
512 if(fDebug)Printf("%s:%d %3.3f",(char*)__FILE__,__LINE__,cent);
513 if(cent<0)cent = 101;
514 }
40445651 515 fCentrality = cent;
516 fRPAngle = 0;
2eded560 517 fPsiVZEROA = 0;
518 fPsiVZEROC = 0;
519
40445651 520
c0997643 521 if(esd){
522 const AliESDVertex *vtxESD = esd->GetPrimaryVertex();
f4132e7d 523 esdVtxValid = IsVertexValid(vtxESD);
524 esdVtxIn = IsVertexIn(vtxESD);
d8f21f85 525 if(aodH&&physicsSelection&&fFilterAODCollisions&&aod){
40440b28 526 if(fDebug)Printf("%s:%d Centrality %3.3f vtxin %d",(char*)__FILE__,__LINE__,cent,esdVtxIn);
d8f21f85 527 if(cent<=80&&esdVtxIn){
528 aodH->SetFillAOD(kTRUE);
c9931fda 529 aodH->SetFillExtension(kTRUE);
d8f21f85 530 }
531 }
532
533
57ca1193 534 Float_t zvtx = vtxESD->GetZ();
f4132e7d 535 Int_t iCl = GetEventClass(esd);
536 AliAnalysisHelperJetTasks::EventClass(kTRUE,iCl);
537 Bool_t cand = physicsSelection;
538
ffab794c 539 if(fDebug)Printf("%s:%d %d %d %d Icl %d",(char*)__FILE__,__LINE__,esdVtxValid,esdVtxIn,cand,iCl);
d8f21f85 540 fh2ESDTriggerCount->Fill(0.,kAllTriggered);
541 fh2ESDTriggerCount->Fill(iCl,kAllTriggered);
f4132e7d 542 if(cand){
543 fh2ESDTriggerCount->Fill(0.,kSelectedALICE);
544 fh2ESDTriggerCount->Fill(iCl,kSelectedALICE);
545 fh2ESDTriggerVtx->Fill(kSelectedALICE*(iCl+1),zvtx);
546 }
547 // if(!fUsePhysicsSelection)cand = AliAnalysisHelperJetTasks::IsTriggerFired(esd,AliAnalysisHelperJetTasks::kMB1);
548 if(esdVtxValid){
549 fh2ESDTriggerCount->Fill(0.,kTriggeredVertex);
550 fh2ESDTriggerCount->Fill(iCl,kTriggeredVertex);
551 fh2ESDTriggerVtx->Fill(iCl,zvtx);
552 if(esdVtxIn){
553 fh2ESDTriggerCount->Fill(0.,kTriggeredVertexIn);
554 fh2ESDTriggerCount->Fill(iCl,kTriggeredVertexIn);
555 fh2ESDTriggerVtx->Fill(kTriggeredVertexIn*(iCl+1),zvtx);
bf7b8731 556 }
f4132e7d 557 if(cand){
558 fh2ESDTriggerCount->Fill(0.,kSelectedALICEVertexValid);
559 fh2ESDTriggerCount->Fill(iCl,kSelectedALICEVertexValid);
560 fh2ESDTriggerVtx->Fill(kSelectedALICEVertexValid*(iCl+1),zvtx);
c0997643 561 }
bf7b8731 562 }
742ee86c 563
c08c3ad2 564 if(cand&&esdVtxIn&&iCl<5){
f4132e7d 565 fh2ESDTriggerCount->Fill(0.,kSelectedALICEVertexIn);
566 fh2ESDTriggerCount->Fill(iCl,kSelectedALICEVertexIn);
567 fh2ESDTriggerVtx->Fill(kSelectedALICEVertexIn*(iCl+1),zvtx);
568 fh2ESDTriggerVtx->Fill(kSelected*(iCl+1),zvtx);
569 fh2ESDTriggerCount->Fill(iCl,kSelected);
570 fh2ESDTriggerCount->Fill(0.,kSelected);
571 AliAnalysisHelperJetTasks::Selected(kTRUE,kTRUE);// select this event
742ee86c 572 if(esd->GetCentrality()){
573 Float_t tmpCent = 100;
574 tmpCent = esd->GetCentrality()->GetCentralityPercentile("V0M");
f5c02503 575 if(tmpCent<0)tmpCent = 101;
742ee86c 576 fh1CentralityESD->Fill(tmpCent);
577 }
f4132e7d 578 }
bf7b8731 579 }
580
ffab794c 581
582
c0997643 583 if(aod){
584 const AliAODVertex *vtxAOD = aod->GetPrimaryVertex();
6d597ca2 585 aodVtxValid = IsVertexValid(vtxAOD);
586 aodVtxIn = IsVertexIn(vtxAOD);
ffab794c 587 Float_t zvtx = vtxAOD->GetZ();
588 Int_t iCl = GetEventClass(aod);
589 AliAnalysisHelperJetTasks::EventClass(kTRUE,iCl);
590 Bool_t cand = aod->GetHeader()->GetOfflineTrigger()&fPhysicsSelectionFlag;
591 if(fDebug)Printf("%s:%d AOD selection %d %d",(char*)__FILE__,__LINE__,cand,aod->GetHeader()->GetOfflineTrigger());
d8f21f85 592 fh2TriggerCount->Fill(0.,kAllTriggered);
593 fh2TriggerCount->Fill(iCl,kAllTriggered);
ffab794c 594 if(cand){
595 fh2TriggerCount->Fill(0.,kSelectedALICE);
596 fh2TriggerCount->Fill(iCl,kSelectedALICE);
597 fh2TriggerVtx->Fill(kSelectedALICE*(iCl+1),zvtx);
598 }
599 if(aodVtxValid){
600 fh2TriggerCount->Fill(0.,kTriggeredVertex);
601 fh2TriggerCount->Fill(iCl,kTriggeredVertex);
602 fh2TriggerVtx->Fill(iCl,zvtx);
603 if(aodVtxIn){
604 fh2TriggerCount->Fill(0.,kTriggeredVertexIn);
605 fh2TriggerCount->Fill(iCl,kTriggeredVertexIn);
606 fh2TriggerVtx->Fill(kTriggeredVertexIn*(iCl+1),zvtx);
c0997643 607 }
ffab794c 608 if(cand){
609 fh2TriggerCount->Fill(0.,kSelectedALICEVertexValid);
610 fh2TriggerCount->Fill(iCl,kSelectedALICEVertexValid);
611 fh2TriggerVtx->Fill(kSelectedALICEVertexValid*(iCl+1),zvtx);
612 }
613 }
90a006c2 614
c08c3ad2 615 if(cand&&aodVtxIn&&iCl<5){
ffab794c 616 fh2TriggerCount->Fill(0.,kSelectedALICEVertexIn);
617 fh2TriggerCount->Fill(iCl,kSelectedALICEVertexIn);
618 fh2TriggerVtx->Fill(kSelectedALICEVertexIn*(iCl+1),zvtx);
619 fh2TriggerVtx->Fill(kSelected*(iCl+1),zvtx);
620 fh2TriggerCount->Fill(iCl,kSelected);
621 fh2TriggerCount->Fill(0.,kSelected);
742ee86c 622 fh1Centrality->Fill(cent);
623 AliAnalysisHelperJetTasks::Selected(kTRUE,kTRUE);// select this event
90a006c2 624 if(aodH&&cand&&fFilterAODCollisions&&!esd){
21df3cc7 625 if(fCentrality<=80&&aodVtxIn){
90a006c2 626 aodH->SetFillAOD(kTRUE);
627 aodH->SetFillExtension(kTRUE);
628 }
629 }
630
40445651 631 TList recTracks;
632 GetListOfTracks(&recTracks);
2eded560 633 CalculateReactionPlaneAngleVZERO(aod);
d3a3f33d 634 fRPAngle = aod->GetHeader()->GetEventplane();
635 fh1RP->Fill(fRPAngle);
636 fh2RPCentrality->Fill(fCentrality,fRPAngle);
2eded560 637 fh2RPACentrality->Fill(fCentrality,fPsiVZEROA);
638 fh2RPCCentrality->Fill(fCentrality,fPsiVZEROC);
639 fh2RPAC->Fill(fPsiVZEROA,fPsiVZEROC);
640 fh2RPAT->Fill(fPsiVZEROA,fRPAngle);
641 fh2RPCT->Fill(fPsiVZEROC,fRPAngle);
642 if(fRPMethod==kRPTracks)AliAnalysisHelperJetTasks::ReactionPlane(kTRUE,fRPAngle); // set slection to false
643 else if(fRPMethod==kRPVZEROA)AliAnalysisHelperJetTasks::ReactionPlane(kTRUE,fPsiVZEROA); // set slection to false
644 else if(fRPMethod==kRPVZEROC)AliAnalysisHelperJetTasks::ReactionPlane(kTRUE,fPsiVZEROA); // set slection to false
d3a3f33d 645
21df3cc7 646 if(fUseAODInput&&fCentrality<=80){
221d8aa9 647 if(fFilterAODCollisions&&aod){
742ee86c 648 aodH->SetFillAOD(kTRUE);
221d8aa9 649 }
650 }
221d8aa9 651 }
c0997643 652 }
bf7b8731 653
654 if (fDebug > 1)printf(" AliAnalysisTaskJetServices: Analysing event # %5d\n", (Int_t) fEntry);
655
656
657 Double_t ptHard = 0;
658 Double_t nTrials = 1; // Trials for MC trigger
659
660 fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
661 AliMCEvent* mcEvent = MCEvent();
662 // AliStack *pStack = 0;
663 if(mcEvent){
664 AliGenPythiaEventHeader* pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
665 if(pythiaGenHeader){
666 nTrials = pythiaGenHeader->Trials();
667 ptHard = pythiaGenHeader->GetPtHard();
668 int iProcessType = pythiaGenHeader->ProcessType();
669 // 11 f+f -> f+f
670 // 12 f+barf -> f+barf
671 // 13 f+barf -> g+g
672 // 28 f+g -> f+g
673 // 53 g+g -> f+barf
674 // 68 g+g -> g+g
675 if (fDebug > 10)Printf("%d iProcessType %d",__LINE__, iProcessType);
676 if(fDebug>20)AliAnalysisHelperJetTasks::PrintStack(mcEvent);
677 fh1PtHard->Fill(ptHard);
678 fh1PtHardTrials->Fill(ptHard,nTrials);
679
680 }// if pythia gen header
681 }
682
683 // trigger selection
684
f4132e7d 685 // replication of
686 if(fNonStdFile.Length()&&aod){
687 if (fgAODHeader){
688 *fgAODHeader = *(dynamic_cast<AliAODHeader*>(aod->GetHeader()));
2eded560 689 Double_t q[kRPMethods] = {fRPAngle,fPsiVZEROA,fPsiVZEROC};
690 fgAODHeader->SetQTheta(q,kRPMethods);
691 }
692 if (fgAODVZERO){
693 *fgAODVZERO = *(dynamic_cast<AliAODVZERO*>(aod->GetVZEROData()));
f4132e7d 694 }
80a790fd 695 if(fgAODVertices){
80a790fd 696 fgAODVertices->Delete();
697 TClonesArray &vertices = *fgAODVertices;
80a790fd 698 const AliAODVertex *vtxAOD = aod->GetPrimaryVertex();
070f06d2 699 // we only use some basic information,
700
701
702 Double_t pos[3];
703 Double_t covVtx[6];
704
705 vtxAOD->GetXYZ(pos); // position
706 vtxAOD->GetCovMatrix(covVtx); //covariance matrix
707 Int_t jVertices = 0;
708 AliAODVertex * vtx = new(vertices[jVertices++])
709 AliAODVertex(pos, covVtx, vtxAOD->GetChi2perNDF(), NULL, -1, AliAODVertex::kPrimary);
710 vtx->SetName(vtxAOD->GetName());
711 vtx->SetTitle(vtxAOD->GetTitle());
070f06d2 712 TString vtitle = vtxAOD->GetTitle();
d8f21f85 713 vtx->SetNContributors(vtxAOD->GetNContributors());
070f06d2 714
715 // Add SPD "main" vertex
716 const AliAODVertex *vtxS = aod->GetPrimaryVertexSPD();
717 vtxS->GetXYZ(pos); // position
718 vtxS->GetCovMatrix(covVtx); //covariance matrix
719 AliAODVertex * mVSPD = new(vertices[jVertices++])
720 AliAODVertex(pos, covVtx, vtxS->GetChi2perNDF(), NULL, -1, AliAODVertex::kMainSPD);
721 mVSPD->SetName(vtxS->GetName());
722 mVSPD->SetTitle(vtxS->GetTitle());
723 mVSPD->SetNContributors(vtxS->GetNContributors());
724
725 // Add tpc only vertex
726 if(esd){
727 const AliESDVertex *vtxT = esd->GetPrimaryVertexTPC();
728 vtxT->GetXYZ(pos); // position
729 vtxT->GetCovMatrix(covVtx); //covariance matrix
730 AliAODVertex * mVTPC = new(vertices[jVertices++])
731 AliAODVertex(pos, covVtx, vtxT->GetChi2toNDF(), NULL, -1, AliAODVertex::kMainTPC);
732 mVTPC->SetName(vtxT->GetName());
733 mVTPC->SetTitle(vtxT->GetTitle());
734 mVTPC->SetNContributors(vtxT->GetNContributors());
735 }
80a790fd 736 }
f4132e7d 737 }
738
bf7b8731 739 PostData(1, fHistList);
80a790fd 740}
bf7b8731 741
6d597ca2 742Bool_t AliAnalysisTaskJetServices::IsEventSelected(const AliESDEvent* esd){
c0997643 743 if(!esd)return kFALSE;
744 const AliESDVertex *vtx = esd->GetPrimaryVertex();
6d597ca2 745 return IsVertexIn(vtx); // vertex in calls vertex valid
746}
747
80a790fd 748AliAnalysisTaskJetServices::~AliAnalysisTaskJetServices(){
749 if(fgAODVertices){
750 fgAODVertices->Delete();
751 delete fgAODVertices;
752 }
40445651 753 delete fRandomizer;
070f06d2 754 if(fgAODHeader)delete fgAODHeader;
80a790fd 755}
756
6d597ca2 757
758Bool_t AliAnalysisTaskJetServices::IsEventSelected(const AliAODEvent* aod) const {
759 if(!aod)return kFALSE;
760 const AliAODVertex *vtx = aod->GetPrimaryVertex();
761 return IsVertexIn(vtx); // VertexIn calls VertexValid
762}
763
764Bool_t AliAnalysisTaskJetServices::IsVertexValid ( const AliESDVertex* vtx) {
765
c0997643 766 // We can check the type of the vertex by its name and title
767 // if vertexer failed title is empty (default c'tor) and ncontributors is 0
768 // vtx name title
769 // Tracks PrimaryVertex VertexerTracksNoConstraint
6d597ca2 770 // Tracks PrimaryVertex VertexerTracksWithConstraint
c0997643 771 // TPC TPCVertex VertexerTracksNoConstraint
6d597ca2 772 // TPC TPCVertex VertexerTracksWithConstraint
c0997643 773 // SPD SPDVertex vertexer: 3D
774 // SPD SPDVertex vertexer: Z
775
d3a3f33d 776 if(!vtx){
777 Printf("%s:%d No ESD vertex found",(char*)__FILE__,__LINE__);
778 return kFALSE;
779 }
6d597ca2 780 Int_t nCont = vtx->GetNContributors();
6d597ca2 781 if(nCont>=1){
782 fEventCutInfoESD |= kContributorsCut1;
783 if(nCont>=2){
784 fEventCutInfoESD |= kContributorsCut2;
785 if(nCont>=3){
786 fEventCutInfoESD |= kContributorsCut3;
787 }
788 }
789 }
790
791 if(nCont<3)return kFALSE;
c0997643 792
6d597ca2 793 // do not want tpc only primary vertex
794 TString vtxName(vtx->GetName());
795 if(vtxName.Contains("TPCVertex")){
796 fEventCutInfoESD |= kVertexTPC;
797 return kFALSE;
798 }
799 if(vtxName.Contains("SPDVertex"))fEventCutInfoESD |= kVertexSPD;
800 if(vtxName.Contains("PrimaryVertex"))fEventCutInfoESD |= kVertexGlobal;
c0997643 801
c0997643 802
6d597ca2 803 TString vtxTitle(vtx->GetTitle());
804 if(vtxTitle.Contains("vertexer: Z")){
805 if(vtx->GetDispersion()>0.02)return kFALSE;
806 }
807 fEventCutInfoESD |= kSPDDispersionCut;
808 return kTRUE;
809}
810
811
812Bool_t AliAnalysisTaskJetServices::IsVertexValid ( const AliAODVertex* vtx) const {
813
814 // We can check the type of the vertex by its name and title
815 // if vertexer failed title is empty (default c'tor) and ncontributors is 0
816 // vtx name title
817 // Tracks PrimaryVertex VertexerTracksNoConstraint
818 // TPC TPCVertex VertexerTracksNoConstraint
819 // SPD SPDVertex vertexer: 3D
820 // SPD SPDVertex vertexer: Z
d8f21f85 821
d3a3f33d 822 if(!vtx){
823 Printf("%s:%d No AOD vertex found",(char*)__FILE__,__LINE__);
824 return kFALSE;
825 }
826
827
d8f21f85 828 if(fDebug){
829 Printf(" n contrib %d",vtx->GetNContributors());
830 vtx->Print();
831 }
6d597ca2 832
d8f21f85 833 // if(vtx->GetNContributors()<3)return kFALSE;
c0997643 834 // do not want tpc only primary vertex
835 TString vtxName(vtx->GetName());
836 if(vtxName.Contains("TPCVertex"))return kFALSE;
6d597ca2 837
838 // no dispersion yet...
839 /*
840 TString vtxTitle(vtx->GetTitle());
841 if(vtxTitle.Contains("vertexer: Z")){
842 if(vtx->GetDispersion()>0.02)return kFALSE;
843 }
844 */
845 return kTRUE;
846}
847
848
849Bool_t AliAnalysisTaskJetServices::IsVertexIn (const AliESDVertex* vtx) {
850
851 if(!IsVertexValid(vtx))return kFALSE;
852
c0997643 853 Float_t zvtx = vtx->GetZ();
854 Float_t yvtx = vtx->GetY();
855 Float_t xvtx = vtx->GetX();
856
6d597ca2 857 xvtx -= fVtxXMean;
858 yvtx -= fVtxYMean;
859 zvtx -= fVtxZMean;
860
861
862
863 if(TMath::Abs(zvtx)>fVtxZCut){
864 return kFALSE;
865 }
866 fEventCutInfoESD |= kVertexZCut;
867 Float_t r2 = yvtx*yvtx+xvtx*xvtx;
868 if(r2>(fVtxRCut*fVtxRCut)){
869 return kFALSE;
870 }
871 fEventCutInfoESD |= kVertexRCut;
872 return kTRUE;
873}
874
875
876Bool_t AliAnalysisTaskJetServices::IsVertexIn (const AliAODVertex* vtx) const {
877
878 if(!IsVertexValid(vtx))return kFALSE;
879
880 Float_t zvtx = vtx->GetZ();
881 Float_t yvtx = vtx->GetY();
882 Float_t xvtx = vtx->GetX();
c0997643 883
884 xvtx -= fVtxXMean;
885 yvtx -= fVtxYMean;
886 zvtx -= fVtxZMean;
887
888 Float_t r2 = yvtx*yvtx+xvtx*xvtx;
889
6d597ca2 890 Bool_t vertexIn = TMath::Abs(zvtx)<fVtxZCut&&r2<(fVtxRCut*fVtxRCut);
891 return vertexIn;
c0997643 892}
893
6d597ca2 894Bool_t AliAnalysisTaskJetServices::IsEventPileUp(const AliESDEvent* esd) const{
f2dd0695 895 if(!esd)return kFALSE;
896 return esd->IsPileupFromSPD();
897}
898
6d597ca2 899Bool_t AliAnalysisTaskJetServices::IsEventCosmic(const AliESDEvent* esd) const {
f2dd0695 900 if(!esd)return kFALSE;
901 // add track cuts for which we look for cosmics...
df7848fc 902
903 Bool_t isCosmic = kFALSE;
904 Int_t nTracks = esd->GetNumberOfTracks();
905 Int_t nCosmicCandidates = 0;
906
907 for (Int_t iTrack1 = 0; iTrack1 < nTracks; iTrack1++) {
908 AliESDtrack* track1 = (AliESDtrack*)esd->GetTrack(iTrack1);
909 if (!track1) continue;
75946d5d 910 UInt_t status1 = track1->GetStatus();
911 //If track is ITS stand alone track, skip the track
912 if (((status1 & AliESDtrack::kITSin) == 0 || (status1 & AliESDtrack::kTPCin))) continue;
df7848fc 913 if(track1->Pt()<fPtMinCosmic) continue;
914 //Start 2nd track loop to look for correlations
915 for (Int_t iTrack2 = iTrack1+1; iTrack2 < nTracks; iTrack2++) {
916 AliESDtrack* track2 = (AliESDtrack*)esd->GetTrack(iTrack2);
917 if(!track2) continue;
75946d5d 918 UInt_t status2 = track2->GetStatus();
919 //If track is ITS stand alone track, skip the track
920 if (((status2 & AliESDtrack::kITSin) == 0 || (status2 & AliESDtrack::kTPCin))) continue;
df7848fc 921 if(track2->Pt()<fPtMinCosmic) continue;
922 //Check if back-to-back
923 Double_t mom1[3],mom2[3];
924 track1->GetPxPyPz(mom1);
925 track2->GetPxPyPz(mom2);
926 TVector3 momv1(mom1[0],mom1[1],mom1[2]);
927 TVector3 momv2(mom2[0],mom2[1],mom2[2]);
928 Float_t theta = (float)(momv1.Phi()-momv2.Phi());
929 if(theta<-0.5*TMath::Pi()) theta+=2.*TMath::Pi();
930
931 Float_t deltaPhi = track1->Phi()-track2->Phi();
932 if(deltaPhi<-0.5*TMath::Pi()) deltaPhi+=2.*TMath::Pi();
933
934 Float_t rIsol = (float)(TMath::Sqrt( deltaPhi*deltaPhi+(track1->Eta()-track2->Eta())*(track1->Eta()-track2->Eta()) ));
935 if(rIsol<fRIsolMinCosmic) continue;
936
937 if(TMath::Abs(TMath::Pi()-theta)<fMaxCosmicAngle) {
75946d5d 938 nCosmicCandidates+=1;
df7848fc 939 isCosmic = kTRUE;
940 }
941
942 }
943 }
944
945 fh1NCosmicsPerEvent->Fill((float)nCosmicCandidates);
946
947 return isCosmic;
f2dd0695 948}
949
950
f4132e7d 951Int_t AliAnalysisTaskJetServices::GetEventClass(AliESDEvent *esd){
952
aa3ba8d2 953 Float_t cent = 0;
21df3cc7 954 if(fCollisionType==kPbPb){
955 if(esd->GetCentrality()){
956 cent = esd->GetCentrality()->GetCentralityPercentile("V0M");
957 }
958 if(cent<0)cent = 101;
959 if(cent>80||cent<0)return 5;
960 if(cent>50)return 4;
961 if(cent>30)return 3;
962 if(cent>10)return 2;
963 return 1;
f4132e7d 964 }
f4132e7d 965 return 1;
f4132e7d 966}
f2dd0695 967
ffab794c 968
969Int_t AliAnalysisTaskJetServices::GetEventClass(AliAODEvent *aod){
970
21df3cc7 971 if(fCollisionType==kPbPb){
972 Float_t cent = aod->GetHeader()->GetCentrality();
973 if(cent>80||cent<0)return 5;
974 if(cent>50)return 4;
975 if(cent>30)return 3;
976 if(cent>10)return 2;
977 return 1;
978 }
ffab794c 979 return 1;
980
981}
982
983
bf7b8731 984void AliAnalysisTaskJetServices::Terminate(Option_t */*option*/)
985{
986 // Terminate analysis
987 //
bf7b8731 988}
f4132e7d 989
2eded560 990Bool_t AliAnalysisTaskJetServices::CalculateReactionPlaneAngleVZERO(AliAODEvent *aod){
40445651 991
2eded560 992 // const Double_t arr_eta[11]={-3.7, -3.2, -2.7, -2.2, -1.7,0, 2.8, 3.4, 3.9, 4.5,5.1};
993 if(!aod)return kFALSE;
994 static bool bFirst = true;
995 static Double_t v0phi[64] = {0,};
996
997 if(bFirst){
998 int is=0;
999 for(int iArm = 0; iArm<2; iArm++){
1000 for(int iRing = 0; iRing<4 ; iRing++){
1001 for(int iSec = 0; iSec<8 ; iSec++){
1002 v0phi[is] = 22.5 + 45. * iSec;
1003 v0phi[is] *= TMath::Pi()/180;
1004 // cout<< is <<" "<< v0phi[is]<<endl;
1005 is++;
1006 }
1007 }
40445651 1008 }
2eded560 1009 bFirst = false;
40445651 1010 }
1011
2eded560 1012 //
1013 const AliAODVZERO *aodVZERO = aod->GetVZEROData();
1014 Double_t numYZNA = 0,numXZNA = 0,sumZNA = 0;
1015 Double_t meanXA = 0,meanYA = 0;
1016
1017 Double_t numYZNC = 0,numXZNC = 0,sumZNC = 0;
1018 Double_t meanXC = 0,meanYC = 0;
1019
1020 for (int i=0; i<64; i++) {
1021 Double_t mult = aodVZERO->GetMultiplicity(i);
1022 Double_t phi = v0phi[i];
1023 if (mult>0) {
1024 if (i<32) { //C-side
1025 Double_t wZNC= mult;
1026 numYZNC += sin(2.*phi)*wZNC;
1027 numXZNC += cos(2.*phi)*wZNC;
1028 sumZNC+=wZNC;
1029 }
1030 else if(i>31){ //A-side
1031 Double_t wZNA=mult;
1032 numYZNA += sin(2.*phi)*wZNA;
1033 numXZNA += cos(2.*phi)*wZNA;
1034 sumZNA+=wZNA;
1035 }
1036 }// mult>0
1037 }// 64 sectors
1038
1039 Double_t XC = numXZNC/sumZNC;
1040 Double_t YC = numYZNC/sumZNC;
40445651 1041
2eded560 1042 Double_t XA = numXZNA/sumZNA;
1043 Double_t YA = numYZNA/sumZNA;
40445651 1044
2eded560 1045
1046 fPsiVZEROA = 0.5*TMath::ATan2(YA-meanYA, XA-meanXA);
1047 if(fPsiVZEROA>TMath::Pi()){fPsiVZEROA-=TMath::Pi();}
1048 if(fPsiVZEROA<0){fPsiVZEROA+=TMath::Pi();}
1049
1050 fPsiVZEROC = 0.5*TMath::ATan2(YC-meanYC, XA-meanXC);
1051 if(fPsiVZEROC>TMath::Pi()){fPsiVZEROC-=TMath::Pi();}
1052 if(fPsiVZEROC<0){fPsiVZEROC+=TMath::Pi();}
40445651 1053
2eded560 1054 fh2XYA->Fill(XA,YA);
1055 fp1RPXA->Fill(aod->GetRunNumber(),XA);
1056 fp1RPYA->Fill(aod->GetRunNumber(),YA);
1057 fh2XYC->Fill(XC,YC);
1058 fp1RPXC->Fill(aod->GetRunNumber(),XC);
1059 fp1RPYC->Fill(aod->GetRunNumber(),YC);
40445651 1060 return kTRUE;
40445651 1061
40445651 1062}
1063
40445651 1064Int_t AliAnalysisTaskJetServices::GetListOfTracks(TList *list){
1065 Int_t iCount = 0;
1066 AliAODEvent *aod = 0;
1067 if(fUseAODInput)aod = dynamic_cast<AliAODEvent*>(InputEvent());
1068 else aod = AODEvent();
1069 if(!aod){
1070 return iCount;
1071 }
1072 for(int it = 0;it < aod->GetNumberOfTracks();++it){
1073 AliAODTrack *tr = aod->GetTrack(it);
1074 if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
1075 if(TMath::Abs(tr->Eta())>fTrackRecEtaWindow)continue;
1076 if(tr->Pt()<fMinTrackPt)continue;
1077 list->Add(tr);
1078 iCount++;
1079 }
1080 list->Sort();
1081 return iCount;
1082
1083}
1084