]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/muon/AliAnalysisMuMu.cxx
Compatibility with ROOT trunk
[u/mrichter/AliRoot.git] / PWG / muon / AliAnalysisMuMu.cxx
CommitLineData
5eabea87 1#include "AliAnalysisMuMu.h"
2
3#include "AliAnalysisManager.h"
4#include "AliCounterCollection.h"
5#include "AliHistogramCollection.h"
6#include "AliLog.h"
7#include "AliLog.h"
8#include "Riostream.h"
9#include "TCanvas.h"
10#include "TDatabasePDG.h"
11#include "TH1.h"
12#include "TH2.h"
13#include "THashList.h"
14#include "TList.h"
15#include "TMath.h"
16#include "TObjString.h"
17#include "TPaveText.h"
18#include "TROOT.h"
19#include <algorithm>
20
21//
22// AliAnalysisMuMu : base class for mu pairs analysis
23//
24// Mainly invariant mass (for J/psi and Upsilon) but also
25// some single control histograms.
26//
27// This base class contains common things for ESD-based
28// and AOD-based analysis
29//
30// The output contains an AliHistogramCollection and
31// an AliCounterCollection
32//
33// author: L. Aphecetche (Subatech)
34//
35
3a7af7bd 36using std::cout;
37using std::endl;
5eabea87 38ClassImp(AliAnalysisMuMu)
39
40namespace
41{
42 Int_t GetNbins(Double_t xmin, Double_t xmax, Double_t xstep)
43 {
44 if ( TMath::AreEqualRel(xstep,0.0,1E-9) ) return 1;
45
46 return TMath::Nint(TMath::Abs((xmax-xmin)/xstep));
47 }
48}
49
50//_____________________________________________________________________________
51AliAnalysisMuMu* AliAnalysisMuMu::Create(const char* inputDataType, TList* triggerClassesToConsider)
52{
53 /// Create the right implementation depending on intputDataType
54
55 TString sinputDataType(inputDataType);
56 sinputDataType.ToUpper();
57
58 if ( sinputDataType != "AOD" && sinputDataType != "ESD" )
59 {
60 AliErrorClass(Form("Unknown input data type : %s",inputDataType));
61 return 0x0;
62 }
63
64 return reinterpret_cast<AliAnalysisMuMu*>(gROOT->ProcessLineFast(Form("new AliAnalysisMuMuFrom%s((TList*)%p)",
65 sinputDataType.Data(),
66 triggerClassesToConsider)));
67}
68
69//_____________________________________________________________________________
70AliAnalysisMuMu* AliAnalysisMuMu::Create(const char* inputDataType, Bool_t aa)
71{
72 /// Create the right implementation depending on intputDataType
73
74 TString sinputDataType(inputDataType);
75 sinputDataType.ToUpper();
76
77 if ( sinputDataType != "AOD" && sinputDataType != "ESD" )
78 {
79 AliErrorClass(Form("Unknown input data type : %s",inputDataType));
80 return 0x0;
81 }
82
83 return reinterpret_cast<AliAnalysisMuMu*>(gROOT->ProcessLineFast(Form("new AliAnalysisMuMuFrom%s(%d)",
84 sinputDataType.Data(),aa)));
85}
86
87//_____________________________________________________________________________
88AliAnalysisMuMu::AliAnalysisMuMu() : AliAnalysisTaskSE("AliAnalysisMuMu"),
89fHistogramCollection(0),
90fOutput(0),
91fTriggerClasses(0),
92fEventCounters(0),
93fIsFromESD(kFALSE),
94fSingleTrackCutNames(0x0),
95fPairTrackCutNames(0x0),
96fCentralityLimits(),
97fCentralityNames(0x0),
98fGlobalEventSelectionNames(0x0),
99fAA(kFALSE),
100fIsDynamicTriggerClasses(kFALSE)
101{
102 /// default ctor
103}
104
105//_____________________________________________________________________________
106AliAnalysisMuMu::AliAnalysisMuMu(Bool_t fromESD, Bool_t aa)
107: AliAnalysisTaskSE(Form("AliAnalysisMuMu-from%s",fromESD ? "ESD":"AOD")),
108fHistogramCollection(0),
109fOutput(0),
110fTriggerClasses(new THashList),
111fEventCounters(0),
112fIsFromESD(fromESD),
113fSingleTrackCutNames(0x0),
114fPairTrackCutNames(0x0),
115fCentralityLimits(),
116fCentralityNames(new TObjArray),
117fGlobalEventSelectionNames(0x0),
118fAA(aa),
119fIsDynamicTriggerClasses(kTRUE)
120{
121 /// Constructor
122 /// The list of triggers to be considered will be updated on the fly
123 /// (see method AddTriggerClasses)
124
125 fTriggerClasses->SetOwner(kTRUE);
126
127 DefineOutput(1, TList::Class());
128
129 DefineCentralityClasses();
130
131}
132
133//_____________________________________________________________________________
134AliAnalysisMuMu::AliAnalysisMuMu(Bool_t fromESD, TList* triggerClasses)
135: AliAnalysisTaskSE(Form("AliAnalysisMuMu-from%s",fromESD ? "ESD":"AOD")),
136fHistogramCollection(0),
137fOutput(0),
138fTriggerClasses(new THashList),
139fEventCounters(0),
140fIsFromESD(fromESD),
141fSingleTrackCutNames(0x0),
142fPairTrackCutNames(0x0),
143fCentralityLimits(),
144fCentralityNames(new TObjArray),
145fGlobalEventSelectionNames(0x0),
146fAA(kFALSE),
147fIsDynamicTriggerClasses(kFALSE)
148{
149 /// Constructor with a predefined list of triggers to consider
150
151 fTriggerClasses->SetOwner(kTRUE);
152
153 DefineOutput(1, TList::Class());
154
155 TObjString* tname;
156 TIter next(triggerClasses);
157
158 while ( ( tname = static_cast<TObjString*>(next()) ) )
159 {
160 fTriggerClasses->Add(new TObjString(*tname));
161 if ( tname->String().BeginsWith("CMB") )
162 {
163 fAA = kTRUE;
164 }
165 }
166
167 DefineCentralityClasses();
168}
169
170//_____________________________________________________________________________
171AliAnalysisMuMu::~AliAnalysisMuMu()
172{
173 /// dtor
174 delete fTriggerClasses;
175 delete fSingleTrackCutNames;
176 delete fPairTrackCutNames;
177 if(fOutput && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode())
178 {
179 delete fOutput;
180 }
181 delete fCentralityNames;
182 delete fGlobalEventSelectionNames;
183}
184
185//_____________________________________________________________________________
186void AliAnalysisMuMu::AddGlobalEventSelection(const char* name)
187{
188 /// Add a name to the list of global event event selection ones.
189
190 if (!fGlobalEventSelectionNames)
191 {
192 fGlobalEventSelectionNames = new TObjArray;
193 fGlobalEventSelectionNames->SetOwner(kTRUE);
194 }
195 fGlobalEventSelectionNames->Add(new TObjString(name));
196}
197
198//_____________________________________________________________________________
199UInt_t AliAnalysisMuMu::CodePairCutMask(UInt_t maskForOneOrBothTrack, UInt_t maskForTrackPair) const
200{
201 /// Encode two masks (obviously each one should be 16 bits only) into one
202
203 return ( ( maskForOneOrBothTrack << 16 ) | maskForTrackPair );
204}
205
206//_____________________________________________________________________________
207void AliAnalysisMuMu::DecodePairCutMask(UInt_t code, UInt_t& maskForOneOrBothTrack, UInt_t& maskForTrackPair) const
208{
209 /// Decode the pair cut mask
210 maskForOneOrBothTrack = ( ( code & 0xFFFF0000 ) >> 16 );
211 maskForTrackPair = ( code & 0xFFFF );
212}
213
214//_____________________________________________________________________________
215void AliAnalysisMuMu::DefineCentralityClasses()
216{
217 /// Define the default centrality classes that will be used.
218
219 if ( fAA )
220 {
221 fCentralityLimits.push_back(10.0);
222 fCentralityLimits.push_back(20.0);
223 fCentralityLimits.push_back(30.0);
224 fCentralityLimits.push_back(40.0);
225 fCentralityLimits.push_back(50.0);
226 fCentralityLimits.push_back(60.0);
227 fCentralityLimits.push_back(70.0);
228 fCentralityLimits.push_back(80.0);
229 fCentralityLimits.push_back(90.0);
230 }
231// fCentralityLimits.push_back(100.0);
232
233 for ( std::vector<double>::size_type i = 0; i < fCentralityLimits.size(); ++i )
234 {
235 Double_t limit = fCentralityLimits[i];
236 fCentralityNames->Add(new TObjString(CentralityName(limit)));
237 }
238
239 fCentralityNames->Add(new TObjString(DefaultCentralityName()));
240 fCentralityNames->SetOwner(kTRUE);
241}
242
243//_____________________________________________________________________________
244void AliAnalysisMuMu::AddTriggerClasses(const char* triggerlist)
245{
246 /// Given a list of trigger names (triggerlist) separated by spaces
247 /// add those which we don't know yet (selecting only the few ones
248 /// we're interested in, e.g CINT* CMU* CMB*
249 ///
250
251 TString slist(triggerlist);
252
253 TObjArray* a = slist.Tokenize(" ");
254 TObjString* s;
255 TIter next(a);
256
257 while ( ( s = static_cast<TObjString*>(next()) ) )
258 {
259 TString trigger(s->String());
260 Bool_t add(kFALSE);
261
262 if ( trigger.BeginsWith("CMB") && trigger.Contains("-B-") ) add = kTRUE;
263 if ( trigger.BeginsWith("CINT") && trigger.Contains("-B-") && !trigger.Contains("WU") ) add = kTRUE;
264 if ( trigger.BeginsWith("CMU") && trigger.Contains("-B-") ) add = kTRUE;
265
266 if ( trigger.BeginsWith("CMUP") ) add = kFALSE;
267
268 if ( add && !fTriggerClasses->FindObject(trigger.Data()) )
269 {
270 AliInfo(Form("Adding %s to considered trigger classes",trigger.Data()));
271 fTriggerClasses->Add(new TObjString(trigger));
272 }
273
274 }
275
276 delete a;
277}
278
279//_____________________________________________________________________________
280void AliAnalysisMuMu::AddPairCut(const char* cutName, UInt_t maskForOneOrBothTrack, UInt_t maskForTrackPair)
281{
282 /// Add a cut for a pair.
283 /// maskForOneOrBothTrack is the mask of cuts that at least one track must satisfy
284 /// maskForTrackPair is the mask of cuts that *both* tracks must satisfy.
285 /// if maskForTrackPair is 0, then no (extra) condition is applied to the pair
286
287 if ( !fPairTrackCutNames )
288 {
289 fPairTrackCutNames = new TObjArray;
290 fPairTrackCutNames->SetOwner(kTRUE);
291 }
292 TObjString* oname = new TObjString(Form("p%s",cutName));
293 if ( !maskForTrackPair ) maskForTrackPair = maskForOneOrBothTrack;
294 oname->SetUniqueID(CodePairCutMask(maskForOneOrBothTrack,maskForTrackPair));
295 fPairTrackCutNames->Add(oname);
296}
297
298//_____________________________________________________________________________
299void AliAnalysisMuMu::AddSingleCut(const char* name, UInt_t mask)
300{
301 /// Add a cut for single tracks
302 if ( !fSingleTrackCutNames )
303 {
304 fSingleTrackCutNames = new TObjArray;
305 fSingleTrackCutNames->SetOwner(kTRUE);
306 }
307 TObjString* oname = new TObjString(Form("s%s",name));
308 oname->SetUniqueID(mask);
309 fSingleTrackCutNames->Add(oname);
310}
311
312//_____________________________________________________________________________
313void AliAnalysisMuMu::BeautifyHistos()
314{
315 /// Put the titles, marker sizes, color, etc...
316
317 TIter next(fHistogramCollection->CreateIterator());
318 TH1* h;
319
320 while ( ( h = static_cast<TH1*>(next()) ) )
321 {
322 TString name(h->GetName());
323
324 if ( name.Contains("Plus") )
325 {
326 h->SetMarkerStyle(kFullCircle);
327 h->SetMarkerColor(kBlue);
328 h->SetLineColor(kBlue);
329 }
330 else
331 {
332 h->SetMarkerStyle(kOpenCircle);
333 h->SetMarkerColor(kRed);
334 h->SetLineColor(kRed);
335 }
336 }
337}
338
339//_____________________________________________________________________________
340void
341AliAnalysisMuMu::CreateSingleHisto(const char* physics,
342 const char* triggerClassName,
343 const char* hname, const char* htitle,
344 Int_t nbinsx, Double_t xmin, Double_t xmax,
345 Int_t nbinsy, Double_t ymin, Double_t ymax) const
346{
347 /// Append histograms for single track to our histogram collection
348 CreateHisto(fSingleTrackCutNames,physics,triggerClassName,hname,htitle,
349 nbinsx,xmin,xmax,nbinsy,ymin,ymax);
350}
351
352//_____________________________________________________________________________
353void
354AliAnalysisMuMu::CreatePairHisto(const char* physics,
355 const char* triggerClassName,
356 const char* hname, const char* htitle,
357 Int_t nbinsx, Double_t xmin, Double_t xmax,
358 Int_t nbinsy, Double_t ymin, Double_t ymax) const
359{
360 /// Append histograms for track pairs to our histogram collection
361
362 CreateHisto(fPairTrackCutNames,physics,triggerClassName,hname,htitle,
363 nbinsx,xmin,xmax,nbinsy,ymin,ymax);
364}
365
366//_____________________________________________________________________________
367void
368AliAnalysisMuMu::CreateEventHisto(const char* physics,
369 const char* triggerClassName,
370 const char* hname, const char* htitle,
371 Int_t nbinsx, Double_t xmin, Double_t xmax,
372 Int_t nbinsy, Double_t ymin, Double_t ymax) const
373{
374 /// Append histograms at the event level
375
376 TIter next(fCentralityNames);
377 TObjString* cent;
378
379 while ( ( cent = static_cast<TObjString*>(next()) ) )
380 {
381 TH1* h(0x0);
382
383 if ( nbinsy > 0 )
384 {
385 h = new TH2F(hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
386 }
387 else
388 {
389 h = new TH1F(hname,htitle,nbinsx,xmin,xmax);
390 }
391
392 fHistogramCollection->Adopt(physics,triggerClassName,cent->String().Data(),h);
393 }
394}
395
396//_____________________________________________________________________________
397void
398AliAnalysisMuMu::CreateHisto(TObjArray* array,
399 const char* physics,
400 const char* triggerClassName,
401 const char* hname, const char* htitle,
402 Int_t nbinsx, Double_t xmin, Double_t xmax,
403 Int_t nbinsy, Double_t ymin, Double_t ymax) const
404{
405 /// Create a bunch of histograms for all centralities
406 /// FIXME: have a way to specify the histo precision (i.e. F vs I vs S ...)
407
408 TIter next(array);
409 TObjString* tcn;
410 while ( ( tcn = static_cast<TObjString*>(next()) ) )
411 {
412 TIter nextCent(fCentralityNames);
413 TObjString* cent;
414
415 while ( ( cent = static_cast<TObjString*>(nextCent()) ) )
416 {
417 TH1* h(0x0);
418
419 if ( nbinsy > 0 )
420 {
421 h = new TH2F(hname,htitle,nbinsx,xmin,xmax,nbinsy,ymin,ymax);
422 }
423 else
424 {
425 h = new TH1F(hname,htitle,nbinsx,xmin,xmax);
426 }
427
428 fHistogramCollection->Adopt(physics,triggerClassName,cent->String().Data(),tcn->String().Data(),h);
429 }
430 }
431}
432
433//_____________________________________________________________________________
434const char*
435AliAnalysisMuMu::DefaultCentralityName() const
436{
437 /// Get default centrality name
438 if ( fAA ) return "CENTX";
439 else return "PP";
440}
441
442//_____________________________________________________________________________
443const char*
444AliAnalysisMuMu::CentralityName(Double_t centrality) const
445{
446 /// Get centrality name corresponding to the floating ^point value
447
448 if ( centrality > 0 && centrality <= 100.0 )
449 {
450 return Form("CENT%02d",TMath::Nint(centrality));
451 }
452 else
453 {
454 return DefaultCentralityName();
455 }
456}
457
458//_____________________________________________________________________________
459void AliAnalysisMuMu::AssertHistogramCollection(const char* physics, const char* triggerClassName)
460{
461 // insure that a given set of histogram is created
462 TH1* test = fHistogramCollection->Histo(physics,triggerClassName,DefaultCentralityName(),"Zvertex");
463 if (!test) FillHistogramCollection(physics,triggerClassName);
464}
465
466//_____________________________________________________________________________
467void AliAnalysisMuMu::FillHistogramCollection(const char* physics, const char* triggerClassName)
468{
469 /// Actually create the histograms for phyics/triggerClassName
470
471 AliDebug(1,Form("(%s,%s)",physics,triggerClassName));
472
473 Double_t ptMin = 0;
474 Double_t ptMax = 50;
475 Int_t nbinsPt = GetNbins(ptMin,ptMax,0.25);
476 Double_t pMin = 0;
477 Double_t pMax = 300;
478 Int_t nbinsP = GetNbins(pMin,pMax,1.0);
479 Double_t etaMin = -6;
480 Double_t etaMax = 1;
481 Int_t nbinsEta = GetNbins(etaMin,etaMax,0.1);
482
483 CreateSingleHisto(physics,triggerClassName,"PtEtaMuPlus", "#mu+ P_{T} distribution vs Eta", nbinsEta,etaMin,etaMax, nbinsPt,ptMin,ptMax);
484 CreateSingleHisto(physics,triggerClassName,"PtEtaMuMinus", "#mu- P_{T} distribution vs Eta",nbinsEta,etaMin,etaMax, nbinsPt,ptMin,ptMax);
485
486 CreateSingleHisto(physics,triggerClassName,"PEtaMuPlus", "#mu+ P distribution",nbinsEta,etaMin,etaMax,nbinsP,pMin,pMax);
487 CreateSingleHisto(physics,triggerClassName,"PEtaMuMinus", "#mu- P distribution",nbinsEta,etaMin,etaMax,nbinsP,pMin,pMax);
488
489 Double_t chi2min = 0;
490 Double_t chi2max = 20;
491 Int_t nbinchi2 = GetNbins(chi2min,chi2max,0.1);
492
493 CreateSingleHisto(physics, triggerClassName, "Chi2MuPlus", "chisquare per NDF #mu+", nbinchi2, chi2min, chi2max);
494 CreateSingleHisto(physics, triggerClassName, "Chi2MuMinus", "chisquare per NDF #mu-", nbinchi2, chi2min, chi2max);
495
496 Double_t minvMin = 0;
497 Double_t minvMax = 16;
498 Int_t nMinvBins = GetNbins(minvMin,minvMax,0.05);
499
500 CreatePairHisto(physics,triggerClassName,"MinvUSPt", "#mu+#mu- inv. mass vs Pt",nbinsPt,ptMin,ptMax,nMinvBins,minvMin,minvMax);
501 CreatePairHisto(physics,triggerClassName,"MinvPPPt", "#mu+#mu+ inv. mass vs Pt",nbinsPt,ptMin,ptMax,nMinvBins,minvMin,minvMax);
502 CreatePairHisto(physics,triggerClassName,"MinvMMPt", "#mu-#mu- inv. mass vs Pt",nbinsPt,ptMin,ptMax,nMinvBins,minvMin,minvMax);
503
504
505 Double_t xmin = -40;
506 Double_t xmax = +40;
507 Int_t nbins = GetNbins(xmin,xmax,0.5);
508
509 CreateEventHisto(physics,triggerClassName,"Zvertex","z vertex",nbins,xmin,xmax);
510
511 xmin = -5;
512 xmax = 5;
513 nbins = GetNbins(xmin,xmax,0.01);
514
515 CreateEventHisto(physics,triggerClassName,"Xvertex","x vertex",nbins,xmin,xmax);
516 CreateEventHisto(physics,triggerClassName,"Yvertex","y vertex",nbins,xmin,xmax);
517 CreateEventHisto(physics,triggerClassName,"YXvertex","y vs x vertex",nbins,xmin,xmax,
518 nbins,xmin,xmax);
519
520 if (!fIsFromESD)
521 {
522
523 CreateEventHisto(physics,triggerClassName,"PileUpZvertex","pileup z vertex",nbins,xmin,xmax);
524
525 CreateEventHisto(physics,triggerClassName,"PileUpXvertex","pileup x vertex",nbins,xmin,xmax);
526 CreateEventHisto(physics,triggerClassName,"PileUpYvertex","pileup y vertex",nbins,xmin,xmax);
527
528 CreateEventHisto(physics,triggerClassName,"PileUpYXvertex","pileup y vs x vertex",nbins,xmin,xmax,
529 nbins,xmin,xmax);
530
531 }
532 CreateEventHisto(physics,triggerClassName,"Nevents","number of events",2,-0.5,1.5);
533
534 xmin = 0;
535 xmax = 3564;
853c7f5f 536 nbins = GetNbins(xmin,xmax,1.0);
5eabea87 537
538 CreateEventHisto(physics,triggerClassName,"BCX","bunch-crossing ids",nbins,xmin-0.5,xmax-0.5);
539
540 xmin = -200;
541 xmax = +200;
542 nbins = GetNbins(xmin,xmax,1.0);
543
544 CreateSingleHisto(physics,triggerClassName,"XYdcaMuPlus","#mu+ DCA non bending vs bending;dcaY;dcaX",nbins,xmin,xmax,nbins,xmin,xmax);
545 CreateSingleHisto(physics,triggerClassName,"XYdcaMuMinus","#mu- DCA non bending vs bending;dcaY;dcaX",nbins,xmin,xmax,nbins,xmin,xmax);
546
547 xmin = 0;
548 xmax = 300;
549 nbins = GetNbins(xmin,xmax,1.0);
550
551 CreateSingleHisto(physics,triggerClassName,"dcaP23MuPlus","#mu+ DCA vs P for 2-3 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
552 CreateSingleHisto(physics,triggerClassName,"dcaP23MuMinus","#mu- DCA vs P for 2-3 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
553 CreateSingleHisto(physics,triggerClassName,"dcaP310MuPlus","#mu+ DCA vs P for 3-10 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
554 CreateSingleHisto(physics,triggerClassName,"dcaP310MuMinus","#mu- DCA vs P for 3-10 degrees;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
555
556 CreateSingleHisto(physics,triggerClassName,"dcaPwPtCut23MuPlus","#mu+ DCA vs P for 2-3 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
557 CreateSingleHisto(physics,triggerClassName,"dcaPwPtCut23MuMinus","#mu- DCA vs P for 2-3 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
558 CreateSingleHisto(physics,triggerClassName,"dcaPwPtCut310MuPlus","#mu+ DCA vs P for 3-10 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
559 CreateSingleHisto(physics,triggerClassName,"dcaPwPtCut310MuMinus","#mu- DCA vs P for 3-10 degrees with Pt Cut;P (GeV);DCA (cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
560
561 xmin = 0;
562 xmax = 20000;
563 nbins = GetNbins(xmin,xmax,100.0);
564
565 CreateSingleHisto(physics,triggerClassName,"PDCAcorrP23MuPlus","#mu+ PxDCAcorr vs P for 2-3 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
566 CreateSingleHisto(physics,triggerClassName,"PDCAcorrP23MuMinus","#mu- PxDCAcorr vs P for 2-3 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
567 CreateSingleHisto(physics,triggerClassName,"PDCAcorrP310MuPlus","#mu+ PxDCAcorr vs P for 3-10 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
568 CreateSingleHisto(physics,triggerClassName,"PDCAcorrP310MuMinus","#mu- PxDCAcorr vs P for 3-10 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
569
570 CreateSingleHisto(physics,triggerClassName,"PDCAcutP23MuPlus","#mu+ PxDCAcut vs P for 2-3 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
571 CreateSingleHisto(physics,triggerClassName,"PDCAcutP23MuMinus","#mu- PxDCAcut vs P for 2-3 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
572 CreateSingleHisto(physics,triggerClassName,"PDCAcutP310MuPlus","#mu+ PxDCAcut vs P for 3-10 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
573 CreateSingleHisto(physics,triggerClassName,"PDCAcutP310MuMinus","#mu- PxDCAcut vs P for 3-10 degrees;P (GeV/c);P.DCA (GeV.cm)",nbinsP,pMin,pMax,nbins,xmin,xmax);
574
575
576 if ( fIsFromESD )
577 {
578 xmin = -80;
579 xmax = 80;
580 nbins = GetNbins(xmin,xmax,0.1);
581 CreateEventHisto(physics,triggerClassName,"V0Time","Mean Time V0C versus V0A;Time V0A (ns);Time V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
582
583 xmin = 0;
584 xmax = 20000;
585 nbins = GetNbins(xmin,xmax,10);
586
587 CreateEventHisto(physics,triggerClassName,"V0Amplitude","V0Amult+V0Cmult",nbins,xmin,xmax);
588 }
589
590 if ( fAA )
591 {
592 Double_t* vbins = new Double_t[fCentralityLimits.size()+1];
593
594 vbins[0] = 0.0;
595
596 for ( std::vector<double>::size_type i = 0; i < fCentralityLimits.size(); ++i )
597 {
598 vbins[i+1] = fCentralityLimits[i];
599 }
600
601 TH1* h = new TH1F("Centrality","Centrality",fCentralityLimits.size(),vbins);
602
603 delete[] vbins;
604
605 fHistogramCollection->Adopt(physics,triggerClassName,h);
606
607 }
608
609 xmin = 0;
610 xmax = 5000;
611 nbins = GetNbins(xmin,xmax,10);
612
613 CreateEventHisto(physics,triggerClassName,"Tracklets","Number of tracklets",nbins,xmin,xmax);
614
615}
616
617
618//_____________________________________________________________________________
619Double_t AliAnalysisMuMu::MuonMass2() const
620{
621 /// A usefull constant
622 static Double_t m2 = 1.11636129640000012e-02; // using a constant here as the line below is a problem for CINT...
623// static Double_t m2 = TDatabasePDG::Instance()->GetParticle("mu-")->Mass()*TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
624 return m2;
625}
626
627//_____________________________________________________________________________
628void AliAnalysisMuMu::FinishTaskOutput()
629{
630 /// prune empty histograms BEFORE mergin, in order to save some bytes...
631
632 if ( fHistogramCollection )
633 {
634 UInt_t size = fHistogramCollection->EstimateSize(kFALSE);
635
636 AliInfo(Form("size before prune histograms = %5.1f MB",size/1024.0/1024.0));
637
638 fHistogramCollection->PruneEmptyHistograms();
639
640 AliInfo(Form("size after prune histograms = %5.1f MB",size/1024.0/1024.0));
641
642 }
643}
644
645//_____________________________________________________________________________
646TH1* AliAnalysisMuMu::Histo(const char* physics, const char* triggerClassName, const char* histoname)
647{
648 /// Get one histo back
649 return fHistogramCollection ? fHistogramCollection->Histo(physics,triggerClassName,histoname) : 0x0;
650}
651
652//_____________________________________________________________________________
653TH1* AliAnalysisMuMu::Histo(const char* physics, const char* histoname)
654{
655 /// Get one histo back
656 return fHistogramCollection ? fHistogramCollection->Histo(physics,histoname) : 0x0;
657}
658
659//_____________________________________________________________________________
660TH1* AliAnalysisMuMu::Histo(const char* physics,
661 const char* triggerClassName,
662 const char* what,
663 const char* histoname)
664{
665 /// Get one histo back
666 return fHistogramCollection ? fHistogramCollection->Histo(physics,triggerClassName,what,histoname) : 0x0;
667}
668
669//_____________________________________________________________________________
670TH1* AliAnalysisMuMu::Histo(const char* physics,
671 const char* triggerClassName,
672 const char* cent,
673 const char* what,
674 const char* histoname)
675{
676 /// Get one histo back
677
678 return fHistogramCollection ? fHistogramCollection->Histo(physics,triggerClassName,cent,what,histoname) : 0x0;
679}
680
681//_____________________________________________________________________________
682void AliAnalysisMuMu::NotifyRun()
683{
684 /// Called at each change of run ?
685 AliInfo(Form("Run %09d File %s",fCurrentRunNumber,CurrentFileName()));
686}
687
688//_____________________________________________________________________________
689void
690AliAnalysisMuMu::Print(Option_t* /*opt*/) const
691{
692 /// Print the definition of this analysis
693
694 cout << ClassName() << " - " << GetName() << " - " << ( fAA ? "PbPb mode" : "pp mode" ) << endl;
695
696 if ( !fSingleTrackCutNames || !fSingleTrackCutNames )
697 {
698 cout << "No single track cut defined yet" << endl;
699 }
700 else
701 {
702 TIter next(fSingleTrackCutNames);
703 TObjString* str;
704
705 while ( ( str = static_cast<TObjString*>(next()) ) )
706 {
707 cout << Form("SINGLE CUT %20s MASK %x",str->String().Data(),str->GetUniqueID()) << endl;
708 }
709 }
710
711 if ( !fPairTrackCutNames || !fPairTrackCutNames )
712 {
713 cout << "No track pair cut defined yet" << endl;
714 }
715 else
716 {
717 TIter next2(fPairTrackCutNames);
718 TObjString* str;
719
720 while ( ( str = static_cast<TObjString*>(next2()) ) )
721 {
722 UInt_t single(0);
723 UInt_t pair(0);
724 DecodePairCutMask(str->GetUniqueID(),single,pair);
725
726 cout << Form("PAIR CUT %20s UID %x SINGLE MASK %x PAIR MASK %x",str->String().Data(),str->GetUniqueID(),single,pair) << endl;
727 }
728 }
729
730 if ( !fTriggerClasses || !fTriggerClasses->First() )
731 {
732 cout << "No trigger classes defined yet" << endl;
733 }
734 else
735 {
736 cout << "Trigger classes that will be considered:" << endl;
737 TIter next(fTriggerClasses);
738 TObjString* s;
739
740 while ( ( s = static_cast<TObjString*>(next()) ) )
741 {
742 cout << s->String().Data() << endl;
743 }
744 }
745}
746
747//_____________________________________________________________________________
748void
749AliAnalysisMuMu::Terminate(Option_t *)
750{
751 /// Called once at the end of the query
752 /// Just a simple printout of the stat we analyse and how many histograms
753 /// we got
754
755 fOutput = dynamic_cast<TList*>(GetOutputData(1));
756
757 if (!fOutput) return;
758
759 fHistogramCollection = dynamic_cast<AliHistogramCollection*>(fOutput->FindObject("mumu"));
760
761 if (!fHistogramCollection)
762 {
763 AliError("Could not find back histogram collection in output...");
764 return;
765 }
766
767 fHistogramCollection->PruneEmptyHistograms();
768
769 UInt_t size2 = fHistogramCollection->EstimateSize();
770
771 AliInfo(Form("size after prune histograms = %5.1f MB",size2/1024.0/1024.0));
772
773 BeautifyHistos();
774
775 fHistogramCollection->Print("*Minv*");
776
777 fEventCounters = dynamic_cast<AliCounterCollection*>(fOutput->FindObject("eventCounters"));
778
779 if (!fEventCounters)
780 {
781 AliError("Could not find back counters in output...");
782 return;
783 }
784
785 fEventCounters->Print();
786}
787
788
789//_____________________________________________________________________________
790void AliAnalysisMuMu::UserExec(Option_t* opt)
791{
792 /// Executed at each event
793
794 MuUserExec(opt);
795
796 // Post output data.
797 PostData(1, fOutput);
798}
799
800//_____________________________________________________________________________
801void AliAnalysisMuMu::UserCreateOutputObjects()
802{
803 // Create histograms
804 // Called once
805
806 fTriggerClasses->Print();
807
808 fOutput = new TList;
809 fOutput->SetOwner(kTRUE);
810
811 fHistogramCollection = new AliHistogramCollection("mumu");
812
813 fOutput->Add(fHistogramCollection);
814
815 // initialize event counters
816 fEventCounters = new AliCounterCollection("eventCounters");
817
818 TIter nextGSN(fGlobalEventSelectionNames);
819 TObjString* str;
820 TString eventRubric;
821 while ( ( str = static_cast<TObjString*>(nextGSN()) ) )
822 {
823 if ( eventRubric.Length() > 0 ) eventRubric += "/";
824 eventRubric += str->String();
825 }
826
827 fEventCounters->AddRubric("event", eventRubric.Data());
828
829 fEventCounters->AddRubric("trigger", 100);
830
831 fEventCounters->AddRubric("run", 1000000);
832
833 fEventCounters->Init();
834
835 fOutput->Add(fEventCounters);
836
837 // Post output data.
838 PostData(1, fOutput);
839}