2 // Class AliRsnAnalysisME
5 // Virtual Class derivated from AliRsnVAnalysisTaskME which will be base class
6 // for all RSN SE tasks
8 // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9 // Martin Vala (martin.vala@cern.ch)
12 #include "AliESDEvent.h"
13 #include "AliMCEvent.h"
14 #include "AliAODEvent.h"
15 #include "AliMultiEventInputHandler.h"
16 #include "AliRsnAnalysisME.h"
18 ClassImp(AliRsnAnalysisME)
20 //_____________________________________________________________________________
21 AliRsnAnalysisME::AliRsnAnalysisME(const char *name, Int_t numOfOutputs) :
22 AliRsnVAnalysisTaskME(name, numOfOutputs),
23 fRsnAnalysisManager(),
30 // Default constructor
32 AliDebug(AliLog::kDebug+2, "<-");
34 for (i = 0;i < fNumberOfOutputs;i++) {
35 DefineOutput(i + 2, TList::Class());
37 AliDebug(AliLog::kDebug+2,"->");
40 AliRsnAnalysisME::AliRsnAnalysisME(const AliRsnAnalysisME& copy) : AliRsnVAnalysisTaskME(copy),
41 fRsnAnalysisManager(copy.fRsnAnalysisManager),
42 fPIDIndex(copy.fPIDIndex),
43 fPIDIndexMix(copy.fPIDIndexMix),
45 fEventMix(copy.fEvent)
47 AliDebug(AliLog::kDebug+2, "<-");
48 AliDebug(AliLog::kDebug+2,"->");
51 //_____________________________________________________________________________
52 void AliRsnAnalysisME::RsnUserCreateOutputObjects()
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.
61 AliDebug(AliLog::kDebug+2, "<-");
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();
70 for (i = 0; i < fNumberOfOutputs; i++) {
71 fRsnAnalysisManager[i].InitAllPairMgrs(fOutList[i+1]);
74 AliDebug(AliLog::kDebug+2,"->");
77 void AliRsnAnalysisME::RsnUserExec(Option_t*)
83 fTaskInfo.SetEventUsed(kFALSE);
85 AliDebug(AliLog::kDebug+2, "<-");
86 if (!CheckAndPrintEvents()) return;
88 DoMixing(GetEvent(0));
91 // if cuts are passed or not cuts were defined,
92 // update the task info...
93 fTaskInfo.SetEventUsed(kTRUE);
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]);
102 AliDebug(AliLog::kDebug+2,"->");
106 //_____________________________________________________________________________
107 void AliRsnAnalysisME::DoMixing(AliVEvent* ev)
113 Int_t nEvents = fInputHandler->GetBufferSize();
114 fESDEvent = dynamic_cast<AliESDEvent*>(ev);
115 fAODEvent = dynamic_cast<AliAODEvent*>(ev);
118 AliESDEvent **esdEvent = new AliESDEvent*[nEvents];
119 for (Int_t i = 0; i < nEvents; i++) {
120 esdEvent[i] = dynamic_cast<AliESDEvent*>(GetEvent(i));
122 AliWarning(Form("Null ESD event in index %d", i));
126 DoESDMixing(esdEvent[0], esdEvent[i]);
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));
133 AliWarning(Form("Null AOD event in index %d", i));
137 DoAODMixing(aodEvent[0], aodEvent[i]);
144 //_____________________________________________________________________________
145 void AliRsnAnalysisME::DoAODMixing(AliAODEvent* aod1, AliAODEvent* aod2)
148 // mixing of two aod events
153 fEventMix.SetRef(aod2);
154 if (fEvent.GetMultiplicity() < 2) return;
155 if (fEventMix.GetMultiplicity() < 2) return;
157 // sort tracks w.r. to PID
158 fPIDIndex.ResetAll(fEvent.GetMultiplicity());
159 fEvent.SetPriorProbability(fPrior);
160 fPIDIndex.FillFromEvent(&fEvent);
161 fPIDIndex.SetCorrectIndexSize();
163 fPIDIndexMix.ResetAll(fEventMix.GetMultiplicity());
164 fEventMix.SetPriorProbability(fPrior);
165 fPIDIndexMix.FillFromEvent(&fEventMix);
166 fPIDIndexMix.SetCorrectIndexSize();
168 for (Int_t i = 0; i < fNumberOfOutputs; i++) {
169 fRsnAnalysisManager[i].ProcessAllPairMgrs(&fPIDIndex, &fEvent, &fPIDIndexMix, &fEventMix);
170 PostData(i + 2, fOutList[i+1]);
172 AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod1->GetNumberOfTracks()));
173 AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod2->GetNumberOfTracks()));
178 //_____________________________________________________________________________
179 void AliRsnAnalysisME::DoESDMixing(AliESDEvent* esd1, AliESDEvent* esd2)
182 // mixing of two esd events
185 AliWarning(Form("ESD mixing not supported yet !!! (%p,%p)", esd1, esd2));
191 //_____________________________________________________________________________
192 void AliRsnAnalysisME::RsnTerminate(Option_t*)
198 AliDebug(AliLog::kDebug+2, "<-");
199 AliDebug(AliLog::kDebug+2,"->");
202 //_____________________________________________________________________________
203 AliRsnAnalysisManager* AliRsnAnalysisME::GetAnalysisManager(Int_t index, TString name)
206 // Recovery the analysis manager
209 if (!name.IsNull()) {
210 SetAnalysisManagerName(name.Data(), index);
213 return &fRsnAnalysisManager[index];
217 //_____________________________________________________________________________
218 void AliRsnAnalysisME::SetPriorProbability(AliPID::EParticleType type, Double_t p)
221 // Sets the prior probability for Realistic PID, for a
222 // given particle species.
225 if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
231 //_____________________________________________________________________________
232 void AliRsnAnalysisME::DumpPriors()
235 // Print all prior probabilities
239 for (i = 0; i < AliPID::kSPECIES; i++) {
240 AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
244 //_____________________________________________________________________________
245 void AliRsnAnalysisME::GetPriorProbability(Double_t *out) const
248 // Gets all prior probabilities to out
252 for (i = 0;i < AliPID::kSPECIES;i++) {