1 // **************************************
2 // Full pp jet task - ESD input only
3 // Extract the jet spectrum and all the variations
5 // **************************************
13 #include <TProfile2D.h>
14 #include <THnSparse.h>
18 #include <TClonesArray.h>
23 #include "AliAODEvent.h"
24 #include "AliAODInputHandler.h"
25 #include "AliAnalysisManager.h"
26 #include "AliAnalysisTask.h"
27 #include "AliCentrality.h"
28 #include "AliAnalysisTaskFullppJet.h"
29 #include "AliESDEvent.h"
30 #include "AliESDInputHandler.h"
31 #include "AliESDtrackCuts.h"
32 #include "AliVParticle.h"
33 #include "AliInputEventHandler.h"
34 #include "AliEMCALGeometry.h"
35 #include "AliEMCALRecoUtils.h"
36 #include "TGeoManager.h"
37 #include "AliMCEvent.h"
39 #include "AliGenEventHeader.h"
40 #include "AliGenPythiaEventHeader.h"
41 #include "TGeoGlobalMagField.h"
43 #include "AliAODJet.h"
44 #include "AliFJWrapper.h"
52 ClassImp(AliAnalysisTaskFullppJet)
54 const Float_t kRadius[2] = {0.4,0.2};
55 const Double_t kPI = TMath::Pi();
57 //________________________________________________________________________
58 AliAnalysisTaskFullppJet::AliAnalysisTaskFullppJet() :
59 AliAnalysisTaskSE("default"),
60 fVerbosity(0), fEDSFileCounter(0), fNTracksPerChunk(0),
61 fPeriod("lhc11a"), fESD(0), fAOD(0), fMC(0), fStack(0), fTrackArray(0x0), fClusterArray(0x0), fMcPartArray(0x0),
62 fIsMC(kFALSE), fMCStandalone(kFALSE), fChargedMC(kFALSE), fXsecScale(0.),
63 fCentrality(99), fZVtxMax(10),
64 fTriggerType(-1), fIsTPCOnlyVtx(kFALSE),
65 fIsExoticEvent3GeV(kFALSE), fIsExoticEvent5GeV(kFALSE), fIsEventTriggerBit(kFALSE), fOfflineTrigger(kFALSE), fTriggerMask(0x0),
66 fGeom(0x0), fRecoUtil(0x0),
67 fEsdTrackCuts(0x0), fHybridTrackCuts1(0x0), fHybridTrackCuts2(0x0),fTrackCutsType(0), fKinCutType(0), fTrkEtaMax(0.9),
68 fdEdxMin(73), fdEdxMax(90), fEoverPMin(0.8), fEoverPMax(1.2),
69 fMatchType(0), fRejectExoticCluster(kTRUE), fRemoveBadChannel(kFALSE), fUseGoodSM(kFALSE),
70 fStudySubEInHC(kFALSE), fStudyMcOverSubE(kFALSE),
71 fElectronRejection(kFALSE), fHadronicCorrection(kFALSE), fFractionHC(0.), fHCLowerPtCutMIP(1e4), fClusterEResolution(0x0), fMCNonLin(0x0),
72 fJetNEFMin(0.01), fJetNEFMax(0.98),
73 fSpotGoodJet(kFALSE), fFindChargedOnlyJet(kFALSE), fFindNeutralOnlyJet(kFALSE),
74 fCheckTrkEffCorr(kFALSE), fTrkEffCorrCutZ(0.3), fRandomGen(0x0), fRunUE(0),
75 fSysTrkPtRes(kFALSE), fVaryTrkPtRes(0), fSysTrkEff(kFALSE), fVaryTrkEff(0.),
76 fSysTrkClsMth(kFALSE), fCutdEta(0.05), fCutdPhi(0.05),
77 fSysNonLinearity(kFALSE), fSysClusterEScale(kFALSE), fVaryClusterEScale(0), fSysClusterERes(kFALSE), fVaryClusterERes(0),
78 fNonStdBranch(""), fNonStdFile(""), fAlgorithm("aKt"), fRadius("0.4"), fRecombinationScheme(5),
79 fConstrainChInEMCal(kFALSE), fRejectNK(kFALSE), fRejectWD(kFALSE), fSmearMC(kFALSE), fTrkPtResData(0x0),
80 fOutputList(0x0), fSaveQAHistos(kTRUE), fhJetEventStat(0x0), fhEventCheck(0x0), fhTrkPhiEtaCheck(0x0), fhChunkQA(0x0)
84 // Define input and output slots here
85 // Input slot #0 works with a TChain
86 DefineInput(0, TChain::Class());
87 DefineOutput(1, TList::Class());
88 // Output slot #0 id reserved by the base class for AOD
89 for(Int_t i=0; i<2; i++)
97 for(Int_t r=0; r<2; r++)
102 fhNMatchedTrack[r] = 0x0;
103 for(Int_t j=0; j<4; j++) fhSubEVsTrkPt[r][j] = 0x0;
104 for(Int_t j=0; j<5; j++)
106 fHCOverSubE[r][j] = 0x0;
107 fHCOverSubEFrac[r][j] = 0x0;
108 for(Int_t k=0; k<2; k++)
110 fhSubClsEVsJetPt[k][r][j] = 0x0;
111 fhHCTrkPtClean[k][r][j] = 0x0;
112 fhHCTrkPtAmbig[k][r][j] = 0x0;
115 fJetCount[j][r] = 0x0;
116 fhNeutralPtInJet[j][r] = 0x0;
117 fhChargedPtInJet[j][r] = 0x0;
118 fhLeadNePtInJet[j][r] = 0x0;
119 fhLeadChPtInJet[j][r] = 0x0;
120 fJetEnergyFraction[j][r] = 0x0;
121 fJetNPartFraction[j][r] = 0x0;
123 fRelTrkCon[j][r] = 0x0;
124 fhFcrossVsZleading[j][r] = 0x0;
125 fhChLeadZVsJetPt[j][r] = 0x0;
126 fhJetPtWithTrkThres[j][r]= 0x0;
127 fhJetPtWithClsThres[j][r]= 0x0;
128 fhJetPtVsLowPtCons[j][r]= 0x0;
129 fhJetPtInExoticEvent[r][j] = 0x0;
131 for(Int_t j=0; j<2; j++)
133 fhCorrTrkEffPtBin[j][r] = 0x0;
134 for(Int_t i=0; i<kNBins; i++)
136 fhCorrTrkEffSample[j][r][i] = 0x0;
139 fhJetPtVsUE[r] = 0x0;
143 for(Int_t s=0; s<3; s++)
145 for(Int_t a=0; a<2; a++)
147 for(Int_t r=0; r<2; r++)
149 fDetJetFinder[s][a][r] = 0x0;
150 fJetTCA[s][a][r] = 0x0;
153 fTrueJetFinder[r] = 0x0;
154 fMcTruthAntikt[r] = 0x0;
160 for(Int_t j=0; j<3; j++)
162 fTrkEffFunc[j] = 0x0;
164 for(Int_t i=0; i<10; i++)
166 fTriggerCurve[i] = 0x0;
167 fTriggerEfficiency[i] = 0x0;
172 //________________________________________________________________________
173 AliAnalysisTaskFullppJet::AliAnalysisTaskFullppJet(const char *name) :
174 AliAnalysisTaskSE(name),
175 fVerbosity(0), fEDSFileCounter(0), fNTracksPerChunk(0),
176 fPeriod("lhc11a"), fESD(0), fAOD(0), fMC(0), fStack(0), fTrackArray(0x0), fClusterArray(0x0), fMcPartArray(0x0),
177 fIsMC(kFALSE), fMCStandalone(kFALSE), fChargedMC(kFALSE), fXsecScale(0.),
178 fCentrality(99), fZVtxMax(10),
179 fTriggerType(-1), fIsTPCOnlyVtx(kFALSE),
180 fIsExoticEvent3GeV(kFALSE), fIsExoticEvent5GeV(kFALSE), fIsEventTriggerBit(kFALSE), fOfflineTrigger(kFALSE), fTriggerMask(0x0),
181 fGeom(0x0), fRecoUtil(0x0),
182 fEsdTrackCuts(0x0), fHybridTrackCuts1(0x0), fHybridTrackCuts2(0x0), fTrackCutsType(0), fKinCutType(0), fTrkEtaMax(0.9),
183 fdEdxMin(73), fdEdxMax(90), fEoverPMin(0.8), fEoverPMax(1.2),
184 fMatchType(0), fRejectExoticCluster(kTRUE), fRemoveBadChannel(kFALSE), fUseGoodSM(kFALSE),
185 fStudySubEInHC(kFALSE), fStudyMcOverSubE(kFALSE),
186 fElectronRejection(kFALSE), fHadronicCorrection(kFALSE), fFractionHC(0.), fHCLowerPtCutMIP(1e4), fClusterEResolution(0x0), fMCNonLin(0x0),
187 fJetNEFMin(0.01), fJetNEFMax(0.98),
188 fSpotGoodJet(kFALSE), fFindChargedOnlyJet(kFALSE), fFindNeutralOnlyJet(kFALSE),
189 fCheckTrkEffCorr(kFALSE), fTrkEffCorrCutZ(0.3), fRandomGen(0x0), fRunUE(0),
190 fSysTrkPtRes(kFALSE), fVaryTrkPtRes(0), fSysTrkEff(kFALSE), fVaryTrkEff(0.),
191 fSysTrkClsMth(kFALSE), fCutdEta(0.05), fCutdPhi(0.05),
192 fSysNonLinearity(kFALSE), fSysClusterEScale(kFALSE), fVaryClusterEScale(0), fSysClusterERes(kFALSE), fVaryClusterERes(0),
193 fNonStdBranch(""), fNonStdFile(""), fAlgorithm("aKt"), fRadius("0.4"), fRecombinationScheme(5),
194 fConstrainChInEMCal(kFALSE), fRejectNK(kFALSE), fRejectWD(kFALSE), fSmearMC(kFALSE), fTrkPtResData(0x0),
195 fOutputList(0x0), fSaveQAHistos(kTRUE), fhJetEventStat(0x0), fhEventCheck(0x0), fhTrkPhiEtaCheck(0x0), fhChunkQA(0x0)
199 // Define input and output slots here
200 // Input slot #0 works with a TChain
201 DefineInput(0, TChain::Class());
202 DefineOutput(1, TList::Class());
203 // Output slot #0 id reserved by the base class for AOD
204 for(Int_t i=0; i<2; i++)
212 for(Int_t r=0; r<2; r++)
214 fVertexGenZ[r] = 0x0;
217 fhNMatchedTrack[r] = 0x0;
218 for(Int_t j=0; j<4; j++) fhSubEVsTrkPt[r][j] = 0x0;
219 for(Int_t j=0; j<5; j++)
221 fHCOverSubE[r][j] = 0x0;
222 fHCOverSubEFrac[r][j] = 0x0;
223 for(Int_t k=0; k<2; k++)
225 fhSubClsEVsJetPt[k][r][j] = 0x0;
226 fhHCTrkPtClean[k][r][j] = 0x0;
227 fhHCTrkPtAmbig[k][r][j] = 0x0;
230 fJetCount[j][r] = 0x0;
231 fhNeutralPtInJet[j][r] = 0x0;
232 fhChargedPtInJet[j][r] = 0x0;
233 fhLeadNePtInJet[j][r] = 0x0;
234 fhLeadChPtInJet[j][r] = 0x0;
235 fJetEnergyFraction[j][r] = 0x0;
236 fJetNPartFraction[j][r] = 0x0;
238 fRelTrkCon[j][r] = 0x0;
239 fhFcrossVsZleading[j][r] = 0x0;
240 fhChLeadZVsJetPt[j][r] = 0x0;
241 fhJetPtWithTrkThres[j][r]= 0x0;
242 fhJetPtWithClsThres[j][r]= 0x0;
243 fhJetPtVsLowPtCons[j][r]= 0x0;
244 fhJetPtInExoticEvent[r][j] = 0x0;
246 for(Int_t j=0; j<2; j++)
248 fhCorrTrkEffPtBin[j][r] = 0x0;
249 for(Int_t i=0; i<kNBins; i++)
251 fhCorrTrkEffSample[j][r][i] = 0x0;
254 fhJetPtVsUE[r] = 0x0;
258 for(Int_t s=0; s<3; s++)
260 for(Int_t a=0; a<2; a++)
262 for(Int_t r=0; r<2; r++)
264 fDetJetFinder[s][a][r] = 0x0;
265 fJetTCA[s][a][r] = 0x0;
268 fTrueJetFinder[r] = 0x0;
269 fMcTruthAntikt[r] = 0x0;
274 for(Int_t j=0; j<3; j++)
276 fTrkEffFunc[j] = 0x0;
278 for(Int_t i=0; i<10; i++)
280 fTriggerCurve[i] = 0x0;
281 fTriggerEfficiency[i] = 0x0;
285 //________________________________________________________________________
286 AliAnalysisTaskFullppJet::~AliAnalysisTaskFullppJet()
290 if(fEsdTrackCuts) delete fEsdTrackCuts;
291 if(fHybridTrackCuts1) delete fHybridTrackCuts1;
292 if(fHybridTrackCuts2) delete fHybridTrackCuts2;
294 { fOutputList->Delete(); delete fOutputList;}
295 for(Int_t s=0; s<3; s++)
297 for(Int_t a=0; a<2; a++)
299 for(Int_t r=0; r<2; r++)
301 if(fDetJetFinder[s][a][r]) delete fDetJetFinder[s][a][r];
302 if(fJetTCA[s][a][r]) { fJetTCA[s][a][r]->Delete(); delete fJetTCA[s][a][r]; }
305 if(fTrueJetFinder[r]) delete fTrueJetFinder[r];
306 if(fMcTruthAntikt[r]) { fMcTruthAntikt[r]->Delete(); delete fMcTruthAntikt[r]; }
311 if(fRandomGen) delete fRandomGen;
312 for(Int_t i=0; i<3; i++)
314 if(fTrkEffFunc[i]) delete fTrkEffFunc[i];
316 for(Int_t i=0; i<10; i++)
318 if(fTriggerEfficiency[i]) delete fTriggerEfficiency[i];
319 if(fTriggerCurve[i]) delete fTriggerCurve[i];
321 for(Int_t r=0; r<2; r++)
323 for(Int_t j=0; j<2; j++)
325 if(fhCorrTrkEffPtBin[j][r]) delete fhCorrTrkEffPtBin[j][r];
326 for(Int_t i=0; i<kNBins; i++)
328 if(fhCorrTrkEffSample[j][r][i]) delete fhCorrTrkEffSample[j][r][i];
332 if(fTrackArray) { fTrackArray->Delete(); delete fTrackArray; }
333 if(fClusterArray) { fClusterArray->Delete(); delete fClusterArray; }
334 if(fMcPartArray) { fMcPartArray->Reset(); delete fMcPartArray; }
336 if(fRecoUtil) delete fRecoUtil;
337 if(fClusterEResolution) delete fClusterEResolution;
338 if(fMCNonLin) delete fMCNonLin;
339 if(fTrkPtResData) delete fTrkPtResData;
342 //________________________________________________________________________
343 Bool_t AliAnalysisTaskFullppJet::Notify()
346 // Fill the number of tracks per chunk
349 fhChunkQA->SetBinContent(fEDSFileCounter,fNTracksPerChunk);
350 fNTracksPerChunk = 0;
355 //________________________________________________________________________
356 void AliAnalysisTaskFullppJet::UserCreateOutputObjects()
362 const Int_t nTrkPtBins = 100;
363 const Float_t lowTrkPtBin=0, upTrkPtBin=100.;
365 const Int_t nbins = 220;
367 for(Int_t i=0; i<nbins+1; i++)
371 fOutputList = new TList();
372 fOutputList->SetOwner(1);
374 fhJetEventStat = new TH1F("fhJetEventStat","Event statistics for jet analysis",9,0,9);
375 fhJetEventStat->GetXaxis()->SetBinLabel(1,"ALL");
376 fhJetEventStat->GetXaxis()->SetBinLabel(2,"MB");
377 fhJetEventStat->GetXaxis()->SetBinLabel(3,"MB+vtx+10cm");
378 fhJetEventStat->GetXaxis()->SetBinLabel(4,"EMC");
379 fhJetEventStat->GetXaxis()->SetBinLabel(5,"EMC+vtx+10cm");
380 fhJetEventStat->GetXaxis()->SetBinLabel(6,"MB+vtx");
381 fhJetEventStat->GetXaxis()->SetBinLabel(7,"EMC+vtx");
382 fhJetEventStat->GetXaxis()->SetBinLabel(8,"TriggerBit");
383 fhJetEventStat->GetXaxis()->SetBinLabel(9,"LED");
384 fOutputList->Add(fhJetEventStat);
386 fhEventCheck = new TH1F("fhEventCheck","Event statistics for check",11,0,11);
387 fhEventCheck->GetXaxis()->SetBinLabel(1,"MB");
388 fhEventCheck->GetXaxis()->SetBinLabel(2,"FastOnly");
389 fhEventCheck->GetXaxis()->SetBinLabel(3,"FastOnly+TVtx");
390 fhEventCheck->GetXaxis()->SetBinLabel(4,"FastOnly+PVtx");
391 fhEventCheck->GetXaxis()->SetBinLabel(5,"FastOnly+TVtx+10cm");
392 fhEventCheck->GetXaxis()->SetBinLabel(6,"FastOnly+PVtx+10cm");
393 fhEventCheck->GetXaxis()->SetBinLabel(7,"!FastOnly");
394 fhEventCheck->GetXaxis()->SetBinLabel(8,"!FastOnly+TVtx");
395 fhEventCheck->GetXaxis()->SetBinLabel(9,"!FastOnly+PVtx");
396 fhEventCheck->GetXaxis()->SetBinLabel(10,"!FastOnly+TVtx+10cm");
397 fhEventCheck->GetXaxis()->SetBinLabel(11,"!FastOnly+PVtx+10cm");
398 fOutputList->Add(fhEventCheck);
400 fhTrkPhiEtaCheck = new TH2F("fhTrkPhiEtaCheck","#eta vs #phi of tracks in TPC only vertex events;#eta;#phi",100,-1,1,360,0,360);
401 fOutputList->Add(fhTrkPhiEtaCheck);
403 fhChunkQA = new TH1F("fhChunkQA","# of hybrid tracks per chunk",200,0,200);
404 fOutputList->Add(fhChunkQA);
406 const Int_t dim1 = 3;
407 Int_t nBins1[dim1] = {200,50,110};
408 Double_t lowBin1[dim1] = {0,0,0,};
409 Double_t upBin1[dim1] = {200,0.5,1.1};
411 const Int_t dim2 = 3;
412 Int_t nBins2[dim2] = {200,50,50};
413 Double_t lowBin2[dim2] = {0,0,0,};
414 Double_t upBin2[dim2] = {200,0.5,50};
416 Int_t radiusType = 1;
417 if( fRadius.Contains("0.2") ) radiusType = 2;
418 const char* triggerName[3] = {"MB","EMC","MC"};
419 const char* triggerTitle[3] = {"MB","EMCal-trigger","MC true"};
420 const char* fraction[5] = {"MIP","30","50","70","100"};
421 const char* exotic[2] = {"3GeV","5GeV"};
422 const char* vertexType[2] = {"All MB","MB with vertex"};
423 const char *vertexName[2] = {"All","Vertex"};
428 for(Int_t i=0; i<2; i++)
430 fhNTrials[i] = new TH1F(Form("MC_%s_fhNTrials",triggerName[i]),Form("MC-%s: # of trials",triggerName[i]),1,0,1);
431 fOutputList->Add(fhNTrials[i]);
433 fVertexGenZ[i] = new TH1F(Form("%s_fVertexGenZ",vertexName[i]),Form("Distribution of vertex z (%s); z (cm)",vertexType[i]),60,-30,30);
434 fOutputList->Add(fVertexGenZ[i]);
438 for(Int_t i=0; i<3; i++)
440 if(!fIsMC && i==2) continue;
446 fEventZ[i] = new TH1F(Form("%s_fEventZ",triggerName[i]),Form("%s: Distribution of vertex z; z (cm)",triggerTitle[i]),60,-30,30);
447 fOutputList->Add(fEventZ[i]);
450 for(Int_t r=0; r<radiusType; r++)
452 fJetCount[i][r] = new TH1F(Form("%s_fJetCount_%1.1f",triggerName[i],kRadius[r]),Form("%s: jet p_{T} in EMCal (R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c)",triggerTitle[i],kRadius[r]),nbins,xbins);
453 fOutputList->Add(fJetCount[i][r]);
455 fhNeutralPtInJet[i][r] = new TH2F(Form("%s_fhNeutralPtInJet_%1.1f",triggerName[i],kRadius[r]),Form("%s: p_{T} of neutral constituents vs jet p_{T} in EMCal(R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c); p_{T} (GeV/c)",triggerTitle[i],kRadius[r]),nbins,xbins,nTrkPtBins,lowTrkPtBin,upTrkPtBin);
456 fOutputList->Add(fhNeutralPtInJet[i][r]);
458 fhChargedPtInJet[i][r] = new TH2F(Form("%s_fhChargedPtInJet_%1.1f",triggerName[i],kRadius[r]),Form("%s: p_{T} of charged constituents vs jet p_{T} in EMCal (R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c); p_{T} (GeV/c)",triggerTitle[i],kRadius[r]),nbins,xbins,nTrkPtBins,lowTrkPtBin,upTrkPtBin);
459 fOutputList->Add(fhChargedPtInJet[i][r]);
461 fhLeadNePtInJet[i][r] = new TH2F(Form("%s_fhLeadNePtInJet_%1.1f",triggerName[i],kRadius[r]),Form("%s: p_{T} of leading neutral constituent vs jet p_{T} in EMCal(R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c); p_{T}^{ne} (GeV/c)",triggerTitle[i],kRadius[r]),nbins,xbins,100,0,100);
462 fOutputList->Add(fhLeadNePtInJet[i][r]);
464 fhLeadChPtInJet[i][r] = new TH2F(Form("%s_fhLeadChPtInJet_%1.1f",triggerName[i],kRadius[r]),Form("%s: p_{T} of leading charged constituent vs jet p_{T} in EMCal(R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c); p_{T}^{ch} (GeV/c)",triggerTitle[i],kRadius[r]),nbins,xbins,100,0,100);
465 fOutputList->Add(fhLeadChPtInJet[i][r]);
467 fhJetPtVsZ[i][r] = new TH3F(Form("%s_fhJetPtVsZ_%1.1f",triggerName[i],kRadius[r]),Form("%s: jet p_{T} vs Z_{h} vs constituent type in EMCal (R=%1.1f);p_{T}^{jet} (GeV/c); Z_{h};constituent type",triggerTitle[i],kRadius[r]),200,0,200,110,-0.05,1.05,4,0,4);
468 fOutputList->Add(fhJetPtVsZ[i][r]);
470 fJetEnergyFraction[i][r] = new THnSparseF(Form("%s_fJetEnergyFraction_%1.1f",triggerName[i],kRadius[r]),Form("%s: Jet p_{T} vs radius vs energy fraction in EMCal (R=%1.1f,Z<0.98); p_{T};R;Fraction",triggerName[i],kRadius[r]),dim1,nBins1,lowBin1,upBin1);
471 fOutputList->Add(fJetEnergyFraction[i][r]);
473 fJetNPartFraction[i][r] = new THnSparseF(Form("%s_fJetNPartFraction_%1.1f",triggerName[i],kRadius[r]),Form("%s: Jet p_{T} vs radius vs NPart in EMCal (R=%1.1f,Z<0.98); p_{T};R;NPart",triggerName[i],kRadius[r]),dim2,nBins2,lowBin2,upBin2);
474 fOutputList->Add(fJetNPartFraction[i][r]);
478 fhJetPtInExoticEvent[i][r] = new TH1F(Form("EMC_fhJetPtInExoticEvent_%1.1f_%s",kRadius[r],exotic[i]),Form("EMC: jet p_{T} in events with exotic cluster > %s (R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c)",exotic[i],kRadius[r]),nbins,xbins);
479 fOutputList->Add(fhJetPtInExoticEvent[i][r]);
481 fRelTrkCon[i][r] = new TH3F(Form("%s_fRelTrkCon_%1.1f",triggerName[i],kRadius[r]),Form("%s: jet p_{T} vs (sum p_{T}^{ch})/p_{T}^{jet} vs track class in EMCal (R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c); (sum p_{T}^{ch})/p_{T}^{jet}; track class",triggerTitle[i],kRadius[r]),200,0,200,110,-0.05,1.05,3,0,3);
482 fOutputList->Add(fRelTrkCon[i][r]);
484 fhFcrossVsZleading[i][r] = new TH3F(Form("%s_fhFcrossVsZleading_%1.1f",triggerName[i],kRadius[r]),Form("%s: jet p_{T} vs F_{cross} vs Z_{leading}^{ne} in EMCal (R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c);F_{cross};Z_{leading}^{ne}",triggerTitle[i],kRadius[r]),200,0,200,55,-0.05,1.05,55,-0.05,1.05);
485 fOutputList->Add(fhFcrossVsZleading[i][r]);
487 fhChLeadZVsJetPt[i][r] = new TH2F(Form("%s_fhChLeadZVsJetPt_%1.1f",triggerName[i],kRadius[r]),Form("%s: Z of leading charged constituent vs jet p_{T} in EMCal(R=%1.1f,Z<0.98);p_{T}^{jet} (GeV/c); Z_{leading}^{ch}",triggerTitle[i],kRadius[r]),nbins,xbins,100,0,1);
488 fOutputList->Add(fhChLeadZVsJetPt[i][r]);
490 fhJetPtWithTrkThres[i][r] = new TH2F(Form("%s_fhJetPtWithTrkThres_%1.1f",triggerName[i],kRadius[r]),Form("%s: p_{T} of jets containing tracks above certain threshold (15,25,40 GeV/c) (EMCal, R=%1.1f,Z<0.98);Threshold type;p_{T}^{jet} (GeV/c)",triggerTitle[i],kRadius[r]),3,0,3,nbins,xbins);
491 fOutputList->Add(fhJetPtWithTrkThres[i][r]);
493 fhJetPtWithClsThres[i][r] = new TH2F(Form("%s_fhJetPtWithClsThres_%1.1f",triggerName[i],kRadius[r]),Form("%s: p_{T} of jets containing clusters above certain threshold (15,25,40 GeV) (EMCal, R=%1.1f,Z<0.98);Threshold type;p_{T}^{jet} (GeV/c)",triggerTitle[i],kRadius[r]),3,0,3,nbins,xbins);
494 fOutputList->Add(fhJetPtWithClsThres[i][r]);
496 fhJetPtVsLowPtCons[i][r] = new TH2F(Form("%s_fhJetPtVsLowPtCons_%1.1f",triggerName[i],kRadius[r]),Form("%s: energy carried by constituents less than 200MeV (EMCal, R=%1.1f,Z<0.98);p_{T}^{low} (GeV/c);p_{T}^{jet} (GeV/c)",triggerTitle[i],kRadius[r]),nbins,xbins,100,0,100);
497 fOutputList->Add(fhJetPtVsLowPtCons[i][r]);
501 for(Int_t k=0; k<5; k++)
503 fhSubClsEVsJetPt[i][r][k] = new TH2F(Form("%s_fhSubClsEVsJetPt_%s_%1.1f",triggerName[i],fraction[k],kRadius[r]),Form("%s: relative %s%% subtracted cluster Et vs jet pt (R=%1.1f);jet p_{T} (GeV/c);E_{t}^{sub}/p_{T,jet}",triggerTitle[i],fraction[k], kRadius[r]),nbins,xbins,50,0,0.5);
504 fOutputList->Add(fhSubClsEVsJetPt[i][r][k]);
506 fhHCTrkPtClean[i][r][k] = new TH2F(Form("%s_fhHCTrkPtClean_%s_%1.1f",triggerName[i],fraction[k],kRadius[r]),Form("%s: sum of track p_{T} that are cleanly subtracted vs jet pt (%s%%, R=%1.1f);jet p_{T} (GeV/c);#sum(p_{T,trk}^{clean})/p_{T,jet}",triggerTitle[i],fraction[k], kRadius[r]),nbins,xbins,100,-0.005,0.995);
507 fOutputList->Add(fhHCTrkPtClean[i][r][k]);
509 fhHCTrkPtAmbig[i][r][k] = new TH2F(Form("%s_fhHCTrkPtAmbig_%s_%1.1f",triggerName[i],fraction[k],kRadius[r]),Form("%s: sum of track p_{T} that are ambiguously subtracted vs jet pt (%s%%, R=%1.1f);jet p_{T} (GeV/c);#sum(p_{T,trk}^{ambig})/p_{T,jet}",triggerTitle[i],fraction[k], kRadius[r]),nbins,xbins,100,-0.005,0.995);
510 fOutputList->Add(fhHCTrkPtAmbig[i][r][k]);
517 fhNMatchedTrack[i] = new TH1F(Form("%s_fhNMatchedTrack",triggerName[i]),Form("%s: # of matched tracks per cluster; N_{mth}",triggerTitle[i]),5,0,5);
518 fOutputList->Add(fhNMatchedTrack[i]);
520 for(Int_t j=0; j<4; j++)
522 fhSubEVsTrkPt[i][j] = new TH2F(Form("%s_fhSubEVsTrkPt_%s",triggerName[i],fraction[j+1]),Form("%s: fractional subtracted energy (%s%% HC);#sum(p_{ch,T}^{mth}) (GeV/c);E_{sub}/#sum(P_{ch}^{mth})",triggerTitle[i],fraction[j+1]),50,0,50,110,0,1.1);
523 fOutputList->Add(fhSubEVsTrkPt[i][j]);
527 if(fRunUE && fFindChargedOnlyJet && i<2)
529 fhJetPtVsUE[i] = new TH2F(Form("%s_fhJetPtVsUE",triggerName[i]),Form("%s: jet p_{T} vs UE (R=0.4);p_{T,ch}^{UE} (GeV/c);p_{T,jet} (GeV/c)",triggerTitle[i]),2000,0,20,nbins,xbins);
530 fOutputList->Add(fhJetPtVsUE[i]);
534 fhClsE[i] = new TH1F(Form("%s_fhClsE",triggerName[i]),Form("%s: cluster E;E (GeV)",triggerTitle[i]),1000,0,100);
535 fOutputList->Add(fhClsE[i]);
544 for(Int_t r=0; r<radiusType; r++)
546 for(Int_t i=0; i<5; i++)
548 fHCOverSubE[r][i] = new TH2F(Form("%s_HC_over_sub_e_%s_%1.1f",triggerName[2],fraction[i],kRadius[r]),Form("%s: oversubtracted neutral Et by %s%% HC (R=%1.1f);particle jet p_{T} (GeV/c);#DeltaE_{t} (GeV)",triggerName[2],fraction[i],kRadius[r]),nbins,xbins,200,-49.75,50.25);
549 fOutputList->Add(fHCOverSubE[r][i]);
550 fHCOverSubEFrac[r][i] = new TH2F(Form("%s_HC_over_sub_e_frac_%s_%1.1f",triggerName[2],fraction[i],kRadius[r]),Form("%s: relative oversubtracted neutral Et fraction by %s%% HC (R=%1.1f);jet p_{T} (GeV/c);#DeltaE_{t}/p_{T}^{jet}",triggerName[2],fraction[i],kRadius[r]),nbins,xbins,200,-0.995,1.005);
551 fOutputList->Add(fHCOverSubEFrac[r][i]);
557 printf("\n=======================================\n");
558 printf("===== Jet task configuration ==========\n");
559 if(fNonStdBranch.Length()!=0)
561 const char* species[3] = {"in","ch","ne"};
562 const char* algorithm[2] = {"akt","kt"};
563 const char* radii[2] = {"04","02"};
564 for(Int_t s=0; s<3; s++)
566 if(!fFindChargedOnlyJet && s==1) continue;
567 if(!fFindNeutralOnlyJet && s==2) continue;
568 for(Int_t a=0; a<2; a++)
570 if(!fAlgorithm.Contains("aKt") && a==0) continue;
571 if(!fAlgorithm.Contains("kt") && a==1) continue;
572 for(Int_t r=0; r<2; r++)
574 if(!fRadius.Contains("0.4") && r==0) continue;
575 if(!fRadius.Contains("0.2") && r==1) continue;
576 fJetTCA[s][a][r] = new TClonesArray("AliAODJet",0);
577 fJetTCA[s][a][r]->SetName(Form("Jet_%s_%s_%s_%s",species[s],algorithm[a],radii[r],fNonStdBranch.Data()));
578 AddAODBranch("TClonesArray",&fJetTCA[s][a][r],fNonStdFile.Data());
579 printf("Add branch: Jet_%s_%s_%s_%s\n",species[s],algorithm[a],radii[r],fNonStdBranch.Data());
581 fDetJetFinder[s][a][r] = new AliFJWrapper(Form("DetJetFinder_%s_%s_%s_%s",species[s],algorithm[a],radii[r],fNonStdBranch.Data()),Form("DetJetFinder_%s_%s_%s_%s",species[s],algorithm[a],radii[r],fNonStdBranch.Data()));
582 if(a==0) fDetJetFinder[s][a][r]->SetAlgorithm(fastjet::antikt_algorithm);
583 if(a==1) fDetJetFinder[s][a][r]->SetAlgorithm(fastjet::kt_algorithm);
584 if(fRecombinationScheme==0) fDetJetFinder[s][a][r]->SetRecombScheme(fastjet::E_scheme);
585 fDetJetFinder[s][a][r]->SetR(kRadius[r]);
586 fDetJetFinder[s][a][r]->SetMaxRap(0.9);
587 fDetJetFinder[s][a][r]->Clear();
591 if(fIsMC && fNonStdBranch.Contains("Baseline",TString::kIgnoreCase))
593 fMcTruthAntikt[r] = new TClonesArray("AliAODJet",0);
594 fMcTruthAntikt[r]->SetName(Form("Jet_mc_truth_in_akt_%s_%s",radii[r],fNonStdBranch.Data()));
595 AddAODBranch("TClonesArray",&fMcTruthAntikt[r],fNonStdFile.Data());
596 printf("Add branch: Jet_mc_truth_in_akt_%s_%s\n",radii[r],fNonStdBranch.Data());
598 fTrueJetFinder[r] = new AliFJWrapper(Form("TrueJetFinder_%s_%s_%s_%s",species[s],algorithm[a],radii[r],fNonStdBranch.Data()),Form("TrueJetFinder_%s_%s_%s_%s",species[s],algorithm[a],radii[r],fNonStdBranch.Data()));
599 fTrueJetFinder[r]->SetAlgorithm(fastjet::antikt_algorithm);
600 fTrueJetFinder[r]->SetR(kRadius[r]);
601 fTrueJetFinder[r]->SetMaxRap(0.9);
602 if(fRecombinationScheme==0) fTrueJetFinder[r]->SetRecombScheme(fastjet::E_scheme);
603 fTrueJetFinder[r]->Clear();
611 fRandomGen = new TRandom3(0);
614 TFile f ("/project/projectdirs/alice/marr/Analysis/2.76Jet/CorrectionFunctions/TrkEffFit.root","read");
615 for(Int_t i=0; i<3; i++)
617 fTrkEffFunc[i] = new TF1(*((TF1*)f.Get(Form("Trk_eff_fit_%d",i+1))));
621 if(fPeriod.CompareTo("lhc11a",TString::kIgnoreCase)==0 || fPeriod.CompareTo("lhc11aJet",TString::kIgnoreCase)==0)
623 TFile f1 ("/project/projectdirs/alice/marr/Analysis/2.76Jet/CorrectionFunctions/TrkEffSampling.root","read");
624 for(Int_t j=0; j<2; j++)
627 if(fPeriod.CompareTo("lhc11aJet",TString::kIgnoreCase)==0) tmp = 2;
628 for(Int_t r=0; r<2; r++)
630 fhCorrTrkEffPtBin[j][r] = new TH1F(*((TH1F*)f1.Get(Form("%s_%s_NTrackPerPtBin_%1.1f",fPeriod.Data(),triggerName[tmp],kRadius[r]))));
631 for(Int_t i=0; i<kNBins; i++)
633 fhCorrTrkEffSample[j][r][i] = new TH1F(*((TH1F*)f1.Get(Form("%s_%s_ChTrkPt_Bin%d_%1.1f",fPeriod.Data(),triggerName[tmp],i+1,kRadius[r]))));
642 TFile f ("/project/projectdirs/alice/marr/Analysis/2.76Jet/CorrectionFunctions/TriggerCurve.root","read");
643 fTriggerMask = new TH2F(*((TH2F*)f.Get("lhc11a_TriggerMask")));
646 for(Int_t i=0; i<10; i++)
648 fTriggerEfficiency[i] = new TF1(*((TF1*)f.Get(Form("lhc11a_TriggerEfficiency_SM%d_fit",i))));
649 fTriggerCurve[i] = new TH1D(*((TH1D*)f.Get(Form("lhc11a_TriggerCurve_SM%d",i))));
654 fClusterEResolution = new TF1("fClusterEResolution","sqrt([0]^2+[1]^2*x+([2]*x)^2)*0.01");
655 fClusterEResolution->SetParameters(4.35,9.07,1.63);
657 fMCNonLin = new TF1("f1","([0]/((x+[1])^[2]))+1",0.1,200.0);
658 fMCNonLin->SetParameters(3.11111e-02, -5.71666e-02, 5.67995e-01);
660 fGeom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
661 fRecoUtil = new AliEMCALRecoUtils();
662 if(fRejectExoticCluster)
663 fRecoUtil->SwitchOnRejectExoticCluster();
666 fRecoUtil->SwitchOffRejectExoticCluster();
667 fRecoUtil->SwitchOffRejectExoticCell();
669 if(fRemoveBadChannel)
671 fRecoUtil->SwitchOnBadChannelsRemoval();
672 // Remove the problematic SM4 region due to wrong event sequence
673 for(Int_t ieta=0; ieta<36; ieta++)
674 for(Int_t iphi=0; iphi<8; iphi++)
675 fRecoUtil->SetEMCALChannelStatus(4,ieta,iphi);
678 fRecoUtil->SwitchOffBadChannelsRemoval();
680 fRecoUtil->SetNonLinearityFunction(AliEMCALRecoUtils::kBeamTestCorrected);
683 fRecoUtil->SetNonLinearityParam(0,9.88165e-01);
684 fRecoUtil->SetNonLinearityParam(1,3.07553e-01);
685 fRecoUtil->SetNonLinearityParam(2,4.91690e-01);
686 fRecoUtil->SetNonLinearityParam(3,1.07910e-01);
687 fRecoUtil->SetNonLinearityParam(4,1.54119e+02);
688 fRecoUtil->SetNonLinearityParam(5,2.91142e+01);
692 fRecoUtil->SwitchOnCutEtaPhiSeparate();
693 fRecoUtil->SetCutEta(fCutdEta);
694 fRecoUtil->SetCutPhi(fCutdPhi);
697 fTrackArray = new TObjArray();
698 fTrackArray->SetOwner(1);
699 fClusterArray = new TObjArray();
700 fClusterArray->SetOwner(1);
701 fMcPartArray = new TArrayI();
704 //error calculation in THnSparse
705 Int_t nObj = fOutputList->GetEntries();
706 for(Int_t i=0; i<nObj; i++)
708 TObject *obj = (TObject*) fOutputList->At(i);
709 if (obj->IsA()->InheritsFrom( "THnSparse" ))
711 THnSparseF *hn = (THnSparseF*)obj;
719 //PostData(0, AODEvent());
720 PostData(1, fOutputList);
725 //________________________________________________________________________
726 void AliAnalysisTaskFullppJet::BookHistos()
730 if(fVerbosity>10) printf("[i] Booking histograms \n");
734 //________________________________________________________________________
735 void AliAnalysisTaskFullppJet::UserExec(Option_t *)
738 // Main loop, called for each event.
741 if(fPeriod.CompareTo("lhc11b10a",TString::kIgnoreCase)==0 || fPeriod.CompareTo("lhc11b10b",TString::kIgnoreCase)==0 || fPeriod.CompareTo("lhc11aJet",TString::kIgnoreCase)==0 || fPeriod.CompareTo("lhc12a15a",TString::kIgnoreCase)==0)
746 // Get event pointers, check for signs of life
747 Double_t vtxTrueZ = -100;
753 Printf("ERROR: Could not retrieve MC event");
756 fStack = fMC->Stack();
757 TParticle *particle = fStack->Particle(0);
758 if(particle) vtxTrueZ = particle->Vz();
759 //printf("Generated vertex coordinate: (x,y,z) = (%4.2f, %4.2f, %4.2f)\n", particle->Vx(), particle->Vy(), particle->Vz());
762 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
765 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
770 AliError("Neither fESD nor fAOD available");
774 fhJetEventStat->Fill(0.5);
775 // Centrality, vertex, other event variables...
778 UInt_t trigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
779 if (trigger==0) return;
782 if (trigger & AliVEvent::kFastOnly) return; // Reject fast trigger cluster
783 if(fPeriod.CompareTo("lhc11a",TString::kIgnoreCase)==0)
785 if (trigger & AliVEvent::kMB) fTriggerType = 0;
786 else if(trigger & AliVEvent::kEMC1) fTriggerType = 1;
787 else fTriggerType = -1;
789 else if (fPeriod.CompareTo("lhc11c",TString::kIgnoreCase)==0 || fPeriod.CompareTo("lhc11d",TString::kIgnoreCase)==0)
791 if (trigger & AliVEvent::kINT7) fTriggerType = 0;
792 else if(trigger & AliVEvent::kEMC7) fTriggerType = 1;
793 else fTriggerType = -1;
802 if (trigger & AliVEvent::kMB)
805 if(fOfflineTrigger) fTriggerType = RunOfflineTrigger();
807 else fTriggerType = -1;
812 //printf("Error: worng trigger type %s\n",(fESD->GetFiredTriggerClasses()).Data());
819 if(fVertexGenZ[0]) fVertexGenZ[0]->Fill(vtxTrueZ);
823 fhJetEventStat->Fill(8.5);
827 fhJetEventStat->Fill(1.5+fTriggerType*2);
829 if(!IsPrimaryVertexOk(vtxTrueZ)) return;
830 fIsTPCOnlyVtx = IsTPCOnlyVtx();
832 if(!fIsMC && fTriggerType==1)
834 CheckEventTriggerBit();
835 if(fIsEventTriggerBit) fhJetEventStat->Fill(7.5);
838 fhJetEventStat->Fill(2.5+fTriggerType*2);
842 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
844 // Fast Jet calls BEG --------------------------------------------------------
846 for(Int_t s=0; s<3; s++)
848 for(Int_t a=0; a<2; a++)
850 for(Int_t r=0; r<2; r++)
854 fJetTCA[s][a][r]->Delete();
855 fDetJetFinder[s][a][r]->Clear();
860 if(fMcTruthAntikt[r])
862 fMcTruthAntikt[r]->Delete();
863 fTrueJetFinder[r]->Clear();
870 if(fVerbosity>10) printf("# of jets after clear: %d\n",fJetTCA[0][0][0]->GetEntries());
872 if(fTrackArray) fTrackArray->Delete();
873 if(fClusterArray) fClusterArray->Delete();
874 fMcPartArray->Reset();
877 // get the tracks and fill the input vector for the jet finders
880 // get EMCal clusters and fill the input vector for the jet finders
881 GetESDEMCalClusters();
883 for(Int_t s=0; s<3; s++)
885 for(Int_t a=0; a<2; a++)
887 for(Int_t r=0; r<2; r++)
893 FillAODJets(fJetTCA[s][a][r], fDetJetFinder[s][a][r], 0);
894 if(s==0 && a==0 && fNonStdBranch.Contains("Baseline",TString::kIgnoreCase))
896 if(fSaveQAHistos) AnalyzeJets(fDetJetFinder[s][a][r],fTriggerType, r);
897 if(fRunUE && fFindChargedOnlyJet && s==1 && a==0 && r==0) RunAnalyzeUE(fDetJetFinder[s][a][r]);
907 for(Int_t r=0; r<2; r++)
908 if(fMcTruthAntikt[r]) ProcessMC(r);
911 // Fast Jet calls END --------------------------------------------------------
913 PostData(1, fOutputList);
918 //________________________________________________________________________
919 void AliAnalysisTaskFullppJet::FindDetJets(const Int_t s, const Int_t a, const Int_t r)
922 // Jet finding is happening here
927 if(s==1) isNe = kFALSE;
928 if(s==2) isCh = kFALSE;
932 Int_t countTracks = 0;
933 Int_t ntracks = fTrackArray->GetEntriesFast();
934 for(Int_t it=0; it<ntracks; it++)
936 AliESDtrack *t = (AliESDtrack*) fTrackArray->At(it);
937 if(!t || t->Pt() < fTrkPtMin[fTriggerType]) continue;
940 Double_t pt = t->Pt();
941 if(fRecombinationScheme==0) e = TMath::Sqrt(t->P()*t->P()+0.139*0.139);
942 if(fSysTrkPtRes) pt += GetSmearedTrackPt(t);
943 Double_t phi = t->Phi();
944 Double_t eta = t->Eta();
945 Double_t px = pt*TMath::Cos(phi);
946 Double_t py = pt*TMath::Sin(phi);
947 if(fConstrainChInEMCal && ( TMath::Abs(eta)>0.7 || phi>kPI || phi<TMath::DegToRad()*80) ) continue;
948 fDetJetFinder[s][a][r]->AddInputVector(px,py,t->Pz(), e, it+1);
949 //printf("%d: m_{ch}=%f\n",it+1,t->P()*t->P()-t->Px()*t->Px()-t->Py()*t->Py()-t->Pz()*t->Pz());
951 if(fVerbosity>5) printf("[i] # of tracks filled: %d\n",countTracks);
955 Double_t vertex[3] = {0, 0, 0};
956 fESD->GetVertex()->GetXYZ(vertex) ;
957 TLorentzVector gamma;
959 Int_t countClusters = 0;
960 Int_t nclusters = fClusterArray->GetEntriesFast();
961 for (Int_t ic = 0; ic < nclusters; ic++)
963 AliESDCaloCluster * cl = (AliESDCaloCluster *)fClusterArray->At(ic);
965 cl->GetMomentum(gamma, vertex);
967 Double_t e = gamma.P();
968 if(fRecombinationScheme==0) e = TMath::Sqrt(gamma.P()*gamma.P()+0.139*0.139);
969 fDetJetFinder[s][a][r]->AddInputVector(gamma.Px(), gamma.Py(), gamma.Pz(), e, (ic+1)*(-1));
971 if(fVerbosity>5) printf("[i] # of clusters filled: %d\n",countClusters);
973 fDetJetFinder[s][a][r]->Run();
977 //________________________________________________________________________
978 void AliAnalysisTaskFullppJet::FillAODJets(TClonesArray *fJetArray, AliFJWrapper *jetFinder, const Bool_t isTruth)
981 // Fill the found jets into AOD output
982 // Only consider jets pointing to EMCal and with pt above 1GeV/c
984 Int_t radiusIndex = 0;
985 TString arrayName = fJetArray->GetName();
986 if(arrayName.Contains("_02_")) radiusIndex = 1;
987 std::vector<fastjet::PseudoJet> jetsIncl = jetFinder->GetInclusiveJets();
988 if(fVerbosity>0) printf("[i] # of jets in %s : %d\n",fJetArray->GetName(),(Int_t)jetsIncl.size());
991 for(UInt_t ij=0; ij<jetsIncl.size(); ij++)
993 //printf("fastjet: eta=%f, phi=%f\n",jetsIncl[ij].eta(),jetsIncl[ij].phi()*TMath::RadToDeg());
994 if(!IsGoodJet(jetsIncl[ij],0)) continue;
996 AliAODJet tmpJet (jetsIncl[ij].px(), jetsIncl[ij].py(), jetsIncl[ij].pz(), jetsIncl[ij].E());
997 jet = new ((*fJetArray)[jetCount]) AliAODJet(tmpJet);
999 //printf("AOD jet: ij=%d, pt=%f, eta=%f, phi=%f\n",ij, jet->Pt(), jet->Eta(),jet->Phi()*TMath::RadToDeg());
1001 jet->GetRefTracks()->Clear();
1002 std::vector<fastjet::PseudoJet> constituents = jetFinder->GetJetConstituents(ij);
1003 Double_t totE=0, totPt=0, totChPt=0, leadChPt=0, neE=0, totNePt=0, leadNePt=0, leadPt=0;
1004 Double_t leadTrkType=0, nChPart = 0, nNePart = 0;
1005 Bool_t isHighPtTrigger = kFALSE, isTriggering = kFALSE, isHyperTrack = kFALSE;
1006 for(UInt_t ic=0; ic<constituents.size(); ic++)
1008 //printf("ic=%d: user_index=%d, E=%f\n",ic,constituents[ic].user_index(),constituents[ic].E());
1009 if(constituents[ic].user_index()<0)
1012 totNePt += constituents[ic].perp();
1013 if(constituents[ic].perp()>leadNePt)
1014 leadNePt = constituents[ic].perp();
1016 neE += constituents[ic].E();
1017 if(constituents[ic].perp()>fClsEtMax[fTriggerType])
1018 isHighPtTrigger = kTRUE;
1021 AliESDCaloCluster *cluster = (AliESDCaloCluster *)fClusterArray->At(constituents[ic].user_index()*(-1)-1);
1022 if(cluster->Chi2()==1) isTriggering = kTRUE;
1027 totChPt += constituents[ic].perp();
1029 if(constituents[ic].perp()>leadChPt)
1031 leadChPt = constituents[ic].perp();
1034 AliESDtrack *track = (AliESDtrack*) fTrackArray->At(constituents[ic].user_index()-1);
1035 leadTrkType = track->GetTRDQuality();
1036 if(track->GetIntegratedLength()>500) isHyperTrack = kTRUE;
1039 if(constituents[ic].perp()>fTrkPtMax[fTriggerType])
1040 isHighPtTrigger = kTRUE;
1043 part.SetMomentum(constituents[ic].px(),constituents[ic].py(),constituents[ic].pz(),constituents[ic].E());
1044 jet->AddTrack(&part); //The references are not usable, this line is aimed to count the number of contituents
1045 totE += constituents[ic].E();
1046 totPt += constituents[ic].perp();
1047 if(constituents[ic].perp()>leadPt)
1048 leadPt = constituents[ic].perp();
1050 if(fIsEventTriggerBit) jet->SetTrigger(AliAODJet::kTRDTriggered);
1051 if(isHighPtTrigger) jet->SetTrigger(AliAODJet::kHighTrackPtTriggered);
1052 if(fTriggerType==1) jet->SetTrigger(AliAODJet::kEMCALTriggered);
1053 if(GetLeadingZ(ij,jetFinder) > 0.98 ) jet->SetTrigger(AliAnalysisTaskFullppJet::kHighZ);
1054 if(isTriggering) jet->SetTrigger(AliAnalysisTaskFullppJet::kTrigger);
1055 if(isHyperTrack) jet->SetTrigger(AliAnalysisTaskFullppJet::kSuspicious);
1056 if(fIsTPCOnlyVtx) jet->SetTrigger(AliAnalysisTaskFullppJet::kTPCOnlyVtx);
1057 if(jetsIncl[ij].E()>0) jet->SetNEF(neE/jetsIncl[ij].E());
1059 Double_t effAErrCh = 0, effAErrNe = leadTrkType;
1060 Double_t chBgEnergy = 0, neBgEnergy = nNePart;
1063 effAErrCh = GetMeasuredJetPtResolution(ij,jetFinder);
1064 if(fCheckTrkEffCorr)
1065 chBgEnergy = GetJetMissPtDueToTrackingEfficiency(ij,jetFinder,radiusIndex);
1067 jet->SetEffArea(leadPt, jetFinder->GetJetArea(ij),effAErrCh,effAErrNe);
1068 jet->SetBgEnergy(chBgEnergy,neBgEnergy);
1069 //cout<<"jet pt="<<jetsIncl[ij].perp()<<", nef="<<jet->GetNEF()<<", trk eff corr="<<chBgEnergy<<endl;
1072 printf("# of ref tracks: %d = %d, and nef=%f\n",jet->GetRefTracks()->GetEntries(), (Int_t)constituents.size(), jet->GetNEF());
1074 // For catch good high-E jets
1075 if(fSpotGoodJet && !isTruth)
1077 if(jetsIncl[ij].perp()>100)
1079 printf("\n\n--- HAHAHA: High pt jets ---\n");
1080 printf("File: %s, event = %d, pt=%f\n",CurrentFileName(),(Int_t)Entry(),jetsIncl[ij].perp());
1081 printf("%s , pt < %f\n", fJetArray->GetName(), fTrkPtMax[1]);
1082 printf("Jet: E=%f, eta=%f, phi=%f, # of constituents=%d, nef=%f\n",jetsIncl[ij].E(),jetsIncl[ij].eta(), jetsIncl[ij].phi()*TMath::RadToDeg(), (Int_t)constituents.size(),jet->GetNEF());
1083 for(UInt_t ic=0; ic<constituents.size(); ic++)
1085 if(constituents[ic].user_index()<0)
1087 AliESDCaloCluster *cluster = (AliESDCaloCluster *)fClusterArray->At(constituents[ic].user_index()*(-1)-1);
1088 printf("id = %d, cluster with pt = %f, ncell = %d\n",ic,constituents[ic].perp(), cluster->GetNCells());
1092 AliESDtrack *track = (AliESDtrack*) fTrackArray->At(constituents[ic].user_index()-1);
1093 printf("id = %d, track with pt = %f, track class = %d, originalPt = %f\n",ic,constituents[ic].perp(),(Int_t)track->GetTRDQuality(), track->GetIntegratedLength());
1097 printf("==============================\n\n");
1100 // End of catching good high-E jets
1105 //________________________________________________________________________
1106 Bool_t AliAnalysisTaskFullppJet::IsGoodJet(fastjet::PseudoJet jet, Double_t rad)
1109 // Check if the jet pt and direction fulfill the requirement
1112 if(jet.perp()<1) return kFALSE;
1113 if(TMath::Abs(jet.eta())>(0.7-rad)) return kFALSE;
1114 if(jet.phi() < (80*TMath::DegToRad()+rad) || jet.phi() > (180*TMath::DegToRad()-rad) ) return kFALSE;
1119 //________________________________________________________________________
1120 void AliAnalysisTaskFullppJet::ProcessMC(const Int_t r)
1123 // Main function for jet finding in MC
1126 Int_t npart = fMC->GetNumberOfTracks();
1127 fMcPartArray->Set(npart);
1128 Int_t countPart = 0;
1129 for(Int_t ipart=0; ipart<npart; ipart++)
1131 AliVParticle* vParticle = fMC->GetTrack(ipart);
1132 if(!IsGoodMcPartilce(vParticle,ipart)) continue;
1134 Int_t pdgCode = vParticle->PdgCode();
1135 if( fRejectNK && (pdgCode==130 || pdgCode==2112) ) continue;
1137 if( fRejectWD && (pdgCode==310 || pdgCode==3112 || pdgCode==3122 || pdgCode==3222 || pdgCode==3312 || pdgCode==3322 || pdgCode==3334)) continue;
1139 if( fChargedMC && vParticle->Charge()==0 ) continue;
1142 if(vParticle->Charge()==0) { index=-1; }
1143 fTrueJetFinder[r]->AddInputVector(vParticle->Px(), vParticle->Py(), vParticle->Pz(), vParticle->P(), (ipart+1)*index);
1144 //printf("Input particle: ipart=%d, pdg=%d, species=%s, charge=%d, E=%4.3f\n",(ipart+1)*index,pdgCode,vParticle->GetName(), vParticle->Charge(),vParticle->P());
1146 fMcPartArray->AddAt(ipart, countPart);
1149 fMcPartArray->Set(countPart);
1150 fTrueJetFinder[r]->Run();
1152 FillAODJets(fMcTruthAntikt[r], fTrueJetFinder[r], 1);
1153 if(fSaveQAHistos) AnalyzeJets(fTrueJetFinder[r], 2, r);
1157 //________________________________________________________________________
1158 void AliAnalysisTaskFullppJet::AnalyzeJets(AliFJWrapper *jetFinder, const Int_t type, const Int_t r)
1161 // Fill all the QA plots for jets
1162 // Especailly all the constituents plot must be filled here since the information
1163 // is not available in the output AOD
1165 Double_t vertex[3] = {0, 0, 0};
1166 fESD->GetVertex()->GetXYZ(vertex) ;
1167 TLorentzVector gamma;
1169 const Int_t nBins = fJetEnergyFraction[type][r]->GetAxis(1)->GetNbins();
1170 Float_t radiusCut[nBins];
1171 Float_t eFraction[nBins];
1173 for(Int_t i=0; i<nBins; i++)
1175 radiusCut[i] = (fJetEnergyFraction[type][r]->GetAxis(1)->GetBinWidth(1)) * (i+1);
1179 std::vector<fastjet::PseudoJet> jetsIncl = jetFinder->GetInclusiveJets();
1181 for(UInt_t ij=0; ij<jetsIncl.size(); ij++)
1183 if(!IsGoodJet(jetsIncl[ij],kRadius[r])) continue; // Fidiual cut
1184 Float_t jetEta = jetsIncl[ij].eta();
1185 Float_t jetPhi = jetsIncl[ij].phi();
1186 Float_t jetE = jetsIncl[ij].E();
1187 Float_t jetPt = jetsIncl[ij].perp();
1189 std::vector<fastjet::PseudoJet> constituents = jetFinder->GetJetConstituents(ij);
1190 Double_t neE=0, leadingZ = 0, maxPt = 0;
1191 Int_t constituentType = -1, leadingIndex = 0;
1192 for(UInt_t ic=0; ic<constituents.size(); ic++)
1194 if(constituents[ic].perp()>maxPt)
1196 maxPt = constituents[ic].perp();
1197 leadingIndex = constituents[ic].user_index();
1200 if(constituents[ic].user_index()<0)
1202 neE += constituents[ic].E();
1203 constituentType = 3;
1207 if(type==2) constituentType = 0;
1210 AliESDtrack *track = (AliESDtrack*) fTrackArray->At(constituents[ic].user_index()-1);
1211 constituentType = (Int_t)track->GetTRDQuality();
1214 Double_t cz = GetZ(constituents[ic].px(),constituents[ic].py(),constituents[ic].pz(),jetsIncl[ij].px(),jetsIncl[ij].py(),jetsIncl[ij].pz());
1215 fhJetPtVsZ[type][r]->Fill(jetPt,cz, constituentType);
1216 if(cz>leadingZ) leadingZ = cz;
1219 if(type<2 && leadingIndex<0)
1221 AliESDCaloCluster *cluster = (AliESDCaloCluster *)fClusterArray->At(leadingIndex*(-1)-1);
1222 fhFcrossVsZleading[type][r]->Fill(jetPt,GetExoticEnergyFraction(cluster),leadingZ);
1225 if(leadingZ > 0.98) continue; // Z cut
1227 fJetCount[type][r]->Fill(jetPt);
1228 if(type==1 && fIsExoticEvent3GeV) fhJetPtInExoticEvent[r][0]->Fill(jetPt);
1229 if(type==1 && fIsExoticEvent5GeV) fhJetPtInExoticEvent[r][1]->Fill(jetPt);
1231 Double_t totTrkPt[3] = {0.,0.,0.};
1233 for(Int_t i=0; i<nBins; i++) { eFraction[i] = 0.; nPart[i] = 0;}
1235 Double_t subClsE[5] = {0,0,0,0,0};
1236 Double_t subTrkPtClean[5] = {0,0,0,0,0};
1237 Double_t subTrkPtAmbig[5] = {0,0,0,0,0};
1238 Double_t fraction[5] = {270,0.3,0.5,0.7,1};
1239 Double_t leadChPt=0., leadNePt=0.;
1240 Int_t leadChIndex = -1;
1241 for(UInt_t ic=0; ic<constituents.size(); ic++)
1243 Float_t partEta = constituents[ic].eta();
1244 Float_t partPhi = constituents[ic].phi();
1245 Float_t partE = constituents[ic].E();
1246 Float_t partPt = constituents[ic].perp();
1248 if(constituents[ic].user_index()<0)
1250 fhNeutralPtInJet[type][r]->Fill(jetPt, partPt);
1253 if((fStudySubEInHC || fStudyMcOverSubE) && type<2)
1255 AliESDCaloCluster *cluster = (AliESDCaloCluster *)fClusterArray->At(constituents[ic].user_index()*(-1)-1);
1256 Double_t clsE = cluster->E();
1257 cluster->GetMomentum(gamma, vertex);
1258 Double_t sinTheta = TMath::Sqrt(1-TMath::Power(gamma.CosTheta(),2));
1260 Double_t subEtmp = cluster->GetDispersion();
1261 Double_t mipETmp = cluster->GetEmcCpvDistance();
1262 mcSubE += cluster->GetDistanceToBadChannel()*sinTheta;
1263 subClsE[0] += ((mipETmp>clsE)?clsE:mipETmp)*sinTheta;
1264 for(Int_t j=1; j<5; j++)
1266 subClsE[j] += ((fraction[j]*subEtmp>clsE)?clsE:fraction[j]*subEtmp)*sinTheta;
1272 if(partPt>leadChPt) {leadChPt = partPt;leadChIndex=ic;}
1273 fhChargedPtInJet[type][r]->Fill(jetPt, partPt);
1274 chPt += constituents[ic].perp();
1277 AliESDtrack *track = (AliESDtrack*) fTrackArray->At(constituents[ic].user_index()-1);
1278 Int_t trkType = (Int_t)track->GetTRDQuality();
1279 totTrkPt[trkType] += partPt;
1280 Int_t clusterIndex = track->GetEMCALcluster();
1281 Int_t clusterPos = -1;
1282 Bool_t isExist = kFALSE;
1283 for(Int_t j=0; j<fClusterArray->GetEntriesFast(); j++)
1285 AliESDCaloCluster *cluster = (AliESDCaloCluster*)fClusterArray->At(j);
1286 if( clusterIndex == cluster->GetID() )
1295 AliESDCaloCluster *cluster = (AliESDCaloCluster*)fClusterArray->At(clusterPos);
1296 Double_t subEtmp = cluster->GetDispersion();
1297 Double_t mipETmp = cluster->GetEmcCpvDistance();
1298 for(Int_t k=0; k<5; k++)
1302 if(mipETmp>cluster->E()) subTrkPtClean[k] += partPt;
1303 else subTrkPtAmbig[k] += partPt;
1307 if(fraction[k]*subEtmp>cluster->E()) subTrkPtClean[k] += partPt;
1308 else subTrkPtAmbig[k] += partPt;
1315 Float_t dR = TMath::Sqrt( (partEta-jetEta)*(partEta-jetEta) + (partPhi-jetPhi)*(partPhi-jetPhi) );
1316 for(Int_t i=0; i<nBins; i++)
1318 if( dR < radiusCut[i] )
1320 eFraction[i] += partE;
1326 fhLeadNePtInJet[type][r]->Fill(jetPt, leadNePt);
1327 fhLeadChPtInJet[type][r]->Fill(jetPt, leadChPt);
1328 if(type<2 && leadChIndex>-1)
1330 Double_t cz = GetZ(constituents[leadChIndex].px(),constituents[leadChIndex].py(),constituents[leadChIndex].pz(),jetsIncl[ij].px(),jetsIncl[ij].py(),jetsIncl[ij].pz());
1331 fhChLeadZVsJetPt[type][r]->Fill(jetPt, cz);
1334 if((fStudySubEInHC||fStudyMcOverSubE) && type<2)
1336 for(Int_t i=0; i<5; i++)
1340 fhSubClsEVsJetPt[type][r][i]->Fill(jetPt-subClsE[4],subClsE[i]/(jetPt-subClsE[4]));
1341 fhHCTrkPtClean[type][r][i]->Fill(jetPt-subClsE[4],subTrkPtClean[i]/(jetPt-subClsE[4]));
1342 fhHCTrkPtAmbig[type][r][i]->Fill(jetPt-subClsE[4],subTrkPtAmbig[i]/(jetPt-subClsE[4]));
1344 if(type==0 && fIsMC && fStudyMcOverSubE)
1346 fHCOverSubE[r][i]->Fill(jetPt-subClsE[4],subClsE[i]-mcSubE);
1347 fHCOverSubEFrac[r][i]->Fill(jetPt-subClsE[4],(subClsE[i]-mcSubE)/(jetPt-subClsE[4]));
1351 if(type<2 && chPt>0)
1353 for(Int_t i=0; i<3; i++)
1355 fRelTrkCon[type][r]->Fill(jetPt,totTrkPt[i]/chPt,i);
1360 for(Int_t ibin=0; ibin<nBins; ibin++)
1362 Double_t fill1[3] = {jetPt,radiusCut[ibin]-0.005,eFraction[ibin]/jetE};
1363 fJetEnergyFraction[type][r]->Fill(fill1);
1364 Double_t fill2[3] = {jetPt,radiusCut[ibin]-0.005,nPart[ibin]};
1365 fJetNPartFraction[type][r]->Fill(fill2);
1368 // Get the jet pt containing tracks or clusters above some threshold
1371 Double_t thres[3] = {15,25,40};
1372 Int_t okCh[3] = {0,0,0};
1373 Int_t okNe[3] = {0,0,0};
1375 for(UInt_t ic=0; ic<constituents.size(); ic++)
1377 Float_t partPt = constituents[ic].perp();
1378 if(partPt<0.2) lowPt += partPt;
1379 if(constituents[ic].user_index()>0)
1381 for(Int_t it=0; it<3; it++)
1383 if(partPt>thres[it]) okCh[it] = 1;
1388 for(Int_t icl=0; icl<3; icl++)
1390 if(partPt>thres[icl]) okNe[icl] = 1;
1394 for(Int_t i=0; i<3; i++)
1397 fhJetPtWithTrkThres[type][r]->Fill(i,jetPt);
1399 fhJetPtWithClsThres[type][r]->Fill(i,jetPt);
1401 fhJetPtVsLowPtCons[type][r]->Fill(jetPt,lowPt);
1406 //________________________________________________________________________
1407 void AliAnalysisTaskFullppJet::RunAnalyzeUE(AliFJWrapper *jetFinder)
1410 // Run analysis to estimate the underlying event
1411 // Adapt from Oliver
1413 std::vector<fastjet::PseudoJet> jetsIncl = jetFinder->GetInclusiveJets();
1414 Double_t leadpt=0, leadPhi = -999, leadEta = -999;
1415 for(UInt_t ij=0; ij<jetsIncl.size(); ij++)
1417 Double_t jetPt = jetsIncl[ij].perp();
1418 Double_t jetEta = jetsIncl[ij].eta();
1419 Double_t jetPhi = jetsIncl[ij].phi();
1420 if(TMath::Abs(jetEta)<0.5) continue;
1430 Int_t ntracks = fTrackArray->GetEntriesFast();
1431 for(Int_t it=0; it<ntracks; it++)
1433 AliESDtrack *t = (AliESDtrack*) fTrackArray->At(it);
1435 Double_t axis = leadPhi + 0.5 * kPI;
1436 if(axis > 2*kPI) axis -= 2*kPI;
1437 Double_t dPhi = TMath::Abs(axis-t->Phi());
1438 Double_t dEta = TMath::Abs(leadEta-t->Eta());
1439 cout<<leadPhi*TMath::RadToDeg()<<" -> "<<t->Phi()*TMath::RadToDeg()<<endl;
1440 if(dPhi > 2*kPI) dPhi -= 2*kPI;
1441 if(TMath::Abs(dPhi*dPhi+dEta*dEta)<0.4)
1446 fhJetPtVsUE[fTriggerType]->Fill(ue,leadpt);
1450 //________________________________________________________________________
1451 Bool_t AliAnalysisTaskFullppJet::IsGoodJet(AliAODJet *jet, Double_t rad)
1454 // Check if it is a good jet
1457 if(jet->Pt()<1) return kFALSE;
1458 if(TMath::Abs(jet->Eta())>(0.7-rad)) return kFALSE;
1459 if(jet->Phi() < (80*TMath::DegToRad()+rad) || jet->Phi() > (180*TMath::DegToRad()-rad) ) return kFALSE;
1464 //________________________________________________________________________
1465 Double_t AliAnalysisTaskFullppJet::GetLeadingZ(const Int_t jetIndex, AliFJWrapper *jetFinder)
1468 // Get the leading z of the input jet
1472 std::vector<fastjet::PseudoJet> constituents = jetFinder->GetJetConstituents(jetIndex);
1473 std::vector<fastjet::PseudoJet> jetsIncl = jetFinder->GetInclusiveJets();
1476 for(UInt_t ic=0; ic<constituents.size(); ic++)
1478 if(constituents[ic].perp()>maxPt)
1480 maxPt = constituents[ic].perp();
1485 z = GetZ(constituents[index].px(),constituents[index].py(),constituents[index].pz(),jetsIncl[jetIndex].px(),jetsIncl[jetIndex].py(),jetsIncl[jetIndex].pz());
1489 //________________________________________________________________________
1490 Double_t AliAnalysisTaskFullppJet::GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz) const
1493 // Get the z of a constituent inside of a jet
1496 return (trkPx*jetPx+trkPy*jetPy+trkPz*jetPz)/(jetPx*jetPx+jetPy*jetPy+jetPz*jetPz);
1499 //________________________________________________________________________
1500 Double_t AliAnalysisTaskFullppJet::GetMeasuredJetPtResolution(const Int_t jetIndex, AliFJWrapper *jetFinder)
1503 // Get jet energy resoultion due to intrinsic detector effects
1506 Double_t jetSigma2 = 0;
1507 std::vector<fastjet::PseudoJet> constituents = jetFinder->GetJetConstituents(jetIndex);
1508 for(UInt_t ic=0; ic<constituents.size(); ic++)
1510 if(constituents[ic].user_index()>0)
1512 AliESDtrack *track = (AliESDtrack*) fTrackArray->At(constituents[ic].user_index()-1);
1513 jetSigma2 += TMath::Power(track->Pt()*track->Pt()*TMath::Sqrt(track->GetSigma1Pt2()),2);
1517 AliESDCaloCluster *cluster = (AliESDCaloCluster *)fClusterArray->At(constituents[ic].user_index()*(-1)-1);
1518 jetSigma2 += TMath::Power(cluster->GetTOF(),2);
1521 return TMath::Sqrt(jetSigma2);
1526 //________________________________________________________________________
1527 Double_t AliAnalysisTaskFullppJet::GetJetMissPtDueToTrackingEfficiency(const Int_t jetIndex, AliFJWrapper *jetFinder, const Int_t radiusIndex)
1530 // Correct the tracking inefficiency explicitly
1533 Double_t misspt = 0;
1534 std::vector<fastjet::PseudoJet> jetsIncl = jetFinder->GetInclusiveJets();
1535 Double_t jetPt = jetsIncl[jetIndex].perp();
1536 if(!fhCorrTrkEffPtBin[fTriggerType][radiusIndex])
1538 printf("Warning: can't get the mean # of tracks per jet with pt=%f in: trigger=%d, radiusIndex=%d\n",jetPt,fTriggerType,radiusIndex);
1541 Int_t ibin = fhCorrTrkEffPtBin[fTriggerType][radiusIndex]->FindFixBin(jetPt);
1542 if(!fhCorrTrkEffSample[fTriggerType][radiusIndex][ibin-1] || fhCorrTrkEffSample[fTriggerType][radiusIndex][ibin-1]->Integral()<0.001)
1544 printf("Warning: no sampling distrubtion for jet with pt=%f\n",jetPt);
1547 Double_t ntrack = fhCorrTrkEffPtBin[fTriggerType][radiusIndex]->GetBinContent(ibin);
1548 Int_t nTrk = (Int_t) ntrack;
1549 Double_t res = ntrack-nTrk;
1550 Double_t pro1 = fRandomGen->Uniform();
1551 if(pro1<res) nTrk++;
1552 for(Int_t itry=0; itry<nTrk; itry++)
1554 Double_t trkPt = fhCorrTrkEffSample[fTriggerType][radiusIndex][ibin-1]->GetRandom();
1555 if(trkPt/jetPt>fTrkEffCorrCutZ) continue;
1556 Double_t eff = GetTrkEff(trkPt);
1557 Double_t pro = fRandomGen->Uniform();
1558 if(pro>eff) misspt += trkPt;
1564 //________________________________________________________________________
1565 Bool_t AliAnalysisTaskFullppJet::IsGoodMcPartilce(const AliVParticle* vParticle, const Int_t ipart)
1568 // Select good primary particles to feed into jet finder
1571 if(!vParticle) return kFALSE;
1572 if(!fMC->IsPhysicalPrimary(ipart)) return kFALSE;
1573 if (TMath::Abs(vParticle->Eta())>2) return kFALSE;
1577 //________________________________________________________________________
1578 Int_t AliAnalysisTaskFullppJet::FindSpatialMatchedJet(fastjet::PseudoJet jet, AliFJWrapper *jetFinder, const Double_t rad)
1581 // Find spatially matched detector and particle jets
1586 std::vector<fastjet::PseudoJet> jetsIncl = jetFinder->GetInclusiveJets();
1587 for(UInt_t ij=0; ij<jetsIncl.size(); ij++)
1589 if(!IsGoodJet(jetsIncl[ij],rad)) continue;
1590 if(GetLeadingZ(ij, jetFinder)>0.98) continue;
1591 Double_t tmpR = TMath::Sqrt( TMath::Power(jet.eta()-jetsIncl[ij].eta(), 2) + TMath::Power(jet.phi()-jetsIncl[ij].phi(), 2) );
1601 //________________________________________________________________________
1602 Int_t AliAnalysisTaskFullppJet::FindEnergyMatchedJet(AliFJWrapper *jetFinder1, const Int_t index1, AliFJWrapper *jetFinder2, const Double_t fraction)
1605 // Find matched detector and particle jets based on shared constituents
1608 Int_t matchedIndex = -1;
1609 std::vector<fastjet::PseudoJet> jetsIncl1 = jetFinder1->GetInclusiveJets();
1610 std::vector<fastjet::PseudoJet> jetsIncl2 = jetFinder2->GetInclusiveJets();
1611 std::vector<fastjet::PseudoJet> constituents1 = jetFinder1->GetJetConstituents(index1);
1612 Double_t jetPt1 = jetsIncl1[index1].perp();
1613 if(jetPt1<0) return matchedIndex;
1615 for(UInt_t ij2=0; ij2<jetsIncl2.size(); ij2++)
1617 Double_t jetPt2 = jetsIncl2[ij2].perp();
1618 if(jetPt2<0) return matchedIndex;
1619 std::vector<fastjet::PseudoJet> constituents2 = jetFinder2->GetJetConstituents(ij2);
1620 Double_t sharedPt1 = 0., sharedPt2 = 0.;
1621 for(UInt_t ic2=0; ic2<constituents2.size(); ic2++)
1623 Int_t mcLabel = constituents2[ic2].user_index()-1;
1624 Double_t consPt2 = constituents2[ic2].perp();
1625 for(UInt_t ic1=0; ic1<constituents1.size(); ic1++)
1627 Double_t consPt1 = constituents1[ic1].perp();
1628 if(constituents1[ic1].user_index()>0)
1630 AliESDtrack *track = (AliESDtrack*) fTrackArray->At(constituents1[ic1].user_index()-1);
1631 if(track->GetLabel()==mcLabel) {sharedPt2 += consPt2; sharedPt1 += consPt1; cout<<"Found a matched track"<<endl;break;}
1635 AliESDCaloCluster *cluster = (AliESDCaloCluster *)fClusterArray->At(constituents1[ic1].user_index()*(-1)-1);
1636 if(cluster->GetLabel()==mcLabel) {sharedPt2 += consPt2; sharedPt1 += consPt1; cout<<"Found a matched cluster"<<endl;break;}
1640 cout<<sharedPt1/jetPt1<<" "<<sharedPt2/jetPt2<<endl;
1641 if(sharedPt1/jetPt1 > fraction && sharedPt2/jetPt2 > fraction)
1647 return matchedIndex;
1650 //________________________________________________________________________
1651 void AliAnalysisTaskFullppJet::GetESDTrax()
1657 Int_t nTrax = fESD->GetNumberOfTracks();
1658 if(fVerbosity>5) printf("[i] # of tracks in event: %d\n",nTrax);
1660 for (Int_t i = 0; i < nTrax; ++i)
1662 AliESDtrack* esdtrack = fESD->GetTrack(i);
1665 AliError(Form("Couldn't get ESD track %d\n", i));
1669 AliESDtrack *newtrack = GetAcceptTrack(esdtrack);
1670 if(!newtrack) continue;
1672 Double_t pt = newtrack->Pt();
1673 Double_t eta = newtrack->Eta();
1674 if (pt < 0.15 || pt > fTrkPtMax[fTriggerType] || TMath::Abs(eta) > fTrkEtaMax)
1682 Double_t rand = fRandomGen->Uniform();
1683 if(rand<fVaryTrkEff)
1689 newtrack->SetIntegratedLength(esdtrack->Pt());
1690 fTrackArray->Add(newtrack);
1692 if(fVerbosity>5) printf("[i] # of tracks in event: %d\n", fTrackArray->GetEntries());
1693 fNTracksPerChunk += fTrackArray->GetEntries();
1697 //________________________________________________________________________
1699 AliESDtrack *AliAnalysisTaskFullppJet::GetAcceptTrack(AliESDtrack *esdtrack)
1702 // Get the hybrid tracks
1705 AliESDtrack *newTrack = 0x0;
1707 if(fTrackCutsType==0 || fTrackCutsType==3)
1709 if(fEsdTrackCuts->AcceptTrack(esdtrack))
1711 newTrack = new AliESDtrack(*esdtrack);
1712 newTrack->SetTRDQuality(0);
1714 else if(fHybridTrackCuts1->AcceptTrack(esdtrack))
1716 if(esdtrack->GetConstrainedParam())
1718 newTrack = new AliESDtrack(*esdtrack);
1719 const AliExternalTrackParam* constrainParam = esdtrack->GetConstrainedParam();
1720 newTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1721 newTrack->SetTRDQuality(1);
1726 else if(fHybridTrackCuts2->AcceptTrack(esdtrack))
1728 if(esdtrack->GetConstrainedParam())
1730 newTrack = new AliESDtrack(*esdtrack);
1731 const AliExternalTrackParam* constrainParam = esdtrack->GetConstrainedParam();
1732 newTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1733 newTrack->SetTRDQuality(2);
1743 else if(fTrackCutsType==1)
1745 if(fEsdTrackCuts->AcceptTrack(esdtrack))
1747 newTrack = AliESDtrackCuts::GetTPCOnlyTrack(const_cast<AliESDEvent*>(fESD),esdtrack->GetID());// use TPC only tracks with non default SPD vertex
1748 if(!newTrack) return 0x0;
1749 AliExternalTrackParam exParam;
1750 Bool_t relate = newTrack->RelateToVertexTPC(fESD->GetPrimaryVertexSPD(),fESD->GetMagneticField(),kVeryBig,&exParam); //constrain to SPD vertex
1756 newTrack->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance());
1757 newTrack->SetTRDQuality(1);
1764 else if (fTrackCutsType==2)
1766 if(fEsdTrackCuts->AcceptTrack(esdtrack))
1768 newTrack = new AliESDtrack(*esdtrack);
1769 newTrack->SetTRDQuality(0);
1776 printf("Unknown track cuts type: %d\n",fTrackCutsType);
1783 //________________________________________________________________________
1784 void AliAnalysisTaskFullppJet::GetESDEMCalClusters()
1787 // Get emcal clusters - selected
1792 if (!TGeoGlobalMagField::Instance()->GetField()) fESD->InitMagneticField();
1793 fRecoUtil->FindMatches(fESD,0x0,fGeom);
1794 fRecoUtil->SetClusterMatchedToTrack(fESD);
1795 fRecoUtil->SetTracksMatchedToCluster(fESD);
1798 Double_t vertex[3] = {0, 0, 0};
1799 fESD->GetVertex()->GetXYZ(vertex) ;
1800 TLorentzVector gamma;
1802 const Int_t nCaloClusters = fESD->GetNumberOfCaloClusters();
1803 for(Int_t i = 0 ; i < nCaloClusters; i++)
1805 AliESDCaloCluster * cl = (AliESDCaloCluster *) fESD->GetCaloCluster(i);
1806 if(!IsGoodCluster(cl)) continue;
1807 AliESDCaloCluster *newCluster = new AliESDCaloCluster(*cl);
1809 // Trigger efficiency
1812 Double_t newE = newCluster->E() * (1+fVaryJetTrigEff);
1813 newCluster->SetE(newE);
1814 if(fTriggerType==0) fhClsE[fTriggerType]->Fill(newCluster->E());
1815 if(fTriggerType==1 && newCluster->Chi2()==1) fhClsE[fTriggerType]->Fill(newCluster->E());
1819 // non-linearity correction
1820 if(fPeriod.CompareTo("lhc11a",TString::kIgnoreCase)==0)
1822 Double_t correctedEnergy = fRecoUtil->CorrectClusterEnergyLinearity(newCluster);
1823 newCluster->SetE(correctedEnergy);
1825 if(fPeriod.Contains("lhc12a15a",TString::kIgnoreCase))
1827 Double_t correctedEnergy = newCluster->E() * fMCNonLin->Eval(newCluster->E());
1828 newCluster->SetE(correctedEnergy);
1831 // Cluster energy scale
1832 if(fSysClusterEScale)
1834 Double_t newE = newCluster->E() * (1+fVaryClusterEScale);
1835 newCluster->SetE(newE);
1838 // Cluster energy resolution
1841 Double_t oldE = newCluster->E();
1842 Double_t resolution = fClusterEResolution->Eval(oldE);
1843 Double_t smear = resolution * fVaryClusterERes;
1844 Double_t newE = oldE + fRandomGen->Gaus(0, smear);
1845 newCluster->SetE(newE);
1848 newCluster->GetMomentum(gamma, vertex);
1849 if (gamma.Pt() < fClsEtMin[fTriggerType] || gamma.Pt() > fClsEtMax[fTriggerType]) {delete newCluster; continue;}
1851 Double_t clsE = newCluster->E();
1852 Double_t subE = 0., eRes = 0., mcSubE = 0, MIPE = 0.;
1853 if(fElectronRejection || fHadronicCorrection)
1854 subE= SubtractClusterEnergy(newCluster, eRes, MIPE, mcSubE);
1856 if(!fStudySubEInHC && !fStudyMcOverSubE) clsE -= subE;
1857 if(clsE<0) {delete newCluster; continue;}
1858 newCluster->SetE(clsE);
1859 newCluster->SetTOF(eRes);
1860 newCluster->SetDispersion(subE);
1861 newCluster->SetEmcCpvDistance(MIPE);
1862 newCluster->SetDistanceToBadChannel(mcSubE);
1863 fClusterArray->Add(newCluster);
1866 if(fVerbosity>5) printf("[i] # of EMCal clusters in event: %d\n", fClusterArray->GetEntries());
1871 //________________________________________________________________________
1872 Bool_t AliAnalysisTaskFullppJet::IsGoodCluster(AliESDCaloCluster *cluster)
1875 // Select good clusters
1878 if(!cluster) return kFALSE;
1879 if (!cluster->IsEMCAL()) return kFALSE;
1880 if(fRejectExoticCluster && fRecoUtil->IsExoticCluster(cluster, (AliVCaloCells*)fESD->GetEMCALCells())) return kFALSE;
1881 if(fRemoveBadChannel && fRecoUtil->ClusterContainsBadChannel(fGeom, cluster->GetCellsAbsId(),cluster->GetNCells())) return kFALSE;
1886 //________________________________________________________________________
1887 Double_t AliAnalysisTaskFullppJet::SubtractClusterEnergy(AliESDCaloCluster *cluster, Double_t &eRes, Double_t &MIPE, Double_t &mcSubE)
1890 // Hadronic correction
1897 eRes += TMath::Power(fClusterEResolution->Eval(cluster->E()),2);
1898 Double_t subE = 0., sumTrkPt = 0., sumTrkP = 0.;
1900 TArrayI *matched = cluster->GetTracksMatched();
1901 if(!matched) return 0;
1902 for(Int_t im=0; im<matched->GetSize(); im++)
1904 Int_t trkIndex = matched->At(im);
1905 if(trkIndex<0 || trkIndex>=fESD->GetNumberOfTracks()) continue;
1906 Bool_t isSelected = kFALSE;
1908 for(Int_t j=0; j<fTrackArray->GetEntriesFast(); j++)
1910 AliESDtrack *tr = (AliESDtrack*)fTrackArray->At(j);
1911 if( trkIndex == tr->GetID() )
1918 if(!isSelected) continue;
1920 AliESDtrack *track = (AliESDtrack*)fTrackArray->At(index);
1921 Double_t trkP = track->P();
1922 sumTrkPt += track->Pt(); sumTrkP += track->P();
1923 if(fSysTrkPtRes) trkP = TMath::Sqrt(TMath::Power(track->Pt()+GetSmearedTrackPt(track),2)+TMath::Power(track->Pz(),2));
1925 if(IsElectron(track,cluster->E()))
1927 if(fElectronRejection)
1931 eRes += TMath::Power(track->Pt()*track->Pt()*TMath::Sqrt(track->GetSigma1Pt2()),2);
1936 if(fHadronicCorrection)
1938 MIPE += (trkP>0.27)?0.27:trkP;
1948 eRes += TMath::Power(track->Pt()*track->Pt()*TMath::Sqrt(track->GetSigma1Pt2()),2);
1953 if(trkP>fHCLowerPtCutMIP) subE += 0.27;
1954 else subE+=fFractionHC*trkP;
1955 eRes += TMath::Power(fFractionHC*track->Pt()*track->Pt()*TMath::Sqrt(track->GetSigma1Pt2()),2);
1961 if(fSaveQAHistos) fhNMatchedTrack[fTriggerType]->Fill(nTrack);
1964 Double_t fraction[4] = {0.3,0.5,0.7,1.0};
1965 for(Int_t j=0; j<4; j++)
1967 Double_t subETmp = sumTrkP*fraction[j];
1968 if(subETmp>cluster->E()) subETmp = cluster->E();
1969 if(fSaveQAHistos) fhSubEVsTrkPt[fTriggerType][j]->Fill(sumTrkPt,subETmp/sumTrkP);
1973 eRes = TMath::Sqrt(eRes);
1975 if(fIsMC && nTrack>0)
1977 Double_t neutralE = 0;
1978 TArrayI* labels = cluster->GetLabelsArray();
1979 //cout<<labels<<endl;
1982 //cout<<"# of MC particles: "<<labels->GetSize()<<endl;
1983 for(Int_t il=0; il<labels->GetSize(); il++)
1985 Int_t ipart = labels->At(il);
1986 if(ipart>-1 && ipart<fMC->GetNumberOfTracks())
1988 AliVParticle* vParticle = fMC->GetTrack(ipart);
1989 if(vParticle->Charge()==0)
1991 neutralE += vParticle->E();
1996 mcSubE = cluster->E() - neutralE;
1999 //printf("MIP = %f, subE = %f, clsE = %f, mcSubE = %f\n",MIPE, subE, cluster->E(), mcSubE);
2008 //________________________________________________________________________
2010 Double_t AliAnalysisTaskFullppJet::GetExoticEnergyFraction(AliESDCaloCluster *cluster)
2013 // Exotic fraction: f_cross
2016 if(!cluster) return -1;
2017 AliVCaloCells *cells = (AliVCaloCells*)fESD->GetEMCALCells();
2018 if(!cells) return -1;
2020 // Get highest energy tower
2021 Int_t iSupMod = -1, absID = -1, ieta = -1, iphi = -1,iTower = -1, iIphi = -1, iIeta = -1;
2022 Bool_t share = kFALSE;
2023 fRecoUtil->GetMaxEnergyCell(fGeom, cells, cluster, absID, iSupMod, ieta, iphi, share);
2024 fGeom->GetCellIndex(absID,iSupMod,iTower,iIphi,iIeta);
2025 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
2027 Int_t absID1 = fGeom-> GetAbsCellIdFromCellIndexes(iSupMod, iphi+1, ieta);
2028 Int_t absID2 = fGeom-> GetAbsCellIdFromCellIndexes(iSupMod, iphi-1, ieta);
2029 Int_t absID3 = fGeom-> GetAbsCellIdFromCellIndexes(iSupMod, iphi, ieta+1);
2030 Int_t absID4 = fGeom-> GetAbsCellIdFromCellIndexes(iSupMod, iphi, ieta-1);
2032 Float_t ecell = 0, ecell1 = 0, ecell2 = 0, ecell3 = 0, ecell4 = 0;
2033 Double_t tcell = 0, tcell1 = 0, tcell2 = 0, tcell3 = 0, tcell4 = 0;
2034 Bool_t accept = 0, accept1 = 0, accept2 = 0, accept3 = 0, accept4 = 0;
2037 accept = fRecoUtil->AcceptCalibrateCell(absID, bc, ecell ,tcell ,cells);
2039 if(!accept) return -1;
2041 if(ecell < 0.5) return -1;
2043 accept1 = fRecoUtil->AcceptCalibrateCell(absID1,bc, ecell1,tcell1,cells);
2044 accept2 = fRecoUtil->AcceptCalibrateCell(absID2,bc, ecell2,tcell2,cells);
2045 accept3 = fRecoUtil->AcceptCalibrateCell(absID3,bc, ecell3,tcell3,cells);
2046 accept4 = fRecoUtil->AcceptCalibrateCell(absID4,bc, ecell4,tcell4,cells);
2048 const Double_t exoticCellDiffTime = 1e6;
2049 if(TMath::Abs(tcell-tcell1)*1.e9 > exoticCellDiffTime) ecell1 = 0 ;
2050 if(TMath::Abs(tcell-tcell2)*1.e9 > exoticCellDiffTime) ecell2 = 0 ;
2051 if(TMath::Abs(tcell-tcell3)*1.e9 > exoticCellDiffTime) ecell3 = 0 ;
2052 if(TMath::Abs(tcell-tcell4)*1.e9 > exoticCellDiffTime) ecell4 = 0 ;
2054 Float_t eCross = ecell1+ecell2+ecell3+ecell4;
2056 return 1-eCross/ecell;
2060 //________________________________________________________________________
2061 void AliAnalysisTaskFullppJet::GetMCInfo()
2064 // Get # of trials per ESD event
2067 AliStack *stack = fMC->Stack();
2070 AliGenEventHeader *head = dynamic_cast<AliGenEventHeader*>(fMC->GenEventHeader());
2073 AliError("Could not get the event header");
2077 AliGenPythiaEventHeader *headPy = dynamic_cast<AliGenPythiaEventHeader*>(head);
2080 if (headPy->Trials() > 0)
2082 fhNTrials[0]->Fill(0.5,headPy->Trials());
2091 //________________________________________________________________________
2092 void AliAnalysisTaskFullppJet::Terminate(Option_t *)
2095 // Called once at the end of the query
2097 fhChunkQA->SetBinContent(fEDSFileCounter,fNTracksPerChunk);
2102 //________________________________________________________________________
2104 Int_t AliAnalysisTaskFullppJet::RunOfflineTrigger()
2107 // Run trigger offline
2110 fIsEventTriggerBit = 0;
2111 Int_t isTrigger = 0;
2112 Int_t ncl = fESD->GetNumberOfCaloClusters();
2113 for(Int_t icl=0; icl<ncl; icl++)
2115 AliESDCaloCluster *cluster = fESD->GetCaloCluster(icl);
2116 if(!IsGoodCluster(cluster)) continue;
2117 Double_t pro = GetOfflineTriggerProbability(cluster);
2118 Double_t rand = fRandomGen->Uniform();
2122 cluster->SetChi2(1);
2130 //________________________________________________________________________
2132 Double_t AliAnalysisTaskFullppJet::GetOfflineTriggerProbability(AliESDCaloCluster *cluster)
2135 // Get the probablity of the given cluster to trigger the event
2139 // Check the trigger mask
2140 AliVCaloCells *cells = (AliVCaloCells*)fESD->GetEMCALCells();
2141 Int_t iSupMod = -1, absID = -1, ieta = -1, iphi = -1,iTower = -1, iIphi = -1, iIeta = -1;
2142 Bool_t share = kFALSE;
2143 fRecoUtil->GetMaxEnergyCell(fGeom, cells, cluster, absID, iSupMod, ieta, iphi, share);
2144 fGeom->GetCellIndex(absID,iSupMod,iTower,iIphi,iIeta);
2145 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
2146 // convert co global phi eta
2147 Int_t gphi = iphi + 24*(iSupMod/2);
2148 Int_t geta = ieta + 48*(iSupMod%2);
2149 // get corresponding FALTRO
2150 Int_t fphi = gphi / 2;
2151 Int_t feta = geta / 2;
2152 if(fTriggerMask->GetBinContent(feta+1,fphi+1)>0.5 && iSupMod>-1)
2154 Double_t clsE = cluster->E();
2155 if(fSysJetTrigEff) clsE = clsE * (1+fVaryJetTrigEff);
2159 Int_t bin = fTriggerCurve[iSupMod]->FindFixBin(clsE);
2160 pro = fTriggerCurve[iSupMod]->GetBinContent(bin)/fTriggerEfficiency[iSupMod]->Eval(10);
2169 //________________________________________________________________________
2171 Int_t AliAnalysisTaskFullppJet::GetClusterSuperModule(AliESDCaloCluster *cluster)
2174 // Return the given cluster supermodule
2178 cluster->GetPosition(pos);
2179 TVector3 clsVec(pos[0],pos[1],pos[2]);
2182 fGeom->SuperModuleNumberFromEtaPhi(clsVec.Eta(), clsVec.Phi(), sMod);
2187 //________________________________________________________________________
2188 Bool_t AliAnalysisTaskFullppJet::IsElectron(AliESDtrack *track, Double_t clsE) const
2191 // Check if the given track is an electron candidate based on de/dx
2194 if(track->GetTPCsignal()<=fdEdxMax && track->GetTPCsignal()>=fdEdxMin && (clsE/track->P())<=fEoverPMax && (clsE/track->P())>=fEoverPMin )
2201 //________________________________________________________________________
2202 Double_t AliAnalysisTaskFullppJet::GetTrkEff(Double_t inPt)
2205 // Get tracking efficiency estimated from simulation
2209 Double_t ptBound[4] = {0, 0.5, 3.8, 300};
2211 for(Int_t i=0; i<3; i++)
2213 if( inPt < ptBound[i+1] && inPt >= ptBound[i])
2215 eff = fTrkEffFunc[i]->Eval(inPt);
2222 //________________________________________________________________________
2223 Double_t AliAnalysisTaskFullppJet::GetSmearedTrackPt(AliESDtrack *track)
2226 // Smear track momentum
2229 Double_t resolution = track->Pt()*TMath::Sqrt(track->GetSigma1Pt2());
2230 Double_t smear = (resolution*fVaryTrkPtRes)*track->Pt();
2231 return fRandomGen->Gaus(0, smear);
2234 //________________________________________________________________________
2235 Double_t AliAnalysisTaskFullppJet::GetAdditionalSmearing(AliESDtrack *track)
2238 // Smear track momentum
2241 Double_t resolution = fTrkPtResData->Eval(track->Pt())*track->Pt();
2242 return fRandomGen->Gaus(0, resolution);
2246 //________________________________________________________________________
2247 void AliAnalysisTaskFullppJet::CheckEventTriggerBit()
2250 // Check if the triggered events have correct trigger bit
2253 fIsEventTriggerBit = 0;
2255 const Int_t nColsModule = 2;
2256 const Int_t nRowsModule = 5;
2257 const Int_t nRowsFeeModule = 24;
2258 const Int_t nColsFeeModule = 48;
2259 const Int_t nColsFaltroModule = 24;
2260 const Int_t nRowsFaltroModule = 12;
2262 // part 1, trigger extraction -------------------------------------
2263 Int_t trigtimes[30], globCol, globRow, ntimes;
2264 Int_t trigger[nColsFaltroModule*nColsModule][nRowsFaltroModule*nRowsModule];
2266 // erase trigger maps
2267 for( Int_t i = 0; i < nColsFaltroModule*nColsModule; i++ )
2269 for( Int_t j = 0; j < nRowsFaltroModule*nRowsModule; j++ )
2275 Int_t fTrigCutLow = 7, fTrigCutHigh = 10, trigInCut = 0;
2276 AliESDCaloTrigger * fCaloTrigger = fESD->GetCaloTrigger( "EMCAL" );
2277 // go through triggers
2278 if( fCaloTrigger->GetEntries() > 0 )
2281 fCaloTrigger->Reset();
2282 while( fCaloTrigger->Next() )
2284 fCaloTrigger->GetPosition( globCol, globRow ); // get position in global 2x2 tower coordinates
2285 fCaloTrigger->GetNL0Times( ntimes ); // get dimension of time arrays
2286 if( ntimes < 1 ) continue; // no L0s in this channel. Presence of the channel in the iterator still does not guarantee that L0 was produced!!
2287 fCaloTrigger->GetL0Times( trigtimes ); // get timing array
2288 if(fTriggerMask->GetBinContent(globCol+1,globRow+1)<0.5) continue;
2290 //cout<<globCol<<" "<<globRow<<" "<<ntimes<<endl;
2291 for( Int_t i = 0; i < ntimes; i++ )
2293 //printf("trigger times: %d\n",trigtimes[i]);
2294 if( trigtimes[i] > fTrigCutLow && trigtimes[i] < fTrigCutHigh ) // check if in cut
2299 if(trigInCut==1) trigger[globCol][globRow] = 1;
2300 } // calo trigger entries
2301 } // has calo trigger entries
2305 // part 2 go through the clusters here -----------------------------------
2307 UShort_t *cellAddrs;
2308 Int_t absID = -1, nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1, gphi=-1, geta=-1, feta=-1, fphi=-1;
2309 Bool_t share = kFALSE;
2310 AliVCaloCells *cells = (AliVCaloCells*)fESD->GetEMCALCells();
2311 for(Int_t icl=0; icl<fESD->GetNumberOfCaloClusters(); icl++)
2313 AliESDCaloCluster *cluster = fESD->GetCaloCluster(icl);
2314 if(!IsGoodCluster(cluster)) continue;
2315 cluster->SetChi2(0);
2316 //Clusters with most energetic cell in dead region can't be triggered
2317 fRecoUtil->GetMaxEnergyCell(fGeom, cells, cluster, absID, nSupMod, ieta, iphi, share);
2318 fGeom->GetCellIndex(absID,nSupMod,nModule, nIphi, nIeta);
2319 fGeom->GetCellPhiEtaIndexInSModule(nSupMod,nModule, nIphi, nIeta, iphi, ieta);
2320 gphi = iphi + nRowsFeeModule*(nSupMod/2);
2321 geta = ieta + nColsFeeModule*(nSupMod%2);
2325 if(fTriggerMask->GetBinContent(feta+1,fphi+1)>0.5)
2327 nCell = cluster->GetNCells(); // get cluster cells
2328 cellAddrs = cluster->GetCellsAbsId(); // get the cell addresses
2329 for( iCell = 0; iCell < nCell; iCell++ )
2331 // get cell position
2332 fGeom->GetCellIndex( cellAddrs[iCell], nSupMod, nModule, nIphi, nIeta );
2333 fGeom->GetCellPhiEtaIndexInSModule( nSupMod,nModule, nIphi, nIeta, iphi, ieta);
2335 // convert co global phi eta
2336 gphi = iphi + nRowsFeeModule*(nSupMod/2);
2337 geta = ieta + nColsFeeModule*(nSupMod%2);
2339 // get corresponding FALTRO
2342 // try to match with a triggered
2343 if( trigger[feta][fphi] == 1)
2345 cluster->SetChi2(1);
2346 fIsEventTriggerBit = 1;
2355 //________________________________________________________________________
2356 void AliAnalysisTaskFullppJet::PrintConfig()
2359 // Print configuration
2362 const char *trackCutName[3] = {"Hybrid tracks","TPCOnly tracks","Golden tracks"};
2363 const char *triggerType[2] = {"MB","EMC"};
2364 const char *decision[2] = {"no","yes"};
2365 const char *recombination[] = {"E_scheme","pt_scheme","pt2_scheme","Et_scheme","Et2_scheme","BIpt_scheme","BIpt2_scheme"};
2366 if(fStudySubEInHC || fStudyMcOverSubE)
2368 printf("\n\n=================================\n");
2369 printf("======WARNING: HC is ingored!======\n");
2370 printf("====== NOT for PHYSICS! ======\n\n");
2372 printf("Run period: %s\n",fPeriod.Data());
2373 printf("Is this MC data: %s\n",decision[fIsMC]);
2374 printf("Only find charged jets in MC: %s\n",decision[fChargedMC]);
2375 printf("Run offline trigger on MC: %s\n",decision[fOfflineTrigger]);
2377 printf("Is K0 and n included: %s\n",decision[1-fRejectNK]);
2378 printf("Constrain tracks in EMCal acceptance: %s\n",decision[fConstrainChInEMCal]);
2379 printf("Track selection: %s, |eta| < %2.1f\n",trackCutName[fTrackCutsType], fTrkEtaMax);
2380 for(Int_t i=0; i<2; i++)
2382 printf("Track pt cut: %s -> %2.2f < pT < %2.1f\n",triggerType[i], fTrkPtMin[i], fTrkPtMax[i]);
2384 for(Int_t i=0; i<2; i++)
2386 printf("Cluster selection: %s -> %2.2f < Et < %2.1f\n",triggerType[i],fClsEtMin[i], fClsEtMax[i]);
2388 printf("Electron selectoin: %2.0f < dE/dx < %2.0f, %1.1f < E/P < %1.1f\n",fdEdxMin, fdEdxMax, fEoverPMin, fEoverPMax);
2389 printf("Reject exotic cluster: %s\n",decision[fRejectExoticCluster]);
2390 printf("Remove problematic region in SM4: %s\n",decision[fRemoveBadChannel]);
2391 printf("Use only good SM (1,2,6,7,8,9) for trigger: %s\n",decision[fUseGoodSM]);
2392 printf("Reject electron: %s\n", decision[fElectronRejection]);
2393 printf("Correct hadron: %s\n",decision[fHadronicCorrection]);
2394 printf("HC fraction: %2.1f up to %2.0f GeV/c\n",fFractionHC,fHCLowerPtCutMIP);
2395 printf("Find charged jets: %s\n", decision[fFindChargedOnlyJet]);
2396 printf("Find netural jets: %s\n", decision[fFindNeutralOnlyJet]);
2397 printf("Find good jets: %s\n",decision[fSpotGoodJet]);
2398 printf("Jet radius: %s\n",fRadius.Data());
2399 printf("Jet recombination scheme: %s\n",recombination[fRecombinationScheme]);
2400 printf("Correct tracking efficiency: %s\n",decision[fCheckTrkEffCorr]);
2401 printf("Save jet QA histos: %s\n",decision[fSaveQAHistos]);
2402 printf("Systematics: jet efficiency: %s with variation %1.0f%%\n",decision[fSysJetTrigEff],fVaryJetTrigEff*100);
2403 printf("Systematics: tracking efficiency: %s with variation %1.0f%%\n",decision[fSysTrkEff],fVaryTrkEff*100);
2404 printf("Systematics: track pt resolution: %s with variation %1.0f%%\n",decision[fSysTrkPtRes],fVaryTrkPtRes*100);
2405 printf("Systematics: track-cluster matching: %s with |dEta|<%2.3f, |dPhi|<%2.3f\n",decision[fSysTrkClsMth],fCutdEta,fCutdPhi);
2406 printf("Systematics: EMCal non-linearity: %s\n",decision[fSysNonLinearity]);
2407 printf("Systematics: EMCal energy scale: %s with uncertainty of %1.0f%%\n",decision[fSysClusterEScale],fVaryClusterEScale*100);
2408 printf("Systematics: EMCal energy resolution: %s with uncertainty of %1.0f%%\n",decision[fSysClusterERes],fVaryClusterERes*100);
2409 printf("Smear lhc12a15a: %s\n",decision[fSmearMC]);
2410 printf("=======================================\n\n");
2413 //________________________________________________________________________
2414 void AliAnalysisTaskFullppJet::CheckExoticEvent()
2417 // Check if the event containts exotic clusters
2420 Double_t leadingE = 0;
2421 for(Int_t icl=0; icl<fESD->GetNumberOfCaloClusters(); icl++)
2423 AliESDCaloCluster *cluster = fESD->GetCaloCluster(icl);
2424 if(!cluster) continue;
2425 if (!cluster->IsEMCAL()) continue;
2426 if(fRecoUtil->IsExoticCluster(cluster, (AliVCaloCells*)fESD->GetEMCALCells()) && cluster->E()>leadingE)
2428 leadingE = cluster->E();
2431 if(leadingE>3) fIsExoticEvent3GeV = kTRUE;
2432 if(leadingE>5) fIsExoticEvent5GeV = kTRUE;
2435 //________________________________________________________________________
2436 Bool_t AliAnalysisTaskFullppJet::IsPrimaryVertexOk(const Double_t trueVtxZ) const
2439 // Check if the event vertex is good
2442 const AliESDVertex* vtx = fESD->GetPrimaryVertex();
2443 if (!vtx || vtx->GetNContributors()<1) return kFALSE;
2444 fhJetEventStat->Fill(5.5+fTriggerType);
2446 Double_t zVertex = vtx->GetZ();
2447 if(fEventZ[fTriggerType]) fEventZ[fTriggerType]->Fill(zVertex);
2448 if(fVertexGenZ[1]) fVertexGenZ[1]->Fill(trueVtxZ);
2450 if( TMath::Abs(zVertex) > fZVtxMax ) return kFALSE;
2455 //________________________________________________________________________
2456 Bool_t AliAnalysisTaskFullppJet::IsTPCOnlyVtx() const
2459 // Check if the event only has valid TPC vertex
2462 const AliESDVertex* vertex1 = fESD->GetPrimaryVertexTracks();
2463 const AliESDVertex* vertex2 = fESD->GetPrimaryVertexSPD();
2464 const AliESDVertex* vertex3 = fESD->GetPrimaryVertexTPC();
2465 if(vertex1 && vertex1->GetNContributors()==0 && vertex2 && vertex2->GetStatus()==0 && vertex3 && vertex3->GetNContributors()>0 )
2471 //________________________________________________________________________
2472 Bool_t AliAnalysisTaskFullppJet::IsLEDEvent() const
2475 // Check if the event is contaminated by LED signal
2478 AliESDCaloCells *cells = fESD->GetEMCALCells();
2479 Short_t nCells = cells->GetNumberOfCells();
2480 Int_t nCellCount[2] = {0,0};
2481 for(Int_t iCell=0; iCell<nCells; iCell++)
2483 Int_t cellId = cells->GetCellNumber(iCell);
2484 Double_t cellE = cells->GetCellAmplitude(cellId);
2485 Int_t sMod = fGeom->GetSuperModuleNumber(cellId);
2487 if(sMod==3 || sMod==4)
2490 nCellCount[sMod-3]++;
2493 Bool_t isLED=kFALSE;
2495 if(fPeriod.CompareTo("lhc11a")==0)
2497 if (nCellCount[1] > 100)
2499 Int_t runN = fESD->GetRunNumber();
2500 if (runN>=146858 && runN<=146860)
2502 if(fTriggerType==0 && nCellCount[0]>=21) isLED=kTRUE;
2503 if(fTriggerType==1 && nCellCount[0]>=35) isLED=kTRUE;