]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetV2.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskJetV2.cxx
CommitLineData
eae37c5c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17 * Jet V2 task
18 *
19 * this task is part of the emcal jet framework and should be run in the emcaljet train
20 * the following extensions to an accepted AliVEvent are expected:
21 * - (anti-kt) jets
22 * - background estimate rho
23 * - pico tracks
24 * aod's and esd's are handled transparently
25 * the task will attempt to estimate a phi-dependent background density rho
26 * by fitting vn harmonics to the dpt/dphi distribution
27 *
28 * author: Redmer Alexander Bertens, Utrecht Univeristy, Utrecht, Netherlands
29 * rbertens@cern.ch, rbertens@nikhef.nl, r.a.bertens@uu.nl
30 */
31
32// root includes
33#include <TStyle.h>
34#include <TRandom3.h>
35#include <TChain.h>
36#include <TMath.h>
37#include <TF1.h>
38#include <TF2.h>
39#include <TH1F.h>
40#include <TH2F.h>
41#include <TProfile.h>
42// aliroot includes
43#include <AliAnalysisTask.h>
44#include <AliAnalysisManager.h>
45#include <AliCentrality.h>
46#include <AliVVertex.h>
47#include <AliVTrack.h>
48#include <AliESDEvent.h>
49#include <AliAODEvent.h>
50#include <AliAODTrack.h>
51// emcal jet framework includes
52#include <AliPicoTrack.h>
53#include <AliEmcalJet.h>
54#include <AliRhoParameter.h>
55#include <AliLocalRhoParameter.h>
56#include <AliAnalysisTaskJetV2.h>
57#include <AliClusterContainer.h>
58
59class AliAnalysisTaskJetV2;
60using namespace std;
61
62ClassImp(AliAnalysisTaskJetV2)
63
64AliAnalysisTaskJetV2::AliAnalysisTaskJetV2() : AliAnalysisTaskEmcalJet("AliAnalysisTaskJetV2", kTRUE),
a008f846 65 fDebug(0), fRunToyMC(kFALSE), fLocalInit(0), fAttachToEvent(kTRUE), fFillHistograms(kTRUE), fFillQAHistograms(kTRUE), fReduceBinsXByFactor(-1.), fReduceBinsYByFactor(-1.), fNoEventWeightsForQC(kTRUE), fCentralityClasses(0), fExpectedRuns(0), fExpectedSemiGoodRuns(0), fUserSuppliedV2(0), fUserSuppliedV3(0), fUserSuppliedR2(0), fUserSuppliedR3(0), fTracksCont(0), fClusterCont(0), fJetsCont(0), fLeadingJet(0), fNAcceptedTracks(0), fNAcceptedTracksQCn(0), fFitModulationType(kNoFit), fFitGoodnessTest(kChi2Poisson), fQCRecovery(kTryFit), fUsePtWeight(kTRUE), fUsePtWeightErrorPropagation(kTRUE), fDetectorType(kTPC), fAnalysisType( kCharged), fFitModulationOptions("QWLI"), fRunModeType(kGrid), fDataType(kESD), fCollisionType(kPbPb), fRandom(0), fRunNumber(-1), fMappedRunNumber(0), fInCentralitySelection(-1), fFitModulation(0), fFitControl(0), fMinPvalue(0.01), fMaxPvalue(1), fNameSmallRho(""), fCachedRho(0), fSoftTrackMinPt(0.15), fSoftTrackMaxPt(5.), fSemiGoodJetMinPhi(0.), fSemiGoodJetMaxPhi(4.), fSemiGoodTrackMinPhi(0.), fSemiGoodTrackMaxPhi(4.), fAbsVertexZ(10), fHistCentrality(0), fHistVertexz(0), fHistRunnumbersPhi(0), fHistRunnumbersEta(0), fHistPvalueCDFROOT(0), fHistPvalueCDFROOTCent(0), fHistChi2ROOTCent(0), fHistPChi2Root(0), fHistPvalueCDF(0), fHistPvalueCDFCent(0), fHistChi2Cent(0), fHistPChi2(0), fHistKolmogorovTest(0), fHistKolmogorovTestCent(0), fHistPKolmogorov(0), fHistRhoStatusCent(0), fHistUndeterminedRunQA(0), fMinDisanceRCtoLJ(0), fMaxCones(-1), fExcludeLeadingJetsFromFit(1.), fRebinSwapHistoOnTheFly(kTRUE), fPercentageOfFits(10.), fUseV0EventPlaneFromHeader(kTRUE), /*fExplicitOutlierCut(-1),*/ fOutputList(0), fOutputListGood(0), fOutputListBad(0), fHistAnalysisSummary(0), fHistSwap(0), fProfV2(0), fProfV2Cumulant(0), fProfV3(0), fProfV3Cumulant(0), fHistPsiControl(0), fHistPsiSpread(0), fHistPsiVZEROA(0), fHistPsiVZEROC(0), fHistPsiVZERO(0), fHistPsiTPC(0), fHistPsiVZEROAV0M(0), fHistPsiVZEROCV0M(0), fHistPsiVZEROVV0M(0), fHistPsiTPCiV0M(0), fHistPsiVZEROATRK(0), fHistPsiVZEROCTRK(0), fHistPsiVZEROTRK(0), fHistPsiTPCTRK(0), fHistRhoVsMult(0), fHistRhoVsCent(0), fHistRhoAVsMult(0), fHistRhoAVsCent(0) {
eae37c5c 66 for(Int_t i(0); i < 10; i++) {
67 fProfV2Resolution[i] = 0;
68 fProfV3Resolution[i] = 0;
69 fHistPicoTrackPt[i] = 0;
70 fHistPicoTrackMult[i] = 0;
71 fHistPicoCat1[i] = 0;
72 fHistPicoCat2[i] = 0;
73 fHistPicoCat3[i] = 0;
74 fHistClusterPt[i] = 0;
75 fHistClusterEtaPhi[i] = 0;
76 fHistClusterEtaPhiWeighted[i] = 0;
77 fHistRhoPackage[i] = 0;
78 fHistRho[i] = 0;
79 fHistRCPhiEta[i] = 0;
80 fHistRhoVsRCPt[i] = 0;
81 fHistRCPt[i] = 0;
82 fHistDeltaPtDeltaPhi2[i] = 0;
83 fHistDeltaPtDeltaPhi2Rho0[i] = 0;
84 fHistRCPhiEtaExLJ[i] = 0;
85 fHistRhoVsRCPtExLJ[i] = 0;
86 fHistRCPtExLJ[i] = 0;
87 fHistDeltaPtDeltaPhi2ExLJ[i] = 0;
88 fHistDeltaPtDeltaPhi2ExLJRho0[i] = 0;
89 fHistJetPtRaw[i] = 0;
90 fHistJetPt[i] = 0;
91 fHistJetEtaPhi[i] = 0;
92 fHistJetPtArea[i] = 0;
93 fHistJetPtEta[i] = 0;
94 fHistJetPtConstituents[i] = 0;
95 fHistJetEtaRho[i] = 0;
96 fHistJetPsi2Pt[i] = 0;
97 fHistJetPsi2PtRho0[i] = 0;
98 }
99 // default constructor
100}
101//_____________________________________________________________________________
102AliAnalysisTaskJetV2::AliAnalysisTaskJetV2(const char* name, runModeType type) : AliAnalysisTaskEmcalJet(name, kTRUE),
a008f846 103 fDebug(0), fRunToyMC(kFALSE), fLocalInit(0), fAttachToEvent(kTRUE), fFillHistograms(kTRUE), fFillQAHistograms(kTRUE), fReduceBinsXByFactor(-1.), fReduceBinsYByFactor(-1.), fNoEventWeightsForQC(kTRUE), fCentralityClasses(0), fExpectedRuns(0), fExpectedSemiGoodRuns(0), fUserSuppliedV2(0), fUserSuppliedV3(0), fUserSuppliedR2(0), fUserSuppliedR3(0), fTracksCont(0), fClusterCont(0), fJetsCont(0), fLeadingJet(0), fNAcceptedTracks(0), fNAcceptedTracksQCn(0), fFitModulationType(kNoFit), fFitGoodnessTest(kChi2Poisson), fQCRecovery(kTryFit), fUsePtWeight(kTRUE), fUsePtWeightErrorPropagation(kTRUE), fDetectorType(kTPC), fAnalysisType(kCharged), fFitModulationOptions("QWLI"), fRunModeType(type), fDataType(kESD), fCollisionType(kPbPb), fRandom(0), fRunNumber(-1), fMappedRunNumber(0), fInCentralitySelection(-1), fFitModulation(0), fFitControl(0), fMinPvalue(0.01), fMaxPvalue(1), fNameSmallRho(""), fCachedRho(0), fSoftTrackMinPt(0.15), fSoftTrackMaxPt(5.), fSemiGoodJetMinPhi(0.), fSemiGoodJetMaxPhi(4.), fSemiGoodTrackMinPhi(0.), fSemiGoodTrackMaxPhi(4.), fAbsVertexZ(10), fHistCentrality(0), fHistVertexz(0), fHistRunnumbersPhi(0), fHistRunnumbersEta(0), fHistPvalueCDFROOT(0), fHistPvalueCDFROOTCent(0), fHistChi2ROOTCent(0), fHistPChi2Root(0), fHistPvalueCDF(0), fHistPvalueCDFCent(0), fHistChi2Cent(0), fHistPChi2(0), fHistKolmogorovTest(0), fHistKolmogorovTestCent(0), fHistPKolmogorov(0), fHistRhoStatusCent(0), fHistUndeterminedRunQA(0), fMinDisanceRCtoLJ(0), fMaxCones(-1), fExcludeLeadingJetsFromFit(1.), fRebinSwapHistoOnTheFly(kTRUE), fPercentageOfFits(10.), fUseV0EventPlaneFromHeader(kTRUE), /*fExplicitOutlierCut(-1),*/ fOutputList(0), fOutputListGood(0), fOutputListBad(0), fHistAnalysisSummary(0), fHistSwap(0), fProfV2(0), fProfV2Cumulant(0), fProfV3(0), fProfV3Cumulant(0), fHistPsiControl(0), fHistPsiSpread(0), fHistPsiVZEROA(0), fHistPsiVZEROC(0), fHistPsiVZERO(0), fHistPsiTPC(0), fHistPsiVZEROAV0M(0), fHistPsiVZEROCV0M(0), fHistPsiVZEROVV0M(0), fHistPsiTPCiV0M(0), fHistPsiVZEROATRK(0), fHistPsiVZEROCTRK(0), fHistPsiVZEROTRK(0), fHistPsiTPCTRK(0), fHistRhoVsMult(0), fHistRhoVsCent(0), fHistRhoAVsMult(0), fHistRhoAVsCent(0) {
eae37c5c 104 for(Int_t i(0); i < 10; i++) {
105 fProfV2Resolution[i] = 0;
106 fProfV3Resolution[i] = 0;
107 fHistPicoTrackPt[i] = 0;
108 fHistPicoTrackMult[i] = 0;
109 fHistPicoCat1[i] = 0;
110 fHistPicoCat2[i] = 0;
111 fHistPicoCat3[i] = 0;
112 fHistClusterPt[i] = 0;
113 fHistClusterEtaPhi[i] = 0;
114 fHistClusterEtaPhiWeighted[i] = 0;
115 fHistRhoPackage[i] = 0;
116 fHistRho[i] = 0;
117 fHistRCPhiEta[i] = 0;
118 fHistRhoVsRCPt[i] = 0;
119 fHistRCPt[i] = 0;
120 fHistDeltaPtDeltaPhi2[i] = 0;
121 fHistDeltaPtDeltaPhi2Rho0[i] = 0;
122 fHistRCPhiEtaExLJ[i] = 0;
123 fHistRhoVsRCPtExLJ[i] = 0;
124 fHistRCPtExLJ[i] = 0;
125 fHistDeltaPtDeltaPhi2ExLJ[i] = 0;
126 fHistDeltaPtDeltaPhi2ExLJRho0[i] = 0;
127 fHistJetPtRaw[i] = 0;
128 fHistJetPt[i] = 0;
129 fHistJetEtaPhi[i] = 0;
130 fHistJetPtArea[i] = 0;
131 fHistJetPtEta[i] = 0;
132 fHistJetPtConstituents[i] = 0;
133 fHistJetEtaRho[i] = 0;
134 fHistJetPsi2Pt[i] = 0;
135 fHistJetPsi2PtRho0[i] = 0;
136 }
137 // constructor
138 DefineInput(0, TChain::Class());
139 DefineOutput(1, TList::Class());
140 switch (fRunModeType) {
141 case kLocal : {
142 gStyle->SetOptFit(1);
143 DefineOutput(2, TList::Class());
144 DefineOutput(3, TList::Class());
145 } break;
146 default: fDebug = -1; // suppress debug info explicitely when not running locally
147 }
148 switch (fCollisionType) {
149 case kPythia : {
150 fFitModulationType = kNoFit;
151 } break;
152 default : break;
153 }
154 if(fLocalRhoName=="") fLocalRhoName = Form("LocalRhoFrom_%s", GetName());
155}
156//_____________________________________________________________________________
157AliAnalysisTaskJetV2::~AliAnalysisTaskJetV2()
158{
159 // destructor
f41baaab 160 if(fOutputList) {delete fOutputList; fOutputList = 0x0;}
161 if(fOutputListGood) {delete fOutputListGood; fOutputListGood = 0x0;}
162 if(fOutputListBad) {delete fOutputListBad; fOutputListBad = 0x0;}
163 if(fFitModulation) {delete fFitModulation; fFitModulation = 0x0;}
164 if(fHistSwap) {delete fHistSwap; fHistSwap = 0x0;}
165 if(fCentralityClasses) {delete fCentralityClasses; fCentralityClasses = 0x0;}
166 if(fExpectedRuns) {delete fExpectedRuns; fExpectedRuns = 0x0;}
167 if(fExpectedSemiGoodRuns) {delete fExpectedSemiGoodRuns; fExpectedSemiGoodRuns = 0x0;}
168 if(fFitControl) {delete fFitControl; fFitControl = 0x0;}
eae37c5c 169}
170//_____________________________________________________________________________
171void AliAnalysisTaskJetV2::ExecOnce()
172{
173 // Init the analysis
174 fLocalRho = new AliLocalRhoParameter(fLocalRhoName.Data(), 0);
175 if(fAttachToEvent) {
176 if(!(InputEvent()->FindListObject(fLocalRho->GetName()))) {
177 InputEvent()->AddObject(fLocalRho);
178 } else {
179 AliFatal(Form("%s: Container with name %s already present. Aborting", GetName(), fLocalRho->GetName()));
180 }
181 }
182 AliAnalysisTaskEmcalJet::ExecOnce(); // init the base class
183 AliAnalysisTaskEmcalJet::SetVzRange(-1.*fAbsVertexZ, fAbsVertexZ);
184 if(!GetJetContainer()) AliFatal(Form("%s: Couldn't find jet container. Aborting !", GetName()));
185}
186//_____________________________________________________________________________
f41baaab 187Bool_t AliAnalysisTaskJetV2::Notify()
188{
189 // determine the run number to see if the track and jet cuts should be refreshed for semi-good TPC runs
190 if(fRunNumber != InputEvent()->GetRunNumber()) {
191 fRunNumber = InputEvent()->GetRunNumber(); // set the current run number
192 if(fDebug > 0) printf("__FUNC__ %s > NEW RUNNUMBER DETECTED \n ", __func__);
193 // reset the cuts. should be a pointless operation except for the case where the run number changes
194 // from semi-good back to good on one node, which is not a likely scenario (unless trains will
195 // run as one masterjob)
196 AliAnalysisTaskEmcal::SetTrackPhiLimits(-10., 10.);
197 switch (fAnalysisType) {
198 case kCharged: {
199 AliAnalysisTaskEmcalJet::SetJetPhiLimits(-10., 10.);
200 } break;
201 case kFull: {
202 AliAnalysisTaskEmcalJet::SetJetPhiLimits(1.405 + GetJetRadius(), 3.135 - GetJetRadius());
203 } break;
204 default: break;
205 }
206 if(fCachedRho) { // if there's a cached rho, it's the default, so switch back
207 if(fDebug > 0) printf("__FUNC__ %s > replacing rho with cached rho \n ", __func__);
208 fRho = fCachedRho; // reset rho back to cached value. again, should be pointless
209 }
210 Bool_t flaggedAsSemiGood(kFALSE); // not flagged as anything
211 for(Int_t i(0); i < fExpectedSemiGoodRuns->GetSize(); i++) {
212 if(fExpectedSemiGoodRuns->At(i) == fRunNumber) { // run is semi-good
213 if(fDebug > 0) printf("__FUNC__ %s > semi-good tpc run detected, adjusting acceptance \n ", __func__);
214 flaggedAsSemiGood = kTRUE;
215 switch (fAnalysisType) {
216 // for full jets the jet acceptance does not have to be changed as emcal does not
217 // cover the tpc low voltage readout strips
218 case kCharged: {
219 AliAnalysisTaskEmcalJet::SetJetPhiLimits(fSemiGoodJetMinPhi, fSemiGoodJetMaxPhi); // just an acceptance cut, jets are obtained from full azimuth, so no edge effects
220 } break;
221 default: break;
222 }
223 AliAnalysisTaskEmcal::SetTrackPhiLimits(fSemiGoodTrackMinPhi, fSemiGoodTrackMaxPhi); // only affects vn extraction, NOT jet finding
224 // for semi-good runs, also try to get the 'small rho' estimate, if it is available
225 AliRhoParameter* tempRho(dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fNameSmallRho.Data())));
226 if(tempRho) {
227 if(fDebug > 0) printf("__FUNC__ %s > switching to small rho, caching normal rho \n ", __func__);
228 fHistAnalysisSummary->SetBinContent(54, 1.); // bookkeep the fact that small rho is used
229 fCachedRho = fRho; // cache the original rho ...
230 fRho = tempRho; // ... and use the small rho
231 }
232 }
233 }
234 if(!flaggedAsSemiGood) {
235 // in case the run is not a semi-good run, check if it is recognized as another run
236 // only done to catch unexpected runs
237 for(Int_t i(0); i < fExpectedRuns->GetSize(); i++) {
238 if(fExpectedRuns->At(i) == fRunNumber) break; // run is known, break the loop else store the number in a random bin
239 fHistUndeterminedRunQA->SetBinContent(TMath::Nint(10.*gRandom->Uniform(0.,.9))+1, fRunNumber);
240 }
241 fHistAnalysisSummary->SetBinContent(53, 1.); // bookkeep which rho estimate is used
242 }
243 }
244 return kTRUE;
245}
246//_____________________________________________________________________________
eae37c5c 247Bool_t AliAnalysisTaskJetV2::InitializeAnalysis()
248{
249 // initialize the anaysis
250 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
251 // if not set, estimate the number of cones that would fit into the selected acceptance
252 if(fMaxCones <= 0) fMaxCones = TMath::CeilNint((TMath::Abs(GetJetContainer()->GetJetEtaMax()-GetJetContainer()->GetJetEtaMin())*TMath::Abs(GetJetContainer()->GetJetPhiMax()-GetJetContainer()->GetJetPhiMin()))/(TMath::Pi()*GetJetRadius()*GetJetRadius()));
253 // manually 'override' the default acceptance cuts of the emcal framework (use with caution)
254 if(fMinDisanceRCtoLJ==0) fMinDisanceRCtoLJ = GetJetRadius();
255 if(dynamic_cast<AliAODEvent*>(InputEvent())) fDataType = kAOD; // determine the datatype
256 else if(dynamic_cast<AliESDEvent*>(InputEvent())) fDataType = kESD;
257 fHistAnalysisSummary->SetBinContent(36, (int)fDataType);
258 if(!fRandom) fRandom = new TRandom3(0); // set randomizer and random seed
259 switch (fFitModulationType) {
260 case kNoFit : { SetModulationFit(new TF1("fix_kNoFit", "[0]", 0, TMath::TwoPi())); } break;
261 case kV2 : {
262 SetModulationFit(new TF1("fit_kV2", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi()));
263 fFitModulation->SetParameter(0, 0.); // normalization
264 fFitModulation->SetParameter(3, 0.2); // v2
265 fFitModulation->FixParameter(1, 1.); // constant
266 fFitModulation->FixParameter(2, 2.); // constant
267 } break;
268 case kV3: {
269 SetModulationFit(new TF1("fit_kV3", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi()));
270 fFitModulation->SetParameter(0, 0.); // normalization
271 fFitModulation->SetParameter(3, 0.2); // v3
272 fFitModulation->FixParameter(1, 1.); // constant
273 fFitModulation->FixParameter(2, 3.); // constant
274 } break;
275 default : { // for the combined fit, the 'direct fourier series' or the user supplied vn values we use v2 and v3
276 SetModulationFit(new TF1("fit_kCombined", "[0]*([1]+[2]*([3]*TMath::Cos([2]*(x-[4]))+[7]*TMath::Cos([5]*(x-[6]))))", 0, TMath::TwoPi()));
277 fFitModulation->SetParameter(0, 0.); // normalization
278 fFitModulation->SetParameter(3, 0.2); // v2
279 fFitModulation->FixParameter(1, 1.); // constant
280 fFitModulation->FixParameter(2, 2.); // constant
281 fFitModulation->FixParameter(5, 3.); // constant
282 fFitModulation->SetParameter(7, 0.2); // v3
283 } break;
284 }
285 switch (fRunModeType) {
286 case kGrid : { fFitModulationOptions += "N0"; } break;
287 default : break;
288 }
289 FillAnalysisSummaryHistogram();
290 return kTRUE;
291}
292//_____________________________________________________________________________
293TH1F* AliAnalysisTaskJetV2::BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c, Bool_t append)
294{
295 // book a TH1F and connect it to the output container
296 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
297 if(fReduceBinsXByFactor > 0 ) bins = TMath::Nint(bins/fReduceBinsXByFactor);
298 if(!fOutputList) return 0x0;
299 TString title(name);
300 if(c!=-1) { // format centrality dependent histograms accordingly
301 name = Form("%s_%i", name, c);
302 title += Form("_%i-%i", (int)(fCentralityClasses->At(c)), (int)(fCentralityClasses->At((1+c))));
303 }
304 title += Form(";%s;[counts]", x);
305 TH1F* histogram = new TH1F(name, title.Data(), bins, min, max);
306 histogram->Sumw2();
307 if(append) fOutputList->Add(histogram);
308 return histogram;
309}
310//_____________________________________________________________________________
311TH2F* AliAnalysisTaskJetV2::BookTH2F(const char* name, const char* x, const char*y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t c, Bool_t append)
312{
313 // book a TH2F and connect it to the output container
314 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
315 if(fReduceBinsXByFactor > 0 ) binsx = TMath::Nint(binsx/fReduceBinsXByFactor);
316 if(fReduceBinsYByFactor > 0 ) binsy = TMath::Nint(binsy/fReduceBinsYByFactor);
317 if(!fOutputList) return 0x0;
318 TString title(name);
319 if(c!=-1) { // format centrality dependent histograms accordingly
320 name = Form("%s_%i", name, c);
321 title += Form("_%i-%i", (int)fCentralityClasses->At(c), (int)(fCentralityClasses->At((1+c))));
322 }
323 title += Form(";%s;%s", x, y);
324 TH2F* histogram = new TH2F(name, title.Data(), binsx, minx, maxx, binsy, miny, maxy);
325 histogram->Sumw2();
326 if(append) fOutputList->Add(histogram);
327 return histogram;
328}
329//_____________________________________________________________________________
330void AliAnalysisTaskJetV2::UserCreateOutputObjects()
331{
332 // create output objects. also initializes some default values in case they aren't
333 // loaded via the AddTask macro
334 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
335 fOutputList = new TList();
336 fOutputList->SetOwner(kTRUE);
337 if(!fCentralityClasses) { // classes must be defined at this point
338 Double_t c[] = {0., 20., 40., 60., 80., 100.};
339 fCentralityClasses = new TArrayD(sizeof(c)/sizeof(c[0]), c);
340 }
341 if(!fExpectedRuns) { // expected runs must be defined at this point
342 Int_t r[] = {167813, 167988, 168066, 168068, 168069, 168076, 168104, 168212, 168311, 168322, 168325, 168341, 168361, 168362, 168458, 168460, 168461, 168992, 169091, 169094, 169138, 169143, 169167, 169417, 169835, 169837, 169838, 169846, 169855, 169858, 169859, 169923, 169956, 170027, 170036, 170081, /* up till here original good TPC list */169975, 169981, 170038, 170040, 170083, 170084, 170085, 170088, 170089, 170091, 170152, 170155, 170159, 170163, 170193, 170195, 170203, 170204, 170205, 170228, 170230, 170264, 170268, 170269, 170270, 170306, 170308, 170309, /* original semi-good tpc list */169415, 169411, 169035, 168988, 168984, 168826, 168777, 168512, 168511, 168467, 168464, 168342, 168310, 168115, 168108, 168107, 167987, 167915, 167903, /*new runs, good according to RCT */ 169238, 169160, 169156, 169148, 169145, 169144 /* run swith missing OROC 8 but seem ok in QA */};
343 fExpectedRuns = new TArrayI(sizeof(r)/sizeof(r[0]), r);
344 }
345 if(!fExpectedSemiGoodRuns) {
346 Int_t r[] = {169975, 169981, 170038, 170040, 170083, 170084, 170085, 170088, 170089, 170091, 170152, 170155, 170159, 170163, 170193, 170195, 170203, 170204, 170205, 170228, 170230, 170264, 170268, 170269, 170270, 170306, 170308, 170309};
347 fExpectedSemiGoodRuns = new TArrayI(sizeof(r)/sizeof(r[0]), r);
348 }
349 // global QA
350 fHistCentrality = BookTH1F("fHistCentrality", "centrality", 102, -2, 100);
351 fHistVertexz = BookTH1F("fHistVertexz", "vertex z (cm)", 100, -12, 12);
352
353 // pico track and emcal cluster kinematics
354 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i++) {
355 fHistPicoTrackPt[i] = BookTH1F("fHistPicoTrackPt", "p_{t} [GeV/c]", 100, 0, 100, i);
356 fHistPicoTrackMult[i] = BookTH1F("fHistPicoTrackMult", "multiplicity", 100, 0, 5000, i);
357 if(fFillQAHistograms) {
358 fHistPicoCat1[i] = BookTH2F("fHistPicoCat1", "#eta", "#phi", 50, -1, 1, 50, 0, TMath::TwoPi(), i);
359 fHistPicoCat2[i] = BookTH2F("fHistPicoCat2", "#eta", "#phi", 50, -1, 1, 50, 0, TMath::TwoPi(), i);
360 fHistPicoCat3[i] = BookTH2F("fHistPicoCat3", "#eta", "#phi", 50, -1, 1, 50, 0, TMath::TwoPi(), i);
361 if(fAnalysisType == AliAnalysisTaskJetV2::kFull) {
362 fHistClusterPt[i] = BookTH1F("fHistClusterPt", "p_{t} [GeV/c]", 100, 0, 100, i);
363 fHistClusterEtaPhi[i] = BookTH2F("fHistClusterEtaPhi", "#eta", "#phi", 100, -1., 1., 100, 0, TMath::TwoPi(), i);
364 fHistClusterEtaPhiWeighted[i] = BookTH2F("fHistClusterEtaPhiWeighted", "#eta", "#phi", 100, -1., 1., 100, 0, TMath::TwoPi(), i);
365 }
366 }
367 }
368
369 if(fFillQAHistograms) {
370 // event plane estimates and quality
371 fHistPsiControl = new TProfile("fHistPsiControl", "fHistPsiControl", 10, 0, 10);
372 fHistPsiControl->Sumw2();
373 fHistPsiSpread = new TProfile("fHistPsiSpread", "fHistPsiSpread", 4, 0, 4);
374 fHistPsiSpread->Sumw2();
375 fHistPsiControl->GetXaxis()->SetBinLabel(1, "<#Psi_{2, VZEROA}>");
376 fHistPsiControl->GetXaxis()->SetBinLabel(2, "<#Psi_{2, VZEROC}>");
377 fHistPsiControl->GetXaxis()->SetBinLabel(3, "<#Psi_{2, TPC}>");
378 fHistPsiControl->GetXaxis()->SetBinLabel(4, "<#Psi_{2, TPC, #eta < 0}>");
379 fHistPsiControl->GetXaxis()->SetBinLabel(5, "<#Psi_{2, TPC, #eta > 0}>");
380 fHistPsiControl->GetXaxis()->SetBinLabel(6, "<#Psi_{3, VZEROA}>");
381 fHistPsiControl->GetXaxis()->SetBinLabel(7, "<#Psi_{3, VZEROC}>");
382 fHistPsiControl->GetXaxis()->SetBinLabel(8, "<#Psi_{3, TPC}>");
383 fHistPsiControl->GetXaxis()->SetBinLabel(9, "<#Psi_{3, TPC, #eta < 0}>");
384 fHistPsiControl->GetXaxis()->SetBinLabel(10, "<#Psi_{3, TPC, #eta > 0}>");
385 fHistPsiSpread->GetXaxis()->SetBinLabel(1, "<#Psi_{2, VZEROA} - #Psi_{2, VZEROC}>");
386 fHistPsiSpread->GetXaxis()->SetBinLabel(2, "<#Psi_{2, VZEROC} - #Psi_{2, TPC}>");
387 fHistPsiSpread->GetXaxis()->SetBinLabel(3, "<#Psi_{2, VZEROC} - #Psi_{2, TPC}>");
388 fHistPsiSpread->GetXaxis()->SetBinLabel(4, "<#Psi_{2, TPC, #eta < 0} - #Psi_{2, TPC, #eta > 0}>");
389 fOutputList->Add(fHistPsiControl);
390 fOutputList->Add(fHistPsiSpread);
391 fHistPsiVZEROA = BookTH1F("fHistPsiVZEROA", "#Psi_{VZEROA}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
392 fHistPsiVZEROC = BookTH1F("fHistPsiVZEROC", "#Psi_{VZEROC}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
393 fHistPsiVZERO = BookTH1F("fHistPsiVZERO", "#Psi_{VZERO}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
394 fHistPsiTPC = BookTH1F("fHistPsiTPC", "#Psi_{TPC}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
395 fHistPsiVZEROAV0M = BookTH2F("fHistPsiVZEROAV0M", "V0M", "#Psi_{2, VZEROA}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
396 fHistPsiVZEROCV0M = BookTH2F("fHistPsiVZEROCV0M", "V0M", "#Psi_{2, VZEROC}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
397 fHistPsiVZEROVV0M = BookTH2F("fHistPsiVZEROV0M", "V0M", "#Psi_{2, VZERO}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
398 fHistPsiTPCiV0M = BookTH2F("fHistPsiTPCV0M", "V0M", "#Psi_{2, TRK}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
399 fHistPsiVZEROATRK = BookTH2F("fHistPsiVZEROATRK", "TRK", "#Psi_{2, VZEROA}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
400 fHistPsiVZEROCTRK = BookTH2F("fHistPsiVZEROCTRK", "TRK", "#Psi_{2, VZEROC}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
401 fHistPsiVZEROTRK = BookTH2F("fHistPsiVZEROTRK", "TRK", "#Psi_{2, VZERO}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
402 fHistPsiTPCTRK = BookTH2F("fHistPsiTPCTRK", "TRK", "#Psi_{2, TRK}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
403 }
404 // background
405 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i ++) {
406 fHistRhoPackage[i] = BookTH1F("fHistRhoPackage", "#rho [GeV/c]", 100, 0, 150, i);
407 fHistRho[i] = BookTH1F("fHistRho", "#rho [GeV/c]", 100, 0, 150, i);
408 }
409 fHistRhoVsMult = BookTH2F("fHistRhoVsMult", "multiplicity", "#rho [GeV/c]", 100, 0, 4000, 100, 0, 250);
410 fHistRhoVsCent = BookTH2F("fHistRhoVsCent", "centrality", "#rho [GeV/c]", 100, 0, 100, 100, 0, 250);
411 fHistRhoAVsMult = BookTH2F("fHistRhoAVsMult", "multiplicity", "#rho * A (jet) [GeV/c]", 100, 0, 4000, 100, 0, 50);
412 fHistRhoAVsCent = BookTH2F("fHistRhoAVsCent", "centrality", "#rho * A (jet) [GeV/c]", 100, 0, 100, 100, 0, 50);
413
414 TString detector("");
415 switch (fDetectorType) {
416 case kTPC : detector+="TPC";
417 break;
418 case kVZEROA : detector+="VZEROA";
419 break;
420 case kVZEROC : detector+="VZEROC";
421 break;
422 case kVZEROComb : detector+="VZEROComb";
423 break;
424 default: break;
425 }
426 // delta pt distributions
427 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i ++) {
428 if(fFillQAHistograms) fHistRCPhiEta[i] = BookTH2F("fHistRCPhiEta", "#phi (RC)", "#eta (RC)", 40, 0, TMath::TwoPi(), 40, -1, 1, i);
429 fHistRhoVsRCPt[i] = BookTH2F("fHistRhoVsRCPt", "p_{t} (RC) [GeV/c]", "#rho * A (RC) [GeV/c]", 100, 0, 300, 100, 0, 350, i);
430 fHistRCPt[i] = BookTH1F("fHistRCPt", "p_{t} (RC) [GeV/c]", 130, -20, 150, i);
431 if(fFillQAHistograms) fHistRCPhiEtaExLJ[i] = BookTH2F("fHistRCPhiEtaExLJ", "#phi (RC)", "#eta (RC)", 40, 0, TMath::TwoPi(), 40, -1, 1, i);
432 fHistDeltaPtDeltaPhi2[i] = BookTH2F("fHistDeltaPtDeltaPhi2", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
433 fHistDeltaPtDeltaPhi2Rho0[i] = BookTH2F("fHistDeltaPtDeltaPhi2Rho0", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
434 fHistRhoVsRCPtExLJ[i] = BookTH2F("fHistRhoVsRCPtExLJ", "p_{t} (RC) [GeV/c]", "#rho * A (RC) [GeV/c]", 100, 0, 300, 100, 0, 350, i);
435 fHistRCPtExLJ[i] = BookTH1F("fHistRCPtExLJ", "p_{t} (RC) [GeV/c]", 130, -20, 150, i);
436 fHistDeltaPtDeltaPhi2ExLJ[i] = BookTH2F("fHistDeltaPtDeltaPhi2ExLJ", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
437 fHistDeltaPtDeltaPhi2ExLJRho0[i] = BookTH2F("fHistDeltaPtDeltaPhi2ExLJRho0", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
438 // jet histograms (after kinematic cuts)
439 fHistJetPtRaw[i] = BookTH1F("fHistJetPtRaw", "p_{t, jet} RAW [GeV/c]", 200, -50, 150, i);
440 fHistJetPt[i] = BookTH1F("fHistJetPt", "p_{t, jet} [GeV/c]", 350, -100, 250, i);
441 if(fFillQAHistograms) fHistJetEtaPhi[i] = BookTH2F("fHistJetEtaPhi", "#eta", "#phi", 100, -1, 1, 100, 0, TMath::TwoPi(), i);
442 fHistJetPtArea[i] = BookTH2F("fHistJetPtArea", "p_{t, jet} [GeV/c]", "Area", 175, -100, 250, 30, 0, 0.9, i);
443 fHistJetPtEta[i] = BookTH2F("fHistJetPtEta", "p_{t, jet} [GeV/c]", "Eta", 175, -100, 250, 30, -0.9, 0.9, i);
444 fHistJetPtConstituents[i] = BookTH2F("fHistJetPtConstituents", "p_{t, jet} [GeV/c]", "Area", 350, -100, 250, 60, 0, 150, i);
445 fHistJetEtaRho[i] = BookTH2F("fHistJetEtaRho", "#eta", "#rho", 100, -1, 1, 100, 0, 300, i);
446 // in plane and out of plane spectra
447 fHistJetPsi2Pt[i] = BookTH2F("fHistJetPsi2Pt", Form("#phi_{jet} - #Psi_{2, %s}", detector.Data()), "p_{t, jet} [GeV/c]", 40, 0., TMath::Pi(), 350, -100, 250, i);
448 fHistJetPsi2PtRho0[i] = BookTH2F("fHistJetPsi2PtRho0", Form("#phi_{jet} - #Psi_{2, %s}", detector.Data()), "p_{t, jet} [GeV/c]", 40, 0., TMath::Pi(), 350, -100, 250, i);
449 // profiles for all correlator permutations which are necessary to calculate each second and third order event plane resolution
450 fProfV2Resolution[i] = new TProfile(Form("fProfV2Resolution_%i", i), Form("fProfV2Resolution_%i", i), 11, -0.5, 10.5);
451 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(3, "<cos(2(#Psi_{VZEROA} - #Psi_{VZEROC}))>");
452 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(4, "<cos(2(#Psi_{VZEROC} - #Psi_{VZEROA}))>");
453 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(5, "<cos(2(#Psi_{VZEROA} - #Psi_{TPC}))>");
454 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(6, "<cos(2(#Psi_{TPC} - #Psi_{VZEROA}))>");
455 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(7, "<cos(2(#Psi_{VZEROC} - #Psi_{TPC}))>");
456 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(8, "<cos(2(#Psi_{TPC} - #Psi_{VZEROC}))>");
457 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(9, "<cos(2(#Psi_{VZERO} - #Psi_{TPC_A}))>");
458 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(10, "<cos(2(#Psi_{VZERO} - #Psi_{TPC_B}))>");
459 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(11, "<cos(2(#Psi_{TPC_A} - #Psi_{TPC_B}))>");
460 fOutputList->Add(fProfV2Resolution[i]);
461 fProfV3Resolution[i] = new TProfile(Form("fProfV3Resolution_%i", i), Form("fProfV3Resolution_%i", i), 11, -0.5, 10.5);
462 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(3, "<cos(3(#Psi_{VZEROA} - #Psi_{VZEROC}))>");
463 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(4, "<cos(3(#Psi_{VZEROC} - #Psi_{VZEROA}))>");
464 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(5, "<cos(3(#Psi_{VZEROA} - #Psi_{TPC}))>");
465 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(6, "<cos(3(#Psi_{TPC} - #Psi_{VZEROA}))>");
466 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(7, "<cos(3(#Psi_{VZEROC} - #Psi_{TPC}))>");
467 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(8, "<cos(3(#Psi_{TPC} - #Psi_{VZEROC}))>");
468 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(9, "<cos(3(#Psi_{VZERO} - #Psi_{TPC_A}))>");
469 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(10, "<cos(3(#Psi_{VZERO} - #Psi_{TPC_B}))>");
470 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(11, "<cos(3(#Psi_{TPC_A} - #Psi_{TPC_B}))>");
471 fOutputList->Add(fProfV3Resolution[i]);
472 }
473 // vn profile
474 Float_t temp[fCentralityClasses->GetSize()];
475 for(Int_t i(0); i < fCentralityClasses->GetSize(); i++) temp[i] = fCentralityClasses->At(i);
476 fProfV2 = new TProfile("fProfV2", "fProfV2", fCentralityClasses->GetSize()-1, temp);
477 fProfV3 = new TProfile("fProfV3", "fProfV3", fCentralityClasses->GetSize()-1, temp);
478 fOutputList->Add(fProfV2);
479 fOutputList->Add(fProfV3);
480 switch (fFitModulationType) {
481 case kQC2 : {
482 fProfV2Cumulant = new TProfile("fProfV2Cumulant", "fProfV2Cumulant", fCentralityClasses->GetSize()-1, temp);
483 fProfV3Cumulant = new TProfile("fProfV3Cumulant", "fProfV3Cumulant", fCentralityClasses->GetSize()-1, temp);
484 fOutputList->Add(fProfV2Cumulant);
485 fOutputList->Add(fProfV3Cumulant);
486 } break;
487 case kQC4 : {
488 fProfV2Cumulant = new TProfile("fProfV2Cumulant", "fProfV2Cumulant", fCentralityClasses->GetSize()-1, temp);
489 fProfV3Cumulant = new TProfile("fProfV3Cumulant", "fProfV3Cumulant", fCentralityClasses->GetSize()-1, temp);
490 fOutputList->Add(fProfV2Cumulant);
491 fOutputList->Add(fProfV3Cumulant);
492 } break;
493 default : break;
494 }
495 // for the histograms initialized below, binning is fixed to runnumbers or flags
496 fReduceBinsXByFactor = 1;
497 fReduceBinsYByFactor = 1;
498 if(fFillQAHistograms) {
499 fHistRunnumbersEta = new TH2F("fHistRunnumbersEta", "fHistRunnumbersEta", fExpectedRuns->GetSize()+1, -.5, fExpectedRuns->GetSize()+.5, 100, -1.1, 1.1);
500 fHistRunnumbersEta->Sumw2();
501 fOutputList->Add(fHistRunnumbersEta);
502 fHistRunnumbersPhi = new TH2F("fHistRunnumbersPhi", "fHistRunnumbersPhi", fExpectedRuns->GetSize()+1, -.5, fExpectedRuns->GetSize()+.5, 100, -0.2, TMath::TwoPi()+0.2);
503 fHistRunnumbersPhi->Sumw2();
504 fOutputList->Add(fHistRunnumbersPhi);
505 for(Int_t i(0); i < fExpectedRuns->GetSize(); i++) {
506 fHistRunnumbersPhi->GetXaxis()->SetBinLabel(i+1, Form("%i", fExpectedRuns->At(i)));
507 fHistRunnumbersEta->GetXaxis()->SetBinLabel(i+1, Form("%i", fExpectedRuns->At(i)));
508 }
509 fHistRunnumbersPhi->GetXaxis()->SetBinLabel(fExpectedRuns->GetSize()+1, "undetermined");
510 fHistRunnumbersEta->GetXaxis()->SetBinLabel(fExpectedRuns->GetSize()+1, "undetermined");
511 }
512 fHistAnalysisSummary = BookTH1F("fHistAnalysisSummary", "flag", 54, -0.5, 54.5);
513 fHistSwap = new TH1F("fHistSwap", "fHistSwap", 20, 0, TMath::TwoPi());
514 if(fUsePtWeight) fHistSwap->Sumw2();
515
516 if(fUserSuppliedV2) fOutputList->Add(fUserSuppliedV2);
517 if(fUserSuppliedV3) fOutputList->Add(fUserSuppliedV3);
518 if(fUserSuppliedR2) fOutputList->Add(fUserSuppliedR2);
519 if(fUserSuppliedR3) fOutputList->Add(fUserSuppliedR3);
520 // increase readability of output list
521 fOutputList->Sort();
522 // cdf and pdf of chisquare distribution
523 fHistPvalueCDF = BookTH1F("fHistPvalueCDF", "CDF #chi^{2}", 50, 0, 1);
524 fHistPvalueCDFCent = BookTH2F("fHistPvalueCDFCent", "centrality", "p-value", 40, 0, 100, 40, 0, 1);
525 fHistChi2Cent = BookTH2F("fHistChi2Cent", "centrality", "#tilde{#chi^{2}}", 100, 0, 100, 100, 0, 5);
526 fHistPChi2 = BookTH2F("fHistPChi2", "p-value", "#tilde{#chi^{2}}", 1000, 0, 1, 100, 0, 5);
527 fHistKolmogorovTest = BookTH1F("fHistKolmogorovTest", "KolmogorovTest", 50, 0, 1);
528 fHistKolmogorovTestCent = BookTH2F("fHistKolmogorovTestCent", "centrality", "Kolmogorov p", 40, 0, 100, 45, 0, 1);
529 fHistPvalueCDFROOT = BookTH1F("fHistPvalueCDFROOT", "CDF #chi^{2} ROOT", 50, 0, 1);
530 fHistPvalueCDFROOTCent = BookTH2F("fHistPvalueCDFROOTCent", "centrality", "p-value ROOT", 40, 0, 100, 45, 0, 1);
531 fHistChi2ROOTCent = BookTH2F("fHistChi2ROOTCent", "centrality", "#tilde{#chi^{2}}", 40, 0, 100, 45, 0, 5);
532 fHistPChi2Root = BookTH2F("fHistPChi2Root", "p-value", "#tilde{#chi^{2}} ROOT", 1000, 0, 1, 100, 0, 5);
533 fHistPKolmogorov = BookTH2F("fHistPKolmogorov", "p-value", "kolmogorov p",40, 0, 1, 40, 0, 1);
534 fHistRhoStatusCent = BookTH2F("fHistRhoStatusCent", "centrality", "status [-1=lin was better, 0=ok, 1 = failed]", 101, -1, 100, 3, -1.5, 1.5);
535 fHistUndeterminedRunQA = BookTH1F("fHistUndeterminedRunQA", "runnumber", 10, 0, 10);
536
537 PostData(1, fOutputList);
538
539 switch (fRunModeType) {
540 case kLocal : {
541 fOutputListGood = new TList();
542 fOutputListGood->SetOwner(kTRUE);
543 fOutputListBad = new TList();
544 fOutputListBad->SetOwner(kTRUE);
545 PostData(2, fOutputListGood);
546 PostData(3, fOutputListBad);
547 } break;
548 default: break;
549 }
550
551 // get the containers
552 fTracksCont = GetParticleContainer("Tracks");
553 fClusterCont = GetClusterContainer(0); // get the default cluster container
554 fJetsCont = GetJetContainer("Jets");
555}
556//_____________________________________________________________________________
557Bool_t AliAnalysisTaskJetV2::Run()
558{
559 // user exec: execute once for each event
560 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
561 if(!fTracks||!fJets||!fRho) return kFALSE;
562 if(!fLocalInit) fLocalInit = InitializeAnalysis();
563 // reject the event if expected data is missing
564 if(!PassesCuts(InputEvent())) return kFALSE;
565 fLeadingJet = GetLeadingJet(); // store the leading jet
566 // set the rho value
567 fLocalRho->SetVal(fRho->GetVal());
568 // [0][0] psi2a [1,0] psi2c
569 // [0][1] psi3a [1,1] psi3c
570 Double_t vzero[2][2];
571 CalculateEventPlaneVZERO(vzero);
572 /* for the combined vzero event plane
573 * [0] psi2 [1] psi3
574 * not fully implmemented yet, use with caution ! */
575 Double_t vzeroComb[2];
576 CalculateEventPlaneCombinedVZERO(vzeroComb);
577 // [0] psi2 [1] psi3
578 Double_t tpc[2];
579 CalculateEventPlaneTPC(tpc);
580 Double_t psi2(-1), psi3(-1);
581 // arrays which will hold the fit parameters
582 switch (fDetectorType) { // determine the detector type for the rho fit
583 case kTPC : { psi2 = tpc[0]; psi3 = tpc[1]; } break;
584 case kVZEROA : { psi2 = vzero[0][0]; psi3 = vzero[0][1]; } break;
585 case kVZEROC : { psi2 = vzero[1][0]; psi3 = vzero[1][1]; } break;
586 case kVZEROComb : { psi2 = vzeroComb[0]; psi3 = vzeroComb[1];} break;
587 default : break;
588 }
589 switch (fFitModulationType) { // do the fits
590 case kNoFit : {
591 switch (fCollisionType) {
592 case kPythia : { // background is zero for pp jets
593 fFitModulation->FixParameter(0, 0);
594 fLocalRho->SetVal(0);
595 } break;
596 default : {
597 fFitModulation->FixParameter(0, fLocalRho->GetVal());
598 } break;
599 }
600 } break;
601 case kV2 : { // only v2
602 if(CorrectRho(psi2, psi3)) {
603 fProfV2->Fill(fCent, fFitModulation->GetParameter(3));
604 if(fUserSuppliedR2) {
605 Double_t r(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
606 if(r > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r);
607 }
608 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
609 }
610 } break;
611 case kV3 : { // only v3
612 if(CorrectRho(psi2, psi3)) {
613 if(fUserSuppliedR3) {
614 Double_t r(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
615 if(r > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r);
616 }
617 fProfV3->Fill(fCent, fFitModulation->GetParameter(3));
618 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
619 }
620 } break;
621 case kQC2 : { // qc2 analysis
622 if(CorrectRho(psi2, psi3)) {
623 if(fUserSuppliedR2 && fUserSuppliedR3) {
624 // note for the qc method, resolution is REVERSED to go back to v2obs
625 Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
626 Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
627 if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)*r2);
628 if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)*r3);
629 }
630 if (fUsePtWeight) { // use weighted weights
631 Double_t dQCnM11 = (fNoEventWeightsForQC) ? 1. : QCnM11();
632 fProfV2->Fill(fCent, fFitModulation->GetParameter(3), dQCnM11);
633 fProfV3->Fill(fCent, fFitModulation->GetParameter(7), dQCnM11);
634 } else {
635 Double_t dQCnM = (fNoEventWeightsForQC) ? 2. : QCnM();
636 fProfV2->Fill(fCent, fFitModulation->GetParameter(3), dQCnM*(dQCnM-1));
637 fProfV3->Fill(fCent, fFitModulation->GetParameter(7), dQCnM*(dQCnM-1));
638 }
639 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
640 }
641 } break;
642 case kQC4 : {
643 if(CorrectRho(psi2, psi3)) {
644 if(fUserSuppliedR2 && fUserSuppliedR3) {
645 // note for the qc method, resolution is REVERSED to go back to v2obs
646 Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
647 Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
648 if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)*r2);
649 if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)*r3);
650 }
651 if (fUsePtWeight) { // use weighted weights
652 fProfV2->Fill(fCent, TMath::Power(fFitModulation->GetParameter(3),0.5)/*, QCnM1111()*/);
653 fProfV3->Fill(fCent, TMath::Power(fFitModulation->GetParameter(7),0.5)/*, QCnM1111()*/);
654 } else {
655 fProfV2->Fill(fCent, TMath::Power(fFitModulation->GetParameter(3),0.5)/*, QCnM()*(QCnM()-1)*(QCnM()-2)*(QCnM()-3)*/);
656 fProfV3->Fill(fCent, TMath::Power(fFitModulation->GetParameter(7),0.5)/*, QCnM()*(QCnM()-1)*(QCnM()-2)*(QCnM()-3)*/);
657 }
658 }
659 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
660 } break;
661 default : {
662 if(CorrectRho(psi2, psi3)) {
663 if(fUserSuppliedR2 && fUserSuppliedR3) {
664 Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
665 Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
666 if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r2);
667 if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)/r3);
668 }
669 fProfV2->Fill(fCent, fFitModulation->GetParameter(3));
670 fProfV3->Fill(fCent, fFitModulation->GetParameter(7));
671 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
672 }
673 } break;
674 }
675 // if all went well, update the local rho parameter
676 fLocalRho->SetLocalRho(fFitModulation);
677 // fill a number of histograms. event qa needs to be filled first as it also determines the runnumber for the track qa
678 if(fFillQAHistograms) FillQAHistograms(InputEvent());
679 if(fFillHistograms) FillHistogramsAfterSubtraction(psi2, vzero, vzeroComb, tpc);
680 // send the output to the connected output container
681 PostData(1, fOutputList);
682 switch (fRunModeType) {
683 case kLocal : {
684 PostData(2, fOutputListGood);
685 PostData(3, fOutputListBad);
686 } break;
687 default: break;
688 }
689
690 return kTRUE;
691}
692//_____________________________________________________________________________
693void AliAnalysisTaskJetV2::CalculateEventPlaneVZERO(Double_t vzero[2][2]) const
694{
695 // get the vzero event plane
696 if(fUseV0EventPlaneFromHeader) { // use the vzero from the header
697 Double_t a(0), b(0), c(0), d(0), e(0), f(0), g(0), h(0);
698 vzero[0][0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 2, a, b);
699 vzero[1][0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 2, c, d);
700 vzero[0][1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 3, e, f);
701 vzero[1][1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 3, g, h);
702 return;
703 }
704 // grab the vzero event plane without recentering
705 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
706 Double_t qxa2(0), qya2(0), qxc2(0), qyc2(0); // for psi2
707 Double_t qxa3(0), qya3(0), qxc3(0), qyc3(0); // for psi3
708 for(Int_t iVZERO(0); iVZERO < 64; iVZERO++) {
709 Double_t phi(TMath::PiOver4()*(.5+iVZERO%8)), /* eta(0), */ weight(InputEvent()->GetVZEROEqMultiplicity(iVZERO));
710 if(iVZERO<32) {
711 qxa2 += weight*TMath::Cos(2.*phi);
712 qya2 += weight*TMath::Sin(2.*phi);
713 qxa3 += weight*TMath::Cos(3.*phi);
714 qya3 += weight*TMath::Sin(3.*phi);
715 }
716 else {
717 qxc2 += weight*TMath::Cos(2.*phi);
718 qyc2 += weight*TMath::Sin(2.*phi);
719 qxc3 += weight*TMath::Cos(3.*phi);
720 qyc3 += weight*TMath::Sin(3.*phi);
721 }
722 }
723 vzero[0][0] = .5*TMath::ATan2(qya2, qxa2);
724 vzero[1][0] = .5*TMath::ATan2(qyc2, qxc2);
725 vzero[0][1] = (1./3.)*TMath::ATan2(qya3, qxa3);
726 vzero[1][1] = (1./3.)*TMath::ATan2(qyc3, qxc3);
727}
728//_____________________________________________________________________________
729void AliAnalysisTaskJetV2::CalculateEventPlaneTPC(Double_t* tpc)
730{
731 // grab the TPC event plane
732 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
733 fNAcceptedTracks = 0; // reset the track counter
734 Double_t qx2(0), qy2(0); // for psi2
735 Double_t qx3(0), qy3(0); // for psi3
736 if(fTracksCont) {
737 Float_t excludeInEta = -999;
738 if(fExcludeLeadingJetsFromFit > 0 ) { // remove the leading jet from ep estimate
739 if(fLeadingJet) excludeInEta = fLeadingJet->Eta();
740 }
741 for(Int_t iTPC(0); iTPC < fTracksCont->GetNEntries(); iTPC++) {
742 AliVParticle* track = fTracksCont->GetParticle(iTPC);
743 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
744 if(fExcludeLeadingJetsFromFit > 0 &&( (TMath::Abs(track->Eta() - excludeInEta) < GetJetContainer()->GetJetRadius()*fExcludeLeadingJetsFromFit ) || (TMath::Abs(track->Eta()) - GetJetContainer()->GetJetRadius() - GetJetContainer()->GetJetEtaMax() ) > 0 )) continue;
745 fNAcceptedTracks++;
746 qx2+= TMath::Cos(2.*track->Phi());
747 qy2+= TMath::Sin(2.*track->Phi());
748 qx3+= TMath::Cos(3.*track->Phi());
749 qy3+= TMath::Sin(3.*track->Phi());
750 }
751 }
752 tpc[0] = .5*TMath::ATan2(qy2, qx2);
753 tpc[1] = (1./3.)*TMath::ATan2(qy3, qx3);
754}
755//_____________________________________________________________________________
756void AliAnalysisTaskJetV2::CalculateEventPlaneCombinedVZERO(Double_t* comb) const
757{
758 // grab the combined vzero event plane
759 Double_t a(0), b(0), c(0), d(0);
760 comb[0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 10, 2, a, b);
761 comb[1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 10, 3, c, d);
762}
763//_____________________________________________________________________________
764void AliAnalysisTaskJetV2::CalculateEventPlaneResolution(Double_t vzero[2][2], Double_t* vzeroComb, Double_t* tpc)
765{
766 // fill the profiles for the resolution parameters
767 if(fDebug > 1) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
768 fProfV2Resolution[fInCentralitySelection]->Fill(2., TMath::Cos(2.*(vzero[0][0] - vzero[1][0])));
769 fProfV2Resolution[fInCentralitySelection]->Fill(3., TMath::Cos(2.*(vzero[1][0] - vzero[0][0])));
770 fProfV2Resolution[fInCentralitySelection]->Fill(4., TMath::Cos(2.*(vzero[0][0] - tpc[0])));
771 fProfV2Resolution[fInCentralitySelection]->Fill(5., TMath::Cos(2.*(tpc[0] - vzero[0][0])));
772 fProfV2Resolution[fInCentralitySelection]->Fill(6., TMath::Cos(2.*(vzero[1][0] - tpc[0])));
773 fProfV2Resolution[fInCentralitySelection]->Fill(7., TMath::Cos(2.*(tpc[0] - vzero[1][0])));
774 fProfV3Resolution[fInCentralitySelection]->Fill(2., TMath::Cos(3.*(vzero[0][0] - vzero[1][0])));
775 fProfV3Resolution[fInCentralitySelection]->Fill(3., TMath::Cos(3.*(vzero[1][0] - vzero[0][0])));
776 fProfV3Resolution[fInCentralitySelection]->Fill(4., TMath::Cos(3.*(vzero[0][0] - tpc[0])));
777 fProfV3Resolution[fInCentralitySelection]->Fill(5., TMath::Cos(3.*(tpc[0] - vzero[0][0])));
778 fProfV3Resolution[fInCentralitySelection]->Fill(6., TMath::Cos(3.*(vzero[1][0] - tpc[0])));
779 fProfV3Resolution[fInCentralitySelection]->Fill(7., TMath::Cos(3.*(tpc[0] - vzero[1][0])));
780 // for the resolution of the combined vzero event plane, use two tpc halves as uncorrelated subdetectors
781 Double_t qx2a(0), qy2a(0); // for psi2a, negative eta
782 Double_t qx3a(0), qy3a(0); // for psi3a, negative eta
783 Double_t qx2b(0), qy2b(0); // for psi2a, positive eta
784 Double_t qx3b(0), qy3b(0); // for psi3a, positive eta
785 if(fTracks) {
786 Int_t iTracks(fTracks->GetEntriesFast());
787 for(Int_t iTPC(0); iTPC < iTracks; iTPC++) {
788 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC));
789 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
790 if(track->Eta() < 0 ) {
791 qx2a+= TMath::Cos(2.*track->Phi());
792 qy2a+= TMath::Sin(2.*track->Phi());
793 qx3a+= TMath::Cos(3.*track->Phi());
794 qy3a+= TMath::Sin(3.*track->Phi());
795 } else if (track->Eta() > 0) {
796 qx2b+= TMath::Cos(2.*track->Phi());
797 qy2b+= TMath::Sin(2.*track->Phi());
798 qx3b+= TMath::Cos(3.*track->Phi());
799 qy3b+= TMath::Sin(3.*track->Phi());
800 }
801 }
802 }
803 Double_t tpca2(.5*TMath::ATan2(qy2a, qx2a));
804 Double_t tpca3((1./3.)*TMath::ATan2(qy3a, qx3a));
805 Double_t tpcb2(.5*TMath::ATan2(qy2b, qx2b));
806 Double_t tpcb3((1./3.)*TMath::ATan2(qy3b, qx3b));
807 fProfV2Resolution[fInCentralitySelection]->Fill(8., TMath::Cos(2.*(vzeroComb[0] - tpca2)));
808 fProfV2Resolution[fInCentralitySelection]->Fill(9., TMath::Cos(2.*(vzeroComb[0] - tpcb2)));
809 fProfV2Resolution[fInCentralitySelection]->Fill(10., TMath::Cos(2.*(tpca2 - tpcb2)));
810 fProfV3Resolution[fInCentralitySelection]->Fill(8., TMath::Cos(3.*(vzeroComb[1] - tpca3)));
811 fProfV3Resolution[fInCentralitySelection]->Fill(9., TMath::Cos(3.*(vzeroComb[1] - tpcb3)));
812 fProfV3Resolution[fInCentralitySelection]->Fill(10., TMath::Cos(3.*(tpca3 - tpcb3)));
813}
814//_____________________________________________________________________________
815void AliAnalysisTaskJetV2::CalculateRandomCone(Float_t &pt, Float_t &eta, Float_t &phi,
816 AliParticleContainer* tracksCont, AliClusterContainer* clusterCont, AliEmcalJet* jet) const
817{
818 // get a random cone
819 if(fDebug > 1) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
820 pt = 0; eta = 0; phi = 0;
821 Float_t etaJet(999), phiJet(999), dJet(999); // no jet: same as jet very far away
822 if(jet) { // if a leading jet is given, use its kinematic properties to exclude it
823 etaJet = jet->Eta();
824 phiJet = jet->Phi();
825 }
826 // the random cone acceptance has to equal the jet acceptance
827 // this also insures safety when runnnig on the semi-good tpc runs for 11h data,
828 // where jet acceptance is adjusted to reduced acceptance - hence random cone acceptance as well
829 Float_t minPhi(GetJetContainer()->GetJetPhiMin()), maxPhi(GetJetContainer()->GetJetPhiMax());
830 if(maxPhi > TMath::TwoPi()) maxPhi = TMath::TwoPi();
831 if(minPhi < 0 ) minPhi = 0.;
832 // construct a random cone and see if it's far away enough from the leading jet
833 Int_t attempts(1000);
834 while(kTRUE) {
835 attempts--;
836 eta = gRandom->Uniform(GetJetContainer()->GetJetEtaMin(), GetJetContainer()->GetJetEtaMax());
837 phi = gRandom->Uniform(minPhi, maxPhi);
838
839 dJet = TMath::Sqrt((etaJet-eta)*(etaJet-eta)+(phiJet-phi)*(phiJet-phi));
840 if(dJet > fMinDisanceRCtoLJ) break;
841 else if (attempts == 0) {
842 printf(" > No random cone after 1000 tries, giving up ... !\n");
843 return;
844 }
845 }
846 // get the charged energy (if tracks are provided)
847 if(tracksCont) {
848 AliVParticle* track = tracksCont->GetNextAcceptParticle(0);
849 while(track) {
850 Float_t etaTrack(track->Eta()), phiTrack(track->Phi());
851 // get distance from cone
852 if(TMath::Abs(phiTrack-phi) > TMath::Abs(phiTrack - phi + TMath::TwoPi())) phiTrack+=TMath::TwoPi();
853 if(TMath::Abs(phiTrack-phi) > TMath::Abs(phiTrack - phi - TMath::TwoPi())) phiTrack-=TMath::TwoPi();
854 if(TMath::Sqrt(TMath::Abs((etaTrack-eta)*(etaTrack-eta)+(phiTrack-phi)*(phiTrack-phi))) <= GetJetRadius()) pt += track->Pt();
855 track = tracksCont->GetNextAcceptParticle();
856 }
857 }
858 // get the neutral energy (if clusters are provided)
859 if(clusterCont) {
860 AliVCluster* cluster = clusterCont->GetNextAcceptCluster(0);
861 while(cluster) {
862 TLorentzVector momentum;
863 cluster->GetMomentum(momentum, const_cast<Double_t*>(fVertex));
864 Float_t etaClus(momentum.Eta()), phiClus(momentum.Phi());
865 // get distance from cone
866 if(TMath::Abs(phiClus-phi) > TMath::Abs(phiClus - phi + TMath::TwoPi())) phiClus+=TMath::TwoPi();
867 if(TMath::Abs(phiClus-phi) > TMath::Abs(phiClus - phi - TMath::TwoPi())) phiClus-=TMath::TwoPi();
868 if(TMath::Sqrt(TMath::Abs((etaClus-eta)*(etaClus-eta)+(phiClus-phi)*(phiClus-phi))) <= GetJetRadius()) pt += momentum.Pt();
869 cluster = clusterCont->GetNextAcceptCluster();
870 }
871 }
872}
873//_____________________________________________________________________________
874Double_t AliAnalysisTaskJetV2::CalculateQC2(Int_t harm) {
875 // get the second order q-cumulant, a -999 return will be caught in the qa routine of CorrectRho
876 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
877 Double_t reQ(0), imQ(0), modQ(0), M11(0), M(0);
878 if(fUsePtWeight) { // for the weighted 2-nd order q-cumulant
879 QCnQnk(harm, 1, reQ, imQ); // get the weighted 2-nd order q-vectors
880 modQ = reQ*reQ+imQ*imQ; // get abs Q-squared
881 M11 = QCnM11(); // equals S2,1 - S1,2
882 return (M11 > 0) ? ((modQ - QCnS(1,2))/M11) : -999;
883 } // else return the non-weighted 2-nd order q-cumulant
884 QCnQnk(harm, 0, reQ, imQ); // get the non-weighted 2-nd order q-vectors
885 modQ = reQ*reQ+imQ*imQ; // get abs Q-squared
886 M = QCnM();
887 return (M > 1) ? (modQ - M)/(M*(M-1)) : -999;
888}
889//_____________________________________________________________________________
890Double_t AliAnalysisTaskJetV2::CalculateQC4(Int_t harm) {
891 // get the fourth order q-cumulant, a -999 return will be caught in the qa routine of CorrectRho
892 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
893 Double_t reQn1(0), imQn1(0), reQ2n2(0), imQ2n2(0), reQn3(0), imQn3(0), M1111(0), M(0);
894 Double_t a(0), b(0), c(0), d(0), e(0), f(0), g(0); // terms of the calculation
895 if(fUsePtWeight) { // for the weighted 4-th order q-cumulant
896 QCnQnk(harm, 1, reQn1, imQn1);
897 QCnQnk(harm*2, 2, reQ2n2, imQ2n2);
898 QCnQnk(harm, 3, reQn3, imQn3);
899 // fill in the terms ...
900 a = (reQn1*reQn1+imQn1*imQn1)*(reQn1*reQn1+imQn1*imQn1);
901 b = reQ2n2*reQ2n2 + imQ2n2*imQ2n2;
902 c = -2.*(reQ2n2*reQn1*reQn1-reQ2n2*imQn1*imQn1+2.*imQ2n2*reQn1*imQn1);
903 d = 8.*(reQn3*reQn1+imQn3*imQn1);
904 e = -4.*QCnS(1,2)*(reQn1*reQn1+imQn1*imQn1);
905 f = -6.*QCnS(1,4);
906 g = 2.*QCnS(2,2);
907 M1111 = QCnM1111();
908 return (M1111 > 0) ? (a+b+c+d+e+f+g)/M1111 : -999;
909 } // else return the unweighted case
910 Double_t reQn(0), imQn(0), reQ2n(0), imQ2n(0);
911 QCnQnk(harm, 0, reQn, imQn);
912 QCnQnk(harm*2, 0, reQ2n, imQ2n);
913 // fill in the terms ...
914 M = QCnM();
915 if(M < 4) return -999;
916 a = (reQn*reQn+imQn*imQn)*(reQn*reQn+imQn*imQn);
917 b = reQ2n*reQ2n + imQ2n*imQ2n;
918 c = -2.*(reQ2n*reQn*reQn-reQ2n*imQn*imQn+2.*imQ2n*reQn*imQn);
919 e = -4.*(M-2)*(reQn*reQn+imQn*imQn);
920 f = 2.*M*(M-3);
921 return (a+b+c+e+f)/(M*(M-1)*(M-2)*(M-3));
922}
923//_____________________________________________________________________________
924void AliAnalysisTaskJetV2::QCnQnk(Int_t n, Int_t k, Double_t &reQ, Double_t &imQ) {
925 // get the weighted n-th order q-vector, pass real and imaginary part as reference
926 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
927 if(!fTracks) return;
928 fNAcceptedTracksQCn = 0;
929 Int_t iTracks(fTracks->GetEntriesFast());
930 for(Int_t iTPC(0); iTPC < iTracks; iTPC++) {
931 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC));
932 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
933 fNAcceptedTracksQCn++;
934 // for the unweighted case, k equals zero and the weight doesn't contribute to the equation below
935 reQ += TMath::Power(track->Pt(), k) * TMath::Cos(((double)n)*track->Phi());
936 imQ += TMath::Power(track->Pt(), k) * TMath::Sin(((double)n)*track->Phi());
937 }
938}
939//_____________________________________________________________________________
940void AliAnalysisTaskJetV2::QCnDiffentialFlowVectors(
941 TClonesArray* pois, TArrayD* ptBins, Bool_t vpart, Double_t* repn, Double_t* impn,
942 Double_t *mp, Double_t *reqn, Double_t *imqn, Double_t* mq, Int_t n)
943{
944 // get unweighted differential flow vectors
945 Int_t iPois(pois->GetEntriesFast());
946 if(vpart) {
947 for(Int_t i(0); i < iPois; i++) {
948 for(Int_t ptBin(0); ptBin < ptBins->GetSize()-1; ptBin++) {
949 AliVTrack* poi = static_cast<AliVTrack*>(pois->At(i));
950 if(PassesCuts(poi)) {
951 if(poi->Pt() >= ptBins->At(ptBin) && poi->Pt() < ptBins->At(ptBin+1)) {
952 // fill the flow vectors assuming that all poi's are in the rp selection (true by design)
953 repn[ptBin]+=TMath::Cos(((double)n)*poi->Phi());
954 impn[ptBin]+=TMath::Sin(((double)n)*poi->Phi());
955 mp[ptBin]++;
956 reqn[ptBin]+=TMath::Cos(((double)n)*poi->Phi());
957 imqn[ptBin]+=TMath::Sin(((double)n)*poi->Phi());
958 mq[ptBin]++;
959 }
960 }
961 }
962 }
963 } else {
964 for(Int_t i(0); i < iPois; i++) {
965 for(Int_t ptBin(0); ptBin < ptBins->GetSize()-1; ptBin++) {
966 AliEmcalJet* poi = static_cast<AliEmcalJet*>(pois->At(i));
967 if(PassesCuts(poi)) {
968 Double_t pt(poi->Pt()-poi->Area()*fLocalRho->GetLocalVal(poi->Phi(), GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
969 if(pt >= ptBins->At(ptBin) && pt < ptBins->At(ptBin+1)) {
970 repn[ptBin]+=TMath::Cos(((double)n)*poi->Phi());
971 impn[ptBin]+=TMath::Sin(((double)n)*poi->Phi());
972 mp[ptBin]++; // qn isn't filled, no overlap between poi's and rp's
973 }
974 }
975 }
976 }
977 }
978}
979//_____________________________________________________________________________
980Double_t AliAnalysisTaskJetV2::QCnS(Int_t i, Int_t j) {
981 // get the weighted ij-th order autocorrelation correction
982 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
983 if(!fTracks || i <= 0 || j <= 0) return -999;
984 Int_t iTracks(fTracks->GetEntriesFast());
985 Double_t Sij(0);
986 for(Int_t iTPC(0); iTPC < iTracks; iTPC++) {
987 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC));
988 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
989 Sij+=TMath::Power(track->Pt(), j);
990 }
991 return TMath::Power(Sij, i);
992}
993//_____________________________________________________________________________
994Double_t AliAnalysisTaskJetV2::QCnM() {
995 // get multiplicity for unweighted q-cumulants. function QCnQnk should be called first
996 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
997 return (Double_t) fNAcceptedTracksQCn;
998}
999//_____________________________________________________________________________
1000Double_t AliAnalysisTaskJetV2::QCnM11() {
1001 // get multiplicity weights for the weighted two particle cumulant
1002 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1003 return (QCnS(2,1) - QCnS(1,2));
1004}
1005//_____________________________________________________________________________
1006Double_t AliAnalysisTaskJetV2::QCnM1111() {
1007 // get multiplicity weights for the weighted four particle cumulant
1008 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1009 return (QCnS(4,1)-6*QCnS(1,2)*QCnS(2,1)+8*QCnS(1,3)*QCnS(1,1)+3*QCnS(2,2)-6*QCnS(1,4));
1010}
1011//_____________________________________________________________________________
1012Bool_t AliAnalysisTaskJetV2::QCnRecovery(Double_t psi2, Double_t psi3) {
1013 // decides how to deal with the situation where c2 or c3 is negative
1014 // returns kTRUE depending on whether or not a modulated rho is used for the jet background
1015 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1016 if(TMath::AreEqualAbs(fFitModulation->GetParameter(3), .0, 1e-10) && TMath::AreEqualAbs(fFitModulation->GetParameter(7), .0,1e-10)) {
1017 fFitModulation->SetParameter(7, 0);
1018 fFitModulation->SetParameter(3, 0);
1019 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1020 return kTRUE; // v2 and v3 have physical null values
1021 }
1022 switch (fQCRecovery) {
1023 case kFixedRho : { // roll back to the original rho
1024 fFitModulation->SetParameter(7, 0);
1025 fFitModulation->SetParameter(3, 0);
1026 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1027 return kFALSE; // rho is forced to be fixed
1028 }
1029 case kNegativeVn : {
1030 Double_t c2(fFitModulation->GetParameter(3));
1031 Double_t c3(fFitModulation->GetParameter(7));
1032 if( c2 < 0 ) c2 = -1.*TMath::Sqrt(-1.*c2);
1033 if( c3 < 0 ) c3 = -1.*TMath::Sqrt(-1.*c3);
1034 fFitModulation->SetParameter(3, c2);
1035 fFitModulation->SetParameter(7, c3);
1036 return kTRUE; // is this a physical quantity ?
1037 }
1038 case kTryFit : {
1039 fitModulationType tempType(fFitModulationType); // store temporarily
1040 fFitModulationType = kCombined;
1041 fFitModulation->SetParameter(7, 0);
1042 fFitModulation->SetParameter(3, 0);
1043 Bool_t pass(CorrectRho(psi2, psi3)); // do the fit and all quality checks
1044 fFitModulationType = tempType; // roll back for next event
1045 return pass;
1046 }
1047 default : return kFALSE;
1048 }
1049 return kFALSE;
1050}
1051//_____________________________________________________________________________
1052Bool_t AliAnalysisTaskJetV2::CorrectRho(Double_t psi2, Double_t psi3)
1053{
1054 // get rho' -> rho(phi)
1055 // two routines are available, both can be used with or without pt weights
1056 // [1] get vn from q-cumulants or as an integrated value from a user supplied histogram
1057 // in case of cumulants, both cumulants and vn values are stored. in both cases, v2 and v3
1058 // are expected. a check is performed to see if rho has no negative local minimum
1059 // for full description, see Phys. Rev. C 83, 044913
1060 // since the cn distribution has negative values, vn = sqrt(cn) can be imaginary sometimes
1061 // in this case one can either roll back to the 'original' rixed rho, do a fit for vn or take use
1062 // vn = - sqrt(|cn|)
1063 // [2] fitting a fourier expansion to the de/dphi distribution
1064 // the fit can be done with either v2, v3 or a combination.
1065 // in all cases, a cut can be made on the p-value of the chi-squared value of the fit
1066 // and a check can be performed to see if rho has no negative local minimum
1067 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1068 Int_t freeParams(2); // free parameters of the fit (for NDF)
1069 switch (fFitModulationType) { // for approaches where no fitting is required
1070 case kQC2 : {
1071 fFitModulation->FixParameter(4, psi2);
1072 fFitModulation->FixParameter(6, psi3);
1073 fFitModulation->FixParameter(3, CalculateQC2(2)); // set here with cn, vn = sqrt(cn)
1074 fFitModulation->FixParameter(7, CalculateQC2(3));
1075 // first fill the histos of the raw cumulant distribution
1076 if (fUsePtWeight) { // use weighted weights
1077 Double_t dQCnM11 = (fNoEventWeightsForQC) ? 1. : QCnM11();
1078 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3), dQCnM11);
1079 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7), dQCnM11);
1080 } else {
1081 Double_t dQCnM = (fNoEventWeightsForQC) ? 2. : QCnM();
1082 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3), dQCnM*(dQCnM-1));
1083 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7), dQCnM*(dQCnM-1));
1084 }
1085 // then see if one of the cn value is larger than zero and vn is readily available
1086 if(fFitModulation->GetParameter(3) > 0 && fFitModulation->GetParameter(7) > 0) {
1087 fFitModulation->FixParameter(3, TMath::Sqrt(fFitModulation->GetParameter(3)));
1088 fFitModulation->FixParameter(7, TMath::Sqrt(fFitModulation->GetParameter(7)));
1089 } else if (!QCnRecovery(psi2, psi3)) return kFALSE; // try to recover the cumulant, this will set v2 and v3
1090 if(fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { // general check
1091 fFitModulation->SetParameter(7, 0);
1092 fFitModulation->SetParameter(3, 0);
1093 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1094 return kFALSE;
1095 }
1096 return kTRUE;
1097 } break;
1098 case kQC4 : {
1099 fFitModulation->FixParameter(4, psi2);
1100 fFitModulation->FixParameter(6, psi3);
1101 fFitModulation->FixParameter(3, CalculateQC4(2)); // set here with cn, vn = sqrt(cn)
1102 fFitModulation->FixParameter(7, CalculateQC4(3));
1103 // first fill the histos of the raw cumulant distribution
1104 if (fUsePtWeight) { // use weighted weights
1105 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3)/*, QCnM1111()*/);
1106 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7)/*, QCnM1111()*/);
1107 } else {
1108 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3)/*, QCnM1111()*/);
1109 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7)/*, QCnM1111()*/);
1110 }
1111 // then see if one of the cn value is larger than zero and vn is readily available
1112 if(fFitModulation->GetParameter(3) > 0 && fFitModulation->GetParameter(7) > 0) {
1113 fFitModulation->FixParameter(3, TMath::Sqrt(fFitModulation->GetParameter(3)));
1114 fFitModulation->FixParameter(7, TMath::Sqrt(fFitModulation->GetParameter(7)));
1115 } else if (!QCnRecovery(psi2, psi3)) return kFALSE; // try to recover the cumulant, this will set v2 and v3
1116 if(fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { // general check
1117 fFitModulation->SetParameter(7, 0);
1118 fFitModulation->SetParameter(3, 0);
1119 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1120 return kFALSE;
1121 }
1122 } break;
1123 case kIntegratedFlow : {
1124 // use v2 and v3 values from an earlier iteration over the data
1125 fFitModulation->FixParameter(3, fUserSuppliedV2->GetBinContent(fUserSuppliedV2->GetXaxis()->FindBin(fCent)));
1126 fFitModulation->FixParameter(4, psi2);
1127 fFitModulation->FixParameter(6, psi3);
1128 fFitModulation->FixParameter(7, fUserSuppliedV3->GetBinContent(fUserSuppliedV3->GetXaxis()->FindBin(fCent)));
1129 if(fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) {
1130 fFitModulation->SetParameter(7, 0);
1131 fFitModulation->SetParameter(3, 0);
1132 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1133 return kFALSE;
1134 }
1135 return kTRUE;
1136 }
1137 default : break;
1138 }
1139 TString detector("");
1140 switch (fDetectorType) {
1141 case kTPC : detector+="TPC";
1142 break;
1143 case kVZEROA : detector+="VZEROA";
1144 break;
1145 case kVZEROC : detector+="VZEROC";
1146 break;
1147 case kVZEROComb : detector+="VZEROComb";
1148 break;
1149 default: break;
1150 }
1151 Int_t iTracks(fTracks->GetEntriesFast());
1152 Double_t excludeInEta = -999;
1153 Double_t excludeInPhi = -999;
1154 Double_t excludeInPt = -999;
1155 if(iTracks <= 0 || fLocalRho->GetVal() <= 0 ) return kFALSE; // no use fitting an empty event ...
1156 if(fExcludeLeadingJetsFromFit > 0 ) {
1157 if(fLeadingJet) {
1158 excludeInEta = fLeadingJet->Eta();
1159 excludeInPhi = fLeadingJet->Phi();
1160 excludeInPt = fLeadingJet->Pt();
1161 }
1162 }
1163 // check the acceptance of the track selection that will be used
1164 // if one uses e.g. semi-good tpc tracks, accepance in phi is reduced to 0 < phi < 4
1165 // the defaults (-10 < phi < 10) which accept all, are then overwritten
1166 Double_t lowBound(0.), upBound(TMath::TwoPi()); // bounds for fit
1167 if(GetParticleContainer()->GetParticlePhiMin() > lowBound) lowBound = GetParticleContainer()->GetParticlePhiMin();
1168 if(GetParticleContainer()->GetParticlePhiMax() < upBound) upBound = GetParticleContainer()->GetParticlePhiMax();
1169
1170 fHistSwap->Reset(); // clear the histogram
1171 TH1F _tempSwap; // on stack for quick access
1172 TH1F _tempSwapN; // on stack for quick access, bookkeeping histogram
1173 if(fRebinSwapHistoOnTheFly) {
1174 if(fNAcceptedTracks < 49) fNAcceptedTracks = 49; // avoid aliasing effects
1175 _tempSwap = TH1F("_tempSwap", "_tempSwap", TMath::CeilNint(TMath::Sqrt(fNAcceptedTracks)), lowBound, upBound);
1176 if(fUsePtWeightErrorPropagation) _tempSwapN = TH1F("_tempSwapN", "_tempSwapN", TMath::CeilNint(TMath::Sqrt(fNAcceptedTracks)), lowBound, upBound);
1177 if(fUsePtWeight) _tempSwap.Sumw2();
1178 }
1179 else _tempSwap = *fHistSwap; // now _tempSwap holds the desired histo
1180 // non poissonian error when using pt weights
1181 Double_t totalpts(0.), totalptsquares(0.), totalns(0.);
1182 for(Int_t i(0); i < iTracks; i++) {
1183 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1184 if(fExcludeLeadingJetsFromFit > 0 &&( (TMath::Abs(track->Eta() - excludeInEta) < GetJetContainer()->GetJetRadius()*fExcludeLeadingJetsFromFit ) || (TMath::Abs(track->Eta()) - GetJetContainer()->GetJetRadius() - GetJetContainer()->GetJetEtaMax() ) > 0 )) continue;
1185 if(!PassesCuts(track) || track->Pt() > fSoftTrackMaxPt || track->Pt() < fSoftTrackMinPt) continue;
1186 if(fUsePtWeight) {
1187 _tempSwap.Fill(track->Phi(), track->Pt());
1188 if(fUsePtWeightErrorPropagation) {
1189 totalpts += track->Pt();
1190 totalptsquares += track->Pt()*track->Pt();
1191 totalns += 1;
1192 _tempSwapN.Fill(track->Phi());
1193 }
1194 }
1195 else _tempSwap.Fill(track->Phi());
1196 }
1197 if(fUsePtWeight && fUsePtWeightErrorPropagation) {
1198 // in the case of pt weights overwrite the poissonian error estimate which is assigned by root by a more sophisticated appraoch
1199 // the assumption here is that the bin error will be dominated by the uncertainty in the mean pt in a bin and in the uncertainty
1200 // of the number of tracks in a bin, the first of which will be estimated from the sample standard deviation of all tracks in the
1201 // event, for the latter use a poissonian estimate. the two contrubitions are assumed to be uncorrelated
1202 if(totalns < 1) return kFALSE; // not one track passes the cuts
1203 for(Int_t l = 0; l < _tempSwap.GetNbinsX(); l++) {
1204 if(_tempSwapN.GetBinContent(l+1) == 0) {
1205 _tempSwap.SetBinContent(l+1,0);
1206 _tempSwap.SetBinError(l+1,0);
1207 }
1208 else {
1209 Double_t vartimesnsq = totalptsquares*totalns - totalpts*totalpts;
1210 Double_t variance = vartimesnsq/(totalns*(totalns-1.));
1211 Double_t SDOMSq = variance / _tempSwapN.GetBinContent(l+1);
1212 Double_t SDOMSqOverMeanSq = SDOMSq * _tempSwapN.GetBinContent(l+1) * _tempSwapN.GetBinContent(l+1) / (_tempSwapN.GetBinContent(l+1) * _tempSwapN.GetBinContent(l+1));
1213 Double_t poissonfrac = 1./_tempSwapN.GetBinContent(l+1);
1214 Double_t vartotalfrac = SDOMSqOverMeanSq + poissonfrac;
1215 Double_t vartotal = vartotalfrac * _tempSwap.GetBinContent(l+1) * _tempSwap.GetBinContent(l+1);
1216 if(vartotal > 0.0001) _tempSwap.SetBinError(l+1,TMath::Sqrt(vartotal));
1217 else {
1218 _tempSwap.SetBinContent(l+1,0);
1219 _tempSwap.SetBinError(l+1,0);
1220 }
1221 }
1222 }
1223 }
1224
1225 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1226 switch (fFitModulationType) {
1227 case kNoFit : {
1228 fFitModulation->FixParameter(0, fLocalRho->GetVal() );
1229 freeParams = 0;
1230 } break;
1231 case kV2 : {
1232 fFitModulation->FixParameter(4, psi2);
1233 freeParams = 1;
1234 } break;
1235 case kV3 : {
1236 fFitModulation->FixParameter(4, psi3);
1237 freeParams = 1;
1238 } break;
1239 case kCombined : {
1240 fFitModulation->FixParameter(4, psi2);
1241 fFitModulation->FixParameter(6, psi3);
1242 freeParams = 2;
1243 } break;
1244 case kFourierSeries : {
1245 // in this approach, an explicit calculation will be made of vn = sqrt(xn^2+yn^2)
1246 // where x[y] = Integrate[r(phi)cos[sin](n phi)dphi, 0, 2pi]
1247 Double_t cos2(0), sin2(0), cos3(0), sin3(0), sumPt(0);
1248 for(Int_t i(0); i < iTracks; i++) {
1249 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1250 if(!PassesCuts(track) || track->Pt() > fSoftTrackMaxPt || track->Pt() < fSoftTrackMinPt) continue;
1251 sumPt += track->Pt();
1252 cos2 += track->Pt()*TMath::Cos(2*PhaseShift(track->Phi()-psi2));
1253 sin2 += track->Pt()*TMath::Sin(2*PhaseShift(track->Phi()-psi2));
1254 cos3 += track->Pt()*TMath::Cos(3*PhaseShift(track->Phi()-psi3));
1255 sin3 += track->Pt()*TMath::Sin(3*PhaseShift(track->Phi()-psi3));
1256 }
1257 fFitModulation->SetParameter(3, TMath::Sqrt(cos2*cos2+sin2*sin2)/fLocalRho->GetVal());
1258 fFitModulation->SetParameter(4, psi2);
1259 fFitModulation->SetParameter(6, psi3);
1260 fFitModulation->SetParameter(7, TMath::Sqrt(cos3*cos3+sin3*sin3)/fLocalRho->GetVal());
1261 } break;
1262 default : break;
1263 }
1264 if(fRunToyMC) {
1265 // toy mc, just here to check procedure, azimuthal profile is filled from hypothesis so p-value distribution should be flat
1266 Int_t _bins = _tempSwap.GetXaxis()->GetNbins();
1267 TF1* _tempFit = new TF1("temp_fit_kCombined", "[0]*([1]+[2]*([3]*TMath::Cos([2]*(x-[4]))+[7]*TMath::Cos([5]*(x-[6]))))", 0, TMath::TwoPi());
1268 _tempFit->SetParameter(0, fFitModulation->GetParameter(0)); // normalization
1269 _tempFit->SetParameter(3, 0.1); // v2
1270 _tempFit->FixParameter(1, 1.); // constant
1271 _tempFit->FixParameter(2, 2.); // constant
1272 _tempFit->FixParameter(5, 3.); // constant
1273 _tempFit->FixParameter(4, fFitModulation->GetParameter(4));
1274 _tempFit->FixParameter(6, fFitModulation->GetParameter(6));
1275 _tempFit->SetParameter(7, 0.1); // v3
1276 _tempSwap.Reset(); // rese bin content
1277 for(int _binsI = 0; _binsI < _bins*_bins; _binsI++) _tempSwap.Fill(_tempFit->GetRandom());
1278 }
1279 _tempSwap.Fit(fFitModulation, fFitModulationOptions.Data(), "", lowBound, upBound);
1280 // the quality of the fit is evaluated from 1 - the cdf of the chi square distribution
1281 // three methods are available, all with their drawbacks. all are stored, one is selected to do the cut
1282 Int_t NDF(_tempSwap.GetXaxis()->GetNbins()-freeParams);
1283 if(NDF == 0) return kFALSE;
1284 Double_t CDF(1.-ChiSquareCDF(NDF, ChiSquare(_tempSwap, fFitModulation)));
1285 Double_t CDFROOT(1.-ChiSquareCDF(NDF, fFitModulation->GetChisquare()));
1286 Double_t CDFKolmogorov(KolmogorovTest(_tempSwap, fFitModulation));
1287 // fill the values and centrality correlation (redundant but easy on the eyes)
1288 fHistPvalueCDF->Fill(CDF);
1289 fHistPvalueCDFCent->Fill(fCent, CDF);
1290 fHistPvalueCDFROOT->Fill(CDFROOT);
1291 fHistPvalueCDFROOTCent->Fill(fCent, CDFROOT);
1292 fHistKolmogorovTest->Fill(CDFKolmogorov);
1293 fHistChi2ROOTCent->Fill(fCent, fFitModulation->GetChisquare()/((float)NDF));
1294 fHistChi2Cent->Fill(fCent, ChiSquare(_tempSwap, fFitModulation)/((float)NDF));
1295 fHistKolmogorovTestCent->Fill(fCent, CDFKolmogorov);
1296 fHistPChi2Root->Fill(CDFROOT, fFitModulation->GetChisquare()/((float)NDF));
1297 fHistPChi2->Fill(CDF, ChiSquare(_tempSwap, fFitModulation)/((float)NDF));
1298 fHistPKolmogorov->Fill(CDF, CDFKolmogorov);
1299
1300 // variable CDF is used for making cuts, so we fill it with the selected p-value
1301 switch (fFitGoodnessTest) {
1302 case kChi2ROOT : {
1303 CDF = CDFROOT;
1304 } break;
1305 case kChi2Poisson : break; // CDF is already CDF
1306 case kKolmogorov : {
1307 CDF = CDFKolmogorov;
1308 } break;
1309 default: break;
1310 }
1311
1312 if(fFitControl) {
1313 // as an additional quality check, see if fitting a control fit has a higher significance
1314 _tempSwap.Fit(fFitControl, fFitModulationOptions.Data(), "", lowBound, upBound);
1315 Double_t CDFControl(-1.);
1316 switch (fFitGoodnessTest) {
1317 case kChi2ROOT : {
1318 CDFControl = 1.-ChiSquareCDF(fFitControl->GetNDF(), fFitModulation->GetChisquare());
1319 } break;
1320 case kChi2Poisson : {
1321 CDFControl = 1.-ChiSquareCDF(fFitControl->GetNDF(), ChiSquare(_tempSwap, fFitModulation));
1322 } break;
1323 case kKolmogorov : {
1324 CDFControl = KolmogorovTest(_tempSwap, fFitControl);
1325 } break;
1326 default: break;
1327 }
1328 if(CDFControl > CDF) {
1329 CDF = -1.; // control fit is more significant, so throw out the 'old' fit
1330 fHistRhoStatusCent->Fill(fCent, -1);
1331 }
1332 }
1333 if(CDF >= fMinPvalue && CDF <= fMaxPvalue && ( fFitModulation->GetMinimum(0, TMath::TwoPi()) > 0)) { // fit quality. not that although with limited acceptance the fit is performed on just
1334 // part of phase space, the requirement that energy desntiy is larger than zero is applied
1335 // to the FULL spectrum
1336 fHistRhoStatusCent->Fill(fCent, 0.);
1337 // for LOCAL didactic purposes, save the best and the worst fits
1338 // this routine can produce a lot of output histograms (it's not memory 'safe') and will not work on GRID
1339 // since the output will become unmergeable (i.e. different nodes may produce conflicting output)
1340 switch (fRunModeType) {
1341 case kLocal : {
1342 if(fRandom->Uniform(0, 100) > fPercentageOfFits) break;
1343 static Int_t didacticCounterBest(0);
1344 TProfile* didacticProfile = (TProfile*)_tempSwap.Clone(Form("Fit_%i_1-CDF_%.3f_cen_%i_%s", didacticCounterBest, CDF, fInCentralitySelection, detector.Data()));
1345 TF1* didacticFit = (TF1*)fFitModulation->Clone(Form("fit_%i_CDF_%.3f_cen_%i_%s", didacticCounterBest, CDF, fInCentralitySelection, detector.Data()));
1346 switch(fFitModulationType) {
1347 case kCombined : {
1348 // to make a nice picture also plot the separate components (v2 and v3) of the fit
1349 // only done for cobined fit where there are actually components to split ...
1350 TF1* v0(new TF1("dfit_kV2", "[0]", 0, TMath::TwoPi()));
1351 v0->SetParameter(0, didacticFit->GetParameter(0)); // normalization
1352 v0->SetLineColor(kMagenta);
1353 v0->SetLineStyle(7);
1354 didacticProfile->GetListOfFunctions()->Add(v0);
1355 TF1* v2(new TF1("dfit_kV2", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi()));
1356 v2->SetParameter(0, didacticFit->GetParameter(0)); // normalization
1357 v2->SetParameter(3, didacticFit->GetParameter(3)); // v2
1358 v2->FixParameter(1, 1.); // constant
1359 v2->FixParameter(2, 2.); // constant
1360 v2->FixParameter(4, didacticFit->GetParameter(4)); // psi2
1361 v2->SetLineColor(kGreen);
1362 didacticProfile->GetListOfFunctions()->Add(v2);
1363 TF1* v3(new TF1("dfit_kV3", "[0]*([1]+[2]*[3]*TMath::Cos([5]*(x-[4])))", 0, TMath::TwoPi()));
1364 v3->SetParameter(0, didacticFit->GetParameter(0)); // normalization
1365 v3->SetParameter(3, didacticFit->GetParameter(7)); // v3
1366 v3->FixParameter(1, 1.); // constant
1367 v3->FixParameter(2, 2.); // constant
1368 v3->FixParameter(4, didacticFit->GetParameter(6)); // psi3
1369 v3->FixParameter(5, 3.); // constant
1370 v3->SetLineColor(kCyan);
1371 didacticProfile->GetListOfFunctions()->Add(v3);
1372 }
1373 default : break;
1374 }
1375 didacticProfile->GetListOfFunctions()->Add(didacticFit);
1376 didacticProfile->GetYaxis()->SetTitle("#frac{d #sum #it{p}_{T}}{d #varphi} [GeV/#it{c}]");
1377 didacticProfile->GetXaxis()->SetTitle("#varphi");
1378 fOutputListGood->Add(didacticProfile);
1379 didacticCounterBest++;
1380 TH2F* didacticSurface = BookTH2F(Form("surface_%s", didacticProfile->GetName()), "#phi", "#eta", 50, 0, TMath::TwoPi(), 50, -1, 1, -1, kFALSE);
1381 for(Int_t i(0); i < iTracks; i++) {
1382 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1383 if(PassesCuts(track)) {
1384 if(fUsePtWeight) didacticSurface->Fill(track->Phi(), track->Eta(), track->Pt());
1385 else didacticSurface->Fill(track->Phi(), track->Eta());
1386 }
1387 }
1388 if(fExcludeLeadingJetsFromFit) { // visualize the excluded region
1389 TF2 *f2 = new TF2(Form("%s_LJ", didacticSurface->GetName()),"[0]*TMath::Gaus(x,[1],[2])*TMath::Gaus(y,[3],[4])", 0, TMath::TwoPi(), -1, 1);
1390 f2->SetParameters(excludeInPt/3.,excludeInPhi,.1,excludeInEta,.1);
1391 didacticSurface->GetListOfFunctions()->Add(f2);
1392 }
1393 fOutputListGood->Add(didacticSurface);
1394 } break;
1395 default : break;
1396 }
1397 } else { // if the fit is of poor quality revert to the original rho estimate
1398 switch (fRunModeType) { // again see if we want to save the fit
1399 case kLocal : {
1400 static Int_t didacticCounterWorst(0);
1401 if(fRandom->Uniform(0, 100) > fPercentageOfFits) break;
1402 TProfile* didacticProfile = (TProfile*)_tempSwap.Clone(Form("Fit_%i_1-CDF_%.3f_cen_%i_%s", didacticCounterWorst, CDF, fInCentralitySelection, detector.Data() ));
1403 TF1* didacticFit = (TF1*)fFitModulation->Clone(Form("fit_%i_p_%.3f_cen_%i_%s", didacticCounterWorst, CDF, fInCentralitySelection, detector.Data()));
1404 didacticProfile->GetListOfFunctions()->Add(didacticFit);
1405 fOutputListBad->Add(didacticProfile);
1406 didacticCounterWorst++;
1407 } break;
1408 default : break;
1409 }
1410 switch (fFitModulationType) {
1411 case kNoFit : break; // nothing to do
1412 case kCombined : fFitModulation->SetParameter(7, 0); // no break
1413 case kFourierSeries : fFitModulation->SetParameter(7, 0); // no break
1414 default : { // needs to be done if there was a poor fit
1415 fFitModulation->SetParameter(3, 0);
1416 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1417 } break;
1418 }
1419 if(CDF > -.5) fHistRhoStatusCent->Fill(fCent, 1.);
1420 return kFALSE; // return false if the fit is rejected
1421 }
1422 return kTRUE;
1423}
1424//_____________________________________________________________________________
1425Bool_t AliAnalysisTaskJetV2::PassesCuts(AliVEvent* event)
1426{
1427 // event cuts
1428 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 1429 if(!event || !AliAnalysisTaskEmcal::IsEventSelected()) return kFALSE;
1430 if(TMath::Abs(InputEvent()->GetPrimaryVertex()->GetZ()) > 10.) return kFALSE;
1431 // aod and esd specific checks
1432 switch (fDataType) {
1433 case kESD: {
1434 AliESDEvent* esdEvent = static_cast<AliESDEvent*>(InputEvent());
1435 if( (!esdEvent) || (TMath::Abs(esdEvent->GetPrimaryVertexSPD()->GetZ() - esdEvent->GetPrimaryVertex()->GetZ()) > .5) ) return kFALSE;
1436 } break;
1437 case kAOD: {
1438 AliAODEvent* aodEvent = static_cast<AliAODEvent*>(InputEvent());
1439 if( (!aodEvent) || (TMath::Abs(aodEvent->GetPrimaryVertexSPD()->GetZ() - aodEvent->GetPrimaryVertex()->GetZ()) > .5) ) return kFALSE;
1440 } break;
1441 default: break;
1442 }
1443 fCent = InputEvent()->GetCentrality()->GetCentralityPercentile("V0M");
1444 if(fCent <= fCentralityClasses->At(0) || fCent >= fCentralityClasses->At(fCentralityClasses->GetSize()-1) || TMath::Abs(fCent-InputEvent()->GetCentrality()->GetCentralityPercentile("TRK")) > 5.) return kFALSE;
1445 // determine centrality class
1446 fInCentralitySelection = -1;
1447 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i++) {
1448 if(fCent >= fCentralityClasses->At(i) && fCent <= fCentralityClasses->At(1+i)) {
1449 fInCentralitySelection = i;
1450 break; }
1451 }
1452 if(fInCentralitySelection<0) return kFALSE; // should be null op
a008f846 1453/* if(fExplicitOutlierCut == 2010 || fExplicitOutlierCut == 2011) {
eae37c5c 1454 if(!PassesCuts(fExplicitOutlierCut)) return kFALSE;
a008f846 1455 }*/
eae37c5c 1456 // see if input containers are filled
1457 if(fTracks->GetEntries() < 1) return kFALSE;
1458 if(fRho->GetVal() <= 0 ) return kFALSE;
1459 if(fAnalysisType == AliAnalysisTaskJetV2::kFull && !fClusterCont) return kFALSE;
1460 return kTRUE;
1461}
1462//_____________________________________________________________________________
a008f846 1463/*Bool_t AliAnalysisTaskJetV2::PassesCuts(Int_t year)
eae37c5c 1464{
1465 // additional centrality cut based on relation between tpc and global multiplicity
1466 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1467 AliAODEvent* event(dynamic_cast<AliAODEvent*>(InputEvent()));
1468 if(!event) return kFALSE;
1469 Int_t multTPC(0), multGlob(0), nTracks(InputEvent()->GetNumberOfTracks());
1470 for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
1471 AliAODTrack* track = event->GetTrack(iTracks);
1472 if(!track) continue;
1473 if (!track || track->Pt() < .2 || track->Pt() > 5.0 || TMath::Abs(track->Eta()) > .8 || track->GetTPCNcls() < 70 || !track->GetDetPid() || track->GetDetPid()->GetTPCsignal() < 10.0) continue; // general quality cut
1474 if (track->TestFilterBit(1) && track->Chi2perNDF() > 0.2) multTPC++;
1475 if (!track->TestFilterBit(16) || track->Chi2perNDF() < 0.1) continue;
1476 Double_t b[2] = {-99., -99.};
1477 Double_t bCov[3] = {-99., -99., -99.};
1478 AliAODTrack copy(*track);
1479 if (copy.PropagateToDCA(event->GetPrimaryVertex(), event->GetMagneticField(), 100., b, bCov) && TMath::Abs(b[0]) < 0.3 && TMath::Abs(b[1]) < 0.3) multGlob++;
1480 }
1481 if(year == 2010 && multTPC > (-40.3+1.22*multGlob) && multTPC < (32.1+1.59*multGlob)) return kTRUE;
1482 if(year == 2011 && multTPC > (-36.73 + 1.48*multGlob) && multTPC < (62.87 + 1.78*multGlob)) return kTRUE;
1483 return kFALSE;
a008f846 1484}*/
eae37c5c 1485//_____________________________________________________________________________
1486void AliAnalysisTaskJetV2::FillHistogramsAfterSubtraction(Double_t psi2, Double_t vzero[2][2], Double_t* vzeroComb, Double_t* tpc)
1487{
1488 // fill histograms
1489 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1490 FillTrackHistograms();
1491 if(fAnalysisType == AliAnalysisTaskJetV2::kFull) FillClusterHistograms();
1492 FillJetHistograms(psi2);
1493 if(fFillQAHistograms) FillEventPlaneHistograms(vzero, vzeroComb, tpc);
1494 FillRhoHistograms();
1495 FillDeltaPtHistograms(psi2);
1496}
1497//_____________________________________________________________________________
1498void AliAnalysisTaskJetV2::FillTrackHistograms() const
1499{
1500 // fill track histograms
1501 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1502 Int_t iTracks(fTracks->GetEntriesFast()), iAcceptedTracks(0);
1503 for(Int_t i(0); i < iTracks; i++) {
1504 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1505 if(!PassesCuts(track)) continue;
1506 iAcceptedTracks++;
1507 fHistPicoTrackPt[fInCentralitySelection]->Fill(track->Pt());
1508 if(fFillQAHistograms) FillQAHistograms(track);
1509 }
1510 fHistPicoTrackMult[fInCentralitySelection]->Fill(iAcceptedTracks);
1511}
1512//_____________________________________________________________________________
1513void AliAnalysisTaskJetV2::FillClusterHistograms() const
1514{
1515 // fill cluster histograms
1516 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1517 if(!fClusterCont) return;
1518 Int_t iClusters(fClusterCont->GetNClusters());
1519 for(Int_t i(0); i < iClusters; i++) {
1520 AliVCluster* cluster = fClusterCont->GetCluster(i);
1521 if (!PassesCuts(cluster)) continue;
1522 TLorentzVector clusterLorentzVector;
1523 cluster->GetMomentum(clusterLorentzVector, const_cast<Double_t*>(fVertex));
1524 fHistClusterPt[fInCentralitySelection]->Fill(clusterLorentzVector.Pt());
1525 fHistClusterEtaPhi[fInCentralitySelection]->Fill(clusterLorentzVector.Eta(), clusterLorentzVector.Phi());
1526 fHistClusterEtaPhiWeighted[fInCentralitySelection]->Fill(clusterLorentzVector.Eta(), clusterLorentzVector.Phi(), clusterLorentzVector.Pt());
1527 }
1528 return;
1529}
1530//_____________________________________________________________________________
1531void AliAnalysisTaskJetV2::FillEventPlaneHistograms(Double_t vzero[2][2], Double_t* vzeroComb, Double_t* tpc) const
1532{
1533 // fill event plane histograms
1534 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1535 fHistPsiControl->Fill(0.5, vzero[0][0]); // vzero a psi2
1536 fHistPsiControl->Fill(1.5, vzero[1][0]); // vzero c psi2
1537 fHistPsiControl->Fill(2.5, tpc[0]); // tpc psi 2
1538 fHistPsiControl->Fill(5.5, vzero[0][1]); // vzero a psi3
1539 fHistPsiControl->Fill(6.5, vzero[1][1]); // vzero b psi3
1540 fHistPsiControl->Fill(7.5, tpc[1]); // tpc psi 3
1541 fHistPsiVZEROA->Fill(vzero[0][0]);
1542 fHistPsiVZEROC->Fill(vzero[1][0]);
1543 fHistPsiVZERO->Fill(vzeroComb[0]);
1544 fHistPsiTPC->Fill(tpc[0]);
1545 fHistPsiSpread->Fill(0.5, TMath::Abs(vzero[0][0]-vzero[1][0]));
1546 fHistPsiSpread->Fill(1.5, TMath::Abs(vzero[0][0]-tpc[0]));
1547 fHistPsiSpread->Fill(2.5, TMath::Abs(vzero[1][0]-tpc[0]));
1548 // event plane vs centrality QA histo's to check recentering
1549 Double_t TRK(InputEvent()->GetCentrality()->GetCentralityPercentile("TRK"));
1550 Double_t V0M(InputEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
1551 fHistPsiVZEROAV0M->Fill(V0M, vzero[0][0]);
1552 fHistPsiVZEROCV0M->Fill(V0M, vzero[1][0]);
1553 fHistPsiVZEROVV0M->Fill(V0M, vzeroComb[0]);
1554 fHistPsiTPCiV0M->Fill(V0M, tpc[0]);
1555 fHistPsiVZEROATRK->Fill(TRK, vzero[0][0]);
1556 fHistPsiVZEROCTRK->Fill(TRK, vzero[1][0]);
1557 fHistPsiVZEROTRK->Fill(TRK, vzeroComb[0]);
1558 fHistPsiTPCTRK->Fill(TRK, tpc[0]);
1559}
1560//_____________________________________________________________________________
1561void AliAnalysisTaskJetV2::FillRhoHistograms()
1562{
1563 // fill rho histograms
1564 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1565 fHistRhoPackage[fInCentralitySelection]->Fill(fLocalRho->GetVal()); // save the rho estimate from the emcal jet package
1566 // get multiplicity FIXME inefficient
1567 Int_t iJets(fJets->GetEntriesFast());
1568 Double_t rho(fLocalRho->GetLocalVal(TMath::Pi(), TMath::Pi(), fLocalRho->GetVal()));
1569 fHistRho[fInCentralitySelection]->Fill(rho);
1570 fHistRhoVsMult->Fill(fTracks->GetEntries(), rho);
1571 fHistRhoVsCent->Fill(fCent, rho);
1572 for(Int_t i(0); i < iJets; i++) {
1573 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(i));
1574 if(!PassesCuts(jet)) continue;
1575 fHistRhoAVsMult->Fill(fTracks->GetEntries(), rho * jet->Area());
1576 fHistRhoAVsCent->Fill(fCent, rho * jet->Area());
1577 }
1578}
1579//_____________________________________________________________________________
1580void AliAnalysisTaskJetV2::FillDeltaPtHistograms(Double_t psi2) const
1581{
1582 // fill delta pt histograms
1583 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1584 Int_t i(0);
1585 const Float_t areaRC = GetJetRadius()*GetJetRadius()*TMath::Pi();
1586 // we're retrieved the leading jet, now get a random cone
1587 for(i = 0; i < fMaxCones; i++) {
1588 Float_t pt(0), eta(0), phi(0);
1589 // get a random cone without constraints on leading jet position
1590 CalculateRandomCone(pt, eta, phi, fTracksCont, fClusterCont, 0x0);
1591 if(pt > 0) {
1592 if(fFillQAHistograms) fHistRCPhiEta[fInCentralitySelection]->Fill(phi, eta);
1593 fHistRhoVsRCPt[fInCentralitySelection]->Fill(pt, fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal())*areaRC);
1594 fHistRCPt[fInCentralitySelection]->Fill(pt);
1595 fHistDeltaPtDeltaPhi2[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1596 fHistDeltaPtDeltaPhi2Rho0[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetVal());
1597
1598 }
1599 // get a random cone excluding leading jet area
1600 CalculateRandomCone(pt, eta, phi, fTracksCont, fClusterCont, fLeadingJet);
1601 if(pt > 0) {
1602 if(fFillQAHistograms) fHistRCPhiEtaExLJ[fInCentralitySelection]->Fill(phi, eta);
1603 fHistRhoVsRCPtExLJ[fInCentralitySelection]->Fill(pt, fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal())*areaRC);
1604 fHistRCPtExLJ[fInCentralitySelection]->Fill(pt);
1605 fHistDeltaPtDeltaPhi2ExLJ[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1606 fHistDeltaPtDeltaPhi2ExLJRho0[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetVal());
1607 }
1608 }
1609}
1610//_____________________________________________________________________________
1611void AliAnalysisTaskJetV2::FillJetHistograms(Double_t psi2)
1612{
1613 // fill jet histograms
1614 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1615 Int_t iJets(fJets->GetEntriesFast());
1616 for(Int_t i(0); i < iJets; i++) {
1617 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(i));
1618 if(PassesCuts(jet)) {
1619 Double_t pt(jet->Pt()), area(jet->Area()), eta(jet->Eta()), phi(jet->Phi());
1620 Double_t rho(fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1621 fHistJetPtRaw[fInCentralitySelection]->Fill(pt);
1622 fHistJetPt[fInCentralitySelection]->Fill(pt-area*rho);
1623 if(fFillQAHistograms) fHistJetEtaPhi[fInCentralitySelection]->Fill(eta, phi);
1624 fHistJetPtArea[fInCentralitySelection]->Fill(pt-area*rho, area);
1625 fHistJetPtEta[fInCentralitySelection]->Fill(pt-area*rho, eta);
1626 fHistJetPsi2Pt[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt-area*rho);
1627 fHistJetPsi2PtRho0[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt-area*fLocalRho->GetVal());
1628 fHistJetPtConstituents[fInCentralitySelection]->Fill(pt-area*rho, jet->Nch());
1629 fHistJetEtaRho[fInCentralitySelection]->Fill(eta, pt/area);
1630 }
1631 }
1632}
1633//_____________________________________________________________________________
1634void AliAnalysisTaskJetV2::FillQAHistograms(AliVTrack* vtrack) const
1635{
1636 // fill qa histograms for pico tracks
1637 if(!vtrack) return;
1638 AliPicoTrack* track = static_cast<AliPicoTrack*>(vtrack);
1639 fHistRunnumbersPhi->Fill(fMappedRunNumber, track->Phi());
1640 fHistRunnumbersEta->Fill(fMappedRunNumber, track->Eta());
1641 Int_t type((int)(track->GetTrackType()));
1642 switch (type) {
1643 case 0:
1644 fHistPicoCat1[fInCentralitySelection]->Fill(track->Eta(), track->Phi());
1645 break;
1646 case 1:
1647 fHistPicoCat2[fInCentralitySelection]->Fill(track->Eta(), track->Phi());
1648 break;
1649 case 2:
1650 fHistPicoCat3[fInCentralitySelection]->Fill(track->Eta(), track->Phi());
1651 break;
1652 default: break;
1653 }
1654}
1655//_____________________________________________________________________________
1656void AliAnalysisTaskJetV2::FillQAHistograms(AliVEvent* vevent)
1657{
1658 // fill qa histograms for events
1659 if(!vevent) return;
1660 fHistVertexz->Fill(vevent->GetPrimaryVertex()->GetZ());
1661 fHistCentrality->Fill(fCent);
1662 Int_t runNumber(InputEvent()->GetRunNumber());
1663 for(fMappedRunNumber = 0; fExpectedRuns->GetSize()+1; fMappedRunNumber++) {
1664 if(fExpectedRuns->At(fMappedRunNumber) == runNumber) break;
1665 }
1666}
1667//_____________________________________________________________________________
1668void AliAnalysisTaskJetV2::FillAnalysisSummaryHistogram() const
1669{
1670 // fill the analysis summary histrogram, saves all relevant analysis settigns
1671 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1672 fHistAnalysisSummary->GetXaxis()->SetBinLabel(2, "fJetRadius");
1673 fHistAnalysisSummary->SetBinContent(2, GetJetContainer()->GetJetRadius());
1674 fHistAnalysisSummary->GetXaxis()->SetBinLabel(3, "fJetEtaMin");
1675 fHistAnalysisSummary->SetBinContent(3, GetJetContainer()->GetJetEtaMin());
1676 fHistAnalysisSummary->GetXaxis()->SetBinLabel(4, "fJetEtaMax");
1677 fHistAnalysisSummary->SetBinContent(4, GetJetContainer()->GetJetEtaMax());
1678 fHistAnalysisSummary->GetXaxis()->SetBinLabel(5, "fJetPhiMin");
1679 fHistAnalysisSummary->SetBinContent(5, GetJetContainer()->GetJetPhiMin());
1680 fHistAnalysisSummary->GetXaxis()->SetBinLabel(6, "fJetPhiMax");
1681 fHistAnalysisSummary->SetBinContent(6, GetJetContainer()->GetJetPhiMin());
1682 fHistAnalysisSummary->GetXaxis()->SetBinLabel(16, "fForceBeamType");
1683 fHistAnalysisSummary->SetBinContent(16, fForceBeamType);
1684 fHistAnalysisSummary->GetXaxis()->SetBinLabel(17, "fMinCent");
1685 fHistAnalysisSummary->SetBinContent(17, fMinCent);
1686 fHistAnalysisSummary->GetXaxis()->SetBinLabel(18, "fMaxCent");
1687 fHistAnalysisSummary->SetBinContent(18, fMaxCent);
1688 fHistAnalysisSummary->GetXaxis()->SetBinLabel(19, "fMinVz");
1689 fHistAnalysisSummary->SetBinContent(19, fMinVz);
1690 fHistAnalysisSummary->GetXaxis()->SetBinLabel(20, "fMaxVz");
1691 fHistAnalysisSummary->SetBinContent(20, fMaxVz);
1692 fHistAnalysisSummary->GetXaxis()->SetBinLabel(21, "fOffTrigger");
1693 fHistAnalysisSummary->SetBinContent(21, fOffTrigger);
1694 fHistAnalysisSummary->GetXaxis()->SetBinLabel(34, "fitModulationType");
1695 fHistAnalysisSummary->SetBinContent(34, (int)fFitModulationType);
1696 fHistAnalysisSummary->GetXaxis()->SetBinLabel(35, "runModeType");
1697 fHistAnalysisSummary->SetBinContent(35, (int)fRunModeType);
1698 fHistAnalysisSummary->GetXaxis()->SetBinLabel(36, "data type");
1699 fHistAnalysisSummary->SetBinContent(36, (int)fDataType);
1700 fHistAnalysisSummary->GetXaxis()->SetBinLabel(37, "iterator");
1701 fHistAnalysisSummary->SetBinContent(37, 1.);
1702 fHistAnalysisSummary->GetXaxis()->SetBinLabel(38, "fMinPvalue");
1703 fHistAnalysisSummary->SetBinContent(38, fMinPvalue);
1704 fHistAnalysisSummary->GetXaxis()->SetBinLabel(39, "fMaxPvalue");
1705 fHistAnalysisSummary->SetBinContent(39, fMaxPvalue);
1706 fHistAnalysisSummary->GetXaxis()->SetBinLabel(40, "fExcludeLeadingJetsFromFit");
1707 fHistAnalysisSummary->SetBinContent(40, fExcludeLeadingJetsFromFit);
1708 fHistAnalysisSummary->GetXaxis()->SetBinLabel(41, "fRebinSwapHistoOnTheFly");
1709 fHistAnalysisSummary->SetBinContent(41, (int)fRebinSwapHistoOnTheFly);
1710 fHistAnalysisSummary->GetXaxis()->SetBinLabel(42, "fUsePtWeight");
1711 fHistAnalysisSummary->SetBinContent(42, (int)fUsePtWeight);
a008f846 1712// fHistAnalysisSummary->GetXaxis()->SetBinLabel(43, "fExplicitOutlierCut");
1713// fHistAnalysisSummary->SetBinContent(43, fExplicitOutlierCut);
eae37c5c 1714 fHistAnalysisSummary->GetXaxis()->SetBinLabel(44, "fSoftTrackMinPt");
1715 fHistAnalysisSummary->SetBinContent(44, fSoftTrackMinPt);
1716 fHistAnalysisSummary->GetXaxis()->SetBinLabel(45, "fSoftTrackMaxPt");
1717 fHistAnalysisSummary->SetBinContent(45, fSoftTrackMaxPt);
1718 fHistAnalysisSummary->GetXaxis()->SetBinLabel(46, "fMaxCones");
1719 fHistAnalysisSummary->SetBinContent(46, fMaxCones);
1720 fHistAnalysisSummary->GetXaxis()->SetBinLabel(47, "used rho");
1721 fHistAnalysisSummary->GetXaxis()->SetBinLabel(48, "used small rho");
1722}
1723//_____________________________________________________________________________
1724void AliAnalysisTaskJetV2::Terminate(Option_t *)
1725{
1726 // terminate
1727 switch (fRunModeType) {
1728 case kLocal : {
1729 printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1730 AliAnalysisTaskJetV2::Dump();
1731 for(Int_t i(0); i < fHistAnalysisSummary->GetXaxis()->GetNbins(); i++) printf( " > flag: %s \t content %.2f \n", fHistAnalysisSummary->GetXaxis()->GetBinLabel(1+i), fHistAnalysisSummary->GetBinContent(1+i));
1732 } break;
1733 default : break;
1734 }
1735}
1736//_____________________________________________________________________________
1737void AliAnalysisTaskJetV2::SetModulationFit(TF1* fit)
1738{
1739 // set modulation fit
1740 if (fFitModulation) delete fFitModulation;
1741 fFitModulation = fit;
1742}
1743//_____________________________________________________________________________
1744void AliAnalysisTaskJetV2::SetUseControlFit(Bool_t c)
1745{
1746 // set control fit
1747 if (fFitControl) delete fFitControl;
1748 if (c) {
1749 fFitControl = new TF1("controlFit", "pol0", 0, TMath::TwoPi());
1750 } else fFitControl = 0x0;
1751}
1752//_____________________________________________________________________________
1753TH1F* AliAnalysisTaskJetV2::GetResolutionFromOuptutFile(detectorType det, Int_t h, TArrayD* cen)
1754{
1755 // INTERFACE METHOD FOR OUTPUTFILE
1756 // get the detector resolution, user has ownership of the returned histogram
1757 if(!fOutputList) {
1758 printf(" > Please add fOutputList first < \n");
1759 return 0x0;
1760 }
1761 TH1F* r(0x0);
1762 (cen) ? r = new TH1F("R", "R", cen->GetSize()-1, cen->GetArray()) : r = new TH1F("R", "R", 10, 0, 10);
1763 if(!cen) r->GetXaxis()->SetTitle("number of centrality bin");
1764 r->GetYaxis()->SetTitle(Form("Resolution #Psi_{%i}", h));
1765 for(Int_t i(0); i < 10; i++) {
1766 TProfile* temp((TProfile*)fOutputList->FindObject(Form("fProfV%iResolution_%i", h, i)));
1767 if(!temp) break;
1768 Double_t a(temp->GetBinContent(3)), b(temp->GetBinContent(5)), c(temp->GetBinContent(7));
1769 Double_t d(temp->GetBinContent(9)), e(temp->GetBinContent(10)), f(temp->GetBinContent(11));
1770 Double_t _a(temp->GetBinError(3)), _b(temp->GetBinError(5)), _c(temp->GetBinError(7));
1771 Double_t _d(temp->GetBinError(9)), _e(temp->GetBinError(10)), _f(temp->GetBinError(11));
1772 if(a <= 0 || b <= 0 || c <= 0 || d <= 0 || e <= 0 || f <= 0) continue;
1773 switch (det) {
1774 case kVZEROA : {
1775 r->SetBinContent(1+i, TMath::Sqrt((a*b)/c));
1776 if(i==0) r->SetNameTitle("VZEROA resolution", "VZEROA resolution");
1777 r->SetBinError(1+i, TMath::Sqrt(_a*_a+_b*_b+_c*_c));
1778 } break;
1779 case kVZEROC : {
1780 r->SetBinContent(1+i, TMath::Sqrt((a*c)/b));
1781 if(i==0) r->SetNameTitle("VZEROC resolution", "VZEROC resolution");
1782 r->SetBinError(1+i, TMath::Sqrt(_a*_a+_b*_b+_c*_c));
1783 } break;
1784 case kTPC : {
1785 r->SetBinContent(1+i, TMath::Sqrt((b*c)/a));
1786 if(i==0) r->SetNameTitle("TPC resolution", "TPC resolution");
1787 r->SetBinError(1+i, TMath::Sqrt(_a*_a+_b*_b+_c*_c));
1788 } break;
1789 case kVZEROComb : {
1790 r->SetBinContent(1+i, TMath::Sqrt((d*e)/f));
1791 if(i==0) r->SetNameTitle("VZEROComb resolution", "VZEROComb resolution");
1792 r->SetBinError(1+i, TMath::Sqrt(_d*_d+_e*_e+_f*_f));
1793 } break;
1794 default : break;
1795 }
1796 }
1797 return r;
1798}
1799//_____________________________________________________________________________
1800TH1F* AliAnalysisTaskJetV2::CorrectForResolutionDiff(TH1F* v, detectorType det, TArrayD* cen, Int_t c, Int_t h)
1801{
1802 // INTERFACE METHOD FOR OUTPUT FILE
1803 // correct the supplied differential vn histogram v for detector resolution
1804 TH1F* r(GetResolutionFromOuptutFile(det, h, cen));
1805 if(!r) {
1806 printf(" > Couldn't find resolution < \n");
1807 return 0x0;
1808 }
1809 Double_t res(1./r->GetBinContent(1+r->FindBin(c)));
1810 TF1* line = new TF1("line", "pol0", 0, 200);
1811 line->SetParameter(0, res);
1812 v->Multiply(line);
1813 return v;
1814}
1815//_____________________________________________________________________________
1816TH1F* AliAnalysisTaskJetV2::CorrectForResolutionInt(TH1F* v, detectorType det, TArrayD* cen, Int_t h)
1817{
1818 // INTERFACE METHOD FOR OUTPUT FILE
1819 // correct the supplied intetrated vn histogram v for detector resolution
1820 // integrated vn must have the same centrality binning as the resolotion correction
1821 TH1F* r(GetResolutionFromOuptutFile(det, h, cen));
1822 v->Divide(v, r);
1823 return v;
1824}
1825//_____________________________________________________________________________
1826TH1F* AliAnalysisTaskJetV2::GetDifferentialQC(TProfile* refCumulants, TProfile* diffCumlants, TArrayD* ptBins, Int_t h)
1827{
1828 // get differential QC
1829 Double_t r(refCumulants->GetBinContent(h-1)); // v2 reference flow
1830 if(r > 0) r = TMath::Sqrt(r);
1831 TH1F* qc = new TH1F(Form("QC2v%i", h), Form("QC2v%i", h), ptBins->GetSize()-1, ptBins->GetArray());
1832 Double_t a(0), b(0), c(0); // dummy variables
1833 for(Int_t i(0); i < ptBins->GetSize(); i++) {
1834 if(r > 0) {
1835 a = diffCumlants->GetBinContent(1+i);
1836 b = diffCumlants->GetBinError(1+i);
1837 c = a/r;
1838 qc->SetBinContent(1+i, c);
1839 (a <= 0 || b <= 0) ? qc->SetBinError(1+i, b) : qc->SetBinError(1+i, TMath::Sqrt(c*c*b*b/(a*a)));
1840 }
1841 }
1842 return qc;
1843}
1844
1845//_____________________________________________________________________________