]>
Commit | Line | Data |
---|---|---|
5ce0dc6d | 1 | // $Id$ |
2 | // | |
9239b066 | 3 | // Analysis task to estimate an event's local energy density |
5ce0dc6d | 4 | // |
5 | // This task is part of the emcal jet framework and should be run in the emcaljet train | |
6 | // The following extensions to an accepted AliVEvent are expected: | |
7 | // - (anti-kt) jets -> necessary if one wants to exclude leading jet contribution to the event plane | |
8 | // - background estimate of rho -> this task estimates modulation, not rho itself | |
9 | // - pico tracks -> a uniform track selection is necessary to estimate the contribution of v_n harmonics | |
10 | // aod's and esd's are handled transparently | |
11 | // The task will estimates a phi-dependent background density rho | |
12 | // which is added to the event as a AliLocalRhoParamter object | |
13 | // | |
14 | // Author: Redmer Alexander Bertens, Utrecht Univeristy, Utrecht, Netherlands | |
9239b066 | 15 | // (rbertens@cern.ch, rbertens@nikhef.nl, r.a.bertens@uu.nl) |
5ce0dc6d | 16 | |
17 | // root includes | |
18 | #include <TStyle.h> | |
19 | #include <TRandom3.h> | |
20 | #include <TChain.h> | |
21 | #include <TMath.h> | |
22 | #include <TF1.h> | |
23 | #include <TF2.h> | |
24 | #include <TH1F.h> | |
25 | #include <TH2F.h> | |
26 | #include <TProfile.h> | |
27 | // aliroot includes | |
28 | #include <AliAnalysisTask.h> | |
29 | #include <AliAnalysisManager.h> | |
30 | #include <AliCentrality.h> | |
31 | #include <AliVVertex.h> | |
32 | #include <AliESDEvent.h> | |
33 | #include <AliAODEvent.h> | |
34 | #include <AliAODTrack.h> | |
35 | // emcal jet framework includes | |
36 | #include <AliPicoTrack.h> | |
37 | #include <AliEmcalJet.h> | |
38 | #include <AliRhoParameter.h> | |
39 | #include <AliLocalRhoParameter.h> | |
40 | #include <AliAnalysisTaskLocalRho.h> | |
41 | ||
42 | class AliAnalysisTaskLocalRho; | |
43 | using namespace std; | |
44 | ||
45 | ClassImp(AliAnalysisTaskLocalRho) | |
46 | ||
9239b066 | 47 | //_____________________________________________________________________________ |
48 | AliAnalysisTaskLocalRho::AliAnalysisTaskLocalRho() : | |
49 | AliAnalysisTaskEmcalJet("AliAnalysisTaskLocalRho", kTRUE), | |
50 | fDebug(0), fInitialized(0), fAttachToEvent(kTRUE), fFillHistograms(kFALSE), fNoEventWeightsForQC(kTRUE), | |
51 | fUseScaledRho(0), fCentralityClasses(0), fUserSuppliedV2(0), fUserSuppliedV3(0), fUserSuppliedR2(0), | |
52 | fUserSuppliedR3(0), fNAcceptedTracks(0), fNAcceptedTracksQCn(0), fInCentralitySelection(-1), | |
53 | fFitModulationType(kNoFit), fQCRecovery(kTryFit), fUsePtWeight(kTRUE), fDetectorType(kTPC), | |
54 | fFitModulationOptions("WLQI"), fRunModeType(kGrid), fFitModulation(0), fMinPvalue(0.01), fMaxPvalue(1), | |
55 | fLocalJetMinEta(-10), fLocalJetMaxEta(-10), fLocalJetMinPhi(-10), fLocalJetMaxPhi(-10), fSoftTrackMinPt(0.15), | |
56 | fSoftTrackMaxPt(5.), fHistPvalueCDF(0), fAbsVnHarmonics(kTRUE), fExcludeLeadingJetsFromFit(1.), | |
57 | fRebinSwapHistoOnTheFly(kTRUE), fPercentageOfFits(10.), fUseV0EventPlaneFromHeader(kTRUE), fOutputList(0), | |
58 | fOutputListGood(0), fOutputListBad(0), fHistSwap(0), fHistAnalysisSummary(0), fProfV2(0), fProfV2Cumulant(0), | |
59 | fProfV3(0), fProfV3Cumulant(0) | |
60 | { | |
61 | // Default constructor | |
62 | ||
63 | for(Int_t i(0); i < 10; i++) { | |
64 | fHistPsi2[i] = 0; | |
65 | fHistPsi3[i] = 0; | |
66 | } | |
5ce0dc6d | 67 | } |
9239b066 | 68 | |
5ce0dc6d | 69 | //_____________________________________________________________________________ |
9239b066 | 70 | AliAnalysisTaskLocalRho::AliAnalysisTaskLocalRho(const char* name, runModeType type) : |
71 | AliAnalysisTaskEmcalJet(name, kTRUE), | |
72 | fDebug(0), fInitialized(0), fAttachToEvent(kTRUE), fFillHistograms(kFALSE), fNoEventWeightsForQC(kTRUE), | |
73 | fUseScaledRho(0), fCentralityClasses(0), fUserSuppliedV2(0), fUserSuppliedV3(0), fUserSuppliedR2(0), | |
74 | fUserSuppliedR3(0), fNAcceptedTracks(0), fNAcceptedTracksQCn(0), fInCentralitySelection(-1), | |
75 | fFitModulationType(kNoFit), fQCRecovery(kTryFit), fUsePtWeight(kTRUE), fDetectorType(kTPC), | |
76 | fFitModulationOptions("WLQI"), fRunModeType(type), fFitModulation(0), fMinPvalue(0.01), fMaxPvalue(1), | |
77 | fLocalJetMinEta(-10), fLocalJetMaxEta(-10), fLocalJetMinPhi(-10), fLocalJetMaxPhi(-10), fSoftTrackMinPt(0.15), | |
78 | fSoftTrackMaxPt(5.), fHistPvalueCDF(0), fAbsVnHarmonics(kTRUE), fExcludeLeadingJetsFromFit(1.), | |
79 | fRebinSwapHistoOnTheFly(kTRUE), fPercentageOfFits(10.), fUseV0EventPlaneFromHeader(kTRUE), fOutputList(0), | |
80 | fOutputListGood(0), fOutputListBad(0), fHistSwap(0), fHistAnalysisSummary(0), fProfV2(0), fProfV2Cumulant(0), | |
81 | fProfV3(0), fProfV3Cumulant(0) | |
82 | { | |
83 | // Constructor | |
84 | for(Int_t i(0); i < 10; i++) { | |
85 | fHistPsi2[i] = 0; | |
86 | fHistPsi3[i] = 0; | |
87 | } | |
88 | ||
89 | DefineInput(0, TChain::Class()); | |
90 | DefineOutput(1, TList::Class()); | |
91 | switch (fRunModeType) { | |
92 | case kLocal : { | |
93 | gStyle->SetOptFit(1); | |
94 | DefineOutput(2, TList::Class()); | |
95 | DefineOutput(3, TList::Class()); | |
96 | } break; | |
97 | default: fDebug = -1; // suppress debug info explicitely when not running locally | |
98 | } | |
5ce0dc6d | 99 | } |
9239b066 | 100 | |
5ce0dc6d | 101 | //_____________________________________________________________________________ |
102 | AliAnalysisTaskLocalRho::~AliAnalysisTaskLocalRho() | |
103 | { | |
9239b066 | 104 | // destructor |
105 | if(fOutputList) delete fOutputList; | |
106 | if(fOutputListGood) delete fOutputListGood; | |
107 | if(fOutputListBad) delete fOutputListBad; | |
108 | if(fFitModulation) delete fFitModulation; | |
109 | if(fHistSwap) delete fHistSwap; | |
5ce0dc6d | 110 | } |
9239b066 | 111 | |
5ce0dc6d | 112 | //_____________________________________________________________________________ |
7dd1eeea | 113 | void AliAnalysisTaskLocalRho::ExecOnce() |
114 | { | |
9239b066 | 115 | // Init the analysis |
116 | if(fLocalRhoName=="") fLocalRhoName = Form("LocalRhoFrom_%s", GetName()); | |
117 | fLocalRho = new AliLocalRhoParameter(fLocalRhoName.Data(), 0); | |
118 | // add the local rho to the event if necessary | |
119 | if(fAttachToEvent) { | |
120 | if(!(InputEvent()->FindListObject(fLocalRho->GetName()))) { | |
121 | InputEvent()->AddObject(fLocalRho); | |
122 | } else { | |
123 | AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fLocalRho->GetName())); | |
7dd1eeea | 124 | } |
9239b066 | 125 | } |
126 | AliAnalysisTaskEmcalJet::ExecOnce(); // init the base clas | |
127 | if(fUseScaledRho) { | |
128 | // unscaled rho has been retrieved by the parent class, now we retrieve rho scaled | |
129 | fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(Form("%s_Scaled", fRho->GetName()))); | |
130 | if(!fRho) { | |
131 | AliFatal(Form("%s: Couldn't find container for scaled rho. Aborting !", GetName())); | |
7dd1eeea | 132 | } |
9239b066 | 133 | } |
134 | if(!GetJetContainer()) AliFatal(Form("%s: Couldn't get jet container. Aborting !", GetName())); | |
7dd1eeea | 135 | } |
9239b066 | 136 | |
7dd1eeea | 137 | //_____________________________________________________________________________ |
5ce0dc6d | 138 | Bool_t AliAnalysisTaskLocalRho::InitializeAnalysis() |
139 | { | |
9239b066 | 140 | // Initialize the anaysis |
141 | ||
142 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
143 | if(fLocalJetMinEta > -10 && fLocalJetMaxEta > -10) SetJetEtaLimits(fLocalJetMinEta, fLocalJetMaxEta); | |
144 | if(fLocalJetMinPhi > -10 && fLocalJetMaxPhi > -10) SetJetPhiLimits(fLocalJetMinPhi, fLocalJetMaxPhi); | |
145 | switch (fFitModulationType) { | |
146 | case kNoFit : { SetModulationFit(new TF1("fit_kNoFit", "[0]", 0, TMath::TwoPi())); } break; | |
147 | case kV2 : { | |
148 | SetModulationFit(new TF1("fit_kV2", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi())); | |
149 | fFitModulation->SetParameter(0, 0.); // normalization | |
150 | fFitModulation->SetParameter(3, 0.2); // v2 | |
151 | fFitModulation->FixParameter(1, 1.); // constant | |
152 | fFitModulation->FixParameter(2, 2.); // constant | |
153 | } break; | |
154 | case kV3: { | |
155 | SetModulationFit(new TF1("fit_kV3", "[0]*([1]+[2]*[3]*TMath::Cos([2]*(x-[4])))", 0, TMath::TwoPi())); | |
156 | fFitModulation->SetParameter(0, 0.); // normalization | |
157 | fFitModulation->SetParameter(3, 0.2); // v3 | |
158 | fFitModulation->FixParameter(1, 1.); // constant | |
159 | fFitModulation->FixParameter(2, 3.); // constant | |
160 | } break; | |
161 | default : { // for the combined fit, the 'direct fourier series' or the user supplied vn values we use v2 and v3 | |
162 | SetModulationFit(new TF1("fit_kCombined", "[0]*([1]+[2]*([3]*TMath::Cos([2]*(x-[4]))+[7]*TMath::Cos([5]*(x-[6]))))", 0, TMath::TwoPi())); | |
163 | fFitModulation->SetParameter(0, 0.); // normalization | |
164 | fFitModulation->SetParameter(3, 0.2); // v2 | |
165 | fFitModulation->FixParameter(1, 1.); // constant | |
166 | fFitModulation->FixParameter(2, 2.); // constant | |
167 | fFitModulation->FixParameter(5, 3.); // constant | |
168 | fFitModulation->SetParameter(7, 0.2); // v3 | |
169 | } break; | |
170 | } | |
171 | switch (fRunModeType) { | |
172 | case kGrid : { fFitModulationOptions += "N0"; } break; | |
173 | default : break; | |
174 | } | |
175 | FillAnalysisSummaryHistogram(); | |
176 | return kTRUE; | |
5ce0dc6d | 177 | } |
9239b066 | 178 | |
5ce0dc6d | 179 | //_____________________________________________________________________________ |
180 | void AliAnalysisTaskLocalRho::UserCreateOutputObjects() | |
181 | { | |
9239b066 | 182 | // create output objects |
183 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
184 | fHistSwap = new TH1F("fHistSwap", "fHistSwap", 20, 0, TMath::TwoPi()); | |
185 | if(!fCentralityClasses) { // classes must be defined at this point | |
186 | Int_t c[] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; | |
187 | fCentralityClasses = new TArrayI(sizeof(c)/sizeof(c[0]), c); | |
188 | } | |
189 | fOutputList = new TList(); | |
190 | fOutputList->SetOwner(kTRUE); | |
191 | // the analysis summary histo which stores all the analysis flags is always written to file | |
192 | fHistAnalysisSummary = BookTH1F("fHistAnalysisSummary", "flag", 51, -0.5, 51.5); | |
193 | if(!fFillHistograms) { | |
5ce0dc6d | 194 | PostData(1, fOutputList); |
9239b066 | 195 | return; |
196 | } | |
197 | for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i++) { | |
198 | fHistPsi2[i] = BookTH1F("fHistPsi2", "#Psi_{2}", 100, -.5*TMath::Pi(), .5*TMath::Pi(), i); | |
199 | fHistPsi3[i] = BookTH1F("fHistPsi3", "#Psi_{3}", 100, -1.*TMath::Pi()/3., TMath::Pi()/3., i); | |
200 | } | |
201 | // cdf of chisquare distribution | |
202 | fHistPvalueCDF = BookTH1F("fHistPvalueCDF", "CDF #chi^{2}", 500, 0, 1); | |
203 | // vn profiles | |
204 | Float_t temp[fCentralityClasses->GetSize()]; | |
205 | for(Int_t i(0); i < fCentralityClasses->GetSize(); i++) temp[i] = fCentralityClasses->At(i); | |
206 | fProfV2 = new TProfile("fProfV2", "fProfV2", fCentralityClasses->GetSize()-1, temp); | |
207 | fProfV3 = new TProfile("fProfV3", "fProfV3", fCentralityClasses->GetSize()-1, temp); | |
208 | fOutputList->Add(fProfV2); | |
209 | fOutputList->Add(fProfV3); | |
210 | switch (fFitModulationType) { | |
211 | case kQC2 : { | |
212 | fProfV2Cumulant = new TProfile("fProfV2Cumulant", "fProfV2Cumulant", fCentralityClasses->GetSize()-1, temp); | |
213 | fProfV3Cumulant = new TProfile("fProfV3Cumulant", "fProfV3Cumulant", fCentralityClasses->GetSize()-1, temp); | |
214 | fOutputList->Add(fProfV2Cumulant); | |
215 | fOutputList->Add(fProfV3Cumulant); | |
216 | } break; | |
217 | case kQC4 : { | |
218 | fProfV2Cumulant = new TProfile("fProfV2Cumulant", "fProfV2Cumulant", fCentralityClasses->GetSize()-1, temp); | |
219 | fProfV3Cumulant = new TProfile("fProfV3Cumulant", "fProfV3Cumulant", fCentralityClasses->GetSize()-1, temp); | |
220 | fOutputList->Add(fProfV2Cumulant); | |
221 | fOutputList->Add(fProfV3Cumulant); | |
222 | } break; | |
223 | default : break; | |
224 | } | |
225 | if(fUsePtWeight) fHistSwap->Sumw2(); | |
226 | if(fUserSuppliedV2) fOutputList->Add(fUserSuppliedV2); | |
227 | if(fUserSuppliedV3) fOutputList->Add(fUserSuppliedV3); | |
228 | if(fUserSuppliedR2) fOutputList->Add(fUserSuppliedR2); | |
229 | if(fUserSuppliedR3) fOutputList->Add(fUserSuppliedR3); | |
230 | // increase readability of output list | |
231 | fOutputList->Sort(); | |
232 | PostData(1, fOutputList); | |
233 | switch (fRunModeType) { | |
234 | case kLocal : { | |
235 | fOutputListGood = new TList(); | |
236 | fOutputListGood->SetOwner(kTRUE); | |
237 | fOutputListBad = new TList(); | |
238 | fOutputListBad->SetOwner(kTRUE); | |
239 | PostData(2, fOutputListGood); | |
240 | PostData(3, fOutputListBad); | |
241 | } break; | |
242 | default: break; | |
243 | } | |
5ce0dc6d | 244 | } |
9239b066 | 245 | |
5ce0dc6d | 246 | //_____________________________________________________________________________ |
247 | TH1F* AliAnalysisTaskLocalRho::BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c, Bool_t append) | |
248 | { | |
9239b066 | 249 | // Book a TH1F and connect it to the output container |
250 | ||
251 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
252 | if(!fOutputList) return 0x0; | |
253 | TString title(name); | |
254 | if(c!=-1) { // format centrality dependent histograms accordingly | |
255 | name = Form("%s_%i", name, c); | |
256 | title += Form("_%i-%i", fCentralityClasses->At(c), fCentralityClasses->At(1+c)); | |
257 | } | |
258 | title += Form(";%s;[counts]", x); | |
259 | TH1F* histogram = new TH1F(name, title.Data(), bins, min, max); | |
260 | histogram->Sumw2(); | |
261 | if(append) fOutputList->Add(histogram); | |
262 | return histogram; | |
5ce0dc6d | 263 | } |
9239b066 | 264 | |
5ce0dc6d | 265 | //_____________________________________________________________________________ |
9239b066 | 266 | TH2F* AliAnalysisTaskLocalRho::BookTH2F(const char* name, const char* x, const char*y, Int_t binsx, Double_t minx, Double_t maxx, |
267 | Int_t binsy, Double_t miny, Double_t maxy, Int_t c, Bool_t append) | |
5ce0dc6d | 268 | { |
9239b066 | 269 | // Book a TH2F and connect it to the output container |
270 | ||
271 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
272 | if(!fOutputList) return 0x0; | |
273 | TString title(name); | |
274 | if(c!=-1) { // format centrality dependent histograms accordingly | |
275 | name = Form("%s_%i", name, c); | |
276 | title += Form("_%i-%i", fCentralityClasses->At(c), fCentralityClasses->At(1+c)); | |
277 | } | |
278 | title += Form(";%s;%s", x, y); | |
279 | TH2F* histogram = new TH2F(name, title.Data(), binsx, minx, maxx, binsy, miny, maxy); | |
280 | histogram->Sumw2(); | |
281 | if(append) fOutputList->Add(histogram); | |
282 | return histogram; | |
5ce0dc6d | 283 | } |
9239b066 | 284 | |
5ce0dc6d | 285 | //_____________________________________________________________________________ |
286 | Bool_t AliAnalysisTaskLocalRho::Run() | |
287 | { | |
9239b066 | 288 | // Execute once for each event |
289 | ||
290 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
291 | if(!(InputEvent()||fTracks||fJets||fRho)) return kFALSE; | |
292 | if(!fInitialized) fInitialized = InitializeAnalysis(); | |
293 | // get the centrality bin (necessary for some control histograms | |
294 | fInCentralitySelection = -1; | |
295 | Double_t cent(InputEvent()->GetCentrality()->GetCentralityPercentile("V0M")); | |
296 | for(Int_t i(0); i < fCentralityClasses->GetSize()-1; i++) { | |
297 | if(cent >= fCentralityClasses->At(i) && cent <= fCentralityClasses->At(1+i)) { | |
298 | fInCentralitySelection = i; | |
299 | break; } | |
300 | } | |
301 | if(fInCentralitySelection < 0) return kFALSE; | |
302 | // set the rho value | |
303 | fLocalRho->SetVal(fRho->GetVal()); | |
304 | // set the correct event plane accordign to the requested reference detector | |
305 | Double_t psi2(-1), psi3(-1); | |
306 | switch (fDetectorType) { // determine the detector type for the rho fit | |
307 | case kTPC : { | |
308 | // [0] psi2 [1] psi3 | |
309 | Double_t tpc[2]; | |
310 | CalculateEventPlaneTPC(tpc); | |
311 | psi2 = tpc[0]; psi3 = tpc[1]; | |
312 | } break; | |
313 | case kVZEROA : { | |
314 | // [0][0] psi2a [1,0] psi2c | |
315 | // [0][1] psi3a [1,1] psi3c | |
316 | Double_t vzero[2][2]; | |
317 | CalculateEventPlaneVZERO(vzero); | |
318 | psi2 = vzero[0][0]; psi3 = vzero[0][1]; | |
319 | } break; | |
320 | case kVZEROC : { | |
321 | // [0][0] psi2a [1,0] psi2c | |
322 | // [0][1] psi3a [1,1] psi3c | |
323 | Double_t vzero[2][2]; | |
324 | CalculateEventPlaneVZERO(vzero); | |
325 | psi2 = vzero[1][0]; psi3 = vzero[1][1]; | |
326 | } break; | |
327 | case kVZEROComb : { | |
328 | /* for the combined vzero event plane | |
329 | * [0] psi2 [1] psi3 | |
330 | * not fully implmemented yet, use with caution ! */ | |
331 | Double_t vzeroComb[2]; | |
332 | CalculateEventPlaneCombinedVZERO(vzeroComb); | |
333 | psi2 = vzeroComb[0]; psi3 = vzeroComb[1]; | |
334 | } break; | |
335 | default : break; | |
336 | } | |
337 | if(fFillHistograms) FillEventPlaneHistograms(psi2, psi3); | |
338 | switch (fFitModulationType) { // do the fits | |
339 | case kNoFit : { fFitModulation->FixParameter(0, fLocalRho->GetVal()); } break; | |
340 | case kV2 : { // only v2 | |
341 | if(CorrectRho(psi2, psi3)) { | |
342 | if(fFillHistograms) fProfV2->Fill(fCent, fFitModulation->GetParameter(3)); | |
343 | if(fUserSuppliedR2) { | |
344 | Double_t r(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent))); | |
345 | if(r > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r); | |
346 | } | |
5ce0dc6d | 347 | } |
9239b066 | 348 | } break; |
349 | case kV3 : { // only v3 | |
350 | if(CorrectRho(psi2, psi3)) { | |
351 | if(fUserSuppliedR3) { | |
352 | Double_t r(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent))); | |
353 | if(r > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r); | |
354 | } | |
355 | if(fFillHistograms) fProfV3->Fill(fCent, fFitModulation->GetParameter(3)); | |
5ce0dc6d | 356 | } |
9239b066 | 357 | } break; |
358 | case kQC2 : { // qc2 analysis - NOTE: not a wise idea to use this ! | |
359 | if(CorrectRho(psi2, psi3)) { | |
360 | if(fUserSuppliedR2 && fUserSuppliedR3) { | |
361 | // note for the qc method, resolution is REVERSED to go back to v2obs | |
362 | Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent))); | |
363 | Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent))); | |
364 | if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)*r2); | |
365 | if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)*r3); | |
366 | } | |
367 | if (fUsePtWeight) { // use weighted weights | |
368 | Double_t dQCnM11 = (fNoEventWeightsForQC) ? 1. : QCnM11(); | |
369 | if(fFillHistograms) { | |
370 | fProfV2->Fill(fCent, fFitModulation->GetParameter(3), dQCnM11); | |
371 | fProfV3->Fill(fCent, fFitModulation->GetParameter(7), dQCnM11); | |
372 | } | |
373 | } else { | |
374 | Double_t dQCnM = (fNoEventWeightsForQC) ? 2. : QCnM(); | |
375 | if(fFillHistograms) { | |
376 | fProfV2->Fill(fCent, fFitModulation->GetParameter(3), dQCnM*(dQCnM-1)); | |
377 | fProfV3->Fill(fCent, fFitModulation->GetParameter(7), dQCnM*(dQCnM-1)); | |
378 | } | |
379 | } | |
5ce0dc6d | 380 | } |
9239b066 | 381 | } break; |
382 | case kQC4 : { // NOTE: see comment at kQC2 | |
383 | if(CorrectRho(psi2, psi3)) { | |
384 | if(fUserSuppliedR2 && fUserSuppliedR3) { | |
385 | // note for the qc method, resolution is REVERSED to go back to v2obs | |
386 | Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent))); | |
387 | Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent))); | |
388 | if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)*r2); | |
389 | if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)*r3); | |
390 | } | |
391 | if (fUsePtWeight) { // use weighted weights | |
392 | if(fFillHistograms) { | |
393 | fProfV2->Fill(fCent, TMath::Power(fFitModulation->GetParameter(3),0.5)/*, QCnM1111()*/); | |
394 | fProfV3->Fill(fCent, TMath::Power(fFitModulation->GetParameter(7),0.5)/*, QCnM1111()*/); | |
395 | } | |
396 | } else { | |
397 | if(fFillHistograms) { | |
398 | fProfV2->Fill(fCent, TMath::Power(fFitModulation->GetParameter(3),0.5)/*, QCnM()*(QCnM()-1)*(QCnM()-2)*(QCnM()-3)*/); | |
399 | fProfV3->Fill(fCent, TMath::Power(fFitModulation->GetParameter(7),0.5)/*, QCnM()*(QCnM()-1)*(QCnM()-2)*(QCnM()-3)*/); | |
400 | } | |
401 | } | |
402 | } | |
403 | } break; | |
404 | default : { | |
405 | if(CorrectRho(psi2, psi3)) { | |
406 | if(fUserSuppliedR2 && fUserSuppliedR3) { | |
407 | Double_t r2(fUserSuppliedR2->GetBinContent(fUserSuppliedR2->GetXaxis()->FindBin(fCent))); | |
408 | Double_t r3(fUserSuppliedR3->GetBinContent(fUserSuppliedR3->GetXaxis()->FindBin(fCent))); | |
409 | if(r2 > 0) fFitModulation->SetParameter(3, fFitModulation->GetParameter(3)/r2); | |
410 | if(r3 > 0) fFitModulation->SetParameter(7, fFitModulation->GetParameter(7)/r3); | |
411 | } | |
412 | if(fFillHistograms) { | |
413 | fProfV2->Fill(fCent, fFitModulation->GetParameter(3)); | |
414 | fProfV3->Fill(fCent, fFitModulation->GetParameter(7)); | |
415 | } | |
416 | } | |
417 | } break; | |
418 | } | |
419 | // if all went well, add local rho | |
420 | fLocalRho->SetLocalRho(fFitModulation); | |
421 | PostData(1, fOutputList); | |
422 | return kTRUE; | |
5ce0dc6d | 423 | } |
9239b066 | 424 | |
5ce0dc6d | 425 | //_____________________________________________________________________________ |
426 | void AliAnalysisTaskLocalRho::CalculateEventPlaneVZERO(Double_t vzero[2][2]) const | |
427 | { | |
9239b066 | 428 | // Get the vzero event plane |
429 | if(fUseV0EventPlaneFromHeader) { | |
430 | // use the vzero event plane from the event header | |
431 | // note: to use the calibrated vzero event plane, run | |
432 | // $ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C | |
433 | // prior to this task (make sure the calibration is available for the dataset | |
434 | // you want to use) | |
435 | Double_t a(0), b(0), c(0), d(0), e(0), f(0), g(0), h(0); | |
436 | vzero[0][0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 2, a, b); | |
437 | vzero[1][0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 2, c, d); | |
438 | vzero[0][1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 3, e, f); | |
439 | vzero[1][1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 3, g, h); | |
440 | return; | |
441 | } | |
442 | // grab the vzero event plane without recentering | |
443 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
444 | Double_t qxa2(0), qya2(0), qxc2(0), qyc2(0); // for psi2 | |
445 | Double_t qxa3(0), qya3(0), qxc3(0), qyc3(0); // for psi3 | |
446 | for(Int_t iVZERO(0); iVZERO < 64; iVZERO++) { | |
447 | Double_t phi(TMath::PiOver4()*(.5+iVZERO%8)), /* eta(0), */ weight(InputEvent()->GetVZEROEqMultiplicity(iVZERO)); | |
448 | // (iVZERO<32) ? eta = -3.45+.5*(iVZERO/8) : eta = 4.8-.6*((iVZERO/8)-4); | |
449 | if(iVZERO<32) { | |
450 | qxa2 += weight*TMath::Cos(2.*phi); | |
451 | qya2 += weight*TMath::Sin(2.*phi); | |
452 | qxa3 += weight*TMath::Cos(3.*phi); | |
453 | qya3 += weight*TMath::Sin(3.*phi); | |
5ce0dc6d | 454 | } |
9239b066 | 455 | else { |
456 | qxc2 += weight*TMath::Cos(2.*phi); | |
457 | qyc2 += weight*TMath::Sin(2.*phi); | |
458 | qxc3 += weight*TMath::Cos(3.*phi); | |
459 | qyc3 += weight*TMath::Sin(3.*phi); | |
5ce0dc6d | 460 | } |
9239b066 | 461 | } |
462 | vzero[0][0] = .5*TMath::ATan2(qya2, qxa2); | |
463 | vzero[1][0] = .5*TMath::ATan2(qyc2, qxc2); | |
464 | vzero[0][1] = (1./3.)*TMath::ATan2(qya3, qxa3); | |
465 | vzero[1][1] = (1./3.)*TMath::ATan2(qyc3, qxc3); | |
5ce0dc6d | 466 | } |
9239b066 | 467 | |
5ce0dc6d | 468 | //_____________________________________________________________________________ |
469 | void AliAnalysisTaskLocalRho::CalculateEventPlaneTPC(Double_t* tpc) | |
470 | { | |
9239b066 | 471 | // Grab the TPC event plane. if parameter fExcludeLeadingJetsFromFit is larger than 0, |
472 | // strip in eta of width fExcludeLeadingJetsFromFit * GetJetContainer()->GetJetRadius() around the leading jet (before | |
473 | // subtraction of rho) will be exluded from the event plane estimate | |
474 | ||
475 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
476 | fNAcceptedTracks = 0; // reset the track counter | |
477 | Double_t qx2(0), qy2(0); // for psi2 | |
478 | Double_t qx3(0), qy3(0); // for psi3 | |
479 | if(fTracks) { | |
480 | Float_t excludeInEta = -999; | |
481 | if(fExcludeLeadingJetsFromFit > 0 ) { // remove the leading jet from ep estimate | |
482 | AliEmcalJet* leadingJet(GetJetContainer()->GetLeadingJet()); | |
483 | if(leadingJet) leadingJet->Eta(); | |
484 | } | |
485 | Int_t iTracks(fTracks->GetEntriesFast()); | |
486 | for(Int_t iTPC(0); iTPC < iTracks; iTPC++) { | |
487 | AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC)); | |
488 | if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue; | |
489 | if(fExcludeLeadingJetsFromFit > 0 &&( (TMath::Abs(track->Eta() - excludeInEta) < GetJetContainer()->GetJetRadius()*fExcludeLeadingJetsFromFit ) || (TMath::Abs(track->Eta()) - GetJetContainer()->GetJetRadius() - GetJetContainer()->GetJetEtaMax() ) > 0 )) continue; | |
490 | fNAcceptedTracks++; | |
491 | qx2+= TMath::Cos(2.*track->Phi()); | |
492 | qy2+= TMath::Sin(2.*track->Phi()); | |
493 | qx3+= TMath::Cos(3.*track->Phi()); | |
494 | qy3+= TMath::Sin(3.*track->Phi()); | |
495 | } | |
496 | } | |
497 | tpc[0] = .5*TMath::ATan2(qy2, qx2); | |
498 | tpc[1] = (1./3.)*TMath::ATan2(qy3, qx3); | |
5ce0dc6d | 499 | } |
9239b066 | 500 | |
5ce0dc6d | 501 | //_____________________________________________________________________________ |
502 | void AliAnalysisTaskLocalRho::CalculateEventPlaneCombinedVZERO(Double_t* comb) const | |
503 | { | |
9239b066 | 504 | // Grab the combined vzero event plane |
505 | ||
506 | // if(fUseV0EventPlaneFromHeader) { // use the vzero from the header | |
507 | Double_t a(0), b(0), c(0), d(0); | |
508 | comb[0] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 10, 2, a, b); | |
509 | comb[1] = InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 10, 3, c, d); | |
510 | // FIXME the rest of this function isn't impelmented yet (as of 01-07-2013) | |
511 | // this means a default the combined vzero event plane from the header is used | |
512 | // to get this value 'by hand', vzeroa and vzeroc event planes have to be combined | |
513 | // according to their resolution - this will be added ... | |
514 | // | |
515 | // } else { | |
516 | // Double_t qx2a(0), qy2a(0), qx2c(0), qy2c(0), qx3a(0), qy3a(0), qx3c(0), qy3c(0); | |
517 | // InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 2, qx2a, qy2a); | |
518 | // InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 2, qx2c, qy2c); | |
519 | // InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 8, 3, qx3a, qy3a); | |
520 | // InputEvent()->GetEventplane()->CalculateVZEROEventPlane(InputEvent(), 9, 3, qx3c, qy3c); | |
521 | // Double_t chi2A(-1), chi2C(-1), chi3A(-1), chi3C(-1); // get chi from the resolution | |
522 | // Double_t qx2(chi2A*chi2A*qx2a+chi2C*chi2C*qx2c); | |
523 | // Double_t qy2(chi2A*chi2A*qy2a+chi2C*chi2C*qy2c); | |
524 | // Double_t qx3(chi3A*chi3A*qx3a+chi3C*chi3C*qx3c); | |
525 | // Double_t qy3(chi3A*chi3A*qy3a+chi3C*chi3C*qy3c); | |
526 | // comb[0] = .5*TMath::ATan2(qy2, qx2); | |
527 | // comb[1] = (1./3.)*TMath::ATan2(qy3, qx3); | |
528 | // } | |
5ce0dc6d | 529 | } |
9239b066 | 530 | |
5ce0dc6d | 531 | //_____________________________________________________________________________ |
9239b066 | 532 | Double_t AliAnalysisTaskLocalRho::CalculateQC2(Int_t harm) |
533 | { | |
534 | // Get the second order q-cumulant, a -999 return will be caught in the qa routine of CorrectRho | |
535 | ||
536 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
537 | Double_t reQ(0), imQ(0), modQ(0), M11(0), M(0); | |
538 | if(fUsePtWeight) { // for the weighted 2-nd order q-cumulant | |
539 | QCnQnk(harm, 1, reQ, imQ); // get the weighted 2-nd order q-vectors | |
540 | modQ = reQ*reQ+imQ*imQ; // get abs Q-squared | |
541 | M11 = QCnM11(); // equals S2,1 - S1,2 | |
542 | return (M11 > 0) ? ((modQ - QCnS(1,2))/M11) : -999; | |
543 | } // else return the non-weighted 2-nd order q-cumulant | |
544 | QCnQnk(harm, 0, reQ, imQ); // get the non-weighted 2-nd order q-vectors | |
545 | modQ = reQ*reQ+imQ*imQ; // get abs Q-squared | |
546 | M = QCnM(); | |
547 | return (M > 1) ? (modQ - M)/(M*(M-1)) : -999; | |
5ce0dc6d | 548 | } |
9239b066 | 549 | |
5ce0dc6d | 550 | //_____________________________________________________________________________ |
9239b066 | 551 | Double_t AliAnalysisTaskLocalRho::CalculateQC4(Int_t harm) |
552 | { | |
553 | // Get the fourth order q-cumulant, a -999 return will be caught in the qa routine of CorrectRho | |
554 | ||
555 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
556 | Double_t reQn1(0), imQn1(0), reQ2n2(0), imQ2n2(0), reQn3(0), imQn3(0), M1111(0), M(0); | |
557 | Double_t a(0), b(0), c(0), d(0), e(0), f(0), g(0); // terms of the calculation | |
558 | if(fUsePtWeight) { // for the weighted 4-th order q-cumulant | |
559 | QCnQnk(harm, 1, reQn1, imQn1); | |
560 | QCnQnk(harm*2, 2, reQ2n2, imQ2n2); | |
561 | QCnQnk(harm, 3, reQn3, imQn3); | |
5ce0dc6d | 562 | // fill in the terms ... |
9239b066 | 563 | a = (reQn1*reQn1+imQn1*imQn1)*(reQn1*reQn1+imQn1*imQn1); |
564 | b = reQ2n2*reQ2n2 + imQ2n2*imQ2n2; | |
565 | c = -2.*(reQ2n2*reQn1*reQn1-reQ2n2*imQn1*imQn1+2.*imQ2n2*reQn1*imQn1); | |
566 | d = 8.*(reQn3*reQn1+imQn3*imQn1); | |
567 | e = -4.*QCnS(1,2)*(reQn1*reQn1+imQn1*imQn1); | |
568 | f = -6.*QCnS(1,4); | |
569 | g = 2.*QCnS(2,2); | |
570 | M1111 = QCnM1111(); | |
571 | return (M1111 > 0) ? (a+b+c+d+e+f+g)/M1111 : -999; | |
572 | } // else return the unweighted case | |
573 | Double_t reQn(0), imQn(0), reQ2n(0), imQ2n(0); | |
574 | QCnQnk(harm, 0, reQn, imQn); | |
575 | QCnQnk(harm*2, 0, reQ2n, imQ2n); | |
576 | // fill in the terms ... | |
577 | M = QCnM(); | |
578 | if(M < 4) return -999; | |
579 | a = (reQn*reQn+imQn*imQn)*(reQn*reQn+imQn*imQn); | |
580 | b = reQ2n*reQ2n + imQ2n*imQ2n; | |
581 | c = -2.*(reQ2n*reQn*reQn-reQ2n*imQn*imQn+2.*imQ2n*reQn*imQn); | |
582 | e = -4.*(M-2)*(reQn*reQn+imQn*imQn); | |
583 | f = 2.*M*(M-3); | |
584 | return (a+b+c+e+f)/(M*(M-1)*(M-2)*(M-3)); | |
5ce0dc6d | 585 | } |
9239b066 | 586 | |
5ce0dc6d | 587 | //_____________________________________________________________________________ |
9239b066 | 588 | void AliAnalysisTaskLocalRho::QCnQnk(Int_t n, Int_t k, Double_t &reQ, Double_t &imQ) |
589 | { | |
590 | // Get the weighted n-th order q-vector, pass real and imaginary part as reference | |
591 | ||
592 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
593 | if(!fTracks) return; | |
594 | fNAcceptedTracksQCn = 0; | |
595 | Int_t iTracks(fTracks->GetEntriesFast()); | |
596 | for(Int_t iTPC(0); iTPC < iTracks; iTPC++) { | |
597 | AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC)); | |
598 | if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue; | |
599 | fNAcceptedTracksQCn++; | |
600 | // for the unweighted case, k equals zero and the weight doesn't contribute to the equation below | |
601 | reQ += TMath::Power(track->Pt(), k) * TMath::Cos(((double)n)*track->Phi()); | |
602 | imQ += TMath::Power(track->Pt(), k) * TMath::Sin(((double)n)*track->Phi()); | |
603 | } | |
5ce0dc6d | 604 | } |
9239b066 | 605 | |
5ce0dc6d | 606 | //_____________________________________________________________________________ |
9239b066 | 607 | Double_t AliAnalysisTaskLocalRho::QCnS(Int_t i, Int_t j) |
608 | { | |
609 | // Get the weighted ij-th order autocorrelation correction | |
610 | ||
611 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
612 | if(!fTracks || i <= 0 || j <= 0) return -999; | |
613 | Int_t iTracks(fTracks->GetEntriesFast()); | |
614 | Double_t Sij(0); | |
615 | for(Int_t iTPC(0); iTPC < iTracks; iTPC++) { | |
616 | AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(iTPC)); | |
617 | if(!PassesCuts(track) || track->Pt() < fSoftTrackMinPt || track->Pt() > fSoftTrackMaxPt) continue; | |
618 | Sij+=TMath::Power(track->Pt(), j); | |
619 | } | |
620 | return TMath::Power(Sij, i); | |
5ce0dc6d | 621 | } |
9239b066 | 622 | |
5ce0dc6d | 623 | //_____________________________________________________________________________ |
9239b066 | 624 | Double_t AliAnalysisTaskLocalRho::QCnM() |
625 | { | |
626 | // Get multiplicity for unweighted q-cumulants. function QCnQnk should be called first | |
627 | ||
628 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
629 | return (Double_t) fNAcceptedTracksQCn; | |
5ce0dc6d | 630 | } |
9239b066 | 631 | |
5ce0dc6d | 632 | //_____________________________________________________________________________ |
9239b066 | 633 | Double_t AliAnalysisTaskLocalRho::QCnM11() |
634 | { | |
635 | // Get multiplicity weights for the weighted two particle cumulant | |
636 | ||
637 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
638 | return (QCnS(2,1) - QCnS(1,2)); | |
5ce0dc6d | 639 | } |
9239b066 | 640 | |
5ce0dc6d | 641 | //_____________________________________________________________________________ |
9239b066 | 642 | Double_t AliAnalysisTaskLocalRho::QCnM1111() |
643 | { | |
644 | // Get multiplicity weights for the weighted four particle cumulant | |
645 | ||
646 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
647 | 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)); | |
5ce0dc6d | 648 | } |
9239b066 | 649 | |
5ce0dc6d | 650 | //_____________________________________________________________________________ |
9239b066 | 651 | Bool_t AliAnalysisTaskLocalRho::QCnRecovery(Double_t psi2, Double_t psi3) |
652 | { | |
653 | // Decides how to deal with the situation where c2 or c3 is negative | |
654 | // Returns kTRUE depending on whether or not a modulated rho is used for the jet background | |
655 | ||
656 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
657 | if(TMath::AreEqualAbs(fFitModulation->GetParameter(3), .0, 1e-10) && TMath::AreEqualAbs(fFitModulation->GetParameter(7), .0,1e-10)) { | |
658 | fFitModulation->SetParameter(7, 0); | |
659 | fFitModulation->SetParameter(3, 0); | |
660 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
661 | return kTRUE; // v2 and v3 have physical null values | |
662 | } | |
663 | switch (fQCRecovery) { | |
664 | case kFixedRho : { // roll back to the original rho | |
665 | fFitModulation->SetParameter(7, 0); | |
666 | fFitModulation->SetParameter(3, 0); | |
667 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
668 | return kFALSE; // rho is forced to be fixed | |
669 | } | |
670 | case kNegativeVn : { | |
671 | Double_t c2(fFitModulation->GetParameter(3)); | |
672 | Double_t c3(fFitModulation->GetParameter(7)); | |
673 | if( c2 < 0 ) c2 = -1.*TMath::Sqrt(-1.*c2); | |
674 | if( c3 < 0 ) c3 = -1.*TMath::Sqrt(-1.*c3); | |
675 | fFitModulation->SetParameter(3, c2); | |
676 | fFitModulation->SetParameter(7, c3); | |
677 | return kTRUE; // is this a physical quantity ? | |
678 | } | |
679 | case kTryFit : { | |
680 | fitModulationType tempType(fFitModulationType); // store temporarily | |
681 | fFitModulationType = kCombined; | |
682 | fFitModulation->SetParameter(7, 0); | |
683 | fFitModulation->SetParameter(3, 0); | |
684 | Bool_t pass(CorrectRho(psi2, psi3)); // do the fit and all quality checks | |
685 | fFitModulationType = tempType; // roll back for next event | |
686 | return pass; | |
687 | } | |
688 | default : return kFALSE; | |
689 | } | |
690 | return kFALSE; | |
5ce0dc6d | 691 | } |
9239b066 | 692 | |
5ce0dc6d | 693 | //_____________________________________________________________________________ |
694 | Bool_t AliAnalysisTaskLocalRho::CorrectRho(Double_t psi2, Double_t psi3) | |
695 | { | |
9239b066 | 696 | // Get rho' -> rho(phi) |
697 | // three routines are available, 1 and 2 can be used with or without pt weights | |
698 | // [1] get vn from q-cumulants | |
699 | // in case of cumulants, both cumulants and vn values are stored. in both cases, v2 and v3 | |
700 | // are expected. a check is performed to see if rho has no negative local minimum | |
701 | // for full description, see Phys. Rev. C 83, 044913 | |
702 | // since the cn distribution has negative values, vn = sqrt(cn) can be imaginary sometimes | |
703 | // in this case one can either roll back to the 'original' fixed rho, do a fit for vn or take use | |
704 | // vn = - sqrt(|cn|) note that because of this, use of q-cumulants is not safe ! | |
705 | // [2] fitting a fourier expansion to the de/dphi distribution | |
706 | // the fit can be done with either v2, v3 or a combination. | |
707 | // in all cases, a cut can be made on the p-value of the chi-squared value of the fit | |
708 | // and a check can be performed to see if rho has no negative local minimum | |
709 | // [3] get v2 and v3 from user supplied histograms | |
710 | // in this way, a fixed value of v2 and v3 is subtracted w.r.t. whichever event plane is requested | |
711 | ||
712 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
713 | switch (fFitModulationType) { // for approaches where no fitting is required | |
714 | case kQC2 : { | |
715 | fFitModulation->FixParameter(4, psi2); | |
716 | fFitModulation->FixParameter(6, psi3); | |
717 | fFitModulation->FixParameter(3, CalculateQC2(2)); // set here with cn, vn = sqrt(cn) | |
718 | fFitModulation->FixParameter(7, CalculateQC2(3)); | |
719 | // first fill the histos of the raw cumulant distribution | |
720 | if (fUsePtWeight) { // use weighted weights | |
721 | Double_t dQCnM11 = (fNoEventWeightsForQC) ? 1. : QCnM11(); | |
722 | if(fFillHistograms) { | |
723 | fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3), dQCnM11); | |
724 | fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7), dQCnM11); | |
725 | } | |
726 | } else { | |
727 | Double_t dQCnM = (fNoEventWeightsForQC) ? 2. : QCnM(); | |
728 | if(fFillHistograms) { | |
729 | fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3), dQCnM*(dQCnM-1)); | |
730 | fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7), dQCnM*(dQCnM-1)); | |
731 | } | |
5ce0dc6d | 732 | } |
9239b066 | 733 | // then see if one of the cn value is larger than zero and vn is readily available |
734 | if(fFitModulation->GetParameter(3) > 0 && fFitModulation->GetParameter(7) > 0) { | |
735 | fFitModulation->FixParameter(3, TMath::Sqrt(fFitModulation->GetParameter(3))); | |
736 | fFitModulation->FixParameter(7, TMath::Sqrt(fFitModulation->GetParameter(7))); | |
737 | } else if (!QCnRecovery(psi2, psi3)) return kFALSE; // try to recover the cumulant, this will set v2 and v3 | |
738 | if(fAbsVnHarmonics && fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { // general check | |
739 | fFitModulation->SetParameter(7, 0); | |
740 | fFitModulation->SetParameter(3, 0); | |
741 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
742 | return kFALSE; | |
5ce0dc6d | 743 | } |
9239b066 | 744 | return kTRUE; |
745 | } break; | |
746 | case kQC4 : { | |
747 | fFitModulation->FixParameter(4, psi2); | |
748 | fFitModulation->FixParameter(6, psi3); | |
749 | fFitModulation->FixParameter(3, CalculateQC4(2)); // set here with cn, vn = sqrt(cn) | |
750 | fFitModulation->FixParameter(7, CalculateQC4(3)); | |
751 | // first fill the histos of the raw cumulant distribution | |
752 | if (fUsePtWeight) { // use weighted weights | |
753 | if(fFillHistograms) { | |
754 | fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3)/*, QCnM1111()*/); | |
755 | fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7)/*, QCnM1111()*/); | |
756 | } | |
757 | } else { | |
758 | if(fFillHistograms) { | |
759 | fProfV2Cumulant->Fill(fCent, fFitModulation->GetParameter(3)/*, QCnM1111()*/); | |
760 | fProfV3Cumulant->Fill(fCent, fFitModulation->GetParameter(7)/*, QCnM1111()*/); | |
761 | } | |
762 | } | |
763 | // then see if one of the cn value is larger than zero and vn is readily available | |
764 | if(fFitModulation->GetParameter(3) > 0 && fFitModulation->GetParameter(7) > 0) { | |
765 | fFitModulation->FixParameter(3, TMath::Sqrt(fFitModulation->GetParameter(3))); | |
766 | fFitModulation->FixParameter(7, TMath::Sqrt(fFitModulation->GetParameter(7))); | |
767 | } else if (!QCnRecovery(psi2, psi3)) return kFALSE; // try to recover the cumulant, this will set v2 and v3 | |
768 | if(fAbsVnHarmonics && fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { // general check | |
769 | fFitModulation->SetParameter(7, 0); | |
770 | fFitModulation->SetParameter(3, 0); | |
771 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
772 | return kFALSE; | |
773 | } | |
774 | } break; | |
775 | case kIntegratedFlow : { | |
776 | // use v2 and v3 values from an earlier iteration over the data | |
777 | fFitModulation->FixParameter(3, fUserSuppliedV2->GetBinContent(fUserSuppliedV2->GetXaxis()->FindBin(fCent))); | |
778 | fFitModulation->FixParameter(4, psi2); | |
779 | fFitModulation->FixParameter(6, psi3); | |
780 | fFitModulation->FixParameter(7, fUserSuppliedV3->GetBinContent(fUserSuppliedV3->GetXaxis()->FindBin(fCent))); | |
781 | if(fAbsVnHarmonics && fFitModulation->GetMinimum(0, TMath::TwoPi()) < 0) { | |
782 | fFitModulation->SetParameter(7, 0); | |
783 | fFitModulation->SetParameter(3, 0); | |
784 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
785 | return kFALSE; | |
5ce0dc6d | 786 | } |
9239b066 | 787 | return kTRUE; |
788 | } | |
789 | default : break; | |
790 | } | |
791 | TString detector(""); | |
792 | switch (fDetectorType) { | |
793 | case kTPC : detector+="TPC"; | |
794 | break; | |
795 | case kVZEROA : detector+="VZEROA"; | |
796 | break; | |
797 | case kVZEROC : detector+="VZEROC"; | |
798 | break; | |
799 | case kVZEROComb : detector+="VZEROComb"; | |
800 | break; | |
801 | default: break; | |
802 | } | |
803 | Int_t iTracks(fTracks->GetEntriesFast()); | |
804 | Double_t excludeInEta = -999; | |
805 | Double_t excludeInPhi = -999; | |
806 | Double_t excludeInPt = -999; | |
807 | if(iTracks <= 0 || fLocalRho->GetVal() <= 0 ) return kFALSE; // no use fitting an empty event ... | |
808 | if(fExcludeLeadingJetsFromFit > 0 ) { | |
809 | AliEmcalJet* leadingJet = GetJetContainer()->GetLeadingJet(); | |
810 | if(PassesCuts(leadingJet)) { | |
811 | excludeInEta = leadingJet->Eta(); | |
812 | excludeInPhi = leadingJet->Phi(); | |
813 | excludeInPt = leadingJet->Pt(); | |
5ce0dc6d | 814 | } |
9239b066 | 815 | } |
816 | fHistSwap->Reset(); // clear the histogram | |
817 | TH1F _tempSwap; | |
818 | if(fRebinSwapHistoOnTheFly) { | |
819 | if(fNAcceptedTracks < 49) fNAcceptedTracks = 49; // avoid aliasing effects | |
820 | _tempSwap = TH1F("_tempSwap", "_tempSwap", TMath::CeilNint(TMath::Sqrt(fNAcceptedTracks)), 0, TMath::TwoPi()); | |
821 | if(fUsePtWeight) _tempSwap.Sumw2(); | |
822 | } | |
823 | else _tempSwap = *fHistSwap; // now _tempSwap holds the desired histo | |
824 | for(Int_t i(0); i < iTracks; i++) { | |
825 | AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i)); | |
826 | if(fExcludeLeadingJetsFromFit > 0 &&( (TMath::Abs(track->Eta() - excludeInEta) < GetJetContainer()->GetJetRadius()*fExcludeLeadingJetsFromFit ) || (TMath::Abs(track->Eta()) - GetJetContainer()->GetJetRadius() - GetJetContainer()->GetJetEtaMax() ) > 0 )) continue; | |
827 | if(!PassesCuts(track) || track->Pt() > fSoftTrackMaxPt || track->Pt() < fSoftTrackMinPt) continue; | |
828 | if(fUsePtWeight) _tempSwap.Fill(track->Phi(), track->Pt()); | |
829 | else _tempSwap.Fill(track->Phi()); | |
830 | } | |
831 | // for(Int_t i(0); i < _tempSwap.GetXaxis()->GetNbins(); i++) _tempSwap.SetBinError(1+i, TMath::Sqrt(_tempSwap.GetBinContent(1+i))); | |
832 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
833 | switch (fFitModulationType) { | |
834 | case kNoFit : { fFitModulation->FixParameter(0, fLocalRho->GetVal() ); | |
835 | } break; | |
836 | case kV2 : { | |
837 | fFitModulation->FixParameter(4, psi2); | |
838 | } break; | |
839 | case kV3 : { | |
840 | fFitModulation->FixParameter(4, psi3); | |
841 | } break; | |
842 | case kCombined : { | |
843 | fFitModulation->FixParameter(4, psi2); | |
844 | fFitModulation->FixParameter(6, psi3); | |
845 | } break; | |
846 | case kFourierSeries : { | |
847 | // in this approach, an explicit calculation will be made of vn = sqrt(xn^2+yn^2) | |
848 | // where x[y] = Integrate[r(phi)cos[sin](n phi)dphi, 0, 2pi] | |
849 | Double_t cos2(0), sin2(0), cos3(0), sin3(0), sumPt(0); | |
5ce0dc6d | 850 | for(Int_t i(0); i < iTracks; i++) { |
9239b066 | 851 | AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i)); |
852 | if(!PassesCuts(track) || track->Pt() > fSoftTrackMaxPt || track->Pt() < fSoftTrackMinPt) continue; | |
853 | sumPt += track->Pt(); | |
854 | cos2 += track->Pt()*TMath::Cos(2*PhaseShift(track->Phi()-psi2)); | |
855 | sin2 += track->Pt()*TMath::Sin(2*PhaseShift(track->Phi()-psi2)); | |
856 | cos3 += track->Pt()*TMath::Cos(3*PhaseShift(track->Phi()-psi3)); | |
857 | sin3 += track->Pt()*TMath::Sin(3*PhaseShift(track->Phi()-psi3)); | |
5ce0dc6d | 858 | } |
9239b066 | 859 | fFitModulation->SetParameter(3, TMath::Sqrt(cos2*cos2+sin2*sin2)/fLocalRho->GetVal()); |
860 | fFitModulation->SetParameter(4, psi2); | |
861 | fFitModulation->SetParameter(6, psi3); | |
862 | fFitModulation->SetParameter(7, TMath::Sqrt(cos3*cos3+sin3*sin3)/fLocalRho->GetVal()); | |
863 | } break; | |
864 | default : break; | |
865 | } | |
866 | _tempSwap.Fit(fFitModulation, fFitModulationOptions.Data(), "", 0, TMath::TwoPi()); | |
867 | // the quality of the fit is evaluated from 1 - the cdf of the chi square distribution | |
868 | Double_t CDF(1.-ChiSquareCDF(fFitModulation->GetNDF(), fFitModulation->GetChisquare())); | |
869 | if(fFillHistograms) fHistPvalueCDF->Fill(CDF); | |
870 | if(CDF > fMinPvalue && CDF < fMaxPvalue && ( fAbsVnHarmonics && fFitModulation->GetMinimum(0, TMath::TwoPi()) > 0)) { // fit quality | |
871 | // for LOCAL didactic purposes, save the best and the worst fits | |
872 | // this routine can produce a lot of output histograms (it's not memory 'safe') and will not work on GRID | |
873 | // since the output will become unmergeable (i.e. different nodes may produce conflicting output) | |
874 | switch (fRunModeType) { | |
875 | case kLocal : { | |
876 | if(gRandom->Uniform(0, 100) > fPercentageOfFits) break; | |
877 | static Int_t didacticCounterBest(0); | |
878 | TProfile* didacticProfile = (TProfile*)_tempSwap.Clone(Form("Fit_%i_1-CDF_%.3f_cen_%i_%s", didacticCounterBest, CDF, fInCentralitySelection, detector.Data())); | |
879 | TF1* didactifFit = (TF1*)fFitModulation->Clone(Form("fit_%i_CDF_%.3f_cen_%i_%s", didacticCounterBest, CDF, fInCentralitySelection, detector.Data())); | |
880 | didacticProfile->GetListOfFunctions()->Add(didactifFit); | |
881 | fOutputListGood->Add(didacticProfile); | |
882 | didacticCounterBest++; | |
883 | TH2F* didacticSurface = BookTH2F(Form("surface_%s", didacticProfile->GetName()), "#phi", "#eta", 50, 0, TMath::TwoPi(), 50, -1, 1, -1, kFALSE); | |
884 | for(Int_t i(0); i < iTracks; i++) { | |
885 | AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(i)); | |
886 | if(PassesCuts(track)) { | |
887 | if(fUsePtWeight) didacticSurface->Fill(track->Phi(), track->Eta(), track->Pt()); | |
888 | else didacticSurface->Fill(track->Phi(), track->Eta()); | |
889 | } | |
890 | } | |
891 | if(fExcludeLeadingJetsFromFit) { // visualize the excluded region | |
892 | 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); | |
893 | f2->SetParameters(excludeInPt/3.,excludeInPhi,.1,excludeInEta,.1); | |
894 | didacticSurface->GetListOfFunctions()->Add(f2); | |
895 | } | |
896 | fOutputListGood->Add(didacticSurface); | |
897 | } break; | |
898 | default : break; | |
5ce0dc6d | 899 | } |
9239b066 | 900 | } else { // if the fit is of poor quality revert to the original rho estimate |
901 | switch (fRunModeType) { // again see if we want to save the fit | |
902 | case kLocal : { | |
903 | static Int_t didacticCounterWorst(0); | |
904 | if(gRandom->Uniform(0, 100) > fPercentageOfFits) break; | |
905 | TProfile* didacticProfile = (TProfile*)_tempSwap.Clone(Form("Fit_%i_1-CDF_%.3f_cen_%i_%s", didacticCounterWorst, CDF, fInCentralitySelection, detector.Data() )); | |
906 | TF1* didactifFit = (TF1*)fFitModulation->Clone(Form("fit_%i_p_%.3f_cen_%i_%s", didacticCounterWorst, CDF, fInCentralitySelection, detector.Data())); | |
907 | didacticProfile->GetListOfFunctions()->Add(didactifFit); | |
908 | fOutputListBad->Add(didacticProfile); | |
909 | didacticCounterWorst++; | |
910 | } break; | |
911 | default : break; | |
5ce0dc6d | 912 | } |
9239b066 | 913 | switch (fFitModulationType) { |
914 | case kNoFit : break; // nothing to do | |
915 | case kCombined : fFitModulation->SetParameter(7, 0); // no break | |
916 | case kFourierSeries : fFitModulation->SetParameter(7, 0); // no break | |
917 | default : { // needs to be done if there was a poor fit | |
918 | fFitModulation->SetParameter(3, 0); | |
919 | fFitModulation->SetParameter(0, fLocalRho->GetVal()); | |
920 | } break; | |
921 | } | |
922 | return kFALSE; // return false if the fit is rejected | |
923 | } | |
924 | return kTRUE; | |
5ce0dc6d | 925 | } |
9239b066 | 926 | |
5ce0dc6d | 927 | //_____________________________________________________________________________ |
928 | void AliAnalysisTaskLocalRho::FillAnalysisSummaryHistogram() const | |
929 | { | |
9239b066 | 930 | // Fill the analysis summary histrogram, saves all relevant analysis settigns |
931 | ||
932 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
933 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(2, "fJetRadius"); | |
934 | fHistAnalysisSummary->SetBinContent(2, GetJetContainer()->GetJetRadius()); | |
935 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(3, "fJetEtaMin"); | |
936 | fHistAnalysisSummary->SetBinContent(3, GetJetContainer()->GetJetEtaMin()); | |
937 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(4, "fJetEtaMax"); | |
938 | fHistAnalysisSummary->SetBinContent(4, GetJetContainer()->GetJetEtaMax()); | |
939 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(5, "fJetPhiMin"); | |
940 | fHistAnalysisSummary->SetBinContent(5, GetJetContainer()->GetJetPhiMin()); | |
941 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(6, "fJetPhiMax"); | |
942 | fHistAnalysisSummary->SetBinContent(6, GetJetContainer()->GetJetPhiMin()); | |
943 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(34, "fitModulationType"); | |
944 | fHistAnalysisSummary->SetBinContent(34, (int)fFitModulationType); | |
945 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(35, "runModeType"); | |
946 | fHistAnalysisSummary->SetBinContent(35, (int)fRunModeType); | |
947 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(37, "iterator"); | |
948 | fHistAnalysisSummary->SetBinContent(37, 1.); | |
949 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(38, "fMinPvalue"); | |
950 | fHistAnalysisSummary->SetBinContent(38, fMinPvalue); | |
951 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(39, "fMaxPvalue"); | |
952 | fHistAnalysisSummary->SetBinContent(39, fMaxPvalue); | |
953 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(40, "fExcludeLeadingJetsFromFit"); | |
954 | fHistAnalysisSummary->SetBinContent(40, fExcludeLeadingJetsFromFit); | |
955 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(41, "fRebinSwapHistoOnTheFly"); | |
956 | fHistAnalysisSummary->SetBinContent(41, (int)fRebinSwapHistoOnTheFly); | |
957 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(42, "fUsePtWeight"); | |
958 | fHistAnalysisSummary->SetBinContent(42, (int)fUsePtWeight); | |
959 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(45, "fLocalJetMinEta"); | |
960 | fHistAnalysisSummary->SetBinContent(45,fLocalJetMinEta ); | |
961 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(46, "fLocalJetMaxEta"); | |
962 | fHistAnalysisSummary->SetBinContent(46, fLocalJetMaxEta); | |
963 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(47, "fLocalJetMinPhi"); | |
964 | fHistAnalysisSummary->SetBinContent(47, fLocalJetMinPhi); | |
965 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(48, "fLocalJetMaxPhi"); | |
966 | fHistAnalysisSummary->SetBinContent(48, fLocalJetMaxPhi); | |
967 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(49, "fSoftTrackMinPt"); | |
968 | fHistAnalysisSummary->SetBinContent(49, fSoftTrackMinPt); | |
969 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(50, "fSoftTrackMaxPt"); | |
970 | fHistAnalysisSummary->SetBinContent(50, fSoftTrackMaxPt); | |
971 | fHistAnalysisSummary->GetXaxis()->SetBinLabel(51, "fUseScaledRho"); | |
972 | fHistAnalysisSummary->SetBinContent(51, fUseScaledRho); | |
5ce0dc6d | 973 | } |
9239b066 | 974 | |
5ce0dc6d | 975 | //_____________________________________________________________________________ |
976 | void AliAnalysisTaskLocalRho::FillEventPlaneHistograms(Double_t psi2, Double_t psi3) const | |
977 | { | |
9239b066 | 978 | // Fill event plane histograms |
979 | ||
980 | if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__); | |
981 | fHistPsi2[fInCentralitySelection]->Fill(psi2); | |
982 | fHistPsi3[fInCentralitySelection]->Fill(psi3); | |
5ce0dc6d | 983 | } |
9239b066 | 984 | |
5ce0dc6d | 985 | //_____________________________________________________________________________ |
986 | void AliAnalysisTaskLocalRho::Terminate(Option_t *) | |
987 | { | |
9239b066 | 988 | // Terminate |
5ce0dc6d | 989 | } |
9239b066 | 990 | |
5ce0dc6d | 991 | //_____________________________________________________________________________ |
9239b066 | 992 | void AliAnalysisTaskLocalRho::SetModulationFit(TF1* fit) |
993 | { | |
994 | // Set function to fit modulation | |
995 | ||
996 | if (fFitModulation) delete fFitModulation; | |
997 | fFitModulation = fit; | |
0004064b | 998 | } |