]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnAnalysisME.cxx
add possibility to smear cluster energy, only for MC, some stetic changes in header...
[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   AliRsnEvent::SetCurrentEvent1(&fEvent);
145   AliRsnEvent::SetCurrentEvent2(&fEventMix);
146
147   fRsnAnalysisManager.ProcessAllPairs();
148   PostData(2, fOutList);
149
150   AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod1->GetNumberOfTracks()));
151   AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod2->GetNumberOfTracks()));
152
153 }
154
155
156 //_____________________________________________________________________________
157 void AliRsnAnalysisME::DoESDMixing(AliESDEvent* esd1, AliESDEvent* esd2)
158 {
159 //
160 // mixing of two esd events
161 //
162
163   AliWarning(Form("ESD mixing not supported yet !!! (%p,%p)", esd1, esd2));
164   return;
165 }
166
167
168
169 //_____________________________________________________________________________
170 void AliRsnAnalysisME::RsnTerminate(Option_t*)
171 {
172 //
173 // Rsn Terminate
174 //
175
176   AliDebug(AliLog::kDebug+2, "<-");
177   AliDebug(AliLog::kDebug+2,"->");
178 }
179
180 //_____________________________________________________________________________
181 void AliRsnAnalysisME::SetPriorProbability(AliPID::EParticleType type, Double_t p)
182 {
183 //
184 // Sets the prior probability for Realistic PID, for a
185 // given particle species.
186 //
187
188   if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
189     fPrior[type] = p;
190   }
191
192 }
193
194 //_____________________________________________________________________________
195 void AliRsnAnalysisME::DumpPriors()
196 {
197   //
198   // Print all prior probabilities
199   //
200
201   Int_t i;
202   for (i = 0; i < AliPID::kSPECIES; i++) {
203     AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
204   }
205 }
206
207 //_____________________________________________________________________________
208 void AliRsnAnalysisME::GetPriorProbability(Double_t *out) const
209 {
210 //
211 // Gets all prior probabilities to out
212 //
213
214   Int_t i;
215   for (i = 0;i < AliPID::kSPECIES;i++) {
216     out[i] = fPrior[i];
217   }
218 }
219
220