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