AliPhysics  vAN-20150427 (e6e7aad)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskMuonQA.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
18 #include <Riostream.h>
19 
20 // ROOT includes
21 #include "TH1F.h"
22 #include "TH2F.h"
23 #include "TCanvas.h"
24 #include "TROOT.h"
25 #include "TString.h"
26 #include "TObjArray.h"
27 #include "TMath.h"
28 #include "TFile.h"
29 #include "TRegexp.h"
30 #include "TMap.h"
31 #include "TList.h"
32 #include "TObjString.h"
33 
34 // STEER includes
35 #include "AliESDEvent.h"
36 #include "AliESDMuonTrack.h"
37 #include "AliESDMuonCluster.h"
38 #include "AliESDInputHandler.h"
39 #include "AliESDVZERO.h"
40 
41 // ANALYSIS includes
42 #include "AliAnalysisDataSlot.h"
43 #include "AliAnalysisManager.h"
44 #include "AliAnalysisTaskMuonQA.h"
45 #include "AliCounterCollection.h"
46 #include "AliPhysicsSelection.h"
47 #include "AliTriggerAnalysis.h"
48 
49 // PWG includes
50 #include "AliAnalysisMuonUtility.h"
51 #include "AliMuonTrackCuts.h"
52 
53 using std::cout;
54 using std::endl;
55 
57 
58 const Int_t AliAnalysisTaskMuonQA::nCh = 10;
59 
60 const Int_t AliAnalysisTaskMuonQA::nDE = 1100;
61 
62 const Float_t AliAnalysisTaskMuonQA::dMax[5] = {176.6, 229.0, 308.84, 418.2, 522.0}; // cm
63 
64 //________________________________________________________________________
66  AliAnalysisTaskSE(),
67  fList(0x0),
68  fListExpert(0x0),
69  fListNorm(0x0),
70  fTrackCounters(0x0),
71  fEventCounters(0x0),
72  fSelectCharge(0),
73  fSelectPhysics(kFALSE),
74  fSelectTrigger(kFALSE),
75  fTriggerMask(0),
76  fSelectMatched(kFALSE),
77  fApplyAccCut(kFALSE),
78  fTrackCuts(0x0),
79  fMuonTrigIndex()
80 {
81  // Dummy constructor
82 }
83 
84 //________________________________________________________________________
86  AliAnalysisTaskSE(name),
87  fList(0x0),
88  fListExpert(0x0),
89  fListNorm(0x0),
90  fTrackCounters(0x0),
91  fEventCounters(0x0),
92  fSelectCharge(0),
93  fSelectPhysics(kFALSE),
94  fSelectTrigger(kFALSE),
95  fTriggerMask(0),
96  fSelectMatched(kFALSE),
97  fApplyAccCut(kFALSE),
98  fTrackCuts(new AliMuonTrackCuts("stdMuonCuts","stdMuonCuts")),
99  fMuonTrigIndex()
100 {
102 
103  // Output slot #1 writes into a TObjArray container
104  DefineOutput(1,TObjArray::Class());
105  // Output slot #2 writes into a TObjArray container
106  DefineOutput(2,TObjArray::Class());
107  // Output slot #3 writes track counters
108  DefineOutput(3,AliCounterCollection::Class());
109  // Output slot #4 writes event counters
110  DefineOutput(4,AliCounterCollection::Class());
111  // Output slot #5 writes normalized histograms
112  DefineOutput(5,TObjArray::Class());
113 
114  fTrackCuts->SetFilterMask(AliMuonTrackCuts::kMuEta | AliMuonTrackCuts::kMuThetaAbs | AliMuonTrackCuts::kMuPdca );
115  fTrackCuts->SetAllowDefaultParams(kTRUE);
116 }
117 
118 //________________________________________________________________________
120 {
122  if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
123  delete fList;
124  delete fListExpert;
125  delete fTrackCounters;
126  delete fEventCounters;
127  delete fListNorm;
128  }
129  delete fTrackCuts;
130 }
131 
132 
133 //___________________________________________________________________________
135 {
137  fTrackCuts->SetRun(fInputHandler);
138 }
139 
140 
141 //___________________________________________________________________________
142 void AliAnalysisTaskMuonQA::SetTrackCuts(AliMuonTrackCuts* trackCuts)
143 {
145  if ( fTrackCuts ) delete fTrackCuts;
146  fTrackCuts = new AliMuonTrackCuts(*trackCuts);
147 }
148 
149 
150 //___________________________________________________________________________
152 {
154 
155  // create histograms
156  fList = new TObjArray(2000);
157  fList->SetOwner();
158  fListExpert = new TObjArray(2000);
159  fListExpert->SetOwner();
160 
161  // event info
162  TH1F* hNTracks = new TH1F("hNTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
163  fList->AddAtAndExpand(hNTracks, kNTracks);
164 
165  Int_t muonTrigIndex[] = { AliVEvent::kMuonUnlikePB, AliVEvent::kMuonLikePB, AliVEvent::kMUSHPB, AliVEvent::kMuonUnlikePB | AliVEvent::kMuonLikePB, AliVEvent::kMuonUnlikePB | AliVEvent::kMUSHPB, AliVEvent::kMuonLikePB | AliVEvent::kMUSHPB, AliVEvent::kMuonUnlikePB | AliVEvent::kMuonLikePB | AliVEvent::kMUSHPB};
166  const Int_t nTrigIndexes = sizeof(muonTrigIndex)/sizeof(muonTrigIndex[0]);
167  fMuonTrigIndex.Set(nTrigIndexes, muonTrigIndex);
168  TString label[nTrigIndexes] = {"Unlike","Like", "Single Hpt","Like&Unlike","Unlike&Hpt","Like&Hpt","Unlike&Like&Hpt"};
169  TH1I* hMuonTriggers = new TH1I("hMuonTriggers", "Muon triggers", nTrigIndexes, -0.5, -0.5+(Double_t)nTrigIndexes);
170  for(Int_t ibin=0; ibin<nTrigIndexes; ibin++) hMuonTriggers->GetXaxis()->SetBinLabel(ibin+1,label[ibin].Data());
171  fList->AddAtAndExpand(hMuonTriggers, kMuonTrig);
172 
173  //track info
174  TH1F* hMatchTrig = new TH1F("hMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
175  fList->AddAtAndExpand(hMatchTrig, kMatchTrig);
176 
177  TH1F* hSign = new TH1F("hSign", "track sign;sign", 3, -1.5, 1.5);
178  fList->AddAtAndExpand(hSign, kSign);
179 
180  TH1F* hDCA = new TH1F("hDCA", "DCA distribution;DCA (cm)", 500, 0., 500.);
181  fList->AddAtAndExpand(hDCA, kDCA);
182 
183  TH1F* hP = new TH1F("hP", "momentum distribution;p (GeV/c)", 300, 0., 300.);
184  fList->AddAtAndExpand(hP, kP);
185 
186  TH1F* hPMuPlus = new TH1F("hPMuPlus", "momentum distribution of #mu^{+};p (GeV/c)", 300, 0., 300.);
187  fList->AddAtAndExpand(hPMuPlus, kPMuPlus);
188 
189  TH1F* hPMuMinus = new TH1F("hPMuMinus", "momentum distribution of #mu^{-};p (GeV/c)", 300, 0., 300.);
190  fList->AddAtAndExpand(hPMuMinus, kPMuMinus);
191 
192  Int_t nPtBins = 300;
193  Double_t ptMin = 0., ptMax = 30.;
194 
195  TH1F* hPt = new TH1F("hPt", "transverse momentum distribution;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
196  fList->AddAtAndExpand(hPt, kPt);
197 
198  TH1F* hPtMuPlus = new TH1F("hPtMuPlus", "transverse momentum distribution of #mu^{+};p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
199  fList->AddAtAndExpand(hPtMuPlus, kPtMuPlus);
200 
201  TH1F* hPtMuMinus = new TH1F("hPtMuMinus", "transverse momentum distribution of #mu^{-};p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
202  fList->AddAtAndExpand(hPtMuMinus, kPtMuMinus);
203 
204  TH1F* hRapidity = new TH1F("hRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
205  fList->AddAtAndExpand(hRapidity, kRapidity);
206 
207  TH1F* hThetaX = new TH1F("hThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
208  fList->AddAtAndExpand(hThetaX, kThetaX);
209 
210  TH1F* hThetaY = new TH1F("hThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
211  fList->AddAtAndExpand(hThetaY, kThetaY);
212 
213  TH1F* hChi2 = new TH1F("hChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
214  fList->AddAtAndExpand(hChi2, kChi2);
215 
216  TH1F* hProbChi2 = new TH1F("hProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
217  fList->AddAtAndExpand(hProbChi2, kProbChi2);
218 
219  // cluster info
220  TH1F* hNClustersPerTrack = new TH1F("hNClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
221  fList->AddAtAndExpand(hNClustersPerTrack, kNClustersPerTrack);
222 
223  TH1F* hNChamberHitPerTrack = new TH1F("hNChamberHitPerTrack", "number of chambers hit per track;n_{chamber hit}", 15, 0., 15.);
224  fList->AddAtAndExpand(hNChamberHitPerTrack, kNChamberHitPerTrack);
225 
226  // Matched tracks info
227  TH1F* hPtMatchLpt = new TH1F("hPtMatchLpt", "transverse momentum distribution matching Lpt;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
228  fList->AddAtAndExpand(hPtMatchLpt, kPtMatchLpt);
229 
230  TH1F* hPtMatchHpt = new TH1F("hPtMatchHpt", "transverse momentum distribution matching Hpt;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
231  fList->AddAtAndExpand(hPtMatchHpt, kPtMatchHpt);
232 
233  TH1F* hPtMuPlusMatchLpt = new TH1F("hPtMuPlusMatchLpt", "transverse momentum distribution of #mu^{+} matching Lpt;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
234  fList->AddAtAndExpand(hPtMuPlusMatchLpt, kPtMuPlusMatchLpt);
235 
236  TH1F* hPtMuPlusMatchHpt = new TH1F("hPtMuPlusMatchHpt", "transverse momentum distribution of #mu^{+} matching Hpt;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
237  fList->AddAtAndExpand(hPtMuPlusMatchHpt, kPtMuPlusMatchHpt);
238 
239  TH1F* hPtMuMinusMatchLpt = new TH1F("hPtMuMinusMatchLpt", "transverse momentum distribution of #mu^{-} matching Lpt;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
240  fList->AddAtAndExpand(hPtMuMinusMatchLpt, kPtMuMinusMatchLpt);
241 
242  TH1F* hPtMuMinusMatchHpt = new TH1F("hPtMuMinusMatchHpt", "transverse momentum distribution of #mu^{-} matching Hpt;p_{t} (GeV/c)", nPtBins, ptMin, ptMax);
243  fList->AddAtAndExpand(hPtMuMinusMatchHpt, kPtMuMinusMatchHpt);
244 
245  TH1F* hNClustersPerCh = new TH1F("hNClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
246  hNClustersPerCh->Sumw2();
247  hNClustersPerCh->SetOption("P");
248  hNClustersPerCh->SetMarkerStyle(kFullDotMedium);
249  hNClustersPerCh->SetMarkerColor(kBlue);
250  fListExpert->AddAtAndExpand(hNClustersPerCh, kNClustersPerCh);
251 
252  TH1F* hNClustersPerDE = new TH1F("hNClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
253  hNClustersPerDE->Sumw2();
254  hNClustersPerDE->SetOption("P");
255  hNClustersPerDE->SetMarkerStyle(kFullDotMedium);
256  hNClustersPerDE->SetMarkerColor(kBlue);
257  fListExpert->AddAtAndExpand(hNClustersPerDE, kNClustersPerDE);
258 
259  for (Int_t i = 0; i < nCh; i++) {
260  Float_t rMax = 0.5*dMax[i/2];
261  TH2F* hClusterHitMapInCh = new TH2F(Form("hClusterHitMapInCh%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
262  100, -rMax, rMax, 100, -rMax, rMax);
263  fListExpert->AddAtAndExpand(hClusterHitMapInCh, kClusterHitMapInCh+i);
264 
265  TH1F* hClusterChargeInCh = new TH1F(Form("hClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC)",i+1), 100, 0., 1000.);
266  fListExpert->AddAtAndExpand(hClusterChargeInCh, kClusterChargeInCh+i);
267 
268  TH1F* hClusterSizeInCh = new TH1F(Form("hClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
269  fListExpert->AddAtAndExpand(hClusterSizeInCh, kClusterSizeInCh+i);
270  }
271 
272  TH2F* hClusterChargePerDE = new TH2F("hClusterChargePerDE", "cluster charge distribution per DE;DetElem ID;charge (fC)", nDE+1, -0.5, nDE+0.5, 100, 0., 1000.);
273  fListExpert->AddAtAndExpand(hClusterChargePerDE, kClusterChargePerDE);
274 
275  TH2F* hClusterSizePerDE = new TH2F("hClusterSizePerDE", "cluster size distribution per DE;DetElem ID;size (n_{pads})", nDE+1, -0.5, nDE+0.5, 200, 0., 200.);
276  fListExpert->AddAtAndExpand(hClusterSizePerDE, kClusterSizePerDE);
277 
278  // initialize track counters
279  fTrackCounters = new AliCounterCollection("trackCounters");
280  fTrackCounters->AddRubric("track", "trackeronly/triggeronly/matched/notrack");
281  fTrackCounters->AddRubric("trigger", 1000000);
282  fTrackCounters->AddRubric("run", 1000000);
283  fTrackCounters->AddRubric("selected", "yes/no");
284  fTrackCounters->AddRubric("triggerRO", "good/bad");
285  fTrackCounters->AddRubric("v0mult", "low/int/high/any");
286  fTrackCounters->AddRubric("charge", "pos/neg/any");
287  fTrackCounters->AddRubric("pt", "low/high/any");
288  fTrackCounters->AddRubric("acc", "in/out");
289  fTrackCounters->AddRubric("tagTrack", "beamGas/good");
290  fTrackCounters->AddRubric("t0pileup", "yes/no");
291  fTrackCounters->AddRubric("bgID", "yes/no");
292  fTrackCounters->AddRubric("spdpileup", "yes/no");
293  fTrackCounters->Init();
294 
295 
296  // initialize event counters
297  fEventCounters = new AliCounterCollection("eventCounters");
298  fEventCounters->AddRubric("event", "muon/any");
299  fEventCounters->AddRubric("trigger", 1000000);
300  fEventCounters->AddRubric("run", 1000000);
301  fEventCounters->AddRubric("selected", "yes/no");
302  fEventCounters->AddRubric("triggerRO", "good/bad");
303  fEventCounters->AddRubric("v0mult", "low/int/high/any");
304  fEventCounters->AddRubric("t0pileup", "yes/no");
305  fEventCounters->AddRubric("spdpileup", "yes/no");
306  fEventCounters->AddRubric("bgID", "yes/no");
307  fEventCounters->Init();
308 
309  // Post data at least once per task to ensure data synchronisation (required for merging)
310  PostData(1, fList);
311  PostData(2, fListExpert);
312  PostData(3, fTrackCounters);
313  PostData(4, fEventCounters);
314 }
315 
316 //________________________________________________________________________
318 {
320 
321  AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(InputEvent());
322  if (!fESD) {
323  Printf("ERROR: fESD not available");
324  return;
325  }
326 
327  //Flag for T0Pileup, SPDPileup and bgID (SPD cluster vs tracklet)
328  Bool_t t0PileUp = kFALSE, spdPileUp = kFALSE, bgID = kFALSE;
329  spdPileUp = fESD->IsPileupFromSPDInMultBins();
330  AliPhysicsSelection *physicsSelection = (AliPhysicsSelection*)((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetEventSelection();
331  if ( physicsSelection ) {
332  AliTriggerAnalysis * triggerAnalysis = (AliTriggerAnalysis*)physicsSelection->GetTriggerAnalysis();
333  if ( triggerAnalysis ) {
334  t0PileUp = triggerAnalysis->EvaluateTrigger(fESD, (AliTriggerAnalysis::Trigger) (AliTriggerAnalysis::kOfflineFlag | AliTriggerAnalysis::kT0Pileup));
335  bgID = triggerAnalysis->EvaluateTrigger(fESD, (AliTriggerAnalysis::Trigger) (AliTriggerAnalysis::kSPDClsVsTrkBG | AliTriggerAnalysis::kOfflineFlag));
336  }
337  }
338 
339  UInt_t geomAccMask = ( AliMuonTrackCuts::kMuEta | AliMuonTrackCuts::kMuThetaAbs );
340 
341  // check physics selection
342  UInt_t triggerWord = (fInputHandler) ? fInputHandler->IsEventSelected() : 0;
343  Bool_t isPhysicsSelected = (triggerWord != 0);
344  TString selected = isPhysicsSelected ? "selected:yes" : "selected:no";
345  selected += t0PileUp ? "/t0pileup:yes" : "/t0pileup:no";
346  selected += bgID ? "/bgID:yes" : "/bgID:no";
347  selected += spdPileUp ? "/spdpileup:yes" : "/spdpileup:no";
348 
349  // fill muon trigger cases
350  for ( Int_t idx=0; idx < fMuonTrigIndex.GetSize(); idx++ ) {
351  UInt_t currMask = (UInt_t) fMuonTrigIndex[idx];
352  if ( ( triggerWord & currMask ) == currMask ) ((TH1I*)fList->UncheckedAt(kMuonTrig))->Fill(idx);
353  }
354 
355  // check trigger selection
356  TString FiredTriggerClasses = fESD->GetFiredTriggerClasses();
357  Bool_t isTriggerSelected = ((triggerWord & fTriggerMask) != 0);
358 
359  // get the V0 multiplicity (except for p-p)
360  AliESDVZERO* v0Data = fESD->GetVZEROData();
361  Float_t v0Mult = 0.;
362  const Int_t nV0MultRange = 4;
363  const Int_t nCollType = 2;
364  //define rough V0 mult. range (~ 80%, 60%, 10%, 0%)
365  Int_t v0MultRange[nCollType][nV0MultRange]= {{239,1165,12191,20633},{25,60,200,800}};
366  Int_t iCollType = 0;
367 
368  if (v0Data) {
369  if (!strcmp(fESD->GetBeamType(),"A-A")){
370  iCollType = 0;
371  for (Int_t i = 0 ; i < 64 ; i++) v0Mult += v0Data->GetMultiplicity(i);
372  }
373  else if (!strcmp(fESD->GetBeamType(),"p-A")){
374  iCollType = 1;
375  for (Int_t i = 0 ; i < 32 ; i++) v0Mult += v0Data->GetMultiplicityV0A(i);
376  }
377  else if (!strcmp(fESD->GetBeamType(),"A-p")){
378  iCollType = 1;
379  for (Int_t i = 0 ; i < 32 ; i++) v0Mult += v0Data->GetMultiplicityV0C(i);
380  }
381  }
382 
383  TList listV0MultKey;
384  listV0MultKey.SetOwner();
385  listV0MultKey.AddLast(new TObjString("v0mult:any"));
386  if (v0Mult >= v0MultRange[iCollType][0] && v0Mult < v0MultRange[iCollType][1]) listV0MultKey.AddLast(new TObjString("v0mult:low"));
387  else if (v0Mult >= v0MultRange[iCollType][1] && v0Mult < v0MultRange[iCollType][2]) listV0MultKey.AddLast(new TObjString("v0mult:int"));
388  else if (v0Mult >= v0MultRange[iCollType][2] && v0Mult < v0MultRange[iCollType][3]) listV0MultKey.AddLast(new TObjString("v0mult:high"));
389 
390  TIter nextV0MultKey(&listV0MultKey);
391 
392  // first loop over tracks to check for trigger readout problem
393  Int_t maxTriggerRO = (!strcmp(fESD->GetBeamType(),"p-p")) ? 10 : 1000;
394  Int_t nTracks = (Int_t) fESD->GetNumberOfMuonTracks();
395  Int_t nTriggerTracks = 0;
396  for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack)
397  if (fESD->GetMuonTrack(iTrack)->ContainTriggerData()) nTriggerTracks++;
398  TString triggerRO = (nTriggerTracks < maxTriggerRO) ? "triggerRO:good" : "triggerRO:bad";
399 
400  // --- fill event counters ---
401 
402  // build the list of trigger cases
403  TList* triggerCases = BuildListOfAllTriggerCases(FiredTriggerClasses);
404 
405  // loop over trigger cases
406  TObjString* triggerKey = 0x0;
407  TIter nextTriggerCase(triggerCases);
408  while ((triggerKey = static_cast<TObjString*>(nextTriggerCase()))) {
409 
410  // loop over V0Mult cases
411  TObjString* v0MultKey = 0x0;
412  nextV0MultKey.Reset();
413  while ((v0MultKey = static_cast<TObjString*>(nextV0MultKey()))) {
414 
415  // any event
416  fEventCounters->Count(Form("event:any/%s/run:%d/%s/%s/%s", triggerKey->GetName(), fCurrentRunNumber, selected.Data(), triggerRO.Data(), v0MultKey->GetName()));
417 
418  // muon event
419  if (nTracks > 0) {
420  fEventCounters->Count(Form("event:muon/%s/run:%d/%s/%s/%s", triggerKey->GetName(), fCurrentRunNumber, selected.Data(), triggerRO.Data(), v0MultKey->GetName()));
421  }
422  else {
423  // fill track counter in case of no muon track
424  fTrackCounters->Count(Form("%s/%s/run:%d/%s/%s/%s/%s/%s/%s/%s", "track:notrack", triggerKey->GetName(),
425  fCurrentRunNumber,selected.Data(), "charge:any", "pt:any", "triggerRO:bad",
426  v0MultKey->GetName(), "acc:out", "tagTrack:good"));
427  }
428 
429  }
430 
431  }
432 
433  // second loop over tracks to fill histograms and track counters
434  Int_t nSelectedTrackerTracks = 0;
435  Int_t nSelectedTrackMatchTrig = 0;
436  Int_t nPVTracks = fESD->GetPrimaryVertex()->GetNContributors();
437 
438  for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
439 
440  // get the ESD track
441  AliESDMuonTrack* esdTrack = fESD->GetMuonTrack(iTrack);
442 
443  // --- fill track counters ---
444 
445  // define the key words
446  TString trackKey = "track:";
447  TString accKey = "acc:";
448  Bool_t isBeamGas = kFALSE;
449  TList chargeKeyList;
450  chargeKeyList.SetOwner();
451  chargeKeyList.Add(new TObjString("charge:any"));
452  TList ptKeyList;
453  ptKeyList.SetOwner();
454  ptKeyList.Add(new TObjString("pt:any"));
455 
456  if (esdTrack->ContainTrackerData()) {
457 
458  if (esdTrack->ContainTriggerData()) trackKey += "matched";
459  else trackKey += "trackeronly";
460 
461  Short_t trackCharge = esdTrack->Charge();
462  TString chargeKey = "charge:";
463  chargeKey += ( trackCharge < 0 ) ? "neg" : "pos";
464  chargeKeyList.Add(new TObjString(chargeKey));
465 
466  UInt_t mask = fTrackCuts->GetSelectionMask(esdTrack);
467  Bool_t passGeomAccCuts = ( ( mask & geomAccMask ) == geomAccMask );
468  accKey += ( passGeomAccCuts ) ? "in" : "out";
469  if ( passGeomAccCuts && nPVTracks>0 ) {
470  Double_t trackPt = esdTrack->Pt();
471  if ( trackPt > 1. ) ptKeyList.Add(new TObjString("pt:low"));
472  if ( trackPt > 2. ) ptKeyList.Add(new TObjString("pt:high"));;
473  }
474  if ( ( mask & AliMuonTrackCuts::kMuPdca ) == 0 ) isBeamGas = kTRUE;
475  } else {
476 
477  trackKey += "triggeronly";
478  accKey += "out"; // ghost are labelled out of the acceptance
479 
480  }
481 
482  TString tagKey = "tagTrack:";
483  tagKey += ( isBeamGas ) ? "beamGas" : "good";
484 
485  // loop over trigger cases and fill counters
486  nextTriggerCase.Reset();
487  while ((triggerKey = static_cast<TObjString*>(nextTriggerCase()))) {
488 
489  // loop over V0Mult cases
490  TObjString* v0MultKey = 0x0;
491  nextV0MultKey.Reset();
492  while ((v0MultKey = static_cast<TObjString*>(nextV0MultKey()))) {
493 
494  for ( Int_t icharge=0; icharge<chargeKeyList.GetEntries(); icharge++ ) {
495  for ( Int_t ipt=0; ipt<ptKeyList.GetEntries(); ipt++ ) {
496  fTrackCounters->Count(Form("%s/%s/run:%d/%s/%s/%s/%s/%s/%s/%s", trackKey.Data(), triggerKey->GetName(), fCurrentRunNumber,
497  selected.Data(), chargeKeyList.At(icharge)->GetName(), ptKeyList.At(ipt)->GetName(),
498  triggerRO.Data(), v0MultKey->GetName(), accKey.Data(), tagKey.Data()));
499  }
500  }
501  }
502 
503  }
504 
505  // --- apply selections and fill histograms with selected tracks ---
506 
507  // remove "ghost"
508  if (!esdTrack->ContainTrackerData()) continue;
509 
510  // select on "physics" before filling histograms
511  if (fSelectPhysics && !isPhysicsSelected) continue;
512 
513  // select on trigger before filling histograms
514  if (fSelectTrigger && !isTriggerSelected) continue;
515 
516  // select on track charge
517  if (fSelectCharge*esdTrack->Charge() < 0) continue;
518 
519  // select on track matching
520  if (fSelectMatched && !esdTrack->ContainTriggerData()) continue;
521 
522  // skip tracks that do not pass the acceptance cuts if required
523  if (fApplyAccCut && accKey.EndsWith("out")) continue;
524 
525  nSelectedTrackerTracks++;
526  if (esdTrack->ContainTriggerData()) nSelectedTrackMatchTrig++;
527 
528  Double_t trackP = esdTrack->P();
529  Double_t trackPt = esdTrack->Pt();
530  Short_t trackCharge = esdTrack->Charge();
531  ((TH1F*)fList->UncheckedAt(kP))->Fill(trackP);
532  ((TH1F*)fList->UncheckedAt(kPt))->Fill(trackPt);
533  Bool_t matchTrigLpt = (esdTrack->GetMatchTrigger()>=2);
534  Bool_t matchTrigHpt = (esdTrack->GetMatchTrigger()>=3);
535  if ( matchTrigLpt ) ((TH1F*)fList->UncheckedAt(kPtMatchLpt))->Fill(trackPt);
536  if ( matchTrigHpt ) ((TH1F*)fList->UncheckedAt(kPtMatchHpt))->Fill(trackPt);
537  if (trackCharge < 0) {
538  ((TH1F*)fList->UncheckedAt(kPMuMinus))->Fill(trackP);
539  ((TH1F*)fList->UncheckedAt(kPtMuMinus))->Fill(trackPt);
540  if ( matchTrigLpt ) ((TH1F*)fList->UncheckedAt(kPtMuMinusMatchLpt))->Fill(trackPt);
541  if ( matchTrigHpt ) ((TH1F*)fList->UncheckedAt(kPtMuMinusMatchHpt))->Fill(trackPt);
542  } else {
543  ((TH1F*)fList->UncheckedAt(kPMuPlus))->Fill(trackP);
544  ((TH1F*)fList->UncheckedAt(kPtMuPlus))->Fill(trackPt);
545  if ( matchTrigLpt ) ((TH1F*)fList->UncheckedAt(kPtMuPlusMatchLpt))->Fill(trackPt);
546  if ( matchTrigHpt ) ((TH1F*)fList->UncheckedAt(kPtMuPlusMatchHpt))->Fill(trackPt);
547  }
548  ((TH1F*)fList->UncheckedAt(kRapidity))->Fill(esdTrack->Y());
549  Int_t ndf = 2 * esdTrack->GetNHit() - 5;
550  ((TH1F*)fList->UncheckedAt(kChi2))->Fill(esdTrack->GetChi2()/ndf);
551  ((TH1F*)fList->UncheckedAt(kProbChi2))->Fill(TMath::Prob(esdTrack->GetChi2(),ndf));
552  ((TH1F*)fList->UncheckedAt(kThetaX))->Fill(ChangeThetaRange(esdTrack->GetThetaXUncorrected()));
553  ((TH1F*)fList->UncheckedAt(kThetaY))->Fill(ChangeThetaRange(esdTrack->GetThetaYUncorrected()));
554  ((TH1F*)fList->UncheckedAt(kNClustersPerTrack))->Fill(esdTrack->GetNHit());
555  ((TH1F*)fList->UncheckedAt(kSign))->Fill(trackCharge);
556  ((TH1F*)fList->UncheckedAt(kDCA))->Fill(esdTrack->GetDCA());
557 
558  Int_t nChamberHit = 0;
559  for (Int_t ich=0; ich<10; ich++) if (esdTrack->IsInMuonClusterMap(ich)) nChamberHit++;
560  ((TH1F*)fList->UncheckedAt(kNChamberHitPerTrack))->Fill(nChamberHit);
561 
562  // loop over clusters
563  for (Int_t icl=0; icl<esdTrack->GetNClusters(); icl++) {
564 
565  AliESDMuonCluster* esdCluster = esdTrack->GetESDEvent()->FindMuonCluster(esdTrack->GetClusterId(icl));
566 
567  Int_t chId = esdCluster->GetChamberId();
568  Int_t deId = esdCluster->GetDetElemId();
569 
570  ((TH1F*)fListExpert->UncheckedAt(kNClustersPerCh))->Fill(chId);
571  ((TH1F*)fListExpert->UncheckedAt(kNClustersPerDE))->Fill(deId);
572 
573  ((TH1F*)fListExpert->UncheckedAt(kClusterHitMapInCh+chId))->Fill(esdCluster->GetX(), esdCluster->GetY());
574 
575  ((TH1F*)fListExpert->UncheckedAt(kClusterChargeInCh+chId))->Fill(esdCluster->GetCharge());
576  ((TH1F*)fListExpert->UncheckedAt(kClusterChargePerDE))->Fill(deId, esdCluster->GetCharge());
577 
578  if (esdCluster->PadsStored()) { // discard clusters with pad not stored in ESD
579  ((TH1F*)fListExpert->UncheckedAt(kClusterSizeInCh+chId))->Fill(esdCluster->GetNPads());
580  ((TH1F*)fListExpert->UncheckedAt(kClusterSizePerDE))->Fill(deId, esdCluster->GetNPads());
581  }
582 
583  }
584 
585  }
586 
587  if ( (!fSelectPhysics || isPhysicsSelected) && (!fSelectTrigger || isTriggerSelected) ) {
588  ((TH1F*)fList->UncheckedAt(kNTracks))->Fill(nSelectedTrackerTracks);
589  ((TH1F*)fList->UncheckedAt(kMatchTrig))->Fill(nSelectedTrackMatchTrig);
590  }
591 
592  // clean memory
593  delete triggerCases;
594 
595  // Post final data. It will be written to a file with option "RECREATE"
596  PostData(1, fList);
597  PostData(2, fListExpert);
598  PostData(3, fTrackCounters);
599  PostData(4, fEventCounters);
600 }
601 
602 //________________________________________________________________________
604 {
608 
609  // global statistic
610  fTrackCounters = static_cast<AliCounterCollection*>(GetOutputData(3));
611  fEventCounters = static_cast<AliCounterCollection*>(GetOutputData(4));
613  if (!gROOT->IsBatch()) {
614  cout<<"whole statistics without selection:"<<endl;
615  fEventCounters->Print("trigger/event");
616  fTrackCounters->Print("trigger/track");
617  cout<<"whole statistics of selected events:"<<endl;
618  fEventCounters->Print("trigger/event","selected:yes");
619  fTrackCounters->Print("trigger/track","selected:yes");
620  new TCanvas();
621  fEventCounters->Draw("event","trigger","");
622  new TCanvas();
623  fTrackCounters->Draw("track","trigger","");
624  new TCanvas();
625  fEventCounters->Draw("event","trigger","selected:yes");
626  new TCanvas();
627  fTrackCounters->Draw("track","trigger","selected:yes");
628  }
629  }
630 
631  // recover output histograms
632  fList = static_cast<TObjArray*>(GetOutputData(1));
633  fListExpert = static_cast<TObjArray*>(GetOutputData(2));
634  if (!fList || !fListExpert) return;
635 
636  // create summary plots
637  fListNorm = new TObjArray(1000);
638  fListNorm->SetOwner();
639 
640  // mean/dispersion of cluster charge per chamber/DE
641  TH1F* hClusterChargePerChMean = new TH1F("hClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh, -0.5, nCh-0.5);
642  hClusterChargePerChMean->SetOption("P");
643  hClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
644  hClusterChargePerChMean->SetMarkerColor(kBlue);
645  fListNorm->AddAtAndExpand(hClusterChargePerChMean, kClusterChargePerChMean);
646 
647  TH1F* hClusterChargePerChSigma = new TH1F("hClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh, -0.5, nCh-0.5);
648  hClusterChargePerChSigma->SetOption("P");
649  hClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
650  hClusterChargePerChSigma->SetMarkerColor(kBlue);
651  fListNorm->AddAtAndExpand(hClusterChargePerChSigma, kClusterChargePerChSigma);
652 
653  TH1F* hClusterChargePerDEMean = new TH1F("hClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (fC)", nDE+1, -0.5, nDE+0.5);
654  hClusterChargePerDEMean->SetOption("P");
655  hClusterChargePerDEMean->SetMarkerStyle(kFullDotMedium);
656  hClusterChargePerDEMean->SetMarkerColor(kBlue);
657  fListNorm->AddAtAndExpand(hClusterChargePerDEMean, kClusterChargePerDEMean);
658 
659  TH1F* hClusterChargePerDESigma = new TH1F("hClusterChargePerDESigma", "cluster charge dispersion per DE;DetElem ID;#sigma_{charge} (fC)", nDE+1, -0.5, nDE+0.5);
660  hClusterChargePerDESigma->SetOption("P");
661  hClusterChargePerDESigma->SetMarkerStyle(kFullDotMedium);
662  hClusterChargePerDESigma->SetMarkerColor(kBlue);
663  fListNorm->AddAtAndExpand(hClusterChargePerDESigma, kClusterChargePerDESigma);
664 
665  // mean/dispersion of cluster size per chamber/DE
666  TH1F* hClusterSizePerChMean = new TH1F("hClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
667  hClusterSizePerChMean->SetOption("P");
668  hClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
669  hClusterSizePerChMean->SetMarkerColor(kBlue);
670  fListNorm->AddAtAndExpand(hClusterSizePerChMean, kClusterSizePerChMean);
671 
672  TH1F* hClusterSizePerChSigma = new TH1F("hClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
673  hClusterSizePerChSigma->SetOption("P");
674  hClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
675  hClusterSizePerChSigma->SetMarkerColor(kBlue);
676  fListNorm->AddAtAndExpand(hClusterSizePerChSigma, kClusterSizePerChSigma);
677 
678  TH1F* hClusterSizePerDEMean = new TH1F("hClusterSizePerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
679  hClusterSizePerDEMean->SetOption("P");
680  hClusterSizePerDEMean->SetMarkerStyle(kFullDotMedium);
681  hClusterSizePerDEMean->SetMarkerColor(kBlue);
682  fListNorm->AddAtAndExpand(hClusterSizePerDEMean, kClusterSizePerDEMean);
683 
684  TH1F* hClusterSizePerDESigma = new TH1F("hClusterSizePerDESigma", "cluster size dispersion per DE;DetElem ID;#sigma_{size} (n_{pads})", nDE+1, -0.5, nDE+0.5);
685  hClusterSizePerDESigma->SetOption("P");
686  hClusterSizePerDESigma->SetMarkerStyle(kFullDotMedium);
687  hClusterSizePerDESigma->SetMarkerColor(kBlue);
688  fListNorm->AddAtAndExpand(hClusterSizePerDESigma, kClusterSizePerDESigma);
689 
690  // normalize histograms
691  Float_t nTracks = ((TH1F*)fList->UncheckedAt(kNClustersPerTrack))->GetEntries();
692  if (nTracks > 0.) {
693  ((TH1F*)fListExpert->UncheckedAt(kNClustersPerCh))->Scale(1./nTracks);
694  ((TH1F*)fListExpert->UncheckedAt(kNClustersPerDE))->Scale(1./nTracks);
695  }
696  fListNorm->AddAtAndExpand(((TH1F*)fListExpert->UncheckedAt(kNClustersPerCh))->Clone(), kNClustersPerChPerTrack);
697  fListNorm->AddAtAndExpand(((TH1F*)fListExpert->UncheckedAt(kNClustersPerDE))->Clone(), kNClustersPerDEPerTrack);
698 
699  // fill summary plots per chamber
700  for (Int_t iCh = 0; iCh < nCh; iCh++) {
701 
702  TH1* hClusterChargeInCh = ((TH1F*)fListExpert->UncheckedAt(kClusterChargeInCh+iCh));
703  hClusterChargePerChMean->SetBinContent(iCh+1, hClusterChargeInCh->GetMean());
704  hClusterChargePerChMean->SetBinError(iCh+1, hClusterChargeInCh->GetMeanError());
705  hClusterChargePerChSigma->SetBinContent(iCh+1, hClusterChargeInCh->GetRMS());
706  hClusterChargePerChSigma->SetBinError(iCh+1, hClusterChargeInCh->GetRMSError());
707 
708  TH1* hClusterSizeInCh = ((TH1F*)fListExpert->UncheckedAt(kClusterSizeInCh+iCh));
709  hClusterSizePerChMean->SetBinContent(iCh+1, hClusterSizeInCh->GetMean());
710  hClusterSizePerChMean->SetBinError(iCh+1, hClusterSizeInCh->GetMeanError());
711  hClusterSizePerChSigma->SetBinContent(iCh+1, hClusterSizeInCh->GetRMS());
712  hClusterSizePerChSigma->SetBinError(iCh+1, hClusterSizeInCh->GetRMSError());
713 
714  }
715 
716  // fill summary plots per DE
717  TH2F* hClusterChargePerDE = ((TH2F*)fListExpert->UncheckedAt(kClusterChargePerDE));
718  TH2F* hClusterSizePerDE = ((TH2F*)fListExpert->UncheckedAt(kClusterSizePerDE));
719  for (Int_t iDE = 1; iDE < nDE+1; iDE++) {
720 
721  TH1D *tmp = hClusterChargePerDE->ProjectionY("tmp",iDE,iDE,"e");
722  if (tmp->GetEntries() > 10.) {
723  hClusterChargePerDEMean->SetBinContent(iDE, tmp->GetMean());
724  hClusterChargePerDEMean->SetBinError(iDE, tmp->GetMeanError());
725  hClusterChargePerDESigma->SetBinContent(iDE, tmp->GetRMS());
726  hClusterChargePerDESigma->SetBinError(iDE, tmp->GetRMSError());
727  }
728  delete tmp;
729 
730  tmp = hClusterSizePerDE->ProjectionY("tmp",iDE,iDE,"e");
731  if (tmp->GetEntries() > 10.) {
732  hClusterSizePerDEMean->SetBinContent(iDE, tmp->GetMean());
733  hClusterSizePerDEMean->SetBinError(iDE, tmp->GetMeanError());
734  hClusterSizePerDESigma->SetBinContent(iDE, tmp->GetRMS());
735  hClusterSizePerDESigma->SetBinError(iDE, tmp->GetRMSError());
736  }
737  delete tmp;
738 
739  }
740 
741  // Post summary data.
742  PostData(5, fListNorm);
743 }
744 
745 //________________________________________________________________________
747 {
749  if(theta < -2.5) return (theta / TMath::Pi() + 1.) * 180.;
750  else if(theta > 2.5) return (theta / TMath::Pi() - 1.) * 180.;
751  else return theta / TMath::Pi() * 180.;
752 }
753 
754 
755 
756 //________________________________________________________________________
757 TList* AliAnalysisTaskMuonQA::BuildListOfAllTriggerCases(TString& FiredTriggerClasses)
758 {
761 
762  TList* list = new TList();
763  list->SetOwner();
764 
765  // add case any
766  list->AddLast(new TObjString("trigger:any"));
767 
768  TObjArray *obj = FiredTriggerClasses.Tokenize(" ");
769  if ( obj ){
770  TIter nextTrigger(obj);
771  TObjString* trigClasseName;
772  while ((trigClasseName = static_cast<TObjString*>(nextTrigger()))) {
773 
774  //AliInfo(Form("trigger name %s %s",trigClasseName->GetName(),FiredTriggerClasses.Data()));
775 
776  //Add specific trigger
777  list->AddLast(new TObjString(Form("trigger:%s",trigClasseName->GetName())));
778  }
779  delete obj;
780  }
781 
782  // add case other if no specific trigger was found
783  if (list->GetSize() == 1) list->AddLast(new TObjString("trigger:other"));
784 
785  return list;
786 }
787 
788 
789 
790 
cluster charge distribution in chamber i
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
virtual void Terminate(Option_t *)
virtual void UserExec(Option_t *)
cluster size distribution in chamber i
AliMuonTrackCuts * fTrackCuts
Track cuts.
number of clusters per chamber per track
static const Int_t nCh
number of tracking chambers
TList * list
void SetTrackCuts(AliMuonTrackCuts *trackCuts)
Double_t ptMin
Quality assurance of MUON ESDs.
static const Int_t nDE
number of DE
Int_t nDE
UInt_t fTriggerMask
Trigger mask to be used when selecting events.
Pt distribution of mu+ match Hpt.
Pt distribution of mu- match Lpt.
TObjArray * fListExpert
List of output object for experts.
static const Float_t dMax[5]
maximum diameter of each station
TArrayI fMuonTrigIndex
Combined muon trigger index.
TObjArray * fListNorm
Normalized histograms.
Pt distribution of mu+ match Lpt.
TObjArray * fList
List of output object for everybody.
cluster charge distribution per DE
TList * BuildListOfAllTriggerCases(TString &FiredTriggerClasses)
Double_t ChangeThetaRange(Double_t theta)
cluster size distribution per DE
distribution of probability of chi2
Bool_t fSelectTrigger
Fill histograms only with events passing the trigger selection.
Bool_t fApplyAccCut
use only tracks passing the acceptance cuts (Rabs, eta)
AliCounterCollection * fTrackCounters
track statistics
Bool_t fSelectMatched
Fill histograms only with tracks matching the trigger.
AliCounterCollection * fEventCounters
event statistics
cluster position distribution in chamber i
number of clusters per chamber
Pt distribution of mu- match Hpt.
Double_t ptMax
normalized chi2 distribution
Short_t fSelectCharge
Fill histograms only with negative/position tracks (0=all)
number of tracks matched with trigger
Bool_t fSelectPhysics
Fill histograms only with events passing the physics selection.
virtual void UserCreateOutputObjects()