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