]>
Commit | Line | Data |
---|---|---|
2f331ac9 | 1 | #include "AliAnalysisTaskMuMu.h" |
2 | ||
3 | #include "AliAnalysisManager.h" | |
d440e2c5 | 4 | #include "AliAnalysisMuMuBinning.h" |
5 | #include "AliAnalysisMuonUtility.h" | |
5376e016 | 6 | #include "AliAnalysisUtils.h" |
d440e2c5 | 7 | #include "AliAODEvent.h" |
8 | #include "AliAODMCParticle.h" | |
9 | #include "AliAODTrack.h" | |
10 | #include "AliAODTZERO.h" | |
2f331ac9 | 11 | #include "AliCentrality.h" |
d440e2c5 | 12 | #include "AliCodeTimer.h" |
2f331ac9 | 13 | #include "AliCounterCollection.h" |
d440e2c5 | 14 | #include "AliESDEvent.h" |
d440e2c5 | 15 | #include "AliESDTZERO.h" |
2f331ac9 | 16 | #include "AliInputEventHandler.h" |
17 | #include "AliLog.h" | |
d440e2c5 | 18 | #include "AliMCEvent.h" |
19 | #include "AliMCEventHandler.h" | |
20 | #include "AliMergeableCollection.h" | |
21 | #include "AliMuonEventCuts.h" | |
2f331ac9 | 22 | #include "AliMuonTrackCuts.h" |
23 | #include "Riostream.h" | |
24 | #include "TCanvas.h" | |
25 | #include "TDatabasePDG.h" | |
26 | #include "TFormula.h" | |
27 | #include "TH1.h" | |
28 | #include "TH2.h" | |
29 | #include "THashList.h" | |
30 | #include "TList.h" | |
31 | #include "TMath.h" | |
32 | #include "TObjString.h" | |
33 | #include "TPaveText.h" | |
5376e016 | 34 | #include "TProfile.h" |
d440e2c5 | 35 | #include "TRegexp.h" |
2f331ac9 | 36 | #include "TROOT.h" |
16560e8e | 37 | #include "TParameter.h" |
2f331ac9 | 38 | #include <algorithm> |
d440e2c5 | 39 | #include <cassert> |
5376e016 | 40 | #include "AliAnalysisMuMuBase.h" |
5376e016 CP |
41 | #include "AliAnalysisMuMuCutRegistry.h" |
42 | #include "AliAnalysisMuMuCutElement.h" | |
43 | #include "AliAnalysisMuMuCutCombination.h" | |
44 | #include <set> | |
45 | ||
16560e8e | 46 | /// |
47 | /// AliAnalysisTaskMuMu : steering class for muon analysis | |
48 | /// | |
49 | /// The output contains an AliHistogramCollection and | |
50 | /// an AliCounterCollection | |
51 | /// | |
52 | /// \author: L. Aphecetche (Subatech) | |
53 | /// | |
54 | /// This task must be configured a bit before being used. For instance | |
55 | /// you can select various event cuts, single muon track cuts and | |
56 | /// muon pairs cut, as well as defining various bins (for minv and mean pt | |
57 | /// histograms) in pt,y,phi etc... | |
58 | /// | |
59 | /// Note that it's also possible to disable some (or all) histograms | |
60 | /// (to save speed/memory), using DisableHistograms() method. | |
61 | /// | |
62 | /// For an example of such configuration, \see AddTaskMuMu.C | |
63 | /// | |
2f331ac9 | 64 | |
65 | using std::cout; | |
66 | using std::endl; | |
67 | ||
68 | ClassImp(AliAnalysisTaskMuMu) | |
2f331ac9 | 69 | |
70 | //_____________________________________________________________________________ | |
5376e016 CP |
71 | AliAnalysisTaskMuMu::AliAnalysisTaskMuMu() |
72 | : AliAnalysisTaskSE("AliAnalysisTaskMuMu"), | |
2f331ac9 | 73 | fHistogramCollection(0), |
74 | fEventCounters(0), | |
d440e2c5 | 75 | fBinning(0x0), |
5376e016 CP |
76 | fCutRegistry(0x0), |
77 | fBeamYear(""), | |
d440e2c5 | 78 | fHistogramToDisable(0x0), |
16560e8e | 79 | fSubAnalysisVector(0x0), |
80 | fCountInBins(kFALSE), | |
81 | fDisableHistoLoop(kFALSE) | |
2f331ac9 | 82 | { |
83 | /// Constructor with a predefined list of triggers to consider | |
5376e016 CP |
84 | /// Note that we take ownership of cutRegister |
85 | /// | |
86 | ||
87 | // fBranchNames = "AOD:header,tracks,vertices,tracklets,AliAODTZERO,AliAODVZERO"; | |
2f331ac9 | 88 | |
d440e2c5 | 89 | DefineOutput(1,AliMergeableCollection::Class()); |
90 | DefineOutput(2,AliCounterCollection::Class()); | |
91 | DefineOutput(3,AliAnalysisMuMuBinning::Class()); | |
2f331ac9 | 92 | } |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | AliAnalysisTaskMuMu::~AliAnalysisTaskMuMu() | |
96 | { | |
97 | /// dtor | |
98 | ||
d440e2c5 | 99 | if (fHistogramCollection && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) |
2f331ac9 | 100 | { |
d440e2c5 | 101 | delete fHistogramCollection; |
102 | } | |
103 | ||
104 | if (fEventCounters && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) | |
105 | { | |
106 | delete fEventCounters; | |
107 | } | |
108 | ||
109 | if (fBinning && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) | |
110 | { | |
111 | delete fBinning; | |
2f331ac9 | 112 | } |
113 | ||
d440e2c5 | 114 | delete fHistogramToDisable; |
d440e2c5 | 115 | |
5376e016 | 116 | delete fCutRegistry; |
d440e2c5 | 117 | |
5376e016 | 118 | delete fSubAnalysisVector; |
d440e2c5 | 119 | } |
120 | ||
121 | //_____________________________________________________________________________ | |
5376e016 | 122 | void AliAnalysisTaskMuMu::AdoptSubAnalysis(AliAnalysisMuMuBase* analysis) |
d440e2c5 | 123 | { |
5376e016 | 124 | if (!fSubAnalysisVector) |
2f331ac9 | 125 | { |
5376e016 CP |
126 | fSubAnalysisVector = new TObjArray; |
127 | fSubAnalysisVector->SetOwner(kTRUE); | |
2f331ac9 | 128 | } |
5376e016 | 129 | if ( !fSubAnalysisVector->FindObject(analysis) ) |
2f331ac9 | 130 | { |
5376e016 | 131 | fSubAnalysisVector->Add(analysis); |
2f331ac9 | 132 | } |
133 | } | |
134 | ||
135 | //_____________________________________________________________________________ | |
5376e016 | 136 | AliAnalysisMuMuCutRegistry* AliAnalysisTaskMuMu::CutRegistry() const |
2f331ac9 | 137 | { |
5376e016 CP |
138 | /// Return (and create if not yet there) our cut registry |
139 | if (!fCutRegistry) | |
2f331ac9 | 140 | { |
5376e016 | 141 | fCutRegistry = new AliAnalysisMuMuCutRegistry; |
2f331ac9 | 142 | } |
5376e016 | 143 | return fCutRegistry; |
2f331ac9 | 144 | } |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | const char* | |
148 | AliAnalysisTaskMuMu::DefaultCentralityName() const | |
149 | { | |
150 | /// Get default centrality name | |
151 | if ( !fBeamYear.Contains("pp") ) return "CENTX"; | |
152 | else return "PP"; | |
153 | } | |
154 | ||
2f331ac9 | 155 | //_____________________________________________________________________________ |
d440e2c5 | 156 | void AliAnalysisTaskMuMu::DisableHistograms(const char* pattern) |
2f331ac9 | 157 | { |
d440e2c5 | 158 | /// Disable the histogramming of all the histograms matching the pattern |
2f331ac9 | 159 | |
5376e016 CP |
160 | TIter next(fSubAnalysisVector); |
161 | AliAnalysisMuMuBase* a; | |
2f331ac9 | 162 | |
5376e016 | 163 | while ( ( a = static_cast<AliAnalysisMuMuBase*>(next()) ) ) |
2f331ac9 | 164 | { |
5376e016 | 165 | a->DisableHistograms(pattern); |
2f331ac9 | 166 | } |
2f331ac9 | 167 | } |
168 | ||
169 | //_____________________________________________________________________________ | |
5376e016 CP |
170 | AliVEvent* |
171 | AliAnalysisTaskMuMu::Event() const | |
2f331ac9 | 172 | { |
5376e016 CP |
173 | // some const-dirty-dancing |
174 | return const_cast<AliAnalysisTaskMuMu*>(this)->InputEvent(); | |
2f331ac9 | 175 | } |
176 | ||
61bf1693 | 177 | //_____________________________________________________________________________ |
5376e016 CP |
178 | void AliAnalysisTaskMuMu::Fill(const char* eventSelection, const char* triggerClassName) |
179 | { | |
180 | // Fill one set of histograms (only called for events which pass the eventSelection cut) | |
181 | ||
182 | TString seventSelection(eventSelection); | |
183 | seventSelection.ToLower(); | |
184 | ||
16560e8e | 185 | FillCounters(seventSelection.Data(), triggerClassName, "ALL", fCurrentRunNumber); |
186 | // fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", seventSelection.Data(), triggerClassName, "ALL", fCurrentRunNumber)); | |
91dbbc20 | 187 | |
16560e8e | 188 | // if ( !IsHistogrammingDisabled() ) |
189 | // { | |
190 | TObjArray* centralities = fBinning->CreateBinObjArray("centrality"); | |
191 | ||
192 | TIter next(centralities); | |
193 | AliAnalysisMuMuBinning::Range* r; | |
194 | ||
195 | while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) ) | |
5376e016 | 196 | { |
16560e8e | 197 | TString estimator = r->Quantity(); |
91dbbc20 | 198 | |
16560e8e | 199 | Float_t fcent = Event()->GetCentrality()->GetCentralityPercentile(estimator.Data()); |
200 | // if ( fcent < 0.) FillHistos(eventSelection,triggerClassName,"MV0"); | |
201 | // if ( fcent == 0.) FillHistos(eventSelection,triggerClassName,"0V0"); | |
91dbbc20 | 202 | |
16560e8e | 203 | if ( r->IsInRange(fcent) ) |
91dbbc20 | 204 | { |
16560e8e | 205 | FillHistos(eventSelection,triggerClassName,r->AsString()); |
91dbbc20 | 206 | } |
207 | } | |
16560e8e | 208 | delete centralities; |
209 | // } | |
91dbbc20 | 210 | } |
2f331ac9 | 211 | |
212 | //_____________________________________________________________________________ | |
5376e016 CP |
213 | void AliAnalysisTaskMuMu::FillHistos(const char* eventSelection, |
214 | const char* triggerClassName, | |
215 | const char* centrality) | |
2f331ac9 | 216 | { |
5376e016 | 217 | /// Fill histograms for /physics/triggerClassName/centrality |
2f331ac9 | 218 | |
5376e016 | 219 | AliCodeTimerAuto("",0); |
2f331ac9 | 220 | |
5376e016 CP |
221 | TIter nextAnalysis(fSubAnalysisVector); |
222 | AliAnalysisMuMuBase* analysis; | |
2f331ac9 | 223 | |
5376e016 | 224 | Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event()); |
2f331ac9 | 225 | |
16560e8e | 226 | FillCounters( eventSelection, triggerClassName, centrality, fCurrentRunNumber); |
227 | // fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", eventSelection, triggerClassName, centrality, fCurrentRunNumber)); | |
5376e016 | 228 | |
16560e8e | 229 | |
5376e016 CP |
230 | TIter nextTrackCut(fCutRegistry->GetCutCombinations(AliAnalysisMuMuCutElement::kTrack)); |
231 | TIter nextPairCut(fCutRegistry->GetCutCombinations(AliAnalysisMuMuCutElement::kTrackPair)); | |
232 | ||
233 | // loop on single tracks (whatever the type of tracks | |
16560e8e | 234 | if ( !IsHistogrammingDisabled() && !fDisableHistoLoop ) |
5376e016 | 235 | { |
16560e8e | 236 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) |
5376e016 | 237 | { |
16560e8e | 238 | analysis->DefineHistogramCollection(eventSelection,triggerClassName,centrality); |
5376e016 | 239 | |
16560e8e | 240 | AliCodeTimerAuto(Form("%s (FillHistosForEvent)",analysis->ClassName()),1); |
5376e016 | 241 | |
16560e8e | 242 | if ( MCEvent() != 0x0 ) |
5376e016 | 243 | { |
16560e8e | 244 | analysis->FillHistosForMCEvent(eventSelection,triggerClassName,centrality); |
5376e016 CP |
245 | } |
246 | ||
16560e8e | 247 | analysis->FillHistosForEvent(eventSelection,triggerClassName,centrality); |
5376e016 | 248 | |
16560e8e | 249 | for (Int_t i = 0; i < nTracks; ++i) |
5376e016 | 250 | { |
16560e8e | 251 | AliVParticle* tracki = AliAnalysisMuonUtility::GetTrack(i,Event()); |
5376e016 | 252 | |
16560e8e | 253 | nextTrackCut.Reset(); |
254 | AliAnalysisMuMuCutCombination* trackCut; | |
5376e016 | 255 | |
16560e8e | 256 | while ( ( trackCut = static_cast<AliAnalysisMuMuCutCombination*>(nextTrackCut()) ) ) |
257 | { | |
258 | if ( trackCut->Pass(*tracki) ) | |
259 | { | |
260 | analysis->FillHistosForTrack(eventSelection,triggerClassName,centrality,trackCut->GetName(),*tracki); | |
261 | } | |
262 | } | |
263 | ||
264 | if (!AliAnalysisMuonUtility::IsMuonTrack(tracki) ) continue; | |
265 | ||
266 | // loop on track pairs (here we only consider muon pairs) | |
5376e016 | 267 | |
16560e8e | 268 | for (Int_t j = i+1; j < nTracks; ++j) |
5376e016 | 269 | { |
16560e8e | 270 | AliVParticle* trackj = AliAnalysisMuonUtility::GetTrack(j,Event()); |
271 | ||
272 | if (!AliAnalysisMuonUtility::IsMuonTrack(trackj) ) continue; | |
273 | ||
274 | nextPairCut.Reset(); | |
275 | AliAnalysisMuMuCutCombination* pairCut; | |
5376e016 | 276 | |
16560e8e | 277 | while ( ( pairCut = static_cast<AliAnalysisMuMuCutCombination*>(nextPairCut()) ) ) |
5376e016 | 278 | { |
16560e8e | 279 | Bool_t testi = (pairCut->IsTrackCutter()) ? pairCut->Pass(*tracki) : kTRUE; |
280 | Bool_t testj = (pairCut->IsTrackCutter()) ? pairCut->Pass(*trackj) : kTRUE; | |
281 | Bool_t testij = pairCut->Pass(*tracki,*trackj); | |
282 | ||
283 | if ( ( testi && testj ) && testij ) | |
284 | { | |
285 | analysis->FillHistosForPair(eventSelection,triggerClassName,centrality,pairCut->GetName(),*tracki,*trackj); | |
286 | } | |
5376e016 CP |
287 | } |
288 | } | |
289 | } | |
290 | } | |
291 | } | |
2f331ac9 | 292 | } |
293 | ||
16560e8e | 294 | //_____________________________________________________________________________ |
295 | void AliAnalysisTaskMuMu::FillCounters(const char* eventSelection, const char* triggerClassName, const char* centrality, Int_t currentRun, const char* binningName) | |
296 | { | |
297 | // The binning has to be an already existing event property or one (like i.e. <dNch/dEta>) which we can compute in the SetEvent() method and attach it to the event list | |
298 | // We can generalize this method (if needed), now it is only valid for dNchdEta | |
299 | ||
300 | TString sbinningName(binningName); | |
301 | sbinningName.ToUpper(); | |
302 | ||
303 | if( fCountInBins ) | |
304 | { | |
305 | TParameter<Double_t>* p(0x0); | |
306 | TObjArray* bin = fBinning->CreateBinObjArray("psi",sbinningName.Data(),"JAVI"); // FIXME: Dependence on binning name | |
307 | if ( !bin ) AliError(Form("%s binning does not exist",binningName)); | |
308 | else | |
309 | { | |
310 | TList* list = static_cast<TList*>(Event()->FindListObject("NCH")); | |
311 | if (list) | |
312 | { | |
313 | Int_t i(-1); | |
314 | Bool_t parFound(kFALSE); | |
315 | while ( i < list->GetEntries() - 1 && !parFound ) | |
316 | { | |
317 | i++; | |
318 | while ( list->At(i)->IsA() != TParameter<Double_t>::Class() && i < list->GetEntries() - 1 ) // In case there is a diferent object, just to skip it | |
319 | { | |
320 | i++; | |
321 | } | |
322 | ||
323 | p = static_cast<TParameter<Double_t>*>(list->At(i)); | |
324 | ||
325 | if ( TString(p->GetName()).Contains("NtrCorr") ) // FIXME: make this valid for dnch/deta also | |
326 | { | |
327 | parFound = kTRUE; | |
328 | } | |
329 | } | |
330 | } | |
331 | else AliFatal("No dNchdEta info on Event"); | |
332 | ||
333 | TIter next(bin); | |
334 | AliAnalysisMuMuBinning::Range* r; | |
335 | ||
336 | while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) ) | |
337 | { | |
338 | ||
339 | if ( r->IsInRange(p->GetVal()) ) | |
340 | { | |
341 | fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d/bin:%s", eventSelection, triggerClassName, | |
342 | centrality, currentRun,r->AsString().Data())); | |
343 | } | |
344 | } | |
345 | ||
346 | delete bin; | |
347 | } | |
348 | } | |
349 | ||
350 | else fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", eventSelection, triggerClassName, centrality, currentRun)); | |
351 | } | |
352 | ||
2f331ac9 | 353 | //_____________________________________________________________________________ |
5376e016 | 354 | void AliAnalysisTaskMuMu::FinishTaskOutput() |
2f331ac9 | 355 | { |
5376e016 CP |
356 | /// prune empty histograms BEFORE mergin, in order to save some bytes... |
357 | ||
358 | if ( fHistogramCollection ) | |
359 | { | |
360 | fHistogramCollection->PruneEmptyObjects(); | |
361 | } | |
2f331ac9 | 362 | } |
363 | ||
364 | //_____________________________________________________________________________ | |
5376e016 | 365 | void AliAnalysisTaskMuMu::GetSelectedTrigClassesInEvent(const AliVEvent* event, TObjArray& array) |
2f331ac9 | 366 | { |
5376e016 CP |
367 | /// Fills the array with a list of TObjString of the trigger classes that the various |
368 | /// cuts accept for this event | |
369 | ||
370 | array.Clear(); | |
371 | ||
372 | if (!event) | |
373 | { | |
374 | AliError("Will get a hard time selecting trigger classes with an empty event..."); | |
375 | return; | |
376 | } | |
377 | ||
378 | TString firedTriggerClasses = event->GetFiredTriggerClasses(); | |
379 | UInt_t l0 = AliAnalysisMuonUtility::GetL0TriggerInputs(event); | |
380 | UInt_t l1 = AliAnalysisMuonUtility::GetL1TriggerInputs(event); | |
381 | UInt_t l2 = AliAnalysisMuonUtility::GetL2TriggerInputs(event); | |
2f331ac9 | 382 | |
5376e016 CP |
383 | std::set<std::string> tmpArray; |
384 | ||
385 | TIter nextCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kTriggerClass)); | |
386 | AliAnalysisMuMuCutCombination* cutCombination; | |
387 | ||
388 | while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextCutCombination()) ) ) | |
389 | { | |
390 | TString acceptedTriggerClasses; | |
391 | ||
392 | if ( cutCombination->Pass(firedTriggerClasses,acceptedTriggerClasses,l0,l1,l2) ) | |
393 | { | |
394 | TObjArray* split = acceptedTriggerClasses.Tokenize(" "); | |
395 | TIter next(split); | |
396 | TObjString* str; | |
397 | while ( ( str = static_cast<TObjString*>(next()) ) ) | |
398 | { | |
399 | tmpArray.insert(str->String().Data()); | |
400 | } | |
401 | delete split; | |
402 | } | |
403 | } | |
404 | ||
405 | std::set<std::string>::const_iterator it; | |
406 | ||
407 | for ( it = tmpArray.begin(); it != tmpArray.end(); ++it ) | |
408 | { | |
409 | array.Add(new TObjString(it->c_str())); | |
410 | } | |
2f331ac9 | 411 | } |
412 | ||
5376e016 | 413 | |
2f331ac9 | 414 | //_____________________________________________________________________________ |
d440e2c5 | 415 | Bool_t AliAnalysisTaskMuMu::IsHistogramDisabled(const char* hname) const |
2f331ac9 | 416 | { |
d440e2c5 | 417 | /// Whether or not a given histogram (identified by its name) |
418 | /// is disabled or not | |
2f331ac9 | 419 | |
5376e016 CP |
420 | TIter next(fSubAnalysisVector); |
421 | AliAnalysisMuMuBase* analysis; | |
422 | ||
423 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ) | |
2f331ac9 | 424 | { |
5376e016 | 425 | if ( analysis->IsHistogramDisabled(hname) ) |
d440e2c5 | 426 | { |
427 | return kTRUE; | |
428 | } | |
2f331ac9 | 429 | } |
5376e016 | 430 | |
d440e2c5 | 431 | return kFALSE; |
432 | } | |
433 | ||
434 | //_____________________________________________________________________________ | |
435 | Bool_t AliAnalysisTaskMuMu::IsHistogrammingDisabled() const | |
436 | { | |
437 | /// Whether or not *all* histograms are disabled | |
2f331ac9 | 438 | |
5376e016 CP |
439 | Bool_t disabled(kTRUE); |
440 | ||
441 | TIter next(fSubAnalysisVector); | |
442 | AliAnalysisMuMuBase* analysis; | |
443 | ||
444 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ) | |
2f331ac9 | 445 | { |
5376e016 | 446 | disabled = disabled && analysis->IsHistogrammingDisabled(); |
2f331ac9 | 447 | } |
5376e016 CP |
448 | |
449 | return disabled; | |
d440e2c5 | 450 | } |
451 | ||
452 | //_____________________________________________________________________________ | |
453 | Bool_t AliAnalysisTaskMuMu::IsPP() const | |
454 | { | |
455 | // whether we're dealing with proton proton collisions | |
456 | return fBeamYear.Contains("pp"); | |
2f331ac9 | 457 | } |
458 | ||
2f331ac9 | 459 | //_____________________________________________________________________________ |
460 | void AliAnalysisTaskMuMu::NotifyRun() | |
461 | { | |
462 | /// Called at each change of run | |
463 | ||
464 | AliDebug(1,Form("Run %09d File %s",fCurrentRunNumber,CurrentFileName())); | |
465 | ||
5376e016 CP |
466 | TIter next(fSubAnalysisVector); |
467 | AliAnalysisMuMuBase* analysis; | |
2f331ac9 | 468 | |
5376e016 CP |
469 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ) |
470 | { | |
471 | analysis->SetRun(fInputHandler); | |
472 | } | |
2f331ac9 | 473 | } |
474 | ||
475 | //_____________________________________________________________________________ | |
476 | void | |
5376e016 | 477 | AliAnalysisTaskMuMu::Print(Option_t* opt) const |
2f331ac9 | 478 | { |
479 | /// Print the definition of this analysis | |
480 | ||
481 | cout << ClassName() << " - " << GetName() << " - " << fBeamYear.Data() << endl; | |
5376e016 CP |
482 | |
483 | TIter next(fSubAnalysisVector); | |
484 | AliAnalysisMuMuBase* analysis; | |
2f331ac9 | 485 | |
5376e016 | 486 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ) |
2f331ac9 | 487 | { |
5376e016 | 488 | analysis->Print(opt); |
2f331ac9 | 489 | } |
1afce1ce | 490 | |
5376e016 | 491 | fCutRegistry->Print("ALL"); |
2f331ac9 | 492 | |
d440e2c5 | 493 | if ( fBinning ) |
2f331ac9 | 494 | { |
5376e016 | 495 | cout << "Binning" << endl; |
d440e2c5 | 496 | fBinning->Print(); |
2f331ac9 | 497 | } |
498 | } | |
499 | ||
500 | //_____________________________________________________________________________ | |
501 | void | |
16560e8e | 502 | AliAnalysisTaskMuMu::Terminate(Option_t *) |
2f331ac9 | 503 | { |
504 | /// Called once at the end of the query | |
505 | /// Just a simple printout of the stat we analyse and how many histograms | |
506 | /// we got | |
507 | ||
16560e8e | 508 | |
509 | fHistogramCollection = dynamic_cast<AliMergeableCollection*>(GetOutputData(1)); | |
510 | ||
511 | TIter nextAnalysis(fSubAnalysisVector); | |
5376e016 CP |
512 | AliAnalysisMuMuBase* analysis; |
513 | ||
16560e8e | 514 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) |
5376e016 | 515 | { |
16560e8e | 516 | analysis->SetHistogramCollection(fHistogramCollection); |
517 | analysis->Terminate(); | |
5376e016 CP |
518 | } |
519 | ||
2f331ac9 | 520 | if (!fHistogramCollection) |
521 | { | |
522 | AliError("Could not find back histogram collection in output..."); | |
2f331ac9 | 523 | } |
5376e016 CP |
524 | else |
525 | { | |
16560e8e | 526 | // Removes empty objects |
5376e016 CP |
527 | fHistogramCollection->PruneEmptyObjects(); |
528 | ||
529 | UInt_t size2 = fHistogramCollection->EstimateSize(); | |
2f331ac9 | 530 | |
5376e016 CP |
531 | TIter nextHistogram(fHistogramCollection->CreateIterator()); |
532 | TObject* object; | |
533 | ||
534 | while ( ( object = nextHistogram() ) ) | |
535 | { | |
536 | if ( object->IsA()->InheritsFrom(TH1::Class()) ) | |
537 | { | |
538 | TH1* h = static_cast<TH1*>(object); | |
539 | if ( h->GetXaxis()->GetLabels() ) | |
540 | { | |
541 | h->LabelsDeflate("X"); | |
542 | } | |
543 | } | |
544 | } | |
545 | ||
546 | AliInfo(Form("size after prune histograms = %5.1f MB",size2/1024.0/1024.0)); | |
d440e2c5 | 547 | |
5376e016 CP |
548 | fHistogramCollection->Print("-"); |
549 | } | |
2f331ac9 | 550 | |
d440e2c5 | 551 | fEventCounters = dynamic_cast<AliCounterCollection*>(GetOutputData(2)); |
2f331ac9 | 552 | |
553 | if (!fEventCounters) | |
554 | { | |
555 | AliError("Could not find back counters in output..."); | |
2f331ac9 | 556 | } |
5376e016 CP |
557 | else |
558 | { | |
559 | fEventCounters->Print("trigger/event"); | |
560 | } | |
d440e2c5 | 561 | |
562 | // post param container(s) | |
563 | PostData(3,fBinning); | |
2f331ac9 | 564 | } |
565 | ||
566 | //_____________________________________________________________________________ | |
5376e016 | 567 | AliAnalysisMuMuBinning* AliAnalysisTaskMuMu::Binning() const |
2f331ac9 | 568 | { |
5376e016 CP |
569 | // Return our binning (making a default one if not already created |
570 | if ( fBinning ) return fBinning; | |
2f331ac9 | 571 | |
5376e016 CP |
572 | fBinning = new AliAnalysisMuMuBinning("BIN"); |
573 | ||
574 | return fBinning; | |
2f331ac9 | 575 | } |
576 | ||
577 | //_____________________________________________________________________________ | |
578 | void AliAnalysisTaskMuMu::UserExec(Option_t* /*opt*/) | |
579 | { | |
580 | /// Executed at each event | |
581 | ||
5376e016 CP |
582 | // static Int_t n(0); |
583 | // AliInfo(Form("EVENT %10d Event()=%p MCEvent()=%p",n,Event(),MCEvent())); | |
584 | // ++n; | |
16560e8e | 585 | // |
5376e016 | 586 | AliCodeTimerAuto("",0); |
2f331ac9 | 587 | |
5376e016 | 588 | Binning(); // insure we have a binning... |
2f331ac9 | 589 | |
5376e016 CP |
590 | // if ( MCEvent() ) |
591 | // { | |
592 | TIter nextAnalysis(fSubAnalysisVector); | |
593 | AliAnalysisMuMuBase* analysis; | |
594 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) | |
2f331ac9 | 595 | { |
5376e016 CP |
596 | if ( MCEvent() ) // Set the MC flag for all analysis (prior to call anything from them |
597 | // (e.g. any trigger class selection that might behave differently for | |
598 | // MC and real trigger classes) | |
599 | { | |
600 | analysis->SetMC(); | |
601 | } | |
602 | analysis->SetEvent(Event(),MCEvent()); // Set the new event properties derived in the analysis | |
2f331ac9 | 603 | } |
5376e016 | 604 | // } |
16560e8e | 605 | |
5376e016 | 606 | TString firedTriggerClasses(AliAnalysisMuonUtility::GetFiredTriggerClasses(Event())); |
16560e8e | 607 | |
2f331ac9 | 608 | // first loop to count things not associated to a specific trigger |
5376e016 CP |
609 | TIter nextEventCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent)); |
610 | AliAnalysisMuMuCutCombination* cutCombination; | |
16560e8e | 611 | |
5376e016 | 612 | while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombination()))) |
2f331ac9 | 613 | { |
5376e016 | 614 | if ( cutCombination->Pass(*fInputHandler) ) |
2f331ac9 | 615 | { |
16560e8e | 616 | FillCounters(cutCombination->GetName(), "EVERYTHING", "ALL", fCurrentRunNumber); |
617 | // fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", cutCombination->GetName(), "EVERYTHING", "ALL", fCurrentRunNumber)); | |
618 | ||
2f331ac9 | 619 | if ( firedTriggerClasses == "" ) |
620 | { | |
16560e8e | 621 | FillCounters(cutCombination->GetName(),"EMPTY","ALL",fCurrentRunNumber); |
622 | // fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", cutCombination->GetName(), "EMPTY", "ALL", fCurrentRunNumber)); | |
2f331ac9 | 623 | } |
2f331ac9 | 624 | } |
625 | } | |
626 | ||
627 | // second loop to count only the triggers we're interested in | |
5376e016 | 628 | TObjArray selectedTriggerClasses; |
1afce1ce | 629 | |
5376e016 | 630 | GetSelectedTrigClassesInEvent(Event(),selectedTriggerClasses); |
d440e2c5 | 631 | |
5376e016 CP |
632 | TIter next(&selectedTriggerClasses); |
633 | TObjString* tname; | |
634 | // Bool_t hasSetEventBeenCalled(kFALSE); | |
635 | ||
2f331ac9 | 636 | while ( ( tname = static_cast<TObjString*>(next()) ) ) |
637 | { | |
5376e016 CP |
638 | nextEventCutCombination.Reset(); |
639 | ||
640 | while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombination())) ) | |
2f331ac9 | 641 | { |
5376e016 | 642 | if ( cutCombination->Pass(*fInputHandler) ) |
2f331ac9 | 643 | { |
5376e016 CP |
644 | // if (!hasSetEventBeenCalled) |
645 | // { | |
646 | // TIter nextAnalysis(fSubAnalysisVector); | |
647 | // AliAnalysisMuMuBase* analysis; | |
648 | // | |
649 | // while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) | |
650 | // { | |
651 | // analysis->SetEvent(Event(),MCEvent()); | |
652 | // } | |
653 | // hasSetEventBeenCalled = kTRUE; | |
654 | // } | |
655 | Fill(cutCombination->GetName(),tname->String().Data()); | |
2f331ac9 | 656 | } |
657 | } | |
658 | } | |
659 | ||
660 | // Post output data. | |
d440e2c5 | 661 | PostData(1, fHistogramCollection); |
662 | PostData(2, fEventCounters); | |
663 | PostData(3, fBinning); | |
2f331ac9 | 664 | } |
665 | ||
666 | //_____________________________________________________________________________ | |
667 | void AliAnalysisTaskMuMu::UserCreateOutputObjects() | |
668 | { | |
5376e016 CP |
669 | /// Create histograms |
670 | /// Called once | |
2f331ac9 | 671 | |
672 | OpenFile(1); | |
673 | ||
5376e016 | 674 | AliInfo(Form("fCutRegistry=%p",fCutRegistry)); |
2f331ac9 | 675 | |
5376e016 CP |
676 | if ( fCutRegistry ) |
677 | { | |
678 | fCutRegistry->Print(); | |
679 | } | |
680 | ||
681 | fHistogramCollection = new AliMergeableCollection("OC"); | |
682 | ||
d440e2c5 | 683 | fEventCounters = new AliCounterCollection("CC"); |
2f331ac9 | 684 | |
5376e016 CP |
685 | // initialize event counters |
686 | ||
2f331ac9 | 687 | TString eventRubric; |
5376e016 CP |
688 | TIter next(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent)); |
689 | AliAnalysisMuMuCutCombination* cutCombination; | |
690 | ||
691 | while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(next())) ) | |
2f331ac9 | 692 | { |
5376e016 CP |
693 | TString cutName = cutCombination->GetName(); |
694 | if ( eventRubric.Length() > 0 ) eventRubric += "/"; | |
695 | eventRubric += cutName; | |
2f331ac9 | 696 | } |
697 | ||
2f331ac9 | 698 | fEventCounters->AddRubric("event", eventRubric.Data()); |
699 | ||
700 | fEventCounters->AddRubric("trigger", 100); | |
701 | ||
5376e016 | 702 | fEventCounters->AddRubric("centrality", 100); |
16560e8e | 703 | |
2f331ac9 | 704 | fEventCounters->AddRubric("run", 1000000); |
705 | ||
16560e8e | 706 | //____New |
707 | if ( fCountInBins ) | |
708 | { | |
709 | fEventCounters->AddRubric("bin", 1000000); | |
710 | } | |
711 | //_____ | |
712 | ||
5376e016 CP |
713 | // Initialize our subtasks, if any... |
714 | ||
715 | TIter nextAnalysis(fSubAnalysisVector); | |
716 | AliAnalysisMuMuBase* analysis; | |
717 | ||
718 | while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) | |
719 | { | |
720 | analysis->Init(*fEventCounters,*fHistogramCollection,*fBinning,*fCutRegistry); | |
721 | } | |
722 | ||
723 | // finally end the counters initialization | |
2f331ac9 | 724 | fEventCounters->Init(); |
725 | ||
2f331ac9 | 726 | // Post output data. |
d440e2c5 | 727 | PostData(1,fHistogramCollection); |
728 | PostData(2,fEventCounters); | |
729 | PostData(3,fBinning); | |
2f331ac9 | 730 | } |