]>
Commit | Line | Data |
---|---|---|
5eb970a4 | 1 | // |
2 | // Class AliRsnAnalysisManager | |
3 | // | |
4 | // This is the uppermost level of analysis objects collection. | |
5 | // It contains a list of pair managers, which all will process | |
6 | // a pool of events passed to this object, and fill their histograms. | |
7 | // | |
8 | // The utility of this object is to define a unique implementation | |
9 | // of the whole processing, which can then be included in the different | |
10 | // designs of AnalysisTask provided for SE and ME analysis. | |
11 | // | |
12 | // The base architecture is still AliRsnVManager, but in this case | |
13 | // all the objects in the list will be AliRsnPairManager's. | |
14 | // | |
15 | // author : M. Vala [martin.vala@cern.ch] | |
16 | // revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it] | |
17 | // | |
18 | ||
28399a41 | 19 | #include <TH1.h> |
4fbb2459 | 20 | #include <TROOT.h> |
5eb970a4 | 21 | |
4fbb2459 | 22 | #include "AliLog.h" |
3c07ce75 | 23 | #include "AliStack.h" |
2dab9030 | 24 | #include "AliVEvent.h" |
2e521c29 | 25 | #include "AliMCEvent.h" |
4fbb2459 | 26 | #include "AliRsnEvent.h" |
32992791 | 27 | #include "AliRsnPairFunctions.h" |
28 | #include "AliRsnPairNtuple.h" | |
5eb970a4 | 29 | #include "AliRsnAnalysisManager.h" |
30 | ||
4fbb2459 | 31 | |
5eb970a4 | 32 | ClassImp(AliRsnAnalysisManager) |
33 | ||
34 | //_____________________________________________________________________________ | |
35 | AliRsnAnalysisManager::AliRsnAnalysisManager(const char*name) : | |
2dab9030 | 36 | TNamed(name, ""), |
28399a41 | 37 | fList(0x0), |
32992791 | 38 | fPairs(0), |
39 | fGlobalTrackCuts() | |
5eb970a4 | 40 | { |
41 | // | |
42 | // Default constructor | |
43 | // | |
5eb970a4 | 44 | } |
45 | ||
28399a41 | 46 | //_____________________________________________________________________________ |
47 | AliRsnAnalysisManager::AliRsnAnalysisManager(const AliRsnAnalysisManager& copy) : | |
48 | TNamed(copy), | |
49 | fList(copy.fList), | |
50 | fPairs(copy.fPairs), | |
51 | fGlobalTrackCuts(copy.fGlobalTrackCuts) | |
52 | { | |
53 | // | |
54 | // Copy constructor | |
55 | // | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliRsnAnalysisManager& AliRsnAnalysisManager::operator=(const AliRsnAnalysisManager& copy) | |
60 | { | |
61 | // | |
62 | // Assignment operator | |
63 | // | |
64 | ||
65 | TNamed::operator=(copy); | |
66 | ||
67 | fList = copy.fList; | |
68 | fPairs = copy.fPairs; | |
69 | fGlobalTrackCuts = copy.fGlobalTrackCuts; | |
70 | ||
71 | return (*this); | |
72 | } | |
73 | ||
5eb970a4 | 74 | //_____________________________________________________________________________ |
2dab9030 | 75 | void AliRsnAnalysisManager::Add(AliRsnPair *pair) |
5eb970a4 | 76 | { |
77 | // | |
78 | // Adds a new pair manager to the list. | |
79 | // | |
80 | ||
81 | AliDebug(AliLog::kDebug+2,"<-"); | |
82 | ||
32992791 | 83 | if (!pair) |
84 | { | |
5eb970a4 | 85 | AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair)); |
86 | return; | |
87 | } | |
88 | ||
2dab9030 | 89 | AliDebug(AliLog::kDebug+1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries())); |
32992791 | 90 | fPairs.Add(pair); |
5eb970a4 | 91 | |
92 | AliDebug(AliLog::kDebug+2,"->"); | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const | |
97 | { | |
98 | // | |
99 | // Overload of the TObject::Print() method | |
100 | // | |
101 | ||
102 | AliInfo(Form("\t======== Analysis Manager %s ========", GetName())); | |
103 | PrintArray(); | |
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | void AliRsnAnalysisManager::PrintArray() const | |
108 | { | |
109 | // | |
110 | // Calls the "Print" method of all included pair managers | |
111 | // | |
112 | ||
113 | AliDebug(AliLog::kDebug+2,"<-"); | |
114 | ||
2dab9030 | 115 | AliRsnPair *pair = 0; |
116 | TObjArrayIter next(&fPairs); | |
117 | while ((pair = (AliRsnPair*)next())) pair->Print(); | |
5eb970a4 | 118 | |
119 | AliDebug(AliLog::kDebug+2,"->"); | |
120 | } | |
121 | ||
122 | //_____________________________________________________________________________ | |
2dab9030 | 123 | void AliRsnAnalysisManager::InitAllPairs(TList *list) |
5eb970a4 | 124 | { |
125 | // | |
126 | // Initialize all pair managers, and put all the TList of histograms | |
127 | // generated by each one into a unique final output TList | |
128 | // | |
129 | ||
130 | AliDebug(AliLog::kDebug+2,"<-"); | |
131 | ||
2dab9030 | 132 | AliRsnPair *pair = 0; |
133 | TObjArrayIter next(&fPairs); | |
5eb970a4 | 134 | Int_t i = 0; |
2dab9030 | 135 | while ((pair = (AliRsnPair*)next())) |
136 | { | |
137 | if (!pair) continue; | |
138 | AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++)); | |
139 | pair->Init("", list); | |
28399a41 | 140 | |
141 | // add a counter for used/unused events for each pair | |
142 | TH1I *hPairUsed = new TH1I(Form("_%s_USED", pair->GetName()), "Used events for pair", 2, 0, 2); | |
143 | list->Add(hPairUsed); | |
5eb970a4 | 144 | } |
5faf5a07 | 145 | |
28399a41 | 146 | fList = list; |
5faf5a07 | 147 | |
148 | AliDebug(AliLog::kDebug+2, "->"); | |
5eb970a4 | 149 | } |
150 | ||
151 | //_____________________________________________________________________________ | |
5faf5a07 | 152 | void AliRsnAnalysisManager::ProcessAllPairs() |
5eb970a4 | 153 | { |
154 | // | |
155 | // Process one or two events for all pair managers. | |
156 | // | |
157 | ||
5faf5a07 | 158 | static Int_t evnum = 0; |
159 | evnum++; | |
160 | ||
5eb970a4 | 161 | AliDebug(AliLog::kDebug+2,"<-"); |
2dab9030 | 162 | |
5faf5a07 | 163 | // skip if the global event pointers are NULL |
164 | if (!AliRsnEvent::IsCurrentEvent1()) return; | |
165 | if (!AliRsnEvent::IsCurrentEvent2()) return; | |
2dab9030 | 166 | |
5faf5a07 | 167 | // for better readability, reference two pointers to the current events |
168 | AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1(); | |
169 | AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2(); | |
170 | ||
171 | // count total number of candidates per event | |
172 | // (sum of tracks, V0s and cascades) | |
32992791 | 173 | Int_t nTot[2]; |
5faf5a07 | 174 | nTot[0] = AliRsnEvent::GetCurrentEvent1()->GetAbsoluteSum(); |
175 | nTot[1] = AliRsnEvent::GetCurrentEvent2()->GetAbsoluteSum(); | |
2dab9030 | 176 | |
5faf5a07 | 177 | // variables |
178 | Int_t i0, i1, i, start, index0, index1; | |
2dab9030 | 179 | AliRsnDaughter daughter0, daughter1; |
180 | AliRsnPair *pair = 0x0; | |
181 | TObjArrayIter next(&fPairs); | |
5faf5a07 | 182 | AliRsnDaughter::ERefType type0, type1; |
2dab9030 | 183 | |
5faf5a07 | 184 | // reset all counters which tell us |
185 | // how many entries were added now | |
28399a41 | 186 | while ((pair = (AliRsnPair*)next())) |
187 | { | |
188 | pair->ResetCount(); | |
189 | } | |
190 | ||
5faf5a07 | 191 | // external loop |
2dab9030 | 192 | for (i0 = 0; i0 < nTot[0]; i0++) |
193 | { | |
194 | // assign first track | |
5faf5a07 | 195 | if (!ev0->ConvertAbsoluteIndex(i0, index0, type0)) continue; |
196 | ev0->SetDaughter(daughter0, index0, type0); | |
32992791 | 197 | |
198 | // check global cuts | |
199 | if (!fGlobalTrackCuts.IsSelected(&daughter0)) continue; | |
5faf5a07 | 200 | |
201 | // define start depending if we are processing one or two events | |
202 | start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0); | |
2dab9030 | 203 | |
204 | // internal loop (same criterion) | |
5faf5a07 | 205 | for (i1 = start; i1 < nTot[1]; i1++) |
2dab9030 | 206 | { |
207 | // if looking same event, skip the case when the two indexes are equal | |
5faf5a07 | 208 | // if (AliRsnEvent::SameEvent() && i0 == i1) continue; |
2dab9030 | 209 | |
210 | // assign second track | |
5faf5a07 | 211 | if (!ev1->ConvertAbsoluteIndex(i1, index1, type1)) continue; |
212 | ev1->SetDaughter(daughter1, index1, type1); | |
32992791 | 213 | |
214 | // check global cuts | |
215 | if (!fGlobalTrackCuts.IsSelected(&daughter1)) continue; | |
2dab9030 | 216 | |
217 | // loop over all pairs and make computations | |
218 | next.Reset(); | |
219 | i = 0; | |
220 | while ((pair = (AliRsnPair*)next())) | |
221 | { | |
222 | AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++)); | |
223 | ||
224 | // if the pair is a like-sign, skip the case when i1 < i0, | |
225 | // in order not to double count each like-sign pair | |
226 | // (equivalent to looping from i0+1 to ntracks) | |
5faf5a07 | 227 | // if (AliRsnEvent::SameEvent() && pair->GetPairDef()->IsLikeSign() && i1 < i0) continue; |
2dab9030 | 228 | |
229 | // process the two tracks | |
5faf5a07 | 230 | if (pair->Fill(&daughter0, &daughter1)) |
231 | { | |
232 | pair->Compute(); | |
233 | } | |
234 | else if (pair->Fill(&daughter1, &daughter0)) | |
235 | { | |
236 | pair->Compute(); | |
237 | } | |
2dab9030 | 238 | } |
239 | } | |
5eb970a4 | 240 | } |
28399a41 | 241 | |
242 | // update all count histograms counters | |
243 | next.Reset(); | |
244 | if (!fList) return; | |
245 | while ((pair = (AliRsnPair*)next())) | |
246 | { | |
247 | TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName())); | |
248 | if (!hist) continue; | |
249 | if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0); | |
250 | } | |
5eb970a4 | 251 | |
252 | AliDebug(AliLog::kDebug+2,"->"); | |
253 | } | |
2e521c29 | 254 | |
255 | //_____________________________________________________________________________ | |
5faf5a07 | 256 | void AliRsnAnalysisManager::ProcessAllPairsMC() |
2e521c29 | 257 | { |
258 | // | |
259 | // Process one or two events for all pair managers. | |
260 | // | |
261 | ||
262 | AliDebug(AliLog::kDebug+2,"<-"); | |
263 | ||
5faf5a07 | 264 | // skip if the global event pointers are NULL |
265 | if (!AliRsnEvent::IsCurrentEvent1()) return; | |
266 | if (!AliRsnEvent::IsCurrentEvent2()) return; | |
2e521c29 | 267 | |
5faf5a07 | 268 | // for better readability, reference two pointers to the current events |
269 | AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1(); | |
270 | AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2(); | |
271 | ||
272 | // this time the number of tracks comes from MC | |
2e521c29 | 273 | Int_t nTracks[2]; |
274 | nTracks[0] = ev0->GetRefMC()->GetNumberOfTracks(); | |
275 | nTracks[1] = ev1->GetRefMC()->GetNumberOfTracks(); | |
276 | ||
277 | // external loop | |
278 | // joins the loop on tracks and v0s, by looping the indexes from 0 | |
279 | // to the sum of them, and checking what to take depending of its value | |
5faf5a07 | 280 | Int_t i0, i1, start, i; |
10a049e7 | 281 | Bool_t filled; |
2e521c29 | 282 | AliRsnDaughter daughter0, daughter1; |
283 | AliRsnPair *pair = 0x0; | |
284 | TObjArrayIter next(&fPairs); | |
285 | ||
28399a41 | 286 | // reset all counters |
287 | while ((pair = (AliRsnPair*)next())) | |
288 | { | |
289 | pair->ResetCount(); | |
290 | } | |
291 | ||
2e521c29 | 292 | for (i0 = 0; i0 < nTracks[0]; i0++) |
293 | { | |
3c07ce75 | 294 | // skip not physical primaries |
a378358c | 295 | if (!ev0->GetRefMCESD()->Stack()->IsPhysicalPrimary(i0)) continue; |
3c07ce75 | 296 | |
2e521c29 | 297 | // assign first track |
10a049e7 | 298 | ev0->SetDaughterMC(daughter0, i0); |
5faf5a07 | 299 | |
300 | // define start depending if we are processing one or two events | |
301 | start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0); | |
2e521c29 | 302 | |
303 | // internal loop (same criterion) | |
5faf5a07 | 304 | for (i1 = start; i1 < nTracks[1]; i1++) |
2e521c29 | 305 | { |
306 | // if looking same event, skip the case when the two indexes are equal | |
5faf5a07 | 307 | if (AliRsnEvent::SameEvent() && i0 == i1) continue; |
2e521c29 | 308 | |
3c07ce75 | 309 | // skip not physical primaries |
a378358c | 310 | if (!ev1->GetRefMCESD()->Stack()->IsPhysicalPrimary(i1)) continue; |
3c07ce75 | 311 | |
2e521c29 | 312 | // assign second track |
10a049e7 | 313 | ev1->SetDaughterMC(daughter1, i1); |
2e521c29 | 314 | |
315 | // loop over all pairs and make computations | |
316 | next.Reset(); | |
317 | i = 0; | |
318 | while ((pair = (AliRsnPair*)next())) | |
319 | { | |
320 | AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++)); | |
321 | ||
322 | // if the pair is a like-sign, skip the case when i1 < i0, | |
323 | // in order not to double count each like-sign pair | |
324 | // (equivalent to looping from i0+1 to ntracks) | |
325 | if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue; | |
326 | ||
327 | // process the two tracks | |
5faf5a07 | 328 | filled = pair->Fill(&daughter0, &daughter1); |
10a049e7 | 329 | if (!filled) continue; |
2e521c29 | 330 | pair->Compute(); |
331 | } | |
332 | } | |
333 | } | |
28399a41 | 334 | |
335 | // update all count histograms counters | |
336 | next.Reset(); | |
337 | if (!fList) return; | |
338 | while ((pair = (AliRsnPair*)next())) | |
339 | { | |
340 | TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName())); | |
341 | if (!hist) continue; | |
342 | if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0); | |
343 | } | |
2e521c29 | 344 | |
345 | AliDebug(AliLog::kDebug+2,"->"); | |
346 | } | |
347 |