]>
Commit | Line | Data |
---|---|---|
3074a323 | 1 | // $Id$ |
2 | // | |
3 | // Base class for rho calculation | |
4 | // | |
1b3d7f8f | 5 | // Author: S.Aiola |
3074a323 | 6 | |
7 | #include <TF1.h> | |
8 | ||
3074a323 | 9 | #include "AliAnalysisManager.h" |
3074a323 | 10 | #include "AliCentrality.h" |
1b3d7f8f | 11 | #include "AliESDEvent.h" |
3074a323 | 12 | #include "AliEmcalJet.h" |
1b3d7f8f | 13 | #include "AliLog.h" |
14 | #include "AliRhoParameter.h" | |
3074a323 | 15 | #include "AliVCluster.h" |
1b3d7f8f | 16 | #include "AliVEventHandler.h" |
3074a323 | 17 | |
18 | #include "AliAnalysisTaskRhoBase.h" | |
19 | ||
20 | ClassImp(AliAnalysisTaskRhoBase) | |
21 | ||
22 | //________________________________________________________________________ | |
23 | AliAnalysisTaskRhoBase::AliAnalysisTaskRhoBase() : | |
24 | AliAnalysisTaskSE(), | |
25 | fRhoName("Rho"), | |
26 | fRhoFunction(0x0), | |
27 | fCent(-1), | |
28 | fRho(0) | |
29 | { | |
30 | // Constructor. | |
31 | } | |
32 | ||
33 | //________________________________________________________________________ | |
34 | AliAnalysisTaskRhoBase::AliAnalysisTaskRhoBase(const char *name) : | |
35 | AliAnalysisTaskSE(name), | |
36 | fRhoName("Rho"), | |
37 | fRhoFunction(0x0), | |
38 | fCent(-1), | |
39 | fRho(0) | |
40 | { | |
41 | // Constructor. | |
42 | } | |
43 | ||
44 | //________________________________________________________________________ | |
45 | void AliAnalysisTaskRhoBase::UserCreateOutputObjects() | |
46 | { | |
47 | // Run at beginning of task. | |
48 | ||
49 | AliVEventHandler* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler(); | |
50 | if (!handler) { | |
51 | AliError("Input handler not available!"); | |
52 | return; | |
53 | } | |
54 | ||
1b3d7f8f | 55 | fRho = new AliRhoParameter(fRhoName, 0); |
3074a323 | 56 | } |
57 | ||
58 | //________________________________________________________________________ | |
59 | Double_t AliAnalysisTaskRhoBase::GetRhoFactor(Double_t cent) | |
60 | { | |
61 | // Return rho per centrality. | |
62 | ||
63 | Double_t rho = -1; | |
64 | if (fRhoFunction) | |
65 | rho = fRhoFunction->Eval(cent); | |
66 | return rho; | |
67 | } | |
68 | ||
0627844d | 69 | //_____________________________________________________ |
70 | TString AliAnalysisTaskRhoBase::GetBeamType() | |
71 | { | |
72 | // Get beam type : pp-AA-pA | |
73 | // ESDs have it directly, AODs get it from hardcoded run number ranges | |
74 | ||
75 | AliVEvent *event = InputEvent(); | |
76 | ||
77 | if (!event) { | |
78 | AliError("Couldn't retrieve event!"); | |
79 | return ""; | |
80 | } | |
81 | ||
82 | TString beamType; | |
83 | ||
84 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event); | |
85 | if (esd) { | |
86 | const AliESDRun *run = esd->GetESDRun(); | |
87 | beamType = run->GetBeamType(); | |
88 | } | |
89 | else | |
90 | { | |
91 | Int_t runNumber = event->GetRunNumber(); | |
92 | if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h | |
93 | (runNumber >= 166529 && runNumber <= 170593)) // LHC11h | |
94 | { | |
95 | beamType = "A-A"; | |
96 | } | |
97 | else | |
98 | { | |
99 | beamType = "p-p"; | |
100 | } | |
101 | } | |
102 | ||
103 | return beamType; | |
104 | } | |
105 | ||
3074a323 | 106 | //________________________________________________________________________ |
107 | void AliAnalysisTaskRhoBase::UserExec(Option_t *) | |
108 | { | |
109 | // Main loop, called for each event. | |
110 | ||
111 | // add rho to event if not yet there | |
112 | if (!(InputEvent()->FindListObject(fRhoName))) { | |
3074a323 | 113 | InputEvent()->AddObject(fRho); |
114 | } | |
115 | ||
1b3d7f8f | 116 | // determine centrality |
0627844d | 117 | fCent = 99; |
118 | ||
119 | if (GetBeamType() == "A-A") { | |
120 | AliCentrality *centrality = InputEvent()->GetCentrality(); | |
121 | ||
122 | if (centrality) | |
123 | fCent = centrality->GetCentralityPercentile("V0M"); | |
124 | else | |
125 | fCent = 99; // probably pp data | |
126 | ||
127 | if (fCent < 0) { | |
128 | AliWarning(Form("Centrality negative: %f, assuming 99", fCent)); | |
129 | fCent = 99; | |
130 | } | |
3074a323 | 131 | } |
132 | ||
133 | Double_t rhochem = GetRhoFactor(fCent); | |
134 | fRho->SetVal(rhochem); | |
135 | } | |
136 | ||
137 | //________________________________________________________________________ | |
138 | void AliAnalysisTaskRhoBase::Terminate(Option_t *) | |
139 | { | |
140 | // Run at the end of the task. | |
141 | } |