]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisME.cxx
fix for bug #70582 (change from L. Molnar)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisME.cxx
CommitLineData
5eb970a4 1//
2// Class AliRsnAnalysisME
3//
9477aa42 4//
5// Virtual Class derivated from AliRsnVAnalysisTaskME which will be base class
6// for all RSN SE tasks
5eb970a4 7//
8// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9// Martin Vala (martin.vala@cern.ch)
10//
11
4fbb2459 12#include "AliESDEvent.h"
13#include "AliMCEvent.h"
14#include "AliAODEvent.h"
9477aa42 15#include "AliMultiEventInputHandler.h"
5eb970a4 16#include "AliRsnAnalysisME.h"
17
18ClassImp(AliRsnAnalysisME)
19
20//_____________________________________________________________________________
9477aa42 21AliRsnAnalysisME::AliRsnAnalysisME(const char *name, Int_t numOfOutputs) :
22 AliRsnVAnalysisTaskME(name, numOfOutputs),
e79f56bd 23 fRsnAnalysisManager(),
24 fPIDIndex(0),
25 fPIDIndexMix(0),
26 fEvent(),
4fbb2459 27 fEventMix()
5eb970a4 28{
29//
30// Default constructor
31//
9477aa42 32 AliDebug(AliLog::kDebug+2, "<-");
33 Int_t i = 0;
34 for (i = 0;i < fNumberOfOutputs;i++) {
35 DefineOutput(i + 2, TList::Class());
36 }
5eb970a4 37 AliDebug(AliLog::kDebug+2,"->");
38}
39
40AliRsnAnalysisME::AliRsnAnalysisME(const AliRsnAnalysisME& copy) : AliRsnVAnalysisTaskME(copy),
e79f56bd 41 fRsnAnalysisManager(copy.fRsnAnalysisManager),
42 fPIDIndex(copy.fPIDIndex),
43 fPIDIndexMix(copy.fPIDIndexMix),
44 fEvent(copy.fEvent),
4fbb2459 45 fEventMix(copy.fEvent)
5eb970a4 46{
9477aa42 47 AliDebug(AliLog::kDebug+2, "<-");
5eb970a4 48 AliDebug(AliLog::kDebug+2,"->");
49}
50
51//_____________________________________________________________________________
52void AliRsnAnalysisME::RsnUserCreateOutputObjects()
53{
4fbb2459 54//
9477aa42 55// Creation of output objects.
56// These are created through the utility methods in the analysis manager,
57// which produces a list of histograms for each specified set of pairs.
58// Each of these lists is added to the main list of this task.
4fbb2459 59//
5eb970a4 60
9477aa42 61 AliDebug(AliLog::kDebug+2, "<-");
5eb970a4 62
9477aa42 63 Int_t i;
64 for (i = 1; i < kMaxNumberOfOutputs + 1; i++) {
65 if (i <= fNumberOfOutputs + 1) OpenFile(i/* + 1*/);
66 fOutList[i] = new TList();
67 fOutList[i]->SetOwner();
68 }
5eb970a4 69
9477aa42 70 for (i = 0; i < fNumberOfOutputs; i++) {
71 fRsnAnalysisManager[i].InitAllPairMgrs(fOutList[i+1]);
72 }
5eb970a4 73
74 AliDebug(AliLog::kDebug+2,"->");
75}
76
4fbb2459 77void AliRsnAnalysisME::RsnUserExec(Option_t*)
5eb970a4 78{
4fbb2459 79//
9477aa42 80// Rsn User Exec
4fbb2459 81//
82
9477aa42 83 fTaskInfo.SetEventUsed(kFALSE);
84
85 AliDebug(AliLog::kDebug+2, "<-");
86 if (!CheckAndPrintEvents()) return;
87
88 DoMixing(GetEvent(0));
89
90
91 // if cuts are passed or not cuts were defined,
92 // update the task info...
93 fTaskInfo.SetEventUsed(kTRUE);
94
95 // the virtual class has already sorted tracks in the PID index
96 // so we need here just to call the execution of analysis
97 for (Int_t i = 0; i < fNumberOfOutputs; i++) {
98// fRsnAnalysisManager[i].ProcessAllPairMgrs(&fRsnPIDIndex, &fRsnEvent);
99 PostData(i + 2, fOutList[i+1]);
5eb970a4 100 }
9477aa42 101
102 AliDebug(AliLog::kDebug+2,"->");
103}
104
105
106//_____________________________________________________________________________
107void AliRsnAnalysisME::DoMixing(AliVEvent* ev)
108{
109//
110// Do Mixing
111//
112
113 Int_t nEvents = fInputHandler->GetBufferSize();
114 fESDEvent = dynamic_cast<AliESDEvent*>(ev);
115 fAODEvent = dynamic_cast<AliAODEvent*>(ev);
116
117 if (fESDEvent) {
118 AliESDEvent **esdEvent = new AliESDEvent*[nEvents];
119 for (Int_t i = 0; i < nEvents; i++) {
120 esdEvent[i] = dynamic_cast<AliESDEvent*>(GetEvent(i));
121 if (!esdEvent[i]) {
122 AliWarning(Form("Null ESD event in index %d", i));
123 continue;
124 }
125 if (i > 0)
126 DoESDMixing(esdEvent[0], esdEvent[i]);
127 }
9477aa42 128 } else if (fAODEvent) {
129 AliAODEvent **aodEvent = new AliAODEvent*[nEvents];
130 for (Int_t i = 0; i < nEvents; i++) {
131 aodEvent[i] = dynamic_cast<AliAODEvent*>(GetEvent(i));
132 if (!aodEvent[i]) {
133 AliWarning(Form("Null AOD event in index %d", i));
134 continue;
135 }
136 if (i > 0)
137 DoAODMixing(aodEvent[0], aodEvent[i]);
138 }
5eb970a4 139 }
140
9477aa42 141}
142
143
144//_____________________________________________________________________________
145void AliRsnAnalysisME::DoAODMixing(AliAODEvent* aod1, AliAODEvent* aod2)
146{
147//
148// mixing of two aod events
149//
5eb970a4 150
151 // assign events
152 fEvent.SetRef(aod1);
153 fEventMix.SetRef(aod2);
154 if (fEvent.GetMultiplicity() < 2) return;
155 if (fEventMix.GetMultiplicity() < 2) return;
156
157 // sort tracks w.r. to PID
158 fPIDIndex.ResetAll(fEvent.GetMultiplicity());
4fbb2459 159 fEvent.SetPriorProbability(fPrior);
160 fPIDIndex.FillFromEvent(&fEvent);
5eb970a4 161 fPIDIndex.SetCorrectIndexSize();
162
163 fPIDIndexMix.ResetAll(fEventMix.GetMultiplicity());
4fbb2459 164 fEventMix.SetPriorProbability(fPrior);
165 fPIDIndexMix.FillFromEvent(&fEventMix);
5eb970a4 166 fPIDIndexMix.SetCorrectIndexSize();
167
9477aa42 168 for (Int_t i = 0; i < fNumberOfOutputs; i++) {
169 fRsnAnalysisManager[i].ProcessAllPairMgrs(&fPIDIndex, &fEvent, &fPIDIndexMix, &fEventMix);
170 PostData(i + 2, fOutList[i+1]);
171 }
172 AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod1->GetNumberOfTracks()));
173 AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod2->GetNumberOfTracks()));
5eb970a4 174
5eb970a4 175}
176
177
9477aa42 178//_____________________________________________________________________________
179void AliRsnAnalysisME::DoESDMixing(AliESDEvent* esd1, AliESDEvent* esd2)
180{
181//
182// mixing of two esd events
183//
184
185 AliWarning(Form("ESD mixing not supported yet !!! (%p,%p)", esd1, esd2));
186 return;
187}
188
189
190
5eb970a4 191//_____________________________________________________________________________
4fbb2459 192void AliRsnAnalysisME::RsnTerminate(Option_t*)
5eb970a4 193{
4fbb2459 194//
9477aa42 195// Rsn Terminate
4fbb2459 196//
197
9477aa42 198 AliDebug(AliLog::kDebug+2, "<-");
5eb970a4 199 AliDebug(AliLog::kDebug+2,"->");
200}
201
4fbb2459 202//_____________________________________________________________________________
9477aa42 203AliRsnAnalysisManager* AliRsnAnalysisME::GetAnalysisManager(Int_t index, TString name)
5eb970a4 204{
4fbb2459 205//
9477aa42 206// Recovery the analysis manager
4fbb2459 207//
208
5eb970a4 209 if (!name.IsNull()) {
9477aa42 210 SetAnalysisManagerName(name.Data(), index);
5eb970a4 211 }
9477aa42 212
213 return &fRsnAnalysisManager[index];
5eb970a4 214}
215
9477aa42 216
5eb970a4 217//_____________________________________________________________________________
218void AliRsnAnalysisME::SetPriorProbability(AliPID::EParticleType type, Double_t p)
219{
9477aa42 220//
221// Sets the prior probability for Realistic PID, for a
222// given particle species.
223//
5eb970a4 224
225 if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
226 fPrior[type] = p;
227 }
228
229}
230
231//_____________________________________________________________________________
232void AliRsnAnalysisME::DumpPriors()
233{
234 //
235 // Print all prior probabilities
236 //
237
238 Int_t i;
239 for (i = 0; i < AliPID::kSPECIES; i++) {
240 AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
241 }
242}
243
244//_____________________________________________________________________________
4fbb2459 245void AliRsnAnalysisME::GetPriorProbability(Double_t *out) const
5eb970a4 246{
4fbb2459 247//
248// Gets all prior probabilities to out
249//
5eb970a4 250
251 Int_t i;
9477aa42 252 for (i = 0;i < AliPID::kSPECIES;i++) {
5eb970a4 253 out[i] = fPrior[i];
254 }
255}