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