]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetV2.cxx
add detector response jet mass task
[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>
9e1c2f31 42#include <TFile.h>
eae37c5c 43// aliroot includes
44#include <AliAnalysisTask.h>
45#include <AliAnalysisManager.h>
46#include <AliCentrality.h>
47#include <AliVVertex.h>
48#include <AliVTrack.h>
9e1c2f31 49#include <AliVVZERO.h>
eae37c5c 50#include <AliESDEvent.h>
51#include <AliAODEvent.h>
52#include <AliAODTrack.h>
9e1c2f31 53#include <AliOADBContainer.h>
eae37c5c 54// emcal jet framework includes
55#include <AliPicoTrack.h>
56#include <AliEmcalJet.h>
57#include <AliRhoParameter.h>
58#include <AliLocalRhoParameter.h>
59#include <AliAnalysisTaskJetV2.h>
60#include <AliClusterContainer.h>
61
62class AliAnalysisTaskJetV2;
63using namespace std;
64
65ClassImp(AliAnalysisTaskJetV2)
66
67AliAnalysisTaskJetV2::AliAnalysisTaskJetV2() : AliAnalysisTaskEmcalJet("AliAnalysisTaskJetV2", kTRUE),
06d2671d 68 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(kVZEROComb), 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.), 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), fVZEROgainEqualization(0x0), fVZEROgainEqualizationPerRing(kFALSE), fChi2A(0x0), fChi2C(0x0), fChi3A(0x0), fChi3C(0x0), fOADB(0x0)
9e1c2f31 69{
eae37c5c 70 for(Int_t i(0); i < 10; i++) {
71 fProfV2Resolution[i] = 0;
72 fProfV3Resolution[i] = 0;
73 fHistPicoTrackPt[i] = 0;
74 fHistPicoTrackMult[i] = 0;
75 fHistPicoCat1[i] = 0;
76 fHistPicoCat2[i] = 0;
77 fHistPicoCat3[i] = 0;
78 fHistClusterPt[i] = 0;
79 fHistClusterEtaPhi[i] = 0;
80 fHistClusterEtaPhiWeighted[i] = 0;
81 fHistRhoPackage[i] = 0;
82 fHistRho[i] = 0;
83 fHistRCPhiEta[i] = 0;
84 fHistRhoVsRCPt[i] = 0;
85 fHistRCPt[i] = 0;
86 fHistDeltaPtDeltaPhi2[i] = 0;
87 fHistDeltaPtDeltaPhi2Rho0[i] = 0;
88 fHistRCPhiEtaExLJ[i] = 0;
89 fHistRhoVsRCPtExLJ[i] = 0;
90 fHistRCPtExLJ[i] = 0;
91 fHistDeltaPtDeltaPhi2ExLJ[i] = 0;
92 fHistDeltaPtDeltaPhi2ExLJRho0[i] = 0;
93 fHistJetPtRaw[i] = 0;
94 fHistJetPt[i] = 0;
95 fHistJetEtaPhi[i] = 0;
96 fHistJetPtArea[i] = 0;
97 fHistJetPtEta[i] = 0;
98 fHistJetPtConstituents[i] = 0;
99 fHistJetEtaRho[i] = 0;
100 fHistJetPsi2Pt[i] = 0;
101 fHistJetPsi2PtRho0[i] = 0;
102 }
9e1c2f31 103 for(Int_t i(0); i < 9; i++) {
104 for(Int_t j(0); j < 2; j++) {
105 for(Int_t k(0); k < 2; k++) {
106 fMeanQ[i][j][k] = 0.;
107 fWidthQ[i][j][k] = 0.;
108 fMeanQv3[i][j][k] = 0.;
109 fWidthQv3[i][j][k] = 0.;
110 }
111 }
112 }
113 for(Int_t i(0); i < 4; i++) {
114 fVZEROApol[i] = 0.;
115 fVZEROCpol[i] = 0.;
116 }
117 for(Int_t i(0); i < 8; i++) fUseVZERORing[i] = kTRUE;
118 // default constructor
eae37c5c 119}
120//_____________________________________________________________________________
121AliAnalysisTaskJetV2::AliAnalysisTaskJetV2(const char* name, runModeType type) : AliAnalysisTaskEmcalJet(name, kTRUE),
06d2671d 122 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(kVZEROComb), 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.), 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), fVZEROgainEqualization(0x0), fVZEROgainEqualizationPerRing(kFALSE), fChi2A(0x0), fChi2C(0x0), fChi3A(0x0), fChi3C(0x0), fOADB(0x0)
9e1c2f31 123{
eae37c5c 124 for(Int_t i(0); i < 10; i++) {
125 fProfV2Resolution[i] = 0;
126 fProfV3Resolution[i] = 0;
127 fHistPicoTrackPt[i] = 0;
128 fHistPicoTrackMult[i] = 0;
129 fHistPicoCat1[i] = 0;
130 fHistPicoCat2[i] = 0;
131 fHistPicoCat3[i] = 0;
132 fHistClusterPt[i] = 0;
133 fHistClusterEtaPhi[i] = 0;
134 fHistClusterEtaPhiWeighted[i] = 0;
135 fHistRhoPackage[i] = 0;
136 fHistRho[i] = 0;
137 fHistRCPhiEta[i] = 0;
138 fHistRhoVsRCPt[i] = 0;
139 fHistRCPt[i] = 0;
140 fHistDeltaPtDeltaPhi2[i] = 0;
141 fHistDeltaPtDeltaPhi2Rho0[i] = 0;
142 fHistRCPhiEtaExLJ[i] = 0;
143 fHistRhoVsRCPtExLJ[i] = 0;
144 fHistRCPtExLJ[i] = 0;
145 fHistDeltaPtDeltaPhi2ExLJ[i] = 0;
146 fHistDeltaPtDeltaPhi2ExLJRho0[i] = 0;
147 fHistJetPtRaw[i] = 0;
148 fHistJetPt[i] = 0;
149 fHistJetEtaPhi[i] = 0;
150 fHistJetPtArea[i] = 0;
151 fHistJetPtEta[i] = 0;
152 fHistJetPtConstituents[i] = 0;
153 fHistJetEtaRho[i] = 0;
154 fHistJetPsi2Pt[i] = 0;
155 fHistJetPsi2PtRho0[i] = 0;
9e1c2f31 156 }
157 for(Int_t i(0); i < 9; i++) {
158 for(Int_t j(0); j < 2; j++) {
159 for(Int_t k(0); k < 2; k++) {
160 fMeanQ[i][j][k] = 0.;
161 fWidthQ[i][j][k] = 0.;
162 fMeanQv3[i][j][k] = 0.;
163 fWidthQv3[i][j][k] = 0.;
164 }
165 }
166 }
167 for(Int_t i(0); i < 4; i++) {
168 fVZEROApol[i] = 0.;
169 fVZEROCpol[i] = 0.;
170 }
171 for(Int_t i(0); i < 8; i++) fUseVZERORing[i] = kTRUE;
172
eae37c5c 173 // constructor
174 DefineInput(0, TChain::Class());
175 DefineOutput(1, TList::Class());
176 switch (fRunModeType) {
177 case kLocal : {
178 gStyle->SetOptFit(1);
179 DefineOutput(2, TList::Class());
180 DefineOutput(3, TList::Class());
181 } break;
182 default: fDebug = -1; // suppress debug info explicitely when not running locally
183 }
184 switch (fCollisionType) {
185 case kPythia : {
186 fFitModulationType = kNoFit;
187 } break;
188 default : break;
189 }
190 if(fLocalRhoName=="") fLocalRhoName = Form("LocalRhoFrom_%s", GetName());
191}
192//_____________________________________________________________________________
193AliAnalysisTaskJetV2::~AliAnalysisTaskJetV2()
194{
195 // destructor
9274f9ad 196 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
f41baaab 197 if(fOutputList) {delete fOutputList; fOutputList = 0x0;}
198 if(fOutputListGood) {delete fOutputListGood; fOutputListGood = 0x0;}
199 if(fOutputListBad) {delete fOutputListBad; fOutputListBad = 0x0;}
200 if(fFitModulation) {delete fFitModulation; fFitModulation = 0x0;}
201 if(fHistSwap) {delete fHistSwap; fHistSwap = 0x0;}
202 if(fCentralityClasses) {delete fCentralityClasses; fCentralityClasses = 0x0;}
203 if(fExpectedRuns) {delete fExpectedRuns; fExpectedRuns = 0x0;}
204 if(fExpectedSemiGoodRuns) {delete fExpectedSemiGoodRuns; fExpectedSemiGoodRuns = 0x0;}
205 if(fFitControl) {delete fFitControl; fFitControl = 0x0;}
9e1c2f31 206 if(fVZEROgainEqualization) {delete fVZEROgainEqualization; fVZEROgainEqualization = 0x0;}
207 if(fChi2A) {delete fChi2A; fChi2A = 0x0;}
208 if(fChi2C) {delete fChi2C; fChi2C = 0x0;}
209 if(fChi3A) {delete fChi3A; fChi3A = 0x0;}
210 if(fChi3C) {delete fChi3C; fChi3C = 0x0;}
211 if(fOADB && !fOADB->IsZombie()) {
212 fOADB->Close(); fOADB = 0x0;
213 } else if (fOADB) fOADB = 0x0;
eae37c5c 214}
215//_____________________________________________________________________________
216void AliAnalysisTaskJetV2::ExecOnce()
217{
218 // Init the analysis
9274f9ad 219 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 220 fLocalRho = new AliLocalRhoParameter(fLocalRhoName.Data(), 0);
221 if(fAttachToEvent) {
222 if(!(InputEvent()->FindListObject(fLocalRho->GetName()))) {
223 InputEvent()->AddObject(fLocalRho);
224 } else {
225 AliFatal(Form("%s: Container with name %s already present. Aborting", GetName(), fLocalRho->GetName()));
226 }
227 }
228 AliAnalysisTaskEmcalJet::ExecOnce(); // init the base class
229 AliAnalysisTaskEmcalJet::SetVzRange(-1.*fAbsVertexZ, fAbsVertexZ);
230 if(!GetJetContainer()) AliFatal(Form("%s: Couldn't find jet container. Aborting !", GetName()));
231}
232//_____________________________________________________________________________
f41baaab 233Bool_t AliAnalysisTaskJetV2::Notify()
234{
235 // determine the run number to see if the track and jet cuts should be refreshed for semi-good TPC runs
9274f9ad 236 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
f41baaab 237 if(fRunNumber != InputEvent()->GetRunNumber()) {
238 fRunNumber = InputEvent()->GetRunNumber(); // set the current run number
239 if(fDebug > 0) printf("__FUNC__ %s > NEW RUNNUMBER DETECTED \n ", __func__);
9e1c2f31 240 // check if this is 10h or 11h data
2e9c1578 241 switch (fCollisionType) {
242 case kPbPb10h : {
9e1c2f31 243 if(fDebug > 0) printf(" LHC10h data, assuming full acceptance, reading VZERO calibration DB \n ");
244 // for 10h data the vzero event plane calibration needs to be cached
245 ReadVZEROCalibration2010h();
246 // no need to change rho or acceptance for 10h, so we're done
2e9c1578 247 return kTRUE;
248 } break;
06d2671d 249 case kJetFlowMC : {
250 return kTRUE;
251 } break;
9e1c2f31 252 default : {
253 if(fDebug > 0) printf(" checking runnumber to adjust acceptance on the fly \n");
254 } break;
2e9c1578 255 }
f41baaab 256 // reset the cuts. should be a pointless operation except for the case where the run number changes
257 // from semi-good back to good on one node, which is not a likely scenario (unless trains will
258 // run as one masterjob)
f41baaab 259 switch (fAnalysisType) {
260 case kCharged: {
261 AliAnalysisTaskEmcalJet::SetJetPhiLimits(-10., 10.);
262 } break;
263 case kFull: {
264 AliAnalysisTaskEmcalJet::SetJetPhiLimits(1.405 + GetJetRadius(), 3.135 - GetJetRadius());
265 } break;
9e1c2f31 266 default: {
267 AliAnalysisTaskEmcal::SetTrackPhiLimits(-10., 10.);
268 } break;
f41baaab 269 }
270 if(fCachedRho) { // if there's a cached rho, it's the default, so switch back
271 if(fDebug > 0) printf("__FUNC__ %s > replacing rho with cached rho \n ", __func__);
272 fRho = fCachedRho; // reset rho back to cached value. again, should be pointless
273 }
274 Bool_t flaggedAsSemiGood(kFALSE); // not flagged as anything
275 for(Int_t i(0); i < fExpectedSemiGoodRuns->GetSize(); i++) {
276 if(fExpectedSemiGoodRuns->At(i) == fRunNumber) { // run is semi-good
277 if(fDebug > 0) printf("__FUNC__ %s > semi-good tpc run detected, adjusting acceptance \n ", __func__);
278 flaggedAsSemiGood = kTRUE;
279 switch (fAnalysisType) {
280 // for full jets the jet acceptance does not have to be changed as emcal does not
281 // cover the tpc low voltage readout strips
282 case kCharged: {
283 AliAnalysisTaskEmcalJet::SetJetPhiLimits(fSemiGoodJetMinPhi, fSemiGoodJetMaxPhi); // just an acceptance cut, jets are obtained from full azimuth, so no edge effects
284 } break;
285 default: break;
286 }
287 AliAnalysisTaskEmcal::SetTrackPhiLimits(fSemiGoodTrackMinPhi, fSemiGoodTrackMaxPhi); // only affects vn extraction, NOT jet finding
288 // for semi-good runs, also try to get the 'small rho' estimate, if it is available
289 AliRhoParameter* tempRho(dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fNameSmallRho.Data())));
290 if(tempRho) {
291 if(fDebug > 0) printf("__FUNC__ %s > switching to small rho, caching normal rho \n ", __func__);
292 fHistAnalysisSummary->SetBinContent(54, 1.); // bookkeep the fact that small rho is used
293 fCachedRho = fRho; // cache the original rho ...
294 fRho = tempRho; // ... and use the small rho
295 }
296 }
297 }
298 if(!flaggedAsSemiGood) {
299 // in case the run is not a semi-good run, check if it is recognized as another run
300 // only done to catch unexpected runs
301 for(Int_t i(0); i < fExpectedRuns->GetSize(); i++) {
302 if(fExpectedRuns->At(i) == fRunNumber) break; // run is known, break the loop else store the number in a random bin
303 fHistUndeterminedRunQA->SetBinContent(TMath::Nint(10.*gRandom->Uniform(0.,.9))+1, fRunNumber);
304 }
305 fHistAnalysisSummary->SetBinContent(53, 1.); // bookkeep which rho estimate is used
306 }
307 }
308 return kTRUE;
309}
310//_____________________________________________________________________________
eae37c5c 311Bool_t AliAnalysisTaskJetV2::InitializeAnalysis()
312{
313 // initialize the anaysis
314 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
315 // if not set, estimate the number of cones that would fit into the selected acceptance
316 if(fMaxCones <= 0) fMaxCones = TMath::CeilNint((TMath::Abs(GetJetContainer()->GetJetEtaMax()-GetJetContainer()->GetJetEtaMin())*TMath::Abs(GetJetContainer()->GetJetPhiMax()-GetJetContainer()->GetJetPhiMin()))/(TMath::Pi()*GetJetRadius()*GetJetRadius()));
317 // manually 'override' the default acceptance cuts of the emcal framework (use with caution)
318 if(fMinDisanceRCtoLJ==0) fMinDisanceRCtoLJ = GetJetRadius();
319 if(dynamic_cast<AliAODEvent*>(InputEvent())) fDataType = kAOD; // determine the datatype
320 else if(dynamic_cast<AliESDEvent*>(InputEvent())) fDataType = kESD;
321 fHistAnalysisSummary->SetBinContent(36, (int)fDataType);
322 if(!fRandom) fRandom = new TRandom3(0); // set randomizer and random seed
323 switch (fFitModulationType) {
324 case kNoFit : { SetModulationFit(new TF1("fix_kNoFit", "[0]", 0, TMath::TwoPi())); } break;
325 case kV2 : {
326 SetModulationFit(new TF1("fit_kV2", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi()));
327 fFitModulation->SetParameter(0, 0.); // normalization
328 fFitModulation->SetParameter(3, 0.2); // v2
329 fFitModulation->FixParameter(1, 1.); // constant
330 fFitModulation->FixParameter(2, 2.); // constant
331 } break;
332 case kV3: {
333 SetModulationFit(new TF1("fit_kV3", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi()));
334 fFitModulation->SetParameter(0, 0.); // normalization
335 fFitModulation->SetParameter(3, 0.2); // v3
336 fFitModulation->FixParameter(1, 1.); // constant
337 fFitModulation->FixParameter(2, 3.); // constant
338 } break;
339 default : { // for the combined fit, the 'direct fourier series' or the user supplied vn values we use v2 and v3
340 SetModulationFit(new TF1("fit_kCombined", "[0]*([1]+[2]*([3]*TMath::Cos([2]*(x-[4]))+[7]*TMath::Cos([5]*(x-[6]))))", 0, TMath::TwoPi()));
341 fFitModulation->SetParameter(0, 0.); // normalization
342 fFitModulation->SetParameter(3, 0.2); // v2
343 fFitModulation->FixParameter(1, 1.); // constant
344 fFitModulation->FixParameter(2, 2.); // constant
345 fFitModulation->FixParameter(5, 3.); // constant
346 fFitModulation->SetParameter(7, 0.2); // v3
347 } break;
348 }
349 switch (fRunModeType) {
350 case kGrid : { fFitModulationOptions += "N0"; } break;
351 default : break;
352 }
353 FillAnalysisSummaryHistogram();
354 return kTRUE;
355}
356//_____________________________________________________________________________
357TH1F* AliAnalysisTaskJetV2::BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c, Bool_t append)
358{
359 // book a TH1F and connect it to the output container
360 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
361 if(fReduceBinsXByFactor > 0 ) bins = TMath::Nint(bins/fReduceBinsXByFactor);
362 if(!fOutputList) return 0x0;
363 TString title(name);
364 if(c!=-1) { // format centrality dependent histograms accordingly
365 name = Form("%s_%i", name, c);
366 title += Form("_%i-%i", (int)(fCentralityClasses->At(c)), (int)(fCentralityClasses->At((1+c))));
367 }
368 title += Form(";%s;[counts]", x);
369 TH1F* histogram = new TH1F(name, title.Data(), bins, min, max);
370 histogram->Sumw2();
371 if(append) fOutputList->Add(histogram);
372 return histogram;
373}
374//_____________________________________________________________________________
375TH2F* 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)
376{
377 // book a TH2F and connect it to the output container
378 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
379 if(fReduceBinsXByFactor > 0 ) binsx = TMath::Nint(binsx/fReduceBinsXByFactor);
380 if(fReduceBinsYByFactor > 0 ) binsy = TMath::Nint(binsy/fReduceBinsYByFactor);
381 if(!fOutputList) return 0x0;
382 TString title(name);
383 if(c!=-1) { // format centrality dependent histograms accordingly
384 name = Form("%s_%i", name, c);
385 title += Form("_%i-%i", (int)fCentralityClasses->At(c), (int)(fCentralityClasses->At((1+c))));
386 }
387 title += Form(";%s;%s", x, y);
388 TH2F* histogram = new TH2F(name, title.Data(), binsx, minx, maxx, binsy, miny, maxy);
389 histogram->Sumw2();
390 if(append) fOutputList->Add(histogram);
391 return histogram;
392}
393//_____________________________________________________________________________
394void AliAnalysisTaskJetV2::UserCreateOutputObjects()
395{
396 // create output objects. also initializes some default values in case they aren't
397 // loaded via the AddTask macro
398 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
399 fOutputList = new TList();
400 fOutputList->SetOwner(kTRUE);
401 if(!fCentralityClasses) { // classes must be defined at this point
402 Double_t c[] = {0., 20., 40., 60., 80., 100.};
403 fCentralityClasses = new TArrayD(sizeof(c)/sizeof(c[0]), c);
404 }
405 if(!fExpectedRuns) { // expected runs must be defined at this point
406 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 */};
407 fExpectedRuns = new TArrayI(sizeof(r)/sizeof(r[0]), r);
408 }
2e9c1578 409 // set default semi-good runs only for 11h data
410 switch (fCollisionType) {
411 case kPbPb10h : break;
412 default : {
413 if(!fExpectedSemiGoodRuns) {
414 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};
415 fExpectedSemiGoodRuns = new TArrayI(sizeof(r)/sizeof(r[0]), r);
416 }
417 }
eae37c5c 418 }
2e9c1578 419
eae37c5c 420 // global QA
421 fHistCentrality = BookTH1F("fHistCentrality", "centrality", 102, -2, 100);
422 fHistVertexz = BookTH1F("fHistVertexz", "vertex z (cm)", 100, -12, 12);
423
424 // pico track and emcal cluster kinematics
425 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i++) {
426 fHistPicoTrackPt[i] = BookTH1F("fHistPicoTrackPt", "p_{t} [GeV/c]", 100, 0, 100, i);
427 fHistPicoTrackMult[i] = BookTH1F("fHistPicoTrackMult", "multiplicity", 100, 0, 5000, i);
428 if(fFillQAHistograms) {
429 fHistPicoCat1[i] = BookTH2F("fHistPicoCat1", "#eta", "#phi", 50, -1, 1, 50, 0, TMath::TwoPi(), i);
430 fHistPicoCat2[i] = BookTH2F("fHistPicoCat2", "#eta", "#phi", 50, -1, 1, 50, 0, TMath::TwoPi(), i);
431 fHistPicoCat3[i] = BookTH2F("fHistPicoCat3", "#eta", "#phi", 50, -1, 1, 50, 0, TMath::TwoPi(), i);
432 if(fAnalysisType == AliAnalysisTaskJetV2::kFull) {
433 fHistClusterPt[i] = BookTH1F("fHistClusterPt", "p_{t} [GeV/c]", 100, 0, 100, i);
434 fHistClusterEtaPhi[i] = BookTH2F("fHistClusterEtaPhi", "#eta", "#phi", 100, -1., 1., 100, 0, TMath::TwoPi(), i);
435 fHistClusterEtaPhiWeighted[i] = BookTH2F("fHistClusterEtaPhiWeighted", "#eta", "#phi", 100, -1., 1., 100, 0, TMath::TwoPi(), i);
436 }
437 }
438 }
439
440 if(fFillQAHistograms) {
441 // event plane estimates and quality
442 fHistPsiControl = new TProfile("fHistPsiControl", "fHistPsiControl", 10, 0, 10);
443 fHistPsiControl->Sumw2();
444 fHistPsiSpread = new TProfile("fHistPsiSpread", "fHistPsiSpread", 4, 0, 4);
445 fHistPsiSpread->Sumw2();
446 fHistPsiControl->GetXaxis()->SetBinLabel(1, "<#Psi_{2, VZEROA}>");
447 fHistPsiControl->GetXaxis()->SetBinLabel(2, "<#Psi_{2, VZEROC}>");
448 fHistPsiControl->GetXaxis()->SetBinLabel(3, "<#Psi_{2, TPC}>");
449 fHistPsiControl->GetXaxis()->SetBinLabel(4, "<#Psi_{2, TPC, #eta < 0}>");
450 fHistPsiControl->GetXaxis()->SetBinLabel(5, "<#Psi_{2, TPC, #eta > 0}>");
451 fHistPsiControl->GetXaxis()->SetBinLabel(6, "<#Psi_{3, VZEROA}>");
452 fHistPsiControl->GetXaxis()->SetBinLabel(7, "<#Psi_{3, VZEROC}>");
453 fHistPsiControl->GetXaxis()->SetBinLabel(8, "<#Psi_{3, TPC}>");
454 fHistPsiControl->GetXaxis()->SetBinLabel(9, "<#Psi_{3, TPC, #eta < 0}>");
455 fHistPsiControl->GetXaxis()->SetBinLabel(10, "<#Psi_{3, TPC, #eta > 0}>");
456 fHistPsiSpread->GetXaxis()->SetBinLabel(1, "<#Psi_{2, VZEROA} - #Psi_{2, VZEROC}>");
457 fHistPsiSpread->GetXaxis()->SetBinLabel(2, "<#Psi_{2, VZEROC} - #Psi_{2, TPC}>");
458 fHistPsiSpread->GetXaxis()->SetBinLabel(3, "<#Psi_{2, VZEROC} - #Psi_{2, TPC}>");
459 fHistPsiSpread->GetXaxis()->SetBinLabel(4, "<#Psi_{2, TPC, #eta < 0} - #Psi_{2, TPC, #eta > 0}>");
460 fOutputList->Add(fHistPsiControl);
461 fOutputList->Add(fHistPsiSpread);
462 fHistPsiVZEROA = BookTH1F("fHistPsiVZEROA", "#Psi_{VZEROA}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
463 fHistPsiVZEROC = BookTH1F("fHistPsiVZEROC", "#Psi_{VZEROC}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
464 fHistPsiVZERO = BookTH1F("fHistPsiVZERO", "#Psi_{VZERO}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
465 fHistPsiTPC = BookTH1F("fHistPsiTPC", "#Psi_{TPC}", 40, -.5*TMath::Pi(), .5*TMath::Pi());
466 fHistPsiVZEROAV0M = BookTH2F("fHistPsiVZEROAV0M", "V0M", "#Psi_{2, VZEROA}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
467 fHistPsiVZEROCV0M = BookTH2F("fHistPsiVZEROCV0M", "V0M", "#Psi_{2, VZEROC}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
468 fHistPsiVZEROVV0M = BookTH2F("fHistPsiVZEROV0M", "V0M", "#Psi_{2, VZERO}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
469 fHistPsiTPCiV0M = BookTH2F("fHistPsiTPCV0M", "V0M", "#Psi_{2, TRK}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
470 fHistPsiVZEROATRK = BookTH2F("fHistPsiVZEROATRK", "TRK", "#Psi_{2, VZEROA}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
471 fHistPsiVZEROCTRK = BookTH2F("fHistPsiVZEROCTRK", "TRK", "#Psi_{2, VZEROC}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
472 fHistPsiVZEROTRK = BookTH2F("fHistPsiVZEROTRK", "TRK", "#Psi_{2, VZERO}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
473 fHistPsiTPCTRK = BookTH2F("fHistPsiTPCTRK", "TRK", "#Psi_{2, TRK}", 60, 0, 60, 40, -.5*TMath::Pi(), .5*TMath::Pi());
474 }
475 // background
476 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i ++) {
477 fHistRhoPackage[i] = BookTH1F("fHistRhoPackage", "#rho [GeV/c]", 100, 0, 150, i);
478 fHistRho[i] = BookTH1F("fHistRho", "#rho [GeV/c]", 100, 0, 150, i);
479 }
480 fHistRhoVsMult = BookTH2F("fHistRhoVsMult", "multiplicity", "#rho [GeV/c]", 100, 0, 4000, 100, 0, 250);
481 fHistRhoVsCent = BookTH2F("fHistRhoVsCent", "centrality", "#rho [GeV/c]", 100, 0, 100, 100, 0, 250);
482 fHistRhoAVsMult = BookTH2F("fHistRhoAVsMult", "multiplicity", "#rho * A (jet) [GeV/c]", 100, 0, 4000, 100, 0, 50);
483 fHistRhoAVsCent = BookTH2F("fHistRhoAVsCent", "centrality", "#rho * A (jet) [GeV/c]", 100, 0, 100, 100, 0, 50);
484
485 TString detector("");
486 switch (fDetectorType) {
487 case kTPC : detector+="TPC";
488 break;
489 case kVZEROA : detector+="VZEROA";
490 break;
491 case kVZEROC : detector+="VZEROC";
492 break;
493 case kVZEROComb : detector+="VZEROComb";
494 break;
06d2671d 495 case kFixedEP : detector+="FixedEP";
496 break;
eae37c5c 497 default: break;
498 }
499 // delta pt distributions
500 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i ++) {
501 if(fFillQAHistograms) fHistRCPhiEta[i] = BookTH2F("fHistRCPhiEta", "#phi (RC)", "#eta (RC)", 40, 0, TMath::TwoPi(), 40, -1, 1, i);
502 fHistRhoVsRCPt[i] = BookTH2F("fHistRhoVsRCPt", "p_{t} (RC) [GeV/c]", "#rho * A (RC) [GeV/c]", 100, 0, 300, 100, 0, 350, i);
503 fHistRCPt[i] = BookTH1F("fHistRCPt", "p_{t} (RC) [GeV/c]", 130, -20, 150, i);
504 if(fFillQAHistograms) fHistRCPhiEtaExLJ[i] = BookTH2F("fHistRCPhiEtaExLJ", "#phi (RC)", "#eta (RC)", 40, 0, TMath::TwoPi(), 40, -1, 1, i);
505 fHistDeltaPtDeltaPhi2[i] = BookTH2F("fHistDeltaPtDeltaPhi2", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
506 fHistDeltaPtDeltaPhi2Rho0[i] = BookTH2F("fHistDeltaPtDeltaPhi2Rho0", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
507 fHistRhoVsRCPtExLJ[i] = BookTH2F("fHistRhoVsRCPtExLJ", "p_{t} (RC) [GeV/c]", "#rho * A (RC) [GeV/c]", 100, 0, 300, 100, 0, 350, i);
508 fHistRCPtExLJ[i] = BookTH1F("fHistRCPtExLJ", "p_{t} (RC) [GeV/c]", 130, -20, 150, i);
509 fHistDeltaPtDeltaPhi2ExLJ[i] = BookTH2F("fHistDeltaPtDeltaPhi2ExLJ", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
510 fHistDeltaPtDeltaPhi2ExLJRho0[i] = BookTH2F("fHistDeltaPtDeltaPhi2ExLJRho0", Form("#phi - #Psi_{2, %s}", detector.Data()), "#delta p_{t} [GeV/c]", 40, 0, TMath::Pi(), 400, -70, 130, i);
511 // jet histograms (after kinematic cuts)
512 fHistJetPtRaw[i] = BookTH1F("fHistJetPtRaw", "p_{t, jet} RAW [GeV/c]", 200, -50, 150, i);
513 fHistJetPt[i] = BookTH1F("fHistJetPt", "p_{t, jet} [GeV/c]", 350, -100, 250, i);
514 if(fFillQAHistograms) fHistJetEtaPhi[i] = BookTH2F("fHistJetEtaPhi", "#eta", "#phi", 100, -1, 1, 100, 0, TMath::TwoPi(), i);
515 fHistJetPtArea[i] = BookTH2F("fHistJetPtArea", "p_{t, jet} [GeV/c]", "Area", 175, -100, 250, 30, 0, 0.9, i);
516 fHistJetPtEta[i] = BookTH2F("fHistJetPtEta", "p_{t, jet} [GeV/c]", "Eta", 175, -100, 250, 30, -0.9, 0.9, i);
517 fHistJetPtConstituents[i] = BookTH2F("fHistJetPtConstituents", "p_{t, jet} [GeV/c]", "Area", 350, -100, 250, 60, 0, 150, i);
518 fHistJetEtaRho[i] = BookTH2F("fHistJetEtaRho", "#eta", "#rho", 100, -1, 1, 100, 0, 300, i);
519 // in plane and out of plane spectra
520 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);
521 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);
522 // profiles for all correlator permutations which are necessary to calculate each second and third order event plane resolution
523 fProfV2Resolution[i] = new TProfile(Form("fProfV2Resolution_%i", i), Form("fProfV2Resolution_%i", i), 11, -0.5, 10.5);
524 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(3, "<cos(2(#Psi_{VZEROA} - #Psi_{VZEROC}))>");
525 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(4, "<cos(2(#Psi_{VZEROC} - #Psi_{VZEROA}))>");
526 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(5, "<cos(2(#Psi_{VZEROA} - #Psi_{TPC}))>");
527 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(6, "<cos(2(#Psi_{TPC} - #Psi_{VZEROA}))>");
528 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(7, "<cos(2(#Psi_{VZEROC} - #Psi_{TPC}))>");
529 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(8, "<cos(2(#Psi_{TPC} - #Psi_{VZEROC}))>");
530 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(9, "<cos(2(#Psi_{VZERO} - #Psi_{TPC_A}))>");
531 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(10, "<cos(2(#Psi_{VZERO} - #Psi_{TPC_B}))>");
532 fProfV2Resolution[i]->GetXaxis()->SetBinLabel(11, "<cos(2(#Psi_{TPC_A} - #Psi_{TPC_B}))>");
533 fOutputList->Add(fProfV2Resolution[i]);
534 fProfV3Resolution[i] = new TProfile(Form("fProfV3Resolution_%i", i), Form("fProfV3Resolution_%i", i), 11, -0.5, 10.5);
535 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(3, "<cos(3(#Psi_{VZEROA} - #Psi_{VZEROC}))>");
536 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(4, "<cos(3(#Psi_{VZEROC} - #Psi_{VZEROA}))>");
537 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(5, "<cos(3(#Psi_{VZEROA} - #Psi_{TPC}))>");
538 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(6, "<cos(3(#Psi_{TPC} - #Psi_{VZEROA}))>");
539 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(7, "<cos(3(#Psi_{VZEROC} - #Psi_{TPC}))>");
540 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(8, "<cos(3(#Psi_{TPC} - #Psi_{VZEROC}))>");
541 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(9, "<cos(3(#Psi_{VZERO} - #Psi_{TPC_A}))>");
542 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(10, "<cos(3(#Psi_{VZERO} - #Psi_{TPC_B}))>");
543 fProfV3Resolution[i]->GetXaxis()->SetBinLabel(11, "<cos(3(#Psi_{TPC_A} - #Psi_{TPC_B}))>");
544 fOutputList->Add(fProfV3Resolution[i]);
545 }
546 // vn profile
547 Float_t temp[fCentralityClasses->GetSize()];
548 for(Int_t i(0); i < fCentralityClasses->GetSize(); i++) temp[i] = fCentralityClasses->At(i);
549 fProfV2 = new TProfile("fProfV2", "fProfV2", fCentralityClasses->GetSize()-1, temp);
550 fProfV3 = new TProfile("fProfV3", "fProfV3", fCentralityClasses->GetSize()-1, temp);
551 fOutputList->Add(fProfV2);
552 fOutputList->Add(fProfV3);
553 switch (fFitModulationType) {
554 case kQC2 : {
555 fProfV2Cumulant = new TProfile("fProfV2Cumulant", "fProfV2Cumulant", fCentralityClasses->GetSize()-1, temp);
556 fProfV3Cumulant = new TProfile("fProfV3Cumulant", "fProfV3Cumulant", fCentralityClasses->GetSize()-1, temp);
557 fOutputList->Add(fProfV2Cumulant);
558 fOutputList->Add(fProfV3Cumulant);
559 } break;
560 case kQC4 : {
561 fProfV2Cumulant = new TProfile("fProfV2Cumulant", "fProfV2Cumulant", fCentralityClasses->GetSize()-1, temp);
562 fProfV3Cumulant = new TProfile("fProfV3Cumulant", "fProfV3Cumulant", fCentralityClasses->GetSize()-1, temp);
563 fOutputList->Add(fProfV2Cumulant);
564 fOutputList->Add(fProfV3Cumulant);
565 } break;
566 default : break;
567 }
568 // for the histograms initialized below, binning is fixed to runnumbers or flags
569 fReduceBinsXByFactor = 1;
570 fReduceBinsYByFactor = 1;
571 if(fFillQAHistograms) {
572 fHistRunnumbersEta = new TH2F("fHistRunnumbersEta", "fHistRunnumbersEta", fExpectedRuns->GetSize()+1, -.5, fExpectedRuns->GetSize()+.5, 100, -1.1, 1.1);
573 fHistRunnumbersEta->Sumw2();
574 fOutputList->Add(fHistRunnumbersEta);
575 fHistRunnumbersPhi = new TH2F("fHistRunnumbersPhi", "fHistRunnumbersPhi", fExpectedRuns->GetSize()+1, -.5, fExpectedRuns->GetSize()+.5, 100, -0.2, TMath::TwoPi()+0.2);
576 fHistRunnumbersPhi->Sumw2();
577 fOutputList->Add(fHistRunnumbersPhi);
578 for(Int_t i(0); i < fExpectedRuns->GetSize(); i++) {
579 fHistRunnumbersPhi->GetXaxis()->SetBinLabel(i+1, Form("%i", fExpectedRuns->At(i)));
580 fHistRunnumbersEta->GetXaxis()->SetBinLabel(i+1, Form("%i", fExpectedRuns->At(i)));
581 }
582 fHistRunnumbersPhi->GetXaxis()->SetBinLabel(fExpectedRuns->GetSize()+1, "undetermined");
583 fHistRunnumbersEta->GetXaxis()->SetBinLabel(fExpectedRuns->GetSize()+1, "undetermined");
584 }
585 fHistAnalysisSummary = BookTH1F("fHistAnalysisSummary", "flag", 54, -0.5, 54.5);
586 fHistSwap = new TH1F("fHistSwap", "fHistSwap", 20, 0, TMath::TwoPi());
587 if(fUsePtWeight) fHistSwap->Sumw2();
588
589 if(fUserSuppliedV2) fOutputList->Add(fUserSuppliedV2);
590 if(fUserSuppliedV3) fOutputList->Add(fUserSuppliedV3);
591 if(fUserSuppliedR2) fOutputList->Add(fUserSuppliedR2);
592 if(fUserSuppliedR3) fOutputList->Add(fUserSuppliedR3);
593 // increase readability of output list
594 fOutputList->Sort();
595 // cdf and pdf of chisquare distribution
596 fHistPvalueCDF = BookTH1F("fHistPvalueCDF", "CDF #chi^{2}", 50, 0, 1);
597 fHistPvalueCDFCent = BookTH2F("fHistPvalueCDFCent", "centrality", "p-value", 40, 0, 100, 40, 0, 1);
598 fHistChi2Cent = BookTH2F("fHistChi2Cent", "centrality", "#tilde{#chi^{2}}", 100, 0, 100, 100, 0, 5);
599 fHistPChi2 = BookTH2F("fHistPChi2", "p-value", "#tilde{#chi^{2}}", 1000, 0, 1, 100, 0, 5);
600 fHistKolmogorovTest = BookTH1F("fHistKolmogorovTest", "KolmogorovTest", 50, 0, 1);
601 fHistKolmogorovTestCent = BookTH2F("fHistKolmogorovTestCent", "centrality", "Kolmogorov p", 40, 0, 100, 45, 0, 1);
602 fHistPvalueCDFROOT = BookTH1F("fHistPvalueCDFROOT", "CDF #chi^{2} ROOT", 50, 0, 1);
603 fHistPvalueCDFROOTCent = BookTH2F("fHistPvalueCDFROOTCent", "centrality", "p-value ROOT", 40, 0, 100, 45, 0, 1);
604 fHistChi2ROOTCent = BookTH2F("fHistChi2ROOTCent", "centrality", "#tilde{#chi^{2}}", 40, 0, 100, 45, 0, 5);
605 fHistPChi2Root = BookTH2F("fHistPChi2Root", "p-value", "#tilde{#chi^{2}} ROOT", 1000, 0, 1, 100, 0, 5);
606 fHistPKolmogorov = BookTH2F("fHistPKolmogorov", "p-value", "kolmogorov p",40, 0, 1, 40, 0, 1);
607 fHistRhoStatusCent = BookTH2F("fHistRhoStatusCent", "centrality", "status [-1=lin was better, 0=ok, 1 = failed]", 101, -1, 100, 3, -1.5, 1.5);
608 fHistUndeterminedRunQA = BookTH1F("fHistUndeterminedRunQA", "runnumber", 10, 0, 10);
609
610 PostData(1, fOutputList);
611
612 switch (fRunModeType) {
613 case kLocal : {
614 fOutputListGood = new TList();
615 fOutputListGood->SetOwner(kTRUE);
616 fOutputListBad = new TList();
617 fOutputListBad->SetOwner(kTRUE);
618 PostData(2, fOutputListGood);
619 PostData(3, fOutputListBad);
620 } break;
621 default: break;
622 }
623
624 // get the containers
625 fTracksCont = GetParticleContainer("Tracks");
626 fClusterCont = GetClusterContainer(0); // get the default cluster container
627 fJetsCont = GetJetContainer("Jets");
628}
629//_____________________________________________________________________________
630Bool_t AliAnalysisTaskJetV2::Run()
631{
9e1c2f31 632 // called for each accepted event (call made from user exec of parent class)
eae37c5c 633 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
06d2671d 634 if(!fTracks||!fJets||!fRho) {
635 printf(" > Failed to retrieve input objects ! < \n");
636 return kFALSE;
637 }
eae37c5c 638 if(!fLocalInit) fLocalInit = InitializeAnalysis();
639 // reject the event if expected data is missing
640 if(!PassesCuts(InputEvent())) return kFALSE;
641 fLeadingJet = GetLeadingJet(); // store the leading jet
642 // set the rho value
643 fLocalRho->SetVal(fRho->GetVal());
06d2671d 644 // place holder arrays for the event planes
645 //
eae37c5c 646 // [0][0] psi2a [1,0] psi2c
647 // [0][1] psi3a [1,1] psi3c
648 Double_t vzero[2][2];
eae37c5c 649 /* for the combined vzero event plane
650 * [0] psi2 [1] psi3
651 * not fully implmemented yet, use with caution ! */
652 Double_t vzeroComb[2];
eae37c5c 653 // [0] psi2 [1] psi3
654 Double_t tpc[2];
06d2671d 655 // evaluate the actual event planes
656 switch (fDetectorType) {
657 case kFixedEP : {
658 // for fixed, fix all ep's to default values
659 tpc[0] = 0.; tpc[1] = 1.;
660 vzero[0][0] = 0.; vzero[0][1] = 1.;
661 vzero[1][0] = 0.; vzero[1][1] = 1.;
662 vzeroComb[0] = 0.; vzeroComb[1] = 1.;
663 } break;
664 default : {
665 // else grab the actual data
666 CalculateEventPlaneVZERO(vzero);
667 CalculateEventPlaneCombinedVZERO(vzeroComb);
668 CalculateEventPlaneTPC(tpc);
669 } break;
670 }
eae37c5c 671 Double_t psi2(-1), psi3(-1);
672 // arrays which will hold the fit parameters
673 switch (fDetectorType) { // determine the detector type for the rho fit
06d2671d 674 case kTPC : { psi2 = tpc[0]; psi3 = tpc[1]; } break;
675 case kVZEROA : { psi2 = vzero[0][0]; psi3 = vzero[0][1]; } break;
676 case kVZEROC : { psi2 = vzero[1][0]; psi3 = vzero[1][1]; } break;
677 case kVZEROComb : { psi2 = vzeroComb[0]; psi3 = vzeroComb[1];} break;
678 case kFixedEP : { psi2 = 0.; psi3 = 1.;} break;
eae37c5c 679 default : break;
680 }
681 switch (fFitModulationType) { // do the fits
682 case kNoFit : {
683 switch (fCollisionType) {
684 case kPythia : { // background is zero for pp jets
685 fFitModulation->FixParameter(0, 0);
686 fLocalRho->SetVal(0);
687 } break;
688 default : {
689 fFitModulation->FixParameter(0, fLocalRho->GetVal());
690 } break;
691 }
692 } break;
693 case kV2 : { // only v2
694 if(CorrectRho(psi2, psi3)) {
695 fProfV2->Fill(fCent, fFitModulation->GetParameter(3));
696 if(fUserSuppliedR2) {
697 Double_t r(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
698 if(r > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r);
699 }
700 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
701 }
702 } break;
703 case kV3 : { // only v3
704 if(CorrectRho(psi2, psi3)) {
705 if(fUserSuppliedR3) {
706 Double_t r(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
707 if(r > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r);
708 }
709 fProfV3->Fill(fCent, fFitModulation->GetParameter(3));
710 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
711 }
712 } break;
713 case kQC2 : { // qc2 analysis
714 if(CorrectRho(psi2, psi3)) {
715 if(fUserSuppliedR2 && fUserSuppliedR3) {
716 // note for the qc method, resolution is REVERSED to go back to v2obs
717 Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
718 Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
719 if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)*r2);
720 if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)*r3);
721 }
722 if (fUsePtWeight) { // use weighted weights
723 Double_t dQCnM11 = (fNoEventWeightsForQC) ? 1. : QCnM11();
724 fProfV2->Fill(fCent, fFitModulation->GetParameter(3), dQCnM11);
725 fProfV3->Fill(fCent, fFitModulation->GetParameter(7), dQCnM11);
726 } else {
727 Double_t dQCnM = (fNoEventWeightsForQC) ? 2. : QCnM();
728 fProfV2->Fill(fCent, fFitModulation->GetParameter(3), dQCnM*(dQCnM-1));
729 fProfV3->Fill(fCent, fFitModulation->GetParameter(7), dQCnM*(dQCnM-1));
730 }
731 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
732 }
733 } break;
734 case kQC4 : {
735 if(CorrectRho(psi2, psi3)) {
736 if(fUserSuppliedR2 && fUserSuppliedR3) {
737 // note for the qc method, resolution is REVERSED to go back to v2obs
738 Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
739 Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
740 if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)*r2);
741 if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)*r3);
742 }
743 if (fUsePtWeight) { // use weighted weights
744 fProfV2->Fill(fCent, TMath::Power(fFitModulation->GetParameter(3),0.5)/*, QCnM1111()*/);
745 fProfV3->Fill(fCent, TMath::Power(fFitModulation->GetParameter(7),0.5)/*, QCnM1111()*/);
746 } else {
747 fProfV2->Fill(fCent, TMath::Power(fFitModulation->GetParameter(3),0.5)/*, QCnM()*(QCnM()-1)*(QCnM()-2)*(QCnM()-3)*/);
748 fProfV3->Fill(fCent, TMath::Power(fFitModulation->GetParameter(7),0.5)/*, QCnM()*(QCnM()-1)*(QCnM()-2)*(QCnM()-3)*/);
749 }
750 }
751 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
752 } break;
753 default : {
754 if(CorrectRho(psi2, psi3)) {
755 if(fUserSuppliedR2 && fUserSuppliedR3) {
756 Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent)));
757 Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent)));
758 if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r2);
759 if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)/r3);
760 }
761 fProfV2->Fill(fCent, fFitModulation->GetParameter(3));
762 fProfV3->Fill(fCent, fFitModulation->GetParameter(7));
763 CalculateEventPlaneResolution(vzero, vzeroComb, tpc);
764 }
765 } break;
766 }
767 // if all went well, update the local rho parameter
768 fLocalRho->SetLocalRho(fFitModulation);
769 // fill a number of histograms. event qa needs to be filled first as it also determines the runnumber for the track qa
770 if(fFillQAHistograms) FillQAHistograms(InputEvent());
771 if(fFillHistograms) FillHistogramsAfterSubtraction(psi2, vzero, vzeroComb, tpc);
772 // send the output to the connected output container
773 PostData(1, fOutputList);
774 switch (fRunModeType) {
775 case kLocal : {
776 PostData(2, fOutputListGood);
777 PostData(3, fOutputListBad);
778 } break;
779 default: break;
780 }
781
782 return kTRUE;
783}
784//_____________________________________________________________________________
06d2671d 785void AliAnalysisTaskJetV2::Exec(Option_t* c)
786{
787 // for stand alone, avoid framework event setup
788 switch (fCollisionType) {
789 case kJetFlowMC : {
790 // need to call ExecOnce as it is not loaded otherwise
791 if(!fLocalRho) AliAnalysisTaskJetV2::ExecOnce();
792 AliAnalysisTaskJetV2::Run();
793 } break;
794 default : {
795 AliAnalysisTaskSE::Exec(c);
796 } break;
797 }
798}
799//_____________________________________________________________________________
9e1c2f31 800Double_t AliAnalysisTaskJetV2::CalculateEventPlaneChi(Double_t res)
801{
4a4073c4 802 // return chi for given resolution to combine event plane estimates from two subevents
803 // see Phys. Rev. C no. CS6346 (http://arxiv.org/abs/nucl-ex/9805001)
804 Double_t chi(2.), delta(1.), con((TMath::Sqrt(TMath::Pi()))/(2.*TMath::Sqrt(2)));
9e1c2f31 805 for (Int_t i(0); i < 15; i++) {
806 chi = ((con*chi*TMath::Exp(-chi*chi/4.)*(TMath::BesselI0(chi*chi/4.)+TMath::BesselI1(chi*chi/4.))) < res) ? chi + delta : chi - delta;
807 delta = delta / 2.;
808 }
809 return chi;
810}
811//_____________________________________________________________________________
eae37c5c 812void AliAnalysisTaskJetV2::CalculateEventPlaneVZERO(Double_t vzero[2][2]) const
813{
9e1c2f31 814 // get the vzero event plane (a and c separately)
6c3fa11d 815 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
9e1c2f31 816 switch (fCollisionType) {
817 case kPbPb10h : {
818 // for 10h data, get the calibrated q-vector from the database
819 Double_t QA2[] = {-999., -999.};
820 Double_t QA3[] = {-999., -999.};
821 Double_t QC2[] = {-999., -999.};
822 Double_t QC3[] = {-999., -999.};
823 CalculateQvectorVZERO(QA2, QA3, QC2, QC3);
824 vzero[0][0] = .5*TMath::ATan2(QA2[1], QA2[0]);
825 vzero[1][0] = .5*TMath::ATan2(QC2[1], QC2[0]);
826 vzero[0][1] = (1./3.)*TMath::ATan2(QA3[1], QA3[0]);
827 vzero[1][1] = (1./3.)*TMath::ATan2(QC3[1], QC3[0]);
828 } break;
829 default: {
830 // by default use the ep from the event header (make sure EP selection task is enabeled!)
831 Double_t a(0), b(0), c(0), d(0), e(0), f(0), g(0), h(0);
832 vzero[0][0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 2, a, b);
833 vzero[1][0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 2, c, d);
834 vzero[0][1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 3, e, f);
835 vzero[1][1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 3, g, h);
836 return;
837 }
eae37c5c 838 }
9e1c2f31 839}
840//_____________________________________________________________________________
841void AliAnalysisTaskJetV2::CalculateEventPlaneCombinedVZERO(Double_t* comb) const
842{
843 // return the combined vzero event plane
eae37c5c 844 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
9e1c2f31 845 switch (fCollisionType) {
846 // for 10h data call calibration info
847 case kPbPb10h : {
848 // get the calibrated q-vectors
849 Double_t Q2[] = {-999., -999.};
850 Double_t Q3[] = {-999., -999.};
851 // return if something isn't ok from the calibration side
852 CalculateQvectorCombinedVZERO(Q2, Q3);
853 comb[0] = .5*TMath::ATan2(Q2[1], Q2[0]);
854 comb[1] = (1./3.)*TMath::ATan2(Q3[1], Q3[0]);
855 } break;
856 default : {
857 // for all other types use calibrated event plane from the event header
858 Double_t a(0), b(0), c(0), d(0);
859 comb[0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 10, 2, a, b);
860 comb[1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 10, 3, c, d);
861 } break;
eae37c5c 862 }
eae37c5c 863}
864//_____________________________________________________________________________
865void AliAnalysisTaskJetV2::CalculateEventPlaneTPC(Double_t* tpc)
866{
867 // grab the TPC event plane
868 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
869 fNAcceptedTracks = 0; // reset the track counter
870 Double_t qx2(0), qy2(0); // for psi2
871 Double_t qx3(0), qy3(0); // for psi3
872 if(fTracksCont) {
873 Float_t excludeInEta = -999;
874 if(fExcludeLeadingJetsFromFit > 0 ) { // remove the leading jet from ep estimate
875 if(fLeadingJet) excludeInEta = fLeadingJet->Eta();
876 }
877 for(Int_t iTPC(0); iTPC < fTracksCont->GetNEntries(); iTPC++) {
878 AliVParticle* track = fTracksCont->GetParticle(iTPC);
879 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
880 if(fExcludeLeadingJetsFromFit > 0 &&( (TMath::Abs(track->Eta() - excludeInEta) < GetJetContainer()->GetJetRadius()*fExcludeLeadingJetsFromFit ) || (TMath::Abs(track->Eta()) - GetJetContainer()->GetJetRadius() - GetJetContainer()->GetJetEtaMax() ) > 0 )) continue;
881 fNAcceptedTracks++;
882 qx2+= TMath::Cos(2.*track->Phi());
883 qy2+= TMath::Sin(2.*track->Phi());
884 qx3+= TMath::Cos(3.*track->Phi());
885 qy3+= TMath::Sin(3.*track->Phi());
886 }
887 }
888 tpc[0] = .5*TMath::ATan2(qy2, qx2);
889 tpc[1] = (1./3.)*TMath::ATan2(qy3, qx3);
eae37c5c 890}
891//_____________________________________________________________________________
892void AliAnalysisTaskJetV2::CalculateEventPlaneResolution(Double_t vzero[2][2], Double_t* vzeroComb, Double_t* tpc)
893{
894 // fill the profiles for the resolution parameters
9e1c2f31 895 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 896 fProfV2Resolution[fInCentralitySelection]->Fill(2., TMath::Cos(2.*(vzero[0][0] - vzero[1][0])));
897 fProfV2Resolution[fInCentralitySelection]->Fill(3., TMath::Cos(2.*(vzero[1][0] - vzero[0][0])));
898 fProfV2Resolution[fInCentralitySelection]->Fill(4., TMath::Cos(2.*(vzero[0][0] - tpc[0])));
899 fProfV2Resolution[fInCentralitySelection]->Fill(5., TMath::Cos(2.*(tpc[0] - vzero[0][0])));
900 fProfV2Resolution[fInCentralitySelection]->Fill(6., TMath::Cos(2.*(vzero[1][0] - tpc[0])));
901 fProfV2Resolution[fInCentralitySelection]->Fill(7., TMath::Cos(2.*(tpc[0] - vzero[1][0])));
902 fProfV3Resolution[fInCentralitySelection]->Fill(2., TMath::Cos(3.*(vzero[0][0] - vzero[1][0])));
903 fProfV3Resolution[fInCentralitySelection]->Fill(3., TMath::Cos(3.*(vzero[1][0] - vzero[0][0])));
904 fProfV3Resolution[fInCentralitySelection]->Fill(4., TMath::Cos(3.*(vzero[0][0] - tpc[0])));
905 fProfV3Resolution[fInCentralitySelection]->Fill(5., TMath::Cos(3.*(tpc[0] - vzero[0][0])));
906 fProfV3Resolution[fInCentralitySelection]->Fill(6., TMath::Cos(3.*(vzero[1][0] - tpc[0])));
907 fProfV3Resolution[fInCentralitySelection]->Fill(7., TMath::Cos(3.*(tpc[0] - vzero[1][0])));
908 // for the resolution of the combined vzero event plane, use two tpc halves as uncorrelated subdetectors
909 Double_t qx2a(0), qy2a(0); // for psi2a, negative eta
910 Double_t qx3a(0), qy3a(0); // for psi3a, negative eta
911 Double_t qx2b(0), qy2b(0); // for psi2a, positive eta
912 Double_t qx3b(0), qy3b(0); // for psi3a, positive eta
913 if(fTracks) {
914 Int_t iTracks(fTracks->GetEntriesFast());
915 for(Int_t iTPC(0); iTPC < iTracks; iTPC++) {
916 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC));
917 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
918 if(track->Eta() < 0 ) {
919 qx2a+= TMath::Cos(2.*track->Phi());
920 qy2a+= TMath::Sin(2.*track->Phi());
921 qx3a+= TMath::Cos(3.*track->Phi());
922 qy3a+= TMath::Sin(3.*track->Phi());
923 } else if (track->Eta() > 0) {
924 qx2b+= TMath::Cos(2.*track->Phi());
925 qy2b+= TMath::Sin(2.*track->Phi());
926 qx3b+= TMath::Cos(3.*track->Phi());
927 qy3b+= TMath::Sin(3.*track->Phi());
928 }
929 }
930 }
931 Double_t tpca2(.5*TMath::ATan2(qy2a, qx2a));
932 Double_t tpca3((1./3.)*TMath::ATan2(qy3a, qx3a));
933 Double_t tpcb2(.5*TMath::ATan2(qy2b, qx2b));
934 Double_t tpcb3((1./3.)*TMath::ATan2(qy3b, qx3b));
935 fProfV2Resolution[fInCentralitySelection]->Fill(8., TMath::Cos(2.*(vzeroComb[0] - tpca2)));
936 fProfV2Resolution[fInCentralitySelection]->Fill(9., TMath::Cos(2.*(vzeroComb[0] - tpcb2)));
937 fProfV2Resolution[fInCentralitySelection]->Fill(10., TMath::Cos(2.*(tpca2 - tpcb2)));
938 fProfV3Resolution[fInCentralitySelection]->Fill(8., TMath::Cos(3.*(vzeroComb[1] - tpca3)));
939 fProfV3Resolution[fInCentralitySelection]->Fill(9., TMath::Cos(3.*(vzeroComb[1] - tpcb3)));
940 fProfV3Resolution[fInCentralitySelection]->Fill(10., TMath::Cos(3.*(tpca3 - tpcb3)));
941}
942//_____________________________________________________________________________
9e1c2f31 943void AliAnalysisTaskJetV2::CalculateQvectorVZERO(Double_t Qa2[2], Double_t Qc2[2], Double_t Qa3[2], Double_t Qc3[2]) const
944{
945 // return the calibrated 2nd and 3rd order q-vectors for vzeroa and vzeroc
946 // function takes arrays as arguments, which correspond to vzero info in the following way
947 //
948 // Qa2[0] = Qx2 for vzero A Qa2[1] = Qy2 for vzero A (etc)
949
950 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
951 // placeholders for geometric information
952 Double_t phi(-999.), weight(-999.);
953 // reset placeholders for Q-vector components
954 Qa2[0] = 0.; Qc2[0] = 0.; Qa3[0] = 0.; Qc3[0] = 0.;
955 Qa2[1] = 0.; Qc2[1] = 0.; Qa3[1] = 0.; Qc3[1] = 0.;
956
957 for(Int_t i(0); i < 64; i++) {
958 // loop over all scintillators, construct Q-vectors in the same loop
959 phi = TMath::PiOver4()*(0.5+i%8);
960 weight = 0.;
961 // note that disabled rings have already been excluded in ReadVZEROCalibration2010h
962 if(i<32) { // v0c side
963 if(i < 8) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROCpol[0]/fVZEROgainEqualization->GetBinContent(1+i);
964 else if (i < 16 ) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROCpol[1]/fVZEROgainEqualization->GetBinContent(1+i);
965 else if (i < 24 ) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROCpol[2]/fVZEROgainEqualization->GetBinContent(1+i);
966 else if (i < 32 ) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROCpol[3]/fVZEROgainEqualization->GetBinContent(1+i);
967 // fill Q-vectors for v0c side
968 Qc2[0]+=weight*TMath::Cos(2.*phi);
969 Qc3[0]+=weight*TMath::Cos(3.*phi);
970 Qc2[1]+=weight*TMath::Sin(2.*phi);
971 Qc3[1]+=weight*TMath::Sin(3.*phi);
972 } else { // v0a side
973 if( i < 40) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROApol[0]/fVZEROgainEqualization->GetBinContent(1+i);
974 else if ( i < 48 ) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROApol[1]/fVZEROgainEqualization->GetBinContent(1+i);
975 else if ( i < 56 ) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROApol[2]/fVZEROgainEqualization->GetBinContent(1+i);
976 else if ( i < 64 ) weight = InputEvent()->GetVZEROData()->GetMultiplicity(i)*fVZEROApol[3]/fVZEROgainEqualization->GetBinContent(1+i);
977 // fill Q-vectors for v0a side
978 Qa2[0]+=weight*TMath::Cos(2.*phi);
979 Qa3[0]+=weight*TMath::Cos(3.*phi);
980 Qa2[1]+=weight*TMath::Sin(2.*phi);
981 Qa3[1]+=weight*TMath::Sin(3.*phi);
982 }
983 }
984 // get the cache index and read the correction terms from the cache
985 Int_t VZEROcentralityBin(GetVZEROCentralityBin());
986 Double_t Qx2amean = fMeanQ[VZEROcentralityBin][1][0];
987 Double_t Qx2arms = fWidthQ[VZEROcentralityBin][1][0];
988 Double_t Qy2amean = fMeanQ[VZEROcentralityBin][1][1];
989 Double_t Qy2arms = fWidthQ[VZEROcentralityBin][1][1];
990
991 Double_t Qx2cmean = fMeanQ[VZEROcentralityBin][0][0];
992 Double_t Qx2crms = fWidthQ[VZEROcentralityBin][0][0];
993 Double_t Qy2cmean = fMeanQ[VZEROcentralityBin][0][1];
994 Double_t Qy2crms = fWidthQ[VZEROcentralityBin][0][1];
995
996 Double_t Qx3amean = fMeanQv3[VZEROcentralityBin][1][0];
997 Double_t Qx3arms = fWidthQv3[VZEROcentralityBin][1][0];
998 Double_t Qy3amean = fMeanQv3[VZEROcentralityBin][1][1];
999 Double_t Qy3arms = fWidthQv3[VZEROcentralityBin][1][1];
1000
1001 Double_t Qx3cmean = fMeanQv3[VZEROcentralityBin][0][0];
1002 Double_t Qx3crms = fWidthQv3[VZEROcentralityBin][0][0];
1003 Double_t Qy3cmean = fMeanQv3[VZEROcentralityBin][0][1];
1004 Double_t Qy3crms = fWidthQv3[VZEROcentralityBin][0][1];
1005
1006 // update the weighted q-vectors with the re-centered values
1007 Qa2[0] = (Qa2[0] - Qx2amean)/Qx2arms;
1008 Qa2[1] = (Qa2[1] - Qy2amean)/Qy2arms;
1009 Qc2[0] = (Qc2[0] - Qx2cmean)/Qx2crms;
1010 Qc2[1] = (Qc2[1] - Qy2cmean)/Qy2crms;
1011
1012 Qa3[0] = (Qa3[0] - Qx3amean)/Qx3arms;
1013 Qa3[1] = (Qa3[1] - Qy3amean)/Qy3arms;
1014 Qc3[0] = (Qc3[0] - Qx3cmean)/Qx3crms;
1015 Qc3[1] = (Qc3[0] - Qy3cmean)/Qy3crms;
1016}
1017//_____________________________________________________________________________
1018void AliAnalysisTaskJetV2::CalculateQvectorCombinedVZERO(Double_t Q2[2], Double_t Q3[2]) const
1019{
1020 // calculate calibrated q-vector of the combined vzeroa, vzeroc system
1021 // this is somewhat ugly as CalculateQvectorCombinedVZERO is called more than once per event
1022 // but for now it will have to do ...
1023 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1024
1025 // first step: retrieve the q-vectors component-wise per vzero detector
1026 Double_t QA2[] = {-999., -999.};
1027 Double_t QA3[] = {-999., -999.};
1028 Double_t QC2[] = {-999., -999.};
1029 Double_t QC3[] = {-999., -999.};
1030 CalculateQvectorVZERO(QA2, QA3, QC2, QC3);
1031
1032 // get cache index and retrieve the chi weights for this centrality
1033 Int_t VZEROcentralityBin(GetVZEROCentralityBin());
1034 Double_t chi2A(fChi2A->At(VZEROcentralityBin));
1035 Double_t chi2C(fChi2C->At(VZEROcentralityBin));
1036 Double_t chi3A(fChi3A->At(VZEROcentralityBin));
1037 Double_t chi3C(fChi3C->At(VZEROcentralityBin));
1038
1039 // combine the vzera and vzeroc signal
1040 Q2[0] = chi2A*chi2A*QA2[0]+chi2C*chi2C*QC2[0];
1041 Q2[1] = chi2A*chi2A*QA2[1]+chi2C*chi2C*QC2[1];
1042 Q3[0] = chi3A*chi3A*QA3[0]+chi3C*chi3C*QC3[0];
1043 Q3[1] = chi3A*chi3A*QC3[1]+chi3C*chi3C*QC3[1];
1044}
1045//_____________________________________________________________________________
eae37c5c 1046void AliAnalysisTaskJetV2::CalculateRandomCone(Float_t &pt, Float_t &eta, Float_t &phi,
1047 AliParticleContainer* tracksCont, AliClusterContainer* clusterCont, AliEmcalJet* jet) const
1048{
1049 // get a random cone
1050 if(fDebug > 1) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1051 pt = 0; eta = 0; phi = 0;
1052 Float_t etaJet(999), phiJet(999), dJet(999); // no jet: same as jet very far away
1053 if(jet) { // if a leading jet is given, use its kinematic properties to exclude it
1054 etaJet = jet->Eta();
1055 phiJet = jet->Phi();
1056 }
1057 // the random cone acceptance has to equal the jet acceptance
1058 // this also insures safety when runnnig on the semi-good tpc runs for 11h data,
1059 // where jet acceptance is adjusted to reduced acceptance - hence random cone acceptance as well
1060 Float_t minPhi(GetJetContainer()->GetJetPhiMin()), maxPhi(GetJetContainer()->GetJetPhiMax());
1061 if(maxPhi > TMath::TwoPi()) maxPhi = TMath::TwoPi();
1062 if(minPhi < 0 ) minPhi = 0.;
1063 // construct a random cone and see if it's far away enough from the leading jet
1064 Int_t attempts(1000);
1065 while(kTRUE) {
1066 attempts--;
1067 eta = gRandom->Uniform(GetJetContainer()->GetJetEtaMin(), GetJetContainer()->GetJetEtaMax());
1068 phi = gRandom->Uniform(minPhi, maxPhi);
1069
1070 dJet = TMath::Sqrt((etaJet-eta)*(etaJet-eta)+(phiJet-phi)*(phiJet-phi));
1071 if(dJet > fMinDisanceRCtoLJ) break;
1072 else if (attempts == 0) {
1073 printf(" > No random cone after 1000 tries, giving up ... !\n");
1074 return;
1075 }
1076 }
1077 // get the charged energy (if tracks are provided)
1078 if(tracksCont) {
1079 AliVParticle* track = tracksCont->GetNextAcceptParticle(0);
1080 while(track) {
1081 Float_t etaTrack(track->Eta()), phiTrack(track->Phi());
1082 // get distance from cone
1083 if(TMath::Abs(phiTrack-phi) > TMath::Abs(phiTrack - phi + TMath::TwoPi())) phiTrack+=TMath::TwoPi();
1084 if(TMath::Abs(phiTrack-phi) > TMath::Abs(phiTrack - phi - TMath::TwoPi())) phiTrack-=TMath::TwoPi();
1085 if(TMath::Sqrt(TMath::Abs((etaTrack-eta)*(etaTrack-eta)+(phiTrack-phi)*(phiTrack-phi))) <= GetJetRadius()) pt += track->Pt();
1086 track = tracksCont->GetNextAcceptParticle();
1087 }
1088 }
1089 // get the neutral energy (if clusters are provided)
1090 if(clusterCont) {
1091 AliVCluster* cluster = clusterCont->GetNextAcceptCluster(0);
1092 while(cluster) {
1093 TLorentzVector momentum;
1094 cluster->GetMomentum(momentum, const_cast<Double_t*>(fVertex));
1095 Float_t etaClus(momentum.Eta()), phiClus(momentum.Phi());
1096 // get distance from cone
1097 if(TMath::Abs(phiClus-phi) > TMath::Abs(phiClus - phi + TMath::TwoPi())) phiClus+=TMath::TwoPi();
1098 if(TMath::Abs(phiClus-phi) > TMath::Abs(phiClus - phi - TMath::TwoPi())) phiClus-=TMath::TwoPi();
1099 if(TMath::Sqrt(TMath::Abs((etaClus-eta)*(etaClus-eta)+(phiClus-phi)*(phiClus-phi))) <= GetJetRadius()) pt += momentum.Pt();
1100 cluster = clusterCont->GetNextAcceptCluster();
1101 }
1102 }
1103}
1104//_____________________________________________________________________________
1105Double_t AliAnalysisTaskJetV2::CalculateQC2(Int_t harm) {
1106 // get the second order q-cumulant, a -999 return will be caught in the qa routine of CorrectRho
1107 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1108 Double_t reQ(0), imQ(0), modQ(0), M11(0), M(0);
1109 if(fUsePtWeight) { // for the weighted 2-nd order q-cumulant
1110 QCnQnk(harm, 1, reQ, imQ); // get the weighted 2-nd order q-vectors
1111 modQ = reQ*reQ+imQ*imQ; // get abs Q-squared
1112 M11 = QCnM11(); // equals S2,1 - S1,2
1113 return (M11 > 0) ? ((modQ - QCnS(1,2))/M11) : -999;
1114 } // else return the non-weighted 2-nd order q-cumulant
1115 QCnQnk(harm, 0, reQ, imQ); // get the non-weighted 2-nd order q-vectors
1116 modQ = reQ*reQ+imQ*imQ; // get abs Q-squared
1117 M = QCnM();
1118 return (M > 1) ? (modQ - M)/(M*(M-1)) : -999;
1119}
1120//_____________________________________________________________________________
1121Double_t AliAnalysisTaskJetV2::CalculateQC4(Int_t harm) {
1122 // get the fourth order q-cumulant, a -999 return will be caught in the qa routine of CorrectRho
1123 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1124 Double_t reQn1(0), imQn1(0), reQ2n2(0), imQ2n2(0), reQn3(0), imQn3(0), M1111(0), M(0);
1125 Double_t a(0), b(0), c(0), d(0), e(0), f(0), g(0); // terms of the calculation
1126 if(fUsePtWeight) { // for the weighted 4-th order q-cumulant
1127 QCnQnk(harm, 1, reQn1, imQn1);
1128 QCnQnk(harm*2, 2, reQ2n2, imQ2n2);
1129 QCnQnk(harm, 3, reQn3, imQn3);
1130 // fill in the terms ...
1131 a = (reQn1*reQn1+imQn1*imQn1)*(reQn1*reQn1+imQn1*imQn1);
1132 b = reQ2n2*reQ2n2 + imQ2n2*imQ2n2;
1133 c = -2.*(reQ2n2*reQn1*reQn1-reQ2n2*imQn1*imQn1+2.*imQ2n2*reQn1*imQn1);
1134 d = 8.*(reQn3*reQn1+imQn3*imQn1);
1135 e = -4.*QCnS(1,2)*(reQn1*reQn1+imQn1*imQn1);
1136 f = -6.*QCnS(1,4);
1137 g = 2.*QCnS(2,2);
1138 M1111 = QCnM1111();
1139 return (M1111 > 0) ? (a+b+c+d+e+f+g)/M1111 : -999;
1140 } // else return the unweighted case
1141 Double_t reQn(0), imQn(0), reQ2n(0), imQ2n(0);
1142 QCnQnk(harm, 0, reQn, imQn);
1143 QCnQnk(harm*2, 0, reQ2n, imQ2n);
1144 // fill in the terms ...
1145 M = QCnM();
1146 if(M < 4) return -999;
1147 a = (reQn*reQn+imQn*imQn)*(reQn*reQn+imQn*imQn);
1148 b = reQ2n*reQ2n + imQ2n*imQ2n;
1149 c = -2.*(reQ2n*reQn*reQn-reQ2n*imQn*imQn+2.*imQ2n*reQn*imQn);
1150 e = -4.*(M-2)*(reQn*reQn+imQn*imQn);
1151 f = 2.*M*(M-3);
1152 return (a+b+c+e+f)/(M*(M-1)*(M-2)*(M-3));
1153}
1154//_____________________________________________________________________________
1155void AliAnalysisTaskJetV2::QCnQnk(Int_t n, Int_t k, Double_t &reQ, Double_t &imQ) {
1156 // get the weighted n-th order q-vector, pass real and imaginary part as reference
1157 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1158 if(!fTracks) return;
1159 fNAcceptedTracksQCn = 0;
1160 Int_t iTracks(fTracks->GetEntriesFast());
1161 for(Int_t iTPC(0); iTPC < iTracks; iTPC++) {
1162 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC));
1163 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
1164 fNAcceptedTracksQCn++;
1165 // for the unweighted case, k equals zero and the weight doesn't contribute to the equation below
1166 reQ += TMath::Power(track->Pt(), k) * TMath::Cos(((double)n)*track->Phi());
1167 imQ += TMath::Power(track->Pt(), k) * TMath::Sin(((double)n)*track->Phi());
1168 }
1169}
1170//_____________________________________________________________________________
1171void AliAnalysisTaskJetV2::QCnDiffentialFlowVectors(
1172 TClonesArray* pois, TArrayD* ptBins, Bool_t vpart, Double_t* repn, Double_t* impn,
1173 Double_t *mp, Double_t *reqn, Double_t *imqn, Double_t* mq, Int_t n)
1174{
9e1c2f31 1175 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1176 // get unweighted differential flow vectors
eae37c5c 1177 Int_t iPois(pois->GetEntriesFast());
1178 if(vpart) {
1179 for(Int_t i(0); i < iPois; i++) {
1180 for(Int_t ptBin(0); ptBin < ptBins->GetSize()-1; ptBin++) {
1181 AliVTrack* poi = static_cast<AliVTrack*>(pois->At(i));
1182 if(PassesCuts(poi)) {
1183 if(poi->Pt() >= ptBins->At(ptBin) && poi->Pt() < ptBins->At(ptBin+1)) {
1184 // fill the flow vectors assuming that all poi's are in the rp selection (true by design)
1185 repn[ptBin]+=TMath::Cos(((double)n)*poi->Phi());
1186 impn[ptBin]+=TMath::Sin(((double)n)*poi->Phi());
1187 mp[ptBin]++;
1188 reqn[ptBin]+=TMath::Cos(((double)n)*poi->Phi());
1189 imqn[ptBin]+=TMath::Sin(((double)n)*poi->Phi());
1190 mq[ptBin]++;
1191 }
1192 }
1193 }
1194 }
1195 } else {
1196 for(Int_t i(0); i < iPois; i++) {
1197 for(Int_t ptBin(0); ptBin < ptBins->GetSize()-1; ptBin++) {
1198 AliEmcalJet* poi = static_cast<AliEmcalJet*>(pois->At(i));
1199 if(PassesCuts(poi)) {
1200 Double_t pt(poi->Pt()-poi->Area()*fLocalRho->GetLocalVal(poi->Phi(), GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1201 if(pt >= ptBins->At(ptBin) && pt < ptBins->At(ptBin+1)) {
1202 repn[ptBin]+=TMath::Cos(((double)n)*poi->Phi());
1203 impn[ptBin]+=TMath::Sin(((double)n)*poi->Phi());
1204 mp[ptBin]++; // qn isn't filled, no overlap between poi's and rp's
1205 }
1206 }
1207 }
1208 }
1209 }
1210}
1211//_____________________________________________________________________________
1212Double_t AliAnalysisTaskJetV2::QCnS(Int_t i, Int_t j) {
1213 // get the weighted ij-th order autocorrelation correction
1214 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1215 if(!fTracks || i <= 0 || j <= 0) return -999;
1216 Int_t iTracks(fTracks->GetEntriesFast());
1217 Double_t Sij(0);
1218 for(Int_t iTPC(0); iTPC < iTracks; iTPC++) {
1219 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC));
1220 if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue;
1221 Sij+=TMath::Power(track->Pt(), j);
1222 }
1223 return TMath::Power(Sij, i);
1224}
1225//_____________________________________________________________________________
1226Double_t AliAnalysisTaskJetV2::QCnM() {
1227 // get multiplicity for unweighted q-cumulants. function QCnQnk should be called first
1228 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1229 return (Double_t) fNAcceptedTracksQCn;
1230}
1231//_____________________________________________________________________________
1232Double_t AliAnalysisTaskJetV2::QCnM11() {
1233 // get multiplicity weights for the weighted two particle cumulant
1234 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1235 return (QCnS(2,1) - QCnS(1,2));
1236}
1237//_____________________________________________________________________________
1238Double_t AliAnalysisTaskJetV2::QCnM1111() {
1239 // get multiplicity weights for the weighted four particle cumulant
1240 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1241 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));
1242}
1243//_____________________________________________________________________________
1244Bool_t AliAnalysisTaskJetV2::QCnRecovery(Double_t psi2, Double_t psi3) {
1245 // decides how to deal with the situation where c2 or c3 is negative
1246 // returns kTRUE depending on whether or not a modulated rho is used for the jet background
1247 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1248 if(TMath::AreEqualAbs(fFitModulation->GetParameter(3), .0, 1e-10) && TMath::AreEqualAbs(fFitModulation->GetParameter(7), .0,1e-10)) {
1249 fFitModulation->SetParameter(7, 0);
1250 fFitModulation->SetParameter(3, 0);
1251 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1252 return kTRUE; // v2 and v3 have physical null values
1253 }
1254 switch (fQCRecovery) {
1255 case kFixedRho : { // roll back to the original rho
1256 fFitModulation->SetParameter(7, 0);
1257 fFitModulation->SetParameter(3, 0);
1258 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1259 return kFALSE; // rho is forced to be fixed
1260 }
1261 case kNegativeVn : {
1262 Double_t c2(fFitModulation->GetParameter(3));
1263 Double_t c3(fFitModulation->GetParameter(7));
1264 if( c2 < 0 ) c2 = -1.*TMath::Sqrt(-1.*c2);
1265 if( c3 < 0 ) c3 = -1.*TMath::Sqrt(-1.*c3);
1266 fFitModulation->SetParameter(3, c2);
1267 fFitModulation->SetParameter(7, c3);
1268 return kTRUE; // is this a physical quantity ?
1269 }
1270 case kTryFit : {
1271 fitModulationType tempType(fFitModulationType); // store temporarily
1272 fFitModulationType = kCombined;
1273 fFitModulation->SetParameter(7, 0);
1274 fFitModulation->SetParameter(3, 0);
1275 Bool_t pass(CorrectRho(psi2, psi3)); // do the fit and all quality checks
1276 fFitModulationType = tempType; // roll back for next event
1277 return pass;
1278 }
1279 default : return kFALSE;
1280 }
1281 return kFALSE;
1282}
1283//_____________________________________________________________________________
1284Bool_t AliAnalysisTaskJetV2::CorrectRho(Double_t psi2, Double_t psi3)
1285{
1286 // get rho' -> rho(phi)
1287 // two routines are available, both can be used with or without pt weights
1288 // [1] get vn from q-cumulants or as an integrated value from a user supplied histogram
1289 // in case of cumulants, both cumulants and vn values are stored. in both cases, v2 and v3
1290 // are expected. a check is performed to see if rho has no negative local minimum
1291 // for full description, see Phys. Rev. C 83, 044913
1292 // since the cn distribution has negative values, vn = sqrt(cn) can be imaginary sometimes
1293 // in this case one can either roll back to the 'original' rixed rho, do a fit for vn or take use
1294 // vn = - sqrt(|cn|)
1295 // [2] fitting a fourier expansion to the de/dphi distribution
1296 // the fit can be done with either v2, v3 or a combination.
1297 // in all cases, a cut can be made on the p-value of the chi-squared value of the fit
1298 // and a check can be performed to see if rho has no negative local minimum
1299 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1300 Int_t freeParams(2); // free parameters of the fit (for NDF)
1301 switch (fFitModulationType) { // for approaches where no fitting is required
1302 case kQC2 : {
1303 fFitModulation->FixParameter(4, psi2);
1304 fFitModulation->FixParameter(6, psi3);
1305 fFitModulation->FixParameter(3, CalculateQC2(2)); // set here with cn, vn = sqrt(cn)
1306 fFitModulation->FixParameter(7, CalculateQC2(3));
1307 // first fill the histos of the raw cumulant distribution
1308 if (fUsePtWeight) { // use weighted weights
1309 Double_t dQCnM11 = (fNoEventWeightsForQC) ? 1. : QCnM11();
1310 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3), dQCnM11);
1311 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7), dQCnM11);
1312 } else {
1313 Double_t dQCnM = (fNoEventWeightsForQC) ? 2. : QCnM();
1314 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3), dQCnM*(dQCnM-1));
1315 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7), dQCnM*(dQCnM-1));
1316 }
1317 // then see if one of the cn value is larger than zero and vn is readily available
1318 if(fFitModulation->GetParameter(3) > 0 && fFitModulation->GetParameter(7) > 0) {
1319 fFitModulation->FixParameter(3, TMath::Sqrt(fFitModulation->GetParameter(3)));
1320 fFitModulation->FixParameter(7, TMath::Sqrt(fFitModulation->GetParameter(7)));
1321 } else if (!QCnRecovery(psi2, psi3)) return kFALSE; // try to recover the cumulant, this will set v2 and v3
1322 if(fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { // general check
1323 fFitModulation->SetParameter(7, 0);
1324 fFitModulation->SetParameter(3, 0);
1325 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1326 return kFALSE;
1327 }
1328 return kTRUE;
1329 } break;
1330 case kQC4 : {
1331 fFitModulation->FixParameter(4, psi2);
1332 fFitModulation->FixParameter(6, psi3);
1333 fFitModulation->FixParameter(3, CalculateQC4(2)); // set here with cn, vn = sqrt(cn)
1334 fFitModulation->FixParameter(7, CalculateQC4(3));
1335 // first fill the histos of the raw cumulant distribution
1336 if (fUsePtWeight) { // use weighted weights
1337 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3)/*, QCnM1111()*/);
1338 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7)/*, QCnM1111()*/);
1339 } else {
1340 fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3)/*, QCnM1111()*/);
1341 fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7)/*, QCnM1111()*/);
1342 }
1343 // then see if one of the cn value is larger than zero and vn is readily available
1344 if(fFitModulation->GetParameter(3) > 0 && fFitModulation->GetParameter(7) > 0) {
1345 fFitModulation->FixParameter(3, TMath::Sqrt(fFitModulation->GetParameter(3)));
1346 fFitModulation->FixParameter(7, TMath::Sqrt(fFitModulation->GetParameter(7)));
1347 } else if (!QCnRecovery(psi2, psi3)) return kFALSE; // try to recover the cumulant, this will set v2 and v3
1348 if(fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { // general check
1349 fFitModulation->SetParameter(7, 0);
1350 fFitModulation->SetParameter(3, 0);
1351 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1352 return kFALSE;
1353 }
1354 } break;
1355 case kIntegratedFlow : {
1356 // use v2 and v3 values from an earlier iteration over the data
1357 fFitModulation->FixParameter(3, fUserSuppliedV2->GetBinContent(fUserSuppliedV2->GetXaxis()->FindBin(fCent)));
1358 fFitModulation->FixParameter(4, psi2);
1359 fFitModulation->FixParameter(6, psi3);
1360 fFitModulation->FixParameter(7, fUserSuppliedV3->GetBinContent(fUserSuppliedV3->GetXaxis()->FindBin(fCent)));
1361 if(fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) {
1362 fFitModulation->SetParameter(7, 0);
1363 fFitModulation->SetParameter(3, 0);
1364 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1365 return kFALSE;
1366 }
1367 return kTRUE;
1368 }
1369 default : break;
1370 }
1371 TString detector("");
1372 switch (fDetectorType) {
1373 case kTPC : detector+="TPC";
1374 break;
1375 case kVZEROA : detector+="VZEROA";
1376 break;
1377 case kVZEROC : detector+="VZEROC";
1378 break;
1379 case kVZEROComb : detector+="VZEROComb";
1380 break;
06d2671d 1381 case kFixedEP : detector+="FixedEP";
1382 break;
eae37c5c 1383 default: break;
1384 }
1385 Int_t iTracks(fTracks->GetEntriesFast());
1386 Double_t excludeInEta = -999;
1387 Double_t excludeInPhi = -999;
1388 Double_t excludeInPt = -999;
1389 if(iTracks <= 0 || fLocalRho->GetVal() <= 0 ) return kFALSE; // no use fitting an empty event ...
1390 if(fExcludeLeadingJetsFromFit > 0 ) {
1391 if(fLeadingJet) {
1392 excludeInEta = fLeadingJet->Eta();
1393 excludeInPhi = fLeadingJet->Phi();
1394 excludeInPt = fLeadingJet->Pt();
1395 }
1396 }
1397 // check the acceptance of the track selection that will be used
1398 // if one uses e.g. semi-good tpc tracks, accepance in phi is reduced to 0 < phi < 4
1399 // the defaults (-10 < phi < 10) which accept all, are then overwritten
1400 Double_t lowBound(0.), upBound(TMath::TwoPi()); // bounds for fit
1401 if(GetParticleContainer()->GetParticlePhiMin() > lowBound) lowBound = GetParticleContainer()->GetParticlePhiMin();
1402 if(GetParticleContainer()->GetParticlePhiMax() < upBound) upBound = GetParticleContainer()->GetParticlePhiMax();
6c3fa11d 1403 fHistSwap->Reset(); // clear the histogram
eae37c5c 1404 TH1F _tempSwap; // on stack for quick access
1405 TH1F _tempSwapN; // on stack for quick access, bookkeeping histogram
1406 if(fRebinSwapHistoOnTheFly) {
1407 if(fNAcceptedTracks < 49) fNAcceptedTracks = 49; // avoid aliasing effects
1408 _tempSwap = TH1F("_tempSwap", "_tempSwap", TMath::CeilNint(TMath::Sqrt(fNAcceptedTracks)), lowBound, upBound);
1409 if(fUsePtWeightErrorPropagation) _tempSwapN = TH1F("_tempSwapN", "_tempSwapN", TMath::CeilNint(TMath::Sqrt(fNAcceptedTracks)), lowBound, upBound);
1410 if(fUsePtWeight) _tempSwap.Sumw2();
1411 }
1412 else _tempSwap = *fHistSwap; // now _tempSwap holds the desired histo
1413 // non poissonian error when using pt weights
1414 Double_t totalpts(0.), totalptsquares(0.), totalns(0.);
1415 for(Int_t i(0); i < iTracks; i++) {
9e1c2f31 1416 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1417 if(fExcludeLeadingJetsFromFit > 0 &&( (TMath::Abs(track->Eta() - excludeInEta) < GetJetContainer()->GetJetRadius()*fExcludeLeadingJetsFromFit ) || (TMath::Abs(track->Eta()) - GetJetContainer()->GetJetRadius() - GetJetContainer()->GetJetEtaMax() ) > 0 )) continue;
1418 if(!PassesCuts(track) || track->Pt() > fSoftTrackMaxPt || track->Pt() < fSoftTrackMinPt) continue;
1419 if(fUsePtWeight) {
1420 _tempSwap.Fill(track->Phi(), track->Pt());
1421 if(fUsePtWeightErrorPropagation) {
1422 totalpts += track->Pt();
1423 totalptsquares += track->Pt()*track->Pt();
1424 totalns += 1;
1425 _tempSwapN.Fill(track->Phi());
eae37c5c 1426 }
9e1c2f31 1427 }
1428 else _tempSwap.Fill(track->Phi());
eae37c5c 1429 }
1430 if(fUsePtWeight && fUsePtWeightErrorPropagation) {
1431 // in the case of pt weights overwrite the poissonian error estimate which is assigned by root by a more sophisticated appraoch
1432 // 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
1433 // 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
1434 // event, for the latter use a poissonian estimate. the two contrubitions are assumed to be uncorrelated
9e1c2f31 1435 if(totalns < 2) return kFALSE; // not one track passes the cuts > 2 avoids possible division by 0 later on
eae37c5c 1436 for(Int_t l = 0; l < _tempSwap.GetNbinsX(); l++) {
1437 if(_tempSwapN.GetBinContent(l+1) == 0) {
1438 _tempSwap.SetBinContent(l+1,0);
1439 _tempSwap.SetBinError(l+1,0);
1440 }
1441 else {
1442 Double_t vartimesnsq = totalptsquares*totalns - totalpts*totalpts;
1443 Double_t variance = vartimesnsq/(totalns*(totalns-1.));
1444 Double_t SDOMSq = variance / _tempSwapN.GetBinContent(l+1);
1445 Double_t SDOMSqOverMeanSq = SDOMSq * _tempSwapN.GetBinContent(l+1) * _tempSwapN.GetBinContent(l+1) / (_tempSwapN.GetBinContent(l+1) * _tempSwapN.GetBinContent(l+1));
1446 Double_t poissonfrac = 1./_tempSwapN.GetBinContent(l+1);
1447 Double_t vartotalfrac = SDOMSqOverMeanSq + poissonfrac;
1448 Double_t vartotal = vartotalfrac * _tempSwap.GetBinContent(l+1) * _tempSwap.GetBinContent(l+1);
1449 if(vartotal > 0.0001) _tempSwap.SetBinError(l+1,TMath::Sqrt(vartotal));
1450 else {
1451 _tempSwap.SetBinContent(l+1,0);
1452 _tempSwap.SetBinError(l+1,0);
1453 }
1454 }
1455 }
1456 }
eae37c5c 1457 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1458 switch (fFitModulationType) {
1459 case kNoFit : {
1460 fFitModulation->FixParameter(0, fLocalRho->GetVal() );
1461 freeParams = 0;
1462 } break;
1463 case kV2 : {
1464 fFitModulation->FixParameter(4, psi2);
1465 freeParams = 1;
1466 } break;
1467 case kV3 : {
1468 fFitModulation->FixParameter(4, psi3);
1469 freeParams = 1;
1470 } break;
1471 case kCombined : {
1472 fFitModulation->FixParameter(4, psi2);
1473 fFitModulation->FixParameter(6, psi3);
1474 freeParams = 2;
1475 } break;
1476 case kFourierSeries : {
1477 // in this approach, an explicit calculation will be made of vn = sqrt(xn^2+yn^2)
1478 // where x[y] = Integrate[r(phi)cos[sin](n phi)dphi, 0, 2pi]
1479 Double_t cos2(0), sin2(0), cos3(0), sin3(0), sumPt(0);
1480 for(Int_t i(0); i < iTracks; i++) {
1481 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1482 if(!PassesCuts(track) || track->Pt() > fSoftTrackMaxPt || track->Pt() < fSoftTrackMinPt) continue;
1483 sumPt += track->Pt();
1484 cos2 += track->Pt()*TMath::Cos(2*PhaseShift(track->Phi()-psi2));
1485 sin2 += track->Pt()*TMath::Sin(2*PhaseShift(track->Phi()-psi2));
1486 cos3 += track->Pt()*TMath::Cos(3*PhaseShift(track->Phi()-psi3));
1487 sin3 += track->Pt()*TMath::Sin(3*PhaseShift(track->Phi()-psi3));
1488 }
1489 fFitModulation->SetParameter(3, TMath::Sqrt(cos2*cos2+sin2*sin2)/fLocalRho->GetVal());
1490 fFitModulation->SetParameter(4, psi2);
1491 fFitModulation->SetParameter(6, psi3);
1492 fFitModulation->SetParameter(7, TMath::Sqrt(cos3*cos3+sin3*sin3)/fLocalRho->GetVal());
1493 } break;
1494 default : break;
1495 }
1496 if(fRunToyMC) {
1497 // toy mc, just here to check procedure, azimuthal profile is filled from hypothesis so p-value distribution should be flat
1498 Int_t _bins = _tempSwap.GetXaxis()->GetNbins();
1499 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());
1500 _tempFit->SetParameter(0, fFitModulation->GetParameter(0)); // normalization
1501 _tempFit->SetParameter(3, 0.1); // v2
1502 _tempFit->FixParameter(1, 1.); // constant
1503 _tempFit->FixParameter(2, 2.); // constant
1504 _tempFit->FixParameter(5, 3.); // constant
1505 _tempFit->FixParameter(4, fFitModulation->GetParameter(4));
1506 _tempFit->FixParameter(6, fFitModulation->GetParameter(6));
1507 _tempFit->SetParameter(7, 0.1); // v3
1508 _tempSwap.Reset(); // rese bin content
1509 for(int _binsI = 0; _binsI < _bins*_bins; _binsI++) _tempSwap.Fill(_tempFit->GetRandom());
1510 }
1511 _tempSwap.Fit(fFitModulation, fFitModulationOptions.Data(), "", lowBound, upBound);
1512 // the quality of the fit is evaluated from 1 - the cdf of the chi square distribution
1513 // three methods are available, all with their drawbacks. all are stored, one is selected to do the cut
1514 Int_t NDF(_tempSwap.GetXaxis()->GetNbins()-freeParams);
9e1c2f31 1515 if(NDF == 0 || (float)NDF <= 0.) return kFALSE;
eae37c5c 1516 Double_t CDF(1.-ChiSquareCDF(NDF, ChiSquare(_tempSwap, fFitModulation)));
1517 Double_t CDFROOT(1.-ChiSquareCDF(NDF, fFitModulation->GetChisquare()));
1518 Double_t CDFKolmogorov(KolmogorovTest(_tempSwap, fFitModulation));
1519 // fill the values and centrality correlation (redundant but easy on the eyes)
1520 fHistPvalueCDF->Fill(CDF);
1521 fHistPvalueCDFCent->Fill(fCent, CDF);
1522 fHistPvalueCDFROOT->Fill(CDFROOT);
1523 fHistPvalueCDFROOTCent->Fill(fCent, CDFROOT);
1524 fHistKolmogorovTest->Fill(CDFKolmogorov);
1525 fHistChi2ROOTCent->Fill(fCent, fFitModulation->GetChisquare()/((float)NDF));
1526 fHistChi2Cent->Fill(fCent, ChiSquare(_tempSwap, fFitModulation)/((float)NDF));
1527 fHistKolmogorovTestCent->Fill(fCent, CDFKolmogorov);
1528 fHistPChi2Root->Fill(CDFROOT, fFitModulation->GetChisquare()/((float)NDF));
1529 fHistPChi2->Fill(CDF, ChiSquare(_tempSwap, fFitModulation)/((float)NDF));
1530 fHistPKolmogorov->Fill(CDF, CDFKolmogorov);
1531
1532 // variable CDF is used for making cuts, so we fill it with the selected p-value
1533 switch (fFitGoodnessTest) {
1534 case kChi2ROOT : {
1535 CDF = CDFROOT;
1536 } break;
1537 case kChi2Poisson : break; // CDF is already CDF
1538 case kKolmogorov : {
1539 CDF = CDFKolmogorov;
1540 } break;
1541 default: break;
1542 }
1543
1544 if(fFitControl) {
1545 // as an additional quality check, see if fitting a control fit has a higher significance
1546 _tempSwap.Fit(fFitControl, fFitModulationOptions.Data(), "", lowBound, upBound);
1547 Double_t CDFControl(-1.);
1548 switch (fFitGoodnessTest) {
1549 case kChi2ROOT : {
1550 CDFControl = 1.-ChiSquareCDF(fFitControl->GetNDF(), fFitModulation->GetChisquare());
1551 } break;
1552 case kChi2Poisson : {
1553 CDFControl = 1.-ChiSquareCDF(fFitControl->GetNDF(), ChiSquare(_tempSwap, fFitModulation));
1554 } break;
1555 case kKolmogorov : {
1556 CDFControl = KolmogorovTest(_tempSwap, fFitControl);
1557 } break;
1558 default: break;
1559 }
1560 if(CDFControl > CDF) {
1561 CDF = -1.; // control fit is more significant, so throw out the 'old' fit
1562 fHistRhoStatusCent->Fill(fCent, -1);
1563 }
1564 }
9e1c2f31 1565 if(CDF >= fMinPvalue && CDF <= fMaxPvalue && ( fFitModulation->GetMinimum(0, TMath::TwoPi()) > 0)) {
1566 // fit quality. not that although with limited acceptance the fit is performed on just
1567 // part of phase space, the requirement that energy desntiy is larger than zero is applied
1568 // to the FULL spectrum
eae37c5c 1569 fHistRhoStatusCent->Fill(fCent, 0.);
1570 // for LOCAL didactic purposes, save the best and the worst fits
1571 // this routine can produce a lot of output histograms (it's not memory 'safe') and will not work on GRID
1572 // since the output will become unmergeable (i.e. different nodes may produce conflicting output)
1573 switch (fRunModeType) {
1574 case kLocal : {
1575 if(fRandom->Uniform(0, 100) > fPercentageOfFits) break;
1576 static Int_t didacticCounterBest(0);
1577 TProfile* didacticProfile = (TProfile*)_tempSwap.Clone(Form("Fit_%i_1-CDF_%.3f_cen_%i_%s", didacticCounterBest, CDF, fInCentralitySelection, detector.Data()));
1578 TF1* didacticFit = (TF1*)fFitModulation->Clone(Form("fit_%i_CDF_%.3f_cen_%i_%s", didacticCounterBest, CDF, fInCentralitySelection, detector.Data()));
1579 switch(fFitModulationType) {
1580 case kCombined : {
1581 // to make a nice picture also plot the separate components (v2 and v3) of the fit
1582 // only done for cobined fit where there are actually components to split ...
1583 TF1* v0(new TF1("dfit_kV2", "[0]", 0, TMath::TwoPi()));
1584 v0->SetParameter(0, didacticFit->GetParameter(0)); // normalization
1585 v0->SetLineColor(kMagenta);
1586 v0->SetLineStyle(7);
1587 didacticProfile->GetListOfFunctions()->Add(v0);
1588 TF1* v2(new TF1("dfit_kV2", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi()));
1589 v2->SetParameter(0, didacticFit->GetParameter(0)); // normalization
1590 v2->SetParameter(3, didacticFit->GetParameter(3)); // v2
1591 v2->FixParameter(1, 1.); // constant
1592 v2->FixParameter(2, 2.); // constant
1593 v2->FixParameter(4, didacticFit->GetParameter(4)); // psi2
1594 v2->SetLineColor(kGreen);
1595 didacticProfile->GetListOfFunctions()->Add(v2);
1596 TF1* v3(new TF1("dfit_kV3", "[0]*([1]+[2]*[3]*TMath::Cos([5]*(x-[4])))", 0, TMath::TwoPi()));
1597 v3->SetParameter(0, didacticFit->GetParameter(0)); // normalization
1598 v3->SetParameter(3, didacticFit->GetParameter(7)); // v3
1599 v3->FixParameter(1, 1.); // constant
1600 v3->FixParameter(2, 2.); // constant
1601 v3->FixParameter(4, didacticFit->GetParameter(6)); // psi3
1602 v3->FixParameter(5, 3.); // constant
1603 v3->SetLineColor(kCyan);
1604 didacticProfile->GetListOfFunctions()->Add(v3);
1605 }
1606 default : break;
1607 }
1608 didacticProfile->GetListOfFunctions()->Add(didacticFit);
1609 didacticProfile->GetYaxis()->SetTitle("#frac{d #sum #it{p}_{T}}{d #varphi} [GeV/#it{c}]");
1610 didacticProfile->GetXaxis()->SetTitle("#varphi");
1611 fOutputListGood->Add(didacticProfile);
1612 didacticCounterBest++;
1613 TH2F* didacticSurface = BookTH2F(Form("surface_%s", didacticProfile->GetName()), "#phi", "#eta", 50, 0, TMath::TwoPi(), 50, -1, 1, -1, kFALSE);
1614 for(Int_t i(0); i < iTracks; i++) {
1615 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1616 if(PassesCuts(track)) {
1617 if(fUsePtWeight) didacticSurface->Fill(track->Phi(), track->Eta(), track->Pt());
1618 else didacticSurface->Fill(track->Phi(), track->Eta());
1619 }
1620 }
1621 if(fExcludeLeadingJetsFromFit) { // visualize the excluded region
1622 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);
1623 f2->SetParameters(excludeInPt/3.,excludeInPhi,.1,excludeInEta,.1);
1624 didacticSurface->GetListOfFunctions()->Add(f2);
1625 }
1626 fOutputListGood->Add(didacticSurface);
1627 } break;
1628 default : break;
1629 }
1630 } else { // if the fit is of poor quality revert to the original rho estimate
1631 switch (fRunModeType) { // again see if we want to save the fit
1632 case kLocal : {
1633 static Int_t didacticCounterWorst(0);
1634 if(fRandom->Uniform(0, 100) > fPercentageOfFits) break;
1635 TProfile* didacticProfile = (TProfile*)_tempSwap.Clone(Form("Fit_%i_1-CDF_%.3f_cen_%i_%s", didacticCounterWorst, CDF, fInCentralitySelection, detector.Data() ));
1636 TF1* didacticFit = (TF1*)fFitModulation->Clone(Form("fit_%i_p_%.3f_cen_%i_%s", didacticCounterWorst, CDF, fInCentralitySelection, detector.Data()));
1637 didacticProfile->GetListOfFunctions()->Add(didacticFit);
1638 fOutputListBad->Add(didacticProfile);
1639 didacticCounterWorst++;
1640 } break;
1641 default : break;
1642 }
1643 switch (fFitModulationType) {
1644 case kNoFit : break; // nothing to do
1645 case kCombined : fFitModulation->SetParameter(7, 0); // no break
1646 case kFourierSeries : fFitModulation->SetParameter(7, 0); // no break
1647 default : { // needs to be done if there was a poor fit
1648 fFitModulation->SetParameter(3, 0);
1649 fFitModulation->SetParameter(0, fLocalRho->GetVal());
1650 } break;
1651 }
1652 if(CDF > -.5) fHistRhoStatusCent->Fill(fCent, 1.);
1653 return kFALSE; // return false if the fit is rejected
1654 }
1655 return kTRUE;
1656}
1657//_____________________________________________________________________________
1658Bool_t AliAnalysisTaskJetV2::PassesCuts(AliVEvent* event)
1659{
1660 // event cuts
1661 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
06d2671d 1662 switch (fCollisionType) {
1663 case kJetFlowMC : {
1664 fInCentralitySelection = 0;
1665 return kTRUE;
1666 } break;
1667 default : break;
1668 }
eae37c5c 1669 if(!event || !AliAnalysisTaskEmcal::IsEventSelected()) return kFALSE;
1670 if(TMath::Abs(InputEvent()->GetPrimaryVertex()->GetZ()) > 10.) return kFALSE;
1671 // aod and esd specific checks
1672 switch (fDataType) {
1673 case kESD: {
1674 AliESDEvent* esdEvent = static_cast<AliESDEvent*>(InputEvent());
1675 if( (!esdEvent) || (TMath::Abs(esdEvent->GetPrimaryVertexSPD()->GetZ() - esdEvent->GetPrimaryVertex()->GetZ()) > .5) ) return kFALSE;
1676 } break;
1677 case kAOD: {
1678 AliAODEvent* aodEvent = static_cast<AliAODEvent*>(InputEvent());
1679 if( (!aodEvent) || (TMath::Abs(aodEvent->GetPrimaryVertexSPD()->GetZ() - aodEvent->GetPrimaryVertex()->GetZ()) > .5) ) return kFALSE;
1680 } break;
1681 default: break;
1682 }
1683 fCent = InputEvent()->GetCentrality()->GetCentralityPercentile("V0M");
1684 if(fCent <= fCentralityClasses->At(0) || fCent >= fCentralityClasses->At(fCentralityClasses->GetSize()-1) || TMath::Abs(fCent-InputEvent()->GetCentrality()->GetCentralityPercentile("TRK")) > 5.) return kFALSE;
1685 // determine centrality class
1686 fInCentralitySelection = -1;
1687 for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i++) {
1688 if(fCent >= fCentralityClasses->At(i) && fCent <= fCentralityClasses->At(1+i)) {
1689 fInCentralitySelection = i;
1690 break; }
1691 }
1692 if(fInCentralitySelection<0) return kFALSE; // should be null op
eae37c5c 1693 // see if input containers are filled
1694 if(fTracks->GetEntries() < 1) return kFALSE;
1695 if(fRho->GetVal() <= 0 ) return kFALSE;
1696 if(fAnalysisType == AliAnalysisTaskJetV2::kFull && !fClusterCont) return kFALSE;
1697 return kTRUE;
1698}
1699//_____________________________________________________________________________
eae37c5c 1700void AliAnalysisTaskJetV2::FillHistogramsAfterSubtraction(Double_t psi2, Double_t vzero[2][2], Double_t* vzeroComb, Double_t* tpc)
1701{
1702 // fill histograms
1703 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1704 FillTrackHistograms();
1705 if(fAnalysisType == AliAnalysisTaskJetV2::kFull) FillClusterHistograms();
1706 FillJetHistograms(psi2);
1707 if(fFillQAHistograms) FillEventPlaneHistograms(vzero, vzeroComb, tpc);
1708 FillRhoHistograms();
1709 FillDeltaPtHistograms(psi2);
1710}
1711//_____________________________________________________________________________
1712void AliAnalysisTaskJetV2::FillTrackHistograms() const
1713{
1714 // fill track histograms
1715 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1716 Int_t iTracks(fTracks->GetEntriesFast()), iAcceptedTracks(0);
1717 for(Int_t i(0); i < iTracks; i++) {
1718 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i));
1719 if(!PassesCuts(track)) continue;
1720 iAcceptedTracks++;
1721 fHistPicoTrackPt[fInCentralitySelection]->Fill(track->Pt());
1722 if(fFillQAHistograms) FillQAHistograms(track);
1723 }
1724 fHistPicoTrackMult[fInCentralitySelection]->Fill(iAcceptedTracks);
1725}
1726//_____________________________________________________________________________
1727void AliAnalysisTaskJetV2::FillClusterHistograms() const
1728{
1729 // fill cluster histograms
1730 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1731 if(!fClusterCont) return;
1732 Int_t iClusters(fClusterCont->GetNClusters());
1733 for(Int_t i(0); i < iClusters; i++) {
1734 AliVCluster* cluster = fClusterCont->GetCluster(i);
1735 if (!PassesCuts(cluster)) continue;
1736 TLorentzVector clusterLorentzVector;
1737 cluster->GetMomentum(clusterLorentzVector, const_cast<Double_t*>(fVertex));
1738 fHistClusterPt[fInCentralitySelection]->Fill(clusterLorentzVector.Pt());
1739 fHistClusterEtaPhi[fInCentralitySelection]->Fill(clusterLorentzVector.Eta(), clusterLorentzVector.Phi());
1740 fHistClusterEtaPhiWeighted[fInCentralitySelection]->Fill(clusterLorentzVector.Eta(), clusterLorentzVector.Phi(), clusterLorentzVector.Pt());
1741 }
1742 return;
1743}
1744//_____________________________________________________________________________
1745void AliAnalysisTaskJetV2::FillEventPlaneHistograms(Double_t vzero[2][2], Double_t* vzeroComb, Double_t* tpc) const
1746{
1747 // fill event plane histograms
1748 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1749 fHistPsiControl->Fill(0.5, vzero[0][0]); // vzero a psi2
1750 fHistPsiControl->Fill(1.5, vzero[1][0]); // vzero c psi2
1751 fHistPsiControl->Fill(2.5, tpc[0]); // tpc psi 2
1752 fHistPsiControl->Fill(5.5, vzero[0][1]); // vzero a psi3
1753 fHistPsiControl->Fill(6.5, vzero[1][1]); // vzero b psi3
1754 fHistPsiControl->Fill(7.5, tpc[1]); // tpc psi 3
1755 fHistPsiVZEROA->Fill(vzero[0][0]);
1756 fHistPsiVZEROC->Fill(vzero[1][0]);
1757 fHistPsiVZERO->Fill(vzeroComb[0]);
1758 fHistPsiTPC->Fill(tpc[0]);
1759 fHistPsiSpread->Fill(0.5, TMath::Abs(vzero[0][0]-vzero[1][0]));
1760 fHistPsiSpread->Fill(1.5, TMath::Abs(vzero[0][0]-tpc[0]));
1761 fHistPsiSpread->Fill(2.5, TMath::Abs(vzero[1][0]-tpc[0]));
1762 // event plane vs centrality QA histo's to check recentering
1763 Double_t TRK(InputEvent()->GetCentrality()->GetCentralityPercentile("TRK"));
1764 Double_t V0M(InputEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
1765 fHistPsiVZEROAV0M->Fill(V0M, vzero[0][0]);
1766 fHistPsiVZEROCV0M->Fill(V0M, vzero[1][0]);
1767 fHistPsiVZEROVV0M->Fill(V0M, vzeroComb[0]);
1768 fHistPsiTPCiV0M->Fill(V0M, tpc[0]);
1769 fHistPsiVZEROATRK->Fill(TRK, vzero[0][0]);
1770 fHistPsiVZEROCTRK->Fill(TRK, vzero[1][0]);
1771 fHistPsiVZEROTRK->Fill(TRK, vzeroComb[0]);
1772 fHistPsiTPCTRK->Fill(TRK, tpc[0]);
1773}
1774//_____________________________________________________________________________
1775void AliAnalysisTaskJetV2::FillRhoHistograms()
1776{
1777 // fill rho histograms
1778 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1779 fHistRhoPackage[fInCentralitySelection]->Fill(fLocalRho->GetVal()); // save the rho estimate from the emcal jet package
1780 // get multiplicity FIXME inefficient
1781 Int_t iJets(fJets->GetEntriesFast());
1782 Double_t rho(fLocalRho->GetLocalVal(TMath::Pi(), TMath::Pi(), fLocalRho->GetVal()));
1783 fHistRho[fInCentralitySelection]->Fill(rho);
1784 fHistRhoVsMult->Fill(fTracks->GetEntries(), rho);
1785 fHistRhoVsCent->Fill(fCent, rho);
1786 for(Int_t i(0); i < iJets; i++) {
1787 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(i));
1788 if(!PassesCuts(jet)) continue;
1789 fHistRhoAVsMult->Fill(fTracks->GetEntries(), rho * jet->Area());
1790 fHistRhoAVsCent->Fill(fCent, rho * jet->Area());
1791 }
1792}
1793//_____________________________________________________________________________
1794void AliAnalysisTaskJetV2::FillDeltaPtHistograms(Double_t psi2) const
1795{
1796 // fill delta pt histograms
1797 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1798 Int_t i(0);
1799 const Float_t areaRC = GetJetRadius()*GetJetRadius()*TMath::Pi();
1800 // we're retrieved the leading jet, now get a random cone
1801 for(i = 0; i < fMaxCones; i++) {
1802 Float_t pt(0), eta(0), phi(0);
1803 // get a random cone without constraints on leading jet position
1804 CalculateRandomCone(pt, eta, phi, fTracksCont, fClusterCont, 0x0);
1805 if(pt > 0) {
1806 if(fFillQAHistograms) fHistRCPhiEta[fInCentralitySelection]->Fill(phi, eta);
1807 fHistRhoVsRCPt[fInCentralitySelection]->Fill(pt, fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal())*areaRC);
1808 fHistRCPt[fInCentralitySelection]->Fill(pt);
1809 fHistDeltaPtDeltaPhi2[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1810 fHistDeltaPtDeltaPhi2Rho0[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetVal());
1811
1812 }
1813 // get a random cone excluding leading jet area
1814 CalculateRandomCone(pt, eta, phi, fTracksCont, fClusterCont, fLeadingJet);
1815 if(pt > 0) {
1816 if(fFillQAHistograms) fHistRCPhiEtaExLJ[fInCentralitySelection]->Fill(phi, eta);
1817 fHistRhoVsRCPtExLJ[fInCentralitySelection]->Fill(pt, fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal())*areaRC);
1818 fHistRCPtExLJ[fInCentralitySelection]->Fill(pt);
1819 fHistDeltaPtDeltaPhi2ExLJ[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1820 fHistDeltaPtDeltaPhi2ExLJRho0[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt - areaRC*fLocalRho->GetVal());
1821 }
1822 }
1823}
1824//_____________________________________________________________________________
1825void AliAnalysisTaskJetV2::FillJetHistograms(Double_t psi2)
1826{
1827 // fill jet histograms
1828 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1829 Int_t iJets(fJets->GetEntriesFast());
1830 for(Int_t i(0); i < iJets; i++) {
1831 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(i));
1832 if(PassesCuts(jet)) {
1833 Double_t pt(jet->Pt()), area(jet->Area()), eta(jet->Eta()), phi(jet->Phi());
1834 Double_t rho(fLocalRho->GetLocalVal(phi, GetJetContainer()->GetJetRadius(), fLocalRho->GetVal()));
1835 fHistJetPtRaw[fInCentralitySelection]->Fill(pt);
1836 fHistJetPt[fInCentralitySelection]->Fill(pt-area*rho);
1837 if(fFillQAHistograms) fHistJetEtaPhi[fInCentralitySelection]->Fill(eta, phi);
1838 fHistJetPtArea[fInCentralitySelection]->Fill(pt-area*rho, area);
1839 fHistJetPtEta[fInCentralitySelection]->Fill(pt-area*rho, eta);
1840 fHistJetPsi2Pt[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt-area*rho);
1841 fHistJetPsi2PtRho0[fInCentralitySelection]->Fill(PhaseShift(phi-psi2, 2.), pt-area*fLocalRho->GetVal());
1842 fHistJetPtConstituents[fInCentralitySelection]->Fill(pt-area*rho, jet->Nch());
1843 fHistJetEtaRho[fInCentralitySelection]->Fill(eta, pt/area);
1844 }
1845 }
1846}
1847//_____________________________________________________________________________
1848void AliAnalysisTaskJetV2::FillQAHistograms(AliVTrack* vtrack) const
1849{
1850 // fill qa histograms for pico tracks
028d6739 1851 if(fDebug > 1) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1852 if(!vtrack) return;
eae37c5c 1853 AliPicoTrack* track = static_cast<AliPicoTrack*>(vtrack);
1854 fHistRunnumbersPhi->Fill(fMappedRunNumber, track->Phi());
1855 fHistRunnumbersEta->Fill(fMappedRunNumber, track->Eta());
1856 Int_t type((int)(track->GetTrackType()));
1857 switch (type) {
1858 case 0:
1859 fHistPicoCat1[fInCentralitySelection]->Fill(track->Eta(), track->Phi());
1860 break;
1861 case 1:
1862 fHistPicoCat2[fInCentralitySelection]->Fill(track->Eta(), track->Phi());
1863 break;
1864 case 2:
1865 fHistPicoCat3[fInCentralitySelection]->Fill(track->Eta(), track->Phi());
1866 break;
1867 default: break;
1868 }
1869}
1870//_____________________________________________________________________________
1871void AliAnalysisTaskJetV2::FillQAHistograms(AliVEvent* vevent)
1872{
1873 // fill qa histograms for events
9e1c2f31 1874 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 1875 if(!vevent) return;
1876 fHistVertexz->Fill(vevent->GetPrimaryVertex()->GetZ());
1877 fHistCentrality->Fill(fCent);
1878 Int_t runNumber(InputEvent()->GetRunNumber());
028d6739 1879 for(fMappedRunNumber = 0; fMappedRunNumber < fExpectedRuns->GetSize(); fMappedRunNumber++) {
9e1c2f31 1880 if(fExpectedRuns->At(fMappedRunNumber) == runNumber) return;
eae37c5c 1881 }
028d6739 1882 if(fDebug > 0) printf("\n > TASK %s CANNOT IDENTIFY RUN - CONFIGURATION COULD BE INCORRECT < \n", GetName());
eae37c5c 1883}
1884//_____________________________________________________________________________
1885void AliAnalysisTaskJetV2::FillAnalysisSummaryHistogram() const
1886{
1887 // fill the analysis summary histrogram, saves all relevant analysis settigns
1888 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1889 fHistAnalysisSummary->GetXaxis()->SetBinLabel(2, "fJetRadius");
1890 fHistAnalysisSummary->SetBinContent(2, GetJetContainer()->GetJetRadius());
1891 fHistAnalysisSummary->GetXaxis()->SetBinLabel(3, "fJetEtaMin");
1892 fHistAnalysisSummary->SetBinContent(3, GetJetContainer()->GetJetEtaMin());
1893 fHistAnalysisSummary->GetXaxis()->SetBinLabel(4, "fJetEtaMax");
1894 fHistAnalysisSummary->SetBinContent(4, GetJetContainer()->GetJetEtaMax());
1895 fHistAnalysisSummary->GetXaxis()->SetBinLabel(5, "fJetPhiMin");
1896 fHistAnalysisSummary->SetBinContent(5, GetJetContainer()->GetJetPhiMin());
1897 fHistAnalysisSummary->GetXaxis()->SetBinLabel(6, "fJetPhiMax");
1898 fHistAnalysisSummary->SetBinContent(6, GetJetContainer()->GetJetPhiMin());
1899 fHistAnalysisSummary->GetXaxis()->SetBinLabel(16, "fForceBeamType");
1900 fHistAnalysisSummary->SetBinContent(16, fForceBeamType);
1901 fHistAnalysisSummary->GetXaxis()->SetBinLabel(17, "fMinCent");
1902 fHistAnalysisSummary->SetBinContent(17, fMinCent);
1903 fHistAnalysisSummary->GetXaxis()->SetBinLabel(18, "fMaxCent");
1904 fHistAnalysisSummary->SetBinContent(18, fMaxCent);
1905 fHistAnalysisSummary->GetXaxis()->SetBinLabel(19, "fMinVz");
1906 fHistAnalysisSummary->SetBinContent(19, fMinVz);
1907 fHistAnalysisSummary->GetXaxis()->SetBinLabel(20, "fMaxVz");
1908 fHistAnalysisSummary->SetBinContent(20, fMaxVz);
1909 fHistAnalysisSummary->GetXaxis()->SetBinLabel(21, "fOffTrigger");
1910 fHistAnalysisSummary->SetBinContent(21, fOffTrigger);
1911 fHistAnalysisSummary->GetXaxis()->SetBinLabel(34, "fitModulationType");
1912 fHistAnalysisSummary->SetBinContent(34, (int)fFitModulationType);
1913 fHistAnalysisSummary->GetXaxis()->SetBinLabel(35, "runModeType");
1914 fHistAnalysisSummary->SetBinContent(35, (int)fRunModeType);
1915 fHistAnalysisSummary->GetXaxis()->SetBinLabel(36, "data type");
1916 fHistAnalysisSummary->SetBinContent(36, (int)fDataType);
1917 fHistAnalysisSummary->GetXaxis()->SetBinLabel(37, "iterator");
1918 fHistAnalysisSummary->SetBinContent(37, 1.);
1919 fHistAnalysisSummary->GetXaxis()->SetBinLabel(38, "fMinPvalue");
1920 fHistAnalysisSummary->SetBinContent(38, fMinPvalue);
1921 fHistAnalysisSummary->GetXaxis()->SetBinLabel(39, "fMaxPvalue");
1922 fHistAnalysisSummary->SetBinContent(39, fMaxPvalue);
1923 fHistAnalysisSummary->GetXaxis()->SetBinLabel(40, "fExcludeLeadingJetsFromFit");
1924 fHistAnalysisSummary->SetBinContent(40, fExcludeLeadingJetsFromFit);
1925 fHistAnalysisSummary->GetXaxis()->SetBinLabel(41, "fRebinSwapHistoOnTheFly");
1926 fHistAnalysisSummary->SetBinContent(41, (int)fRebinSwapHistoOnTheFly);
1927 fHistAnalysisSummary->GetXaxis()->SetBinLabel(42, "fUsePtWeight");
1928 fHistAnalysisSummary->SetBinContent(42, (int)fUsePtWeight);
eae37c5c 1929 fHistAnalysisSummary->GetXaxis()->SetBinLabel(44, "fSoftTrackMinPt");
1930 fHistAnalysisSummary->SetBinContent(44, fSoftTrackMinPt);
1931 fHistAnalysisSummary->GetXaxis()->SetBinLabel(45, "fSoftTrackMaxPt");
1932 fHistAnalysisSummary->SetBinContent(45, fSoftTrackMaxPt);
1933 fHistAnalysisSummary->GetXaxis()->SetBinLabel(46, "fMaxCones");
1934 fHistAnalysisSummary->SetBinContent(46, fMaxCones);
1935 fHistAnalysisSummary->GetXaxis()->SetBinLabel(47, "used rho");
1936 fHistAnalysisSummary->GetXaxis()->SetBinLabel(48, "used small rho");
1937}
1938//_____________________________________________________________________________
1939void AliAnalysisTaskJetV2::Terminate(Option_t *)
1940{
1941 // terminate
1942 switch (fRunModeType) {
1943 case kLocal : {
9e1c2f31 1944 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 1945 AliAnalysisTaskJetV2::Dump();
1946 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));
1947 } break;
1948 default : break;
1949 }
1950}
1951//_____________________________________________________________________________
1952void AliAnalysisTaskJetV2::SetModulationFit(TF1* fit)
1953{
1954 // set modulation fit
9e1c2f31 1955 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 1956 if (fFitModulation) delete fFitModulation;
1957 fFitModulation = fit;
1958}
1959//_____________________________________________________________________________
1960void AliAnalysisTaskJetV2::SetUseControlFit(Bool_t c)
1961{
1962 // set control fit
9e1c2f31 1963 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 1964 if (fFitControl) delete fFitControl;
1965 if (c) {
1966 fFitControl = new TF1("controlFit", "pol0", 0, TMath::TwoPi());
1967 } else fFitControl = 0x0;
1968}
1969//_____________________________________________________________________________
1970TH1F* AliAnalysisTaskJetV2::GetResolutionFromOuptutFile(detectorType det, Int_t h, TArrayD* cen)
1971{
1972 // INTERFACE METHOD FOR OUTPUTFILE
1973 // get the detector resolution, user has ownership of the returned histogram
9e1c2f31 1974 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 1975 if(!fOutputList) {
1976 printf(" > Please add fOutputList first < \n");
1977 return 0x0;
1978 }
1979 TH1F* r(0x0);
1980 (cen) ? r = new TH1F("R", "R", cen->GetSize()-1, cen->GetArray()) : r = new TH1F("R", "R", 10, 0, 10);
1981 if(!cen) r->GetXaxis()->SetTitle("number of centrality bin");
1982 r->GetYaxis()->SetTitle(Form("Resolution #Psi_{%i}", h));
1983 for(Int_t i(0); i < 10; i++) {
1984 TProfile* temp((TProfile*)fOutputList->FindObject(Form("fProfV%iResolution_%i", h, i)));
1985 if(!temp) break;
1986 Double_t a(temp->GetBinContent(3)), b(temp->GetBinContent(5)), c(temp->GetBinContent(7));
1987 Double_t d(temp->GetBinContent(9)), e(temp->GetBinContent(10)), f(temp->GetBinContent(11));
1988 Double_t _a(temp->GetBinError(3)), _b(temp->GetBinError(5)), _c(temp->GetBinError(7));
1989 Double_t _d(temp->GetBinError(9)), _e(temp->GetBinError(10)), _f(temp->GetBinError(11));
1990 if(a <= 0 || b <= 0 || c <= 0 || d <= 0 || e <= 0 || f <= 0) continue;
1991 switch (det) {
1992 case kVZEROA : {
1993 r->SetBinContent(1+i, TMath::Sqrt((a*b)/c));
1994 if(i==0) r->SetNameTitle("VZEROA resolution", "VZEROA resolution");
1995 r->SetBinError(1+i, TMath::Sqrt(_a*_a+_b*_b+_c*_c));
1996 } break;
1997 case kVZEROC : {
1998 r->SetBinContent(1+i, TMath::Sqrt((a*c)/b));
1999 if(i==0) r->SetNameTitle("VZEROC resolution", "VZEROC resolution");
2000 r->SetBinError(1+i, TMath::Sqrt(_a*_a+_b*_b+_c*_c));
2001 } break;
2002 case kTPC : {
2003 r->SetBinContent(1+i, TMath::Sqrt((b*c)/a));
2004 if(i==0) r->SetNameTitle("TPC resolution", "TPC resolution");
2005 r->SetBinError(1+i, TMath::Sqrt(_a*_a+_b*_b+_c*_c));
2006 } break;
2007 case kVZEROComb : {
2008 r->SetBinContent(1+i, TMath::Sqrt((d*e)/f));
2009 if(i==0) r->SetNameTitle("VZEROComb resolution", "VZEROComb resolution");
2010 r->SetBinError(1+i, TMath::Sqrt(_d*_d+_e*_e+_f*_f));
2011 } break;
2012 default : break;
2013 }
2014 }
2015 return r;
2016}
2017//_____________________________________________________________________________
2018TH1F* AliAnalysisTaskJetV2::CorrectForResolutionDiff(TH1F* v, detectorType det, TArrayD* cen, Int_t c, Int_t h)
2019{
2020 // INTERFACE METHOD FOR OUTPUT FILE
2021 // correct the supplied differential vn histogram v for detector resolution
9e1c2f31 2022 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 2023 TH1F* r(GetResolutionFromOuptutFile(det, h, cen));
2024 if(!r) {
2025 printf(" > Couldn't find resolution < \n");
2026 return 0x0;
2027 }
2028 Double_t res(1./r->GetBinContent(1+r->FindBin(c)));
2029 TF1* line = new TF1("line", "pol0", 0, 200);
2030 line->SetParameter(0, res);
2031 v->Multiply(line);
2032 return v;
2033}
2034//_____________________________________________________________________________
2035TH1F* AliAnalysisTaskJetV2::CorrectForResolutionInt(TH1F* v, detectorType det, TArrayD* cen, Int_t h)
2036{
2037 // INTERFACE METHOD FOR OUTPUT FILE
2038 // correct the supplied intetrated vn histogram v for detector resolution
2039 // integrated vn must have the same centrality binning as the resolotion correction
9e1c2f31 2040 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 2041 TH1F* r(GetResolutionFromOuptutFile(det, h, cen));
2042 v->Divide(v, r);
2043 return v;
2044}
2045//_____________________________________________________________________________
2046TH1F* AliAnalysisTaskJetV2::GetDifferentialQC(TProfile* refCumulants, TProfile* diffCumlants, TArrayD* ptBins, Int_t h)
2047{
2048 // get differential QC
9e1c2f31 2049 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
eae37c5c 2050 Double_t r(refCumulants->GetBinContent(h-1)); // v2 reference flow
2051 if(r > 0) r = TMath::Sqrt(r);
2052 TH1F* qc = new TH1F(Form("QC2v%i", h), Form("QC2v%i", h), ptBins->GetSize()-1, ptBins->GetArray());
2053 Double_t a(0), b(0), c(0); // dummy variables
2054 for(Int_t i(0); i < ptBins->GetSize(); i++) {
2055 if(r > 0) {
2056 a = diffCumlants->GetBinContent(1+i);
2057 b = diffCumlants->GetBinError(1+i);
2058 c = a/r;
2059 qc->SetBinContent(1+i, c);
2060 (a <= 0 || b <= 0) ? qc->SetBinError(1+i, b) : qc->SetBinError(1+i, TMath::Sqrt(c*c*b*b/(a*a)));
2061 }
2062 }
2063 return qc;
2064}
2065
2066//_____________________________________________________________________________
9e1c2f31 2067void AliAnalysisTaskJetV2::ReadVZEROCalibration2010h()
2068{
2069 // necessary for calibration of 10h vzero event plane. code copied from flow package
2070 // (duplicate, but i didn't want to introduce an ulgy dependency )
2071 // this function is only called when the runnumber changes
2072 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
2073
2074 // 1) check if the proper chi weights for merging vzero a and vzero c ep are present
2075 // if not, use sane defaults. centrality binning is equal to that given in the fVZEROcentralityBin snippet
2076 //
2077 // chi values can be calculated using the static helper function
2078 // AliAnalysisTaskJetV2::CalculateEventPlaneChi(Double_t res) where res is the event plane
2079 // resolution in a given centrality bin
2080 //
2081 // the resolutions that were used for these defaults are
2082 // this might need a bit of updating as they were read 'by-eye' from a performance plot ..
2083 // Double_t R2VZEROA[] = {.35, .40, .48, .50, .48, .45, .38, .26, .16};
2084 // Double_t R2VZEROC[] = {.45, .60, .70, .73, .68, .60, .40, .36, .17};
2085 // Double_t R3VZEROA[] = {.22, .23, .22, .19, .15, .12, .08, .00, .00};
2086 // Double_t R3VZEROC[] = {.30, .30, .28, .25, .22, .17, .11, .00, .00};
2087
2088 Double_t chiC2[] = {0.771423, 1.10236, 1.38116, 1.48077, 1.31964, 1.10236, 0.674622, 0.600403, 0.273865};
2089 Double_t chiA2[] = {0.582214, 0.674622, 0.832214, 0.873962, 0.832214, 0.771423, 0.637146, 0.424255, 0.257385};
2090 Double_t chiC3[] = {0.493347, 0.493347, 0.458557, 0.407166, 0.356628, 0.273865, 0.176208, 6.10352e-05, 6.10352e-05};
2091 Double_t chiA3[] = {0.356628, 0.373474, 0.356628, 0.306702, 0.24115, 0.192322, 0.127869, 6.10352e-05, 6.10352e-05};
2092
2093 if(!fChi2A) fChi2A = new TArrayD(9, chiA2);
2094 if(!fChi2C) fChi2C = new TArrayD(9, chiC2);
2095 if(!fChi3A) fChi3A = new TArrayD(9, chiA3);
2096 if(!fChi3C) fChi3C = new TArrayD(9, chiC3);
2097
2098 // 2) open database file
2099 fOADB = TFile::Open("$ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root");
2100 if(fOADB->IsZombie()){
2101 printf("OADB file $ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root cannot be opened, CALIBRATION FAILED !");
2102 return;
2103 }
2104
2105 AliOADBContainer *cont = (AliOADBContainer*) fOADB->Get("hMultV0BefCorr");
2106 if(!cont){
2107 // see if database is readable
2108 printf("OADB object hMultV0BefCorr is not available in the file\n");
2109 return;
2110 }
2111 Int_t run(fRunNumber);
2112 if(!(cont->GetObject(run))){
2113 // if the run isn't recognized fall back to a default run
2114 printf("OADB object hMultVZEROBefCorr is not available for run %i (used default run 137366)\n",run);
2115 run = 137366;
2116 }
2117 // step 3) get the proper multiplicity weights from the vzero signal
2118 fVZEROgainEqualization = ((TH2F*)cont->GetObject(run))->ProfileX();
2119 if(!fVZEROgainEqualization) {
2120 AliFatal(Form("%s: Fatal error, couldn't read fVZEROgainEqualization from OADB object < \n", GetName()));
2121 return;
2122 }
2123
2124 TF1* fpol0 = new TF1("fpol0","pol0");
2125 if(fVZEROgainEqualizationPerRing) {
2126 // do the calibration per ring
2127 // start with the vzero c rings (segments 0 through 31)
2128 fVZEROgainEqualization->Fit(fpol0, "", "", 0, 8);
2129 (fUseVZERORing[0]) ? SetVZEROCpol(0, fpol0->GetParameter(0)) : SetVZEROCpol(0, 0.);
2130 fVZEROgainEqualization->Fit(fpol0, "", "", 8, 16);
2131 (fUseVZERORing[1]) ? SetVZEROCpol(1, fpol0->GetParameter(0)) : SetVZEROCpol(1, 0.);
2132 fVZEROgainEqualization->Fit(fpol0, "", "", 16, 24);
2133 (fUseVZERORing[2]) ? SetVZEROCpol(2, fpol0->GetParameter(0)) : SetVZEROCpol(2, 0.);
2134 fVZEROgainEqualization->Fit(fpol0, "", "", 24, 32);
2135 (fUseVZERORing[3]) ? SetVZEROCpol(3, fpol0->GetParameter(0)) : SetVZEROCpol(3, 0.);
2136 // same thing for vero A
2137 fVZEROgainEqualization->Fit(fpol0, "", "", 32, 40);
2138 (fUseVZERORing[4]) ? SetVZEROApol(0, fpol0->GetParameter(0)) : SetVZEROApol(0, 0.);
2139 fVZEROgainEqualization->Fit(fpol0, "", "", 40, 48);
2140 (fUseVZERORing[5]) ? SetVZEROApol(1, fpol0->GetParameter(0)) : SetVZEROApol(1, 0.);
2141 fVZEROgainEqualization->Fit(fpol0, "", "", 48, 56);
2142 (fUseVZERORing[6]) ? SetVZEROApol(2, fpol0->GetParameter(0)) : SetVZEROApol(2, 0.);
2143 fVZEROgainEqualization->Fit(fpol0, "", "", 56, 64);
2144 (fUseVZERORing[7]) ? SetVZEROApol(3, fpol0->GetParameter(0)) : SetVZEROApol(3, 0.);
2145 } else {
2146 // do the calibration in one go. the calibration will still be
2147 // stored per ring, but each ring has the same weight now
2148 // this should be the default for the analysis as the database is tuned to this configuration
2149 fVZEROgainEqualization->Fit(fpol0,"","",0,31);
2150 for(Int_t i(0); i < 4; i++) SetVZEROCpol(i, fpol0->GetParameter(0));
2151 fVZEROgainEqualization->Fit(fpol0,"","",32,64);
2152 for(Int_t i(0); i < 4; i++) SetVZEROApol(i, fpol0->GetParameter(0));
2153 }
2154
2155 // step 4) extract the information to re-weight the q-vectors
2156 for(Int_t iside=0;iside<2;iside++){
2157 for(Int_t icoord=0;icoord<2;icoord++){
2158 for(Int_t i=0;i < 9;i++){
2159 char namecont[100];
2160 if(iside==0 && icoord==0)
2161 snprintf(namecont,100,"hQxc2_%i",i);
2162 else if(iside==1 && icoord==0)
2163 snprintf(namecont,100,"hQxa2_%i",i);
2164 else if(iside==0 && icoord==1)
2165 snprintf(namecont,100,"hQyc2_%i",i);
2166 else if(iside==1 && icoord==1)
2167 snprintf(namecont,100,"hQya2_%i",i);
2168
2169 cont = (AliOADBContainer*) fOADB->Get(namecont);
2170 if(!cont){
2171 printf("OADB object %s is not available in the file\n",namecont);
2172 return;
2173 }
2174
2175 if(!(cont->GetObject(run))){
2176 printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
2177 run = 137366;
2178 }
2179
2180 // store info for all centralities to cache
2181 fMeanQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
2182 fWidthQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
2183
2184 //for v3
2185 if(iside==0 && icoord==0)
2186 snprintf(namecont,100,"hQxc3_%i",i);
2187 else if(iside==1 && icoord==0)
2188 snprintf(namecont,100,"hQxa3_%i",i);
2189 else if(iside==0 && icoord==1)
2190 snprintf(namecont,100,"hQyc3_%i",i);
2191 else if(iside==1 && icoord==1)
2192 snprintf(namecont,100,"hQya3_%i",i);
2193
2194 cont = (AliOADBContainer*) fOADB->Get(namecont);
2195 if(!cont){
2196 printf("OADB object %s is not available in the file\n",namecont);
2197 return;
2198 }
2199
2200 if(!(cont->GetObject(run))){
2201 printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
2202 run = 137366;
2203 }
2204 // store info for all centralities to cache
2205 fMeanQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
2206 fWidthQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
2207 }
2208 }
2209 }
2210 // cleanup. the opened file is closed in the destructor, otherwise fVZEROgainEqualization is no longer available
2211 delete fpol0;
2212}
2213//_____________________________________________________________________________
2214Int_t AliAnalysisTaskJetV2::GetVZEROCentralityBin() const
2215{
2216 // return cache index number corresponding to the event centrality
2217 if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
2218 Float_t v0Centr(InputEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
2219 if(v0Centr < 5) return 0;
2220 else if(v0Centr < 10) return 1;
2221 else if(v0Centr < 20) return 2;
2222 else if(v0Centr < 30) return 3;
2223 else if(v0Centr < 40) return 4;
2224 else if(v0Centr < 50) return 5;
2225 else if(v0Centr < 60) return 6;
2226 else if(v0Centr < 70) return 7;
2227 else return 8;
2228}
2229//_____________________________________________________________________________