AliPhysics  vAN-20150319 (55be083)
 All Classes Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskTrigChEff.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 
19 
20 // ROOT includes
21 #include "TH1.h"
22 #include "TH2.h"
23 #include "TCanvas.h"
24 #include "TLegend.h"
25 #include "TMath.h"
26 #include "TObjString.h"
27 #include "TObjArray.h"
28 #include "TStyle.h"
29 #include "TROOT.h"
30 #include "TGraphAsymmErrors.h"
31 #include "TList.h"
32 #include "TFile.h"
33 
34 // STEER includes
35 #include "AliVParticle.h"
36 #include "AliAODTrack.h"
37 #include "AliESDMuonTrack.h"
38 
39 // ANALYSIS includes
40 #include "AliAnalysisManager.h"
41 #include "AliAnalysisDataSlot.h"
42 #include "AliAnalysisDataContainer.h"
43 
44 // PWG3 includes
45 #include "AliVAnalysisMuon.h"
46 #include "AliMuonEventCuts.h"
47 #include "AliMuonTrackCuts.h"
48 #include "AliMergeableCollection.h"
49 #include "AliAnalysisMuonUtility.h"
50 
51 
53 ClassImp(AliAnalysisTaskTrigChEff) // Class implementation in ROOT context
55 
56 
57 //________________________________________________________________________
59  AliVAnalysisMuon(),
60  fTrackSelKeys(0x0),
61  fCountTypeKeys(0x0),
62  fHistoTypeKeys(0x0),
63  fEffMethodKeys(0x0),
64  fMatchTrigKeys(0x0),
65 // fUseGhosts(kFALSE),
66  fList(0x0)
67 {
69 }
70 
71 //________________________________________________________________________
72 AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name, const AliMuonTrackCuts& cuts) :
73  AliVAnalysisMuon(name, cuts),
74  fTrackSelKeys(0x0),
75  fCountTypeKeys(0x0),
76  fHistoTypeKeys(0x0),
77  fEffMethodKeys(0x0),
78  fMatchTrigKeys(0x0),
79 // fUseGhosts(kFALSE),
80  fList(0x0)
81 {
82  //
84  //
85 
86  InitLocalKeys();
87 
88  DefineOutput(2, TList::Class());
89 }
90 
91 
92 //________________________________________________________________________
94 {
95  //
97  //
98  delete fTrackSelKeys;
99  delete fCountTypeKeys;
100  delete fHistoTypeKeys;
101  delete fEffMethodKeys;
102  delete fMatchTrigKeys;
103  if ( ! AliAnalysisManager::GetAnalysisManager() || ! AliAnalysisManager::GetAnalysisManager()->IsProofMode() ) {
104  delete fList;
105  }
106 }
107 
108 //___________________________________________________________________________
109 TList* AliAnalysisTaskTrigChEff::GetEffHistoList(TString physSel, TString trigClassNames, TString centrality, TString trackSelection)
110 {
112  // results from the histogram collection
113 
114  TList* outList = new TList();
115  outList->SetOwner();
116  FillEffHistoList(physSel, trigClassNames, centrality, trackSelection, outList);
117  return outList;
118 }
119 
120 //___________________________________________________________________________
121 Bool_t AliAnalysisTaskTrigChEff::FillEffHistoList(TString physSel, TString trigClassNames, TString centrality, TString trackSelection, TList* outList)
122 {
127 
128  if ( ! fMergeableCollection ) return kFALSE;
129  if ( ! outList ) outList = fList;
130  TString histoName = "";
131  TString histoPattern = "";
132  TH1* histo = 0x0;
133  Bool_t isOk = kTRUE;
134  for ( Int_t icount=0; icount<kNcounts; ++icount ) {
135  histoName = GetHistoName(kHchamberEff, icount, -1, -1, -1, -1);
136  histoPattern = Form("%s%s", histoName.Data(), trackSelection.Data());
137  histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
138  if ( histo ) {
139  histo->SetName(histoName.Data());
140  histo->SetTitle(histoName.Data());
141  histo->SetDirectory(0);
142  outList->Add(histo);
143  }
144  else isOk = kFALSE;
145  }
146  for ( Int_t icount=0; icount<kNcounts; ++icount ) {
147  for ( Int_t ich=0; ich<4; ++ich ) {
148  histoName = GetHistoName(kHslatEff, icount, ich, -1, -1, -1);
149  histoPattern = Form("%s%s", histoName.Data(), trackSelection.Data());
150  histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
151  if ( histo ) {
152  histo->SetName(histoName.Data());
153  histo->SetTitle(histoName.Data());
154  histo->SetDirectory(0);
155  outList->Add(histo);
156  }
157  else isOk = kFALSE;
158  }
159  }
160  for ( Int_t icount=0; icount<kNcounts; ++icount ) {
161  for ( Int_t ich=0; ich<4; ++ich ) {
162  histoName = GetHistoName(kHboardEff, icount, ich, -1, -1, -1);
163  histoPattern = Form("%s%s", histoName.Data(), trackSelection.Data());
164  histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
165  if ( histo ) {
166  histo->SetName(histoName.Data());
167  histo->SetTitle(histoName.Data());
168  histo->SetDirectory(0);
169  outList->Add(histo);
170  }
171  else isOk = kFALSE;
172  }
173  }
174 
175  histoName = GetHistoName(kHcheckBoard, -1, -1, -1, -1, -1);
176  histoPattern = Form("%s%s", histoName.Data(), trackSelection.Data());
177  histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
178  if ( histo ) {
179  histo->SetName(histoName.Data());
180  histo->SetTitle(histoName.Data());
181  histo->SetDirectory(0);
182  outList->Add(histo);
183  }
184  else isOk = kFALSE;
185 
186  return isOk;
187 }
188 
189 //___________________________________________________________________________
191 {
192  //
195  //
196 
197  TString histoName = "";
198  for ( Int_t isel=0; isel<kNselections; ++isel ) {
199  for ( Int_t itrig=0; itrig<GetAllSelectedTrigClasses()->GetEntries(); ++itrig ) {
200  for ( Int_t icent=1; icent<=GetCentralityClasses()->GetNbins(); ++icent ) {
201  for ( Int_t itrackSel=0; itrackSel<kNtrackSel; ++itrackSel ) {
202  for ( Int_t imethod=0; imethod<kNeffMethods; ++imethod ) {
203  for ( Int_t itype=0; itype<kNhistoTypes; ++itype ) {
204  for ( Int_t icount=-1; icount<kNcounts; ++icount ) {
205  for ( Int_t ich=-1; ich<4; ++ich ) {
206  for ( Int_t imatch=kMatchApt; imatch<kMatchHpt; ++imatch ) {
207  TH1* histo = 0x0;
208  for ( Int_t jmatch=imatch+1; jmatch<=kMatchHpt; ++jmatch ) {
209  histoName = GetHistoName(itype, icount, ich, itrackSel, jmatch, imethod);
210  TH1* histoAdd = (TH1*)fMergeableCollection->GetObject(Form("/%s/%s/%s/",fPhysSelKeys->At(isel)->GetName(), GetAllSelectedTrigClasses()->At(itrig)->GetName(), GetCentralityClasses()->GetBinLabel(icent)), histoName);
211  if ( ! histoAdd ) continue;
212  histoName = GetHistoName(itype, icount, ich, itrackSel, imatch, imethod);
213  if ( ! histo ) histo = (TH1*)GetMergeableObject(fPhysSelKeys->At(isel)->GetName(), GetAllSelectedTrigClasses()->At(itrig)->GetName(), GetCentralityClasses()->GetBinLabel(icent), histoName);
214  AliDebug(2,Form("Adding %s (%g) to %s (%g)", histoAdd->GetName(), histoAdd->Integral(), histo->GetName(), histo->Integral()));
215  histo->Add(histoAdd);
216  } // loop on higher pt matching
217  } // loop on match trigger
218  } // loop on chamber
219  } // loop on count type
220  } // loop on histo type
221  } // loop on eff method
222  } // loop on track selection
223  } // loop on centrality
224  } // loop on trigger classes
225  } // loop on physics selection
226 
227  TString physSel = fPhysSelKeys->At(kPhysSelPass)->GetName();
228  TString trigClass = "ANY";
229  TString centrality = "all";
230  TString histoPattern = GetHistoName(-1,-1,-1,kSelectTrack,kMatchApt,kEffFromTrack);
231 
232  FillEffHistoList(physSel, trigClass, centrality, histoPattern, fList);
233 
234  AliVAnalysisMuon::FinishTaskOutput();
235 }
236 
237 
238 //___________________________________________________________________________
240 {
241  //
243  //
244 
245  TString matchTrigNames = "Nopt Apt Lpt Hpt";
246  fMatchTrigKeys = matchTrigNames.Tokenize(" ");
247 
248  TString countTypeNames = "bendPlaneCount nonBendPlaneCount bothPlanesCount allTracksCount";
249  fCountTypeKeys = countTypeNames.Tokenize(" ");
250 
251  TString histoTypeKeys = "Chamber Slat Board checkRejectedBoard";
252  fHistoTypeKeys = histoTypeKeys.Tokenize(" ");
253 
254  TString effMethodKeys = "FromTrk FromTrg";
255  fEffMethodKeys = effMethodKeys.Tokenize(" ");
256 
257  TString trackSelNames = "Match NoSelMatch";
258  fTrackSelKeys = trackSelNames.Tokenize(" ");
259 }
260 
261 //___________________________________________________________________________
263 {
264  //
266  //
267 
268  const Char_t* yAxisTitle = "counts";
269 
270  Int_t nChamberBins = 4;
271  Float_t chamberLow = 11.-0.5, chamberHigh = (Float_t)(nChamberBins)+11.-0.5;
272  const Char_t* chamberName = "chamber";
273 
274  Int_t nSlatBins = 18;
275  Float_t slatLow = 0.-0.5, slatHigh = (Float_t)nSlatBins-0.5;
276  const Char_t* slatName = "slat";
277 
278  Int_t nBoardBins = 234;
279  Float_t boardLow = 1.-0.5, boardHigh = (Float_t)nBoardBins+1.-0.5;
280  const Char_t* boardName = "board";
281 
282  TString baseName, histoName, histoTitle;
283 
284  TH1* histo;
285  TH2F* histo2D;
286 
287  for ( Int_t itrackSel = 0; itrackSel<kNtrackSel; ++itrackSel ) {
288  for ( Int_t imethod=0; imethod<kNeffMethods; ++imethod ) {
289  for ( Int_t imatch = 0; imatch<kNtrigMatch; ++imatch ) {
290  for ( Int_t icount=0; icount<kNcounts; ++icount ) {
291  histoName = GetHistoName(kHchamberEff, icount, -1, itrackSel, imatch, imethod);
292  histo = new TH1F(histoName, histoName,
293  nChamberBins, chamberLow, chamberHigh);
294  histo->GetXaxis()->SetTitle(chamberName);
295  histo->GetYaxis()->SetTitle(yAxisTitle);
296  AddObjectToCollection(histo);
297  } // loop on counts
298 
299  for ( Int_t icount=0; icount<kNcounts; ++icount ) {
300  for ( Int_t ich=0; ich<4; ++ich ) {
301  histoName = GetHistoName(kHslatEff, icount, ich, itrackSel, imatch, imethod);
302  histo = new TH1F(histoName, histoName,
303  nSlatBins, slatLow, slatHigh);
304  histo->GetXaxis()->SetTitle(slatName);
305  histo->GetYaxis()->SetTitle(yAxisTitle);
306  AddObjectToCollection(histo);
307  } // loop on chamber
308  } // loop on counts
309 
310  for ( Int_t icount=0; icount<kNcounts; ++icount ) {
311  for ( Int_t ich=0; ich<4; ++ich ) {
312  histoName = GetHistoName(kHboardEff, icount, ich, itrackSel, imatch, imethod);
313  histo = new TH1F(histoName, histoName,
314  nBoardBins, boardLow, boardHigh);
315  histo->GetXaxis()->SetTitle(boardName);
316  histo->GetYaxis()->SetTitle(yAxisTitle);
317  AddObjectToCollection(histo);
318  } // loop on chamber
319  } // loop on counts
320 
321  histoName = GetHistoName(kHcheckBoard, -1, -1, itrackSel, imatch, imethod);
322  histo2D = new TH2F(histoName.Data(), "Rejected tracks motivation",
323  5, 20.5, 25.5, nBoardBins, boardLow, boardHigh);
324  histo2D->GetXaxis()->SetBinLabel(1,"Many pads");
325  histo2D->GetXaxis()->SetBinLabel(2,"Few pads");
326  histo2D->GetXaxis()->SetBinLabel(3,"Outside geom");
327  histo2D->GetXaxis()->SetBinLabel(4,"Tracker track");
328  histo2D->GetXaxis()->SetBinLabel(5,"Masked board");
329  histo2D->GetYaxis()->SetTitle(boardName);
330  AddObjectToCollection(histo2D);
331  } // loop on trig match
332  } // loop on eff method
333  } // loop on track selection
334 
335  fMuonTrackCuts->Print();
336 
337  fList = new TList();
338  fList->SetOwner();
339  PostData(2, fList);
340 
341 }
342 
343 //___________________________________________________________________________
344 TString AliAnalysisTaskTrigChEff::GetHistoName(Int_t itype, Int_t icount, Int_t ichamber, Int_t itrackSel, Int_t imatch, Int_t imethod)
345 {
347  TString histoName = "";
348  if ( itype < kHcheckBoard && icount >= 0 ) histoName += static_cast<TObjString*>(fCountTypeKeys->At(icount))->GetString();
349  if ( itype >= 0 ) histoName += ((TObjString*)fHistoTypeKeys->At(itype))->GetString();
350  if ( ichamber >= 0 ) histoName += Form("Ch%i", 11+ichamber);
351  if ( itrackSel >= 0 ) histoName += static_cast<TObjString*>(fTrackSelKeys->At(itrackSel))->GetString();
352  if ( imatch >= 0 ) histoName += static_cast<TObjString*>(fMatchTrigKeys->At(imatch))->GetString();
353  if ( imethod >= 0 ) histoName += static_cast<TObjString*>(fEffMethodKeys->At(imethod))->GetString();
354  return histoName;
355 }
356 
357 //________________________________________________________________________
358 void AliAnalysisTaskTrigChEff::ProcessEvent(TString physSel, const TObjArray& selectTrigClasses, TString centrality)
359 {
360  //
362  //
363 
364  Int_t slat = 0, board = 0;
365  UInt_t pattern = 0;
366  TString histoName = "";
367 
368  TArrayI othersEfficient(4);
369 
370  AliVParticle* track = 0x0;
371 
372  UInt_t addMask[4] = {0, AliMuonTrackCuts::kMuMatchApt, AliMuonTrackCuts::kMuMatchApt|AliMuonTrackCuts::kMuMatchLpt, AliMuonTrackCuts::kMuMatchApt|AliMuonTrackCuts::kMuMatchLpt|AliMuonTrackCuts::kMuMatchHpt};
373 
374  Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(InputEvent());
375  for ( Int_t itrack = 0; itrack < nTracks; ++itrack ) {
376  track = AliAnalysisMuonUtility::GetTrack(itrack,InputEvent());
377 
378  Bool_t matchTracker = AliAnalysisMuonUtility::IsMuonTrack(track);
379 
380  Int_t matchTrig = AliAnalysisMuonUtility::GetMatchTrigger(track);
381  UInt_t selection = fMuonTrackCuts->GetSelectionMask(track);
382 
383  // Apply the sharp pt cut according to the matched pt level of the track
384  UInt_t filterMask = fMuonTrackCuts->GetFilterMask() | addMask[matchTrig];
385  Bool_t isSelected = ( ( selection & filterMask ) == filterMask );
386 
387  for ( Int_t imethod=0; imethod<kNeffMethods; ++imethod ) {
388  if ( imethod == kEffFromTrack ) {
389  if ( ! matchTracker || track->P() < 10. ) continue;
390  pattern = AliAnalysisMuonUtility::GetMUONTrigHitsMapTrk(track);
391  board = AliESDMuonTrack::GetCrossedBoard(pattern);
392  }
393  else {
394  if ( matchTrig == 0 ) continue;
395  pattern = AliAnalysisMuonUtility::GetMUONTrigHitsMapTrg(track);
396  board = ( AliAnalysisMuonUtility::IsAODEvent(InputEvent()) ) ? AliESDMuonTrack::GetCrossedBoard(pattern) : ((AliESDMuonTrack*)track)->LoCircuit();
397  }
398 
399  Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
400 
401  if ( effFlag < AliESDMuonTrack::kChEff ) {
402  for ( Int_t itrackSel=0; itrackSel<kNtrackSel; ++itrackSel ) {
403  if ( itrackSel == kSelectTrack && ! isSelected ) continue;
404  for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
405  TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
406 
407  histoName = GetHistoName(kHcheckBoard, -1, -1, itrackSel, matchTrig, imethod);
408  ((TH2F*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(AliESDMuonTrack::GetSlatOrInfo(pattern), board);
409  }
410  }
411  continue; // Track not good for efficiency calculation
412  }
413 
414  othersEfficient.Reset(1);
415  for ( Int_t cath=0; cath<2; ++cath ) {
416  for ( Int_t ich=0; ich<4; ++ich ) {
417  if ( ! AliESDMuonTrack::IsChamberHit(pattern, cath, ich) ) {
418  for ( Int_t jch=0; jch<4; jch++ ) {
419  if ( jch != ich ) othersEfficient[jch] = 0;
420  } // loop on other chambers
421  break;
422  } // if chamber not efficient
423  } // loop on chambers
424  } // loop on cathodes
425 
426  Bool_t rejectTrack = kTRUE;
427  for ( Int_t ich=0; ich<4; ++ich ) {
428  if ( othersEfficient[ich] > 0 ) {
429  rejectTrack = kFALSE;
430  break;
431  }
432  }
433 
434  if ( rejectTrack ) continue;
435 
436  slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
437 
438  for ( Int_t ich=0; ich<4; ++ich ) {
439  if ( ! othersEfficient[ich] )
440  continue; // Reject track if the info of the chamber under study
441  // is necessary to create the track itself
442 
443  Int_t iChamber = 11 + ich;
444 
445  Bool_t hitsBend = AliESDMuonTrack::IsChamberHit(pattern, 0, ich);
446  Bool_t hitsNonBend = AliESDMuonTrack::IsChamberHit(pattern, 1, ich);
447 
448  Bool_t fillHisto[kNcounts] = {
449  hitsBend,
450  hitsNonBend,
451  ( hitsBend && hitsNonBend ),
452  kTRUE
453  };
454 
455  for ( Int_t itrackSel=0; itrackSel<kNtrackSel; ++itrackSel ) {
456  if ( itrackSel == kSelectTrack && ! isSelected ) continue;
457  for (Int_t icount=0; icount<kNcounts; ++icount){
458  if ( ! fillHisto[icount] ) continue;
459  for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
460  TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
461 
462  histoName = GetHistoName(kHchamberEff, icount, -1, itrackSel, matchTrig, imethod);
463  ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(iChamber);
464 
465  if ( effFlag < AliESDMuonTrack::kSlatEff ) continue; // Track crossed different slats
466  histoName = GetHistoName(kHslatEff, icount, ich, itrackSel, matchTrig, imethod);
467  ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(slat);
468 
469  if ( effFlag < AliESDMuonTrack::kBoardEff ) continue; // Track crossed different boards
470  histoName = GetHistoName(kHboardEff, icount, ich, itrackSel, matchTrig, imethod);
471  ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(board);
472  } // loop on trigger classes
473  } // loop on count types
474  } // loop on track selection
475  } // loop on chambers
476  } // loop on tracks
477  } // loop on eff methods
478 
479  PostData(2, fList);
480 }
481 
482 
483 //________________________________________________________________________
485 {
486  //
488  //
489 
490  AliVAnalysisMuon::Terminate("");
491 
492  if ( ! fMergeableCollection ) return;
493 
494 
495  Int_t xshift = 100;
496  Int_t yshift = 20;
497  Int_t igroup1 = -1;
498  Int_t igroup2 = 0;
499 
500  TObjArray* physSel = ((TObjString*)fTerminateOptions->At(0))->GetString().Tokenize(" ");
501  physSel->SetOwner();
502  TObjArray* trigClasses = ((TObjString*)fTerminateOptions->At(1))->GetString().Tokenize(" ");
503  trigClasses->SetOwner();
504  TObjArray* centrality = ((TObjString*)fTerminateOptions->At(2))->GetString().Tokenize(" ");
505  centrality->SetOwner();
506  TString furtherOpt = ((TObjString*)fTerminateOptions->At(3))->GetString();
507 
508  TString currName = "";
509  TObjArray* optArr = furtherOpt.Tokenize(" ");
510  TObjArray trackSel, methodSel;
511  trackSel.SetOwner();
512  methodSel.SetOwner();
513  TString outFileOpt = "";
514  for ( Int_t iopt=0; iopt<optArr->GetEntries(); iopt++ ) {
515  currName = optArr->At(iopt)->GetName();
516  if ( currName.Contains(".root") ) outFileOpt = currName;
517  else if ( currName.Contains("Match") ) trackSel.Add(new TObjString(currName));
518  else if ( currName.Contains("From") ) methodSel.Add(new TObjString(currName));
519  }
520  delete optArr;
521 
522  if ( trackSel.GetEntries() == 0 ) trackSel.Add(new TObjString(GetHistoName(-1,-1,-1,kSelectTrack,kMatchApt,-1)));
523  if ( methodSel.GetEntries() == 0 ) methodSel.Add(new TObjString(fEffMethodKeys->At(kEffFromTrack)->GetName()));
524 
525  furtherOpt.ToUpper();
526 
527  Int_t chosenType = ( furtherOpt.Contains("BOARD") ) ? kHboardEff : kHslatEff;
528 
529  igroup1++;
530  igroup2 = 0;
531  TString histoName = "", yAxisTitle = "";
532 
533  TH1 *num = 0x0;
534  TH1 *den = 0x0;
535  TGraphAsymmErrors* effGraph = 0x0;
536 
538  // Show tests //
540 
541  for ( Int_t icount=0; icount<kNcounts-1; ++icount ) {
542  currName = Form("%s%s_can", fHistoTypeKeys->At(chosenType)->GetName(), fCountTypeKeys->At(icount)->GetName());
543  TCanvas* can = new TCanvas(currName.Data(), currName.Data(), igroup1*xshift,igroup2*yshift,600,600);
544  can->Divide(2,2);
545  TLegend* leg = new TLegend(0.6, 0.6, 0.9, 0.9);
546  leg->SetBorderSize(1);
547  for ( Int_t ich=0; ich<4; ++ich ) {
548  TGraph* refGraph = 0x0;
549  can->cd(ich+1);
550  gPad->SetRightMargin(0.03);
551  Int_t icolor = 1;
552  Int_t istyle = 0;
553  TString drawOpt = "AP";
554  for ( Int_t isel=0; isel<physSel->GetEntries(); ++isel ) {
555  for ( Int_t itrig=0; itrig<trigClasses->GetEntries(); ++itrig ) {
556  for ( Int_t icent=0; icent<centrality->GetEntries(); ++icent ) {
557  for ( Int_t imethodSel=0; imethodSel<methodSel.GetEntries(); ++imethodSel ) {
558  for ( Int_t itrackSel=0; itrackSel<trackSel.GetEntries(); ++itrackSel ) {
559  histoName = GetHistoName(chosenType, kAllTracks, ich, -1, -1, -1); // partial name
560  histoName += Form("%s%s",trackSel.At(itrackSel)->GetName(),methodSel.At(imethodSel)->GetName());
561  den = (TH1*)GetSum(physSel->At(isel)->GetName(), trigClasses->At(itrig)->GetName(), centrality->At(icent)->GetName(), histoName.Data());
562  if ( ! den ) {
563  printf("Warning: cannot find %s\n", histoName.Data());
564  continue;
565  }
566  histoName = GetHistoName(chosenType, icount, ich, -1, -1, -1); // partial name
567  histoName += Form("%s%s",trackSel.At(itrackSel)->GetName(),methodSel.At(imethodSel)->GetName());
568  num = (TH1*)GetSum(physSel->At(isel)->GetName(), trigClasses->At(itrig)->GetName(), centrality->At(icent)->GetName(), histoName.Data());
569  if ( ! num ) continue;
570  effGraph = new TGraphAsymmErrors(num, den, "e0");
571  currName = Form("%s_%s_%s_%s_%s", physSel->At(isel)->GetName(), trigClasses->At(itrig)->GetName(), centrality->At(icent)->GetName(), trackSel.At(itrackSel)->GetName(), methodSel.At(imethodSel)->GetName());
572  effGraph->SetTitle(currName.Data());
573 
574  Double_t ymin = 0.;
575  Double_t ymax = 1.1;
576  yAxisTitle = "Efficiency";
577 
578  if ( furtherOpt.Contains("DIFF") || furtherOpt.Contains("PULL") ) {
579  if ( ! refGraph ) {
580  refGraph = effGraph;
581  continue;
582  }
583  Double_t currX, currY, baseX, baseY, errYlow = 0., errYhigh = 0., newY = 0.;
584  Double_t refVal = 1., errY = 0.;
585  for ( Int_t ipoint=0; ipoint<effGraph->GetN(); ipoint++ ) {
586  refGraph->GetPoint(ipoint, baseX, baseY);
587  effGraph->GetPoint(ipoint, currX, currY);
588  Double_t errX = effGraph->GetErrorXlow(ipoint);
589  if ( furtherOpt.Contains("DIFF") ) {
590  refVal = ( baseY > 0. ) ? baseY : 1.;
591  newY = ( currY - baseY ) / refVal;
592  Double_t errYlow1 = effGraph->GetErrorYlow(ipoint);
593  Double_t errYlow2 = refGraph->GetErrorYlow(ipoint);
594  Double_t errYhigh1 = effGraph->GetErrorYhigh(ipoint);
595  Double_t errYhigh2 = refGraph->GetErrorYhigh(ipoint);
596  errYlow = TMath::Sqrt(errYlow1*errYlow1 + errYlow2*errYlow2) / refVal;
597  errYhigh = TMath::Sqrt(errYhigh1*errYhigh1 + errYhigh2*errYhigh2) / refVal;
598  //yAxisTitle = Form("(%s - %s) / %s", effGraph->GetTitle(), refGraph->GetTitle(), refGraph->GetTitle());
599  yAxisTitle = "(eff - ref ) / ref";
600  effGraph->SetTitle(Form("Rel. diff. w.r.t. %s", refGraph->GetTitle()));
601  ymin = -0.1;
602  ymax = 0.1;
603  }
604  else if ( furtherOpt.Contains("PULL") ) {
605  errY = 0.5 * ( effGraph->GetErrorYlow(ipoint) + effGraph->GetErrorYhigh(ipoint));
606  newY = ( errY > 0. ) ? ( currY - baseY ) / errY : 0.;
607  errYlow = 1.;
608  errYhigh = 1.;
609  //yAxisTitle = Form("( %s - %s ) / err", effGraph->GetTitle(), refGraph->GetTitle());
610  yAxisTitle = "(eff - ref ) / err";
611  effGraph->SetTitle(Form("Pull w.r.t. %s", refGraph->GetTitle()));
612  ymin = -4.;
613  ymax = 4.;
614  }
615  effGraph->SetPoint(ipoint, currX, newY);
616  effGraph->SetPointError(ipoint, errX, errX, errYlow, errYhigh);
617  } // loop on points
618  }
619  effGraph->GetYaxis()->SetRangeUser(ymin, ymax);
620  effGraph->GetYaxis()->SetTitle(yAxisTitle.Data());
621  effGraph->SetLineColor(icolor);
622  effGraph->SetMarkerColor(icolor);
623  effGraph->SetMarkerStyle(20 + istyle);
624  //effGraph->SetMarkerSize(0.3);
625  icolor++;
626  if ( icolor == 5 || icolor == 10 ) icolor++;
627  istyle++;
628  effGraph->Draw(drawOpt.Data());
629  drawOpt = "P";
630  if ( ich < 3 ) continue;
631  leg->AddEntry(effGraph, currName.Data(), "lp");
632  } // loop on match trigger
633  } // loop on eff method
634  } // loop on centrality
635  } // loop on trigger classes
636  } // loop on physics selection
637  } // loop on chamber
638  leg->Draw("same");
639  } // loop on count type
640  //} // loop on detection element type
641 
642  delete physSel;
643  delete trigClasses;
644  delete centrality;
645 
646 
647  fList = dynamic_cast<TList*>(GetOutputData(2));
648  if ( fList ) {
649 
651  // Show final efficiency //
653  TString baseName[3] = {"Chamber", "RPC", "Board"};
654  Int_t baseIndex[3] = {kHchamberEff, kHslatEff, kHboardEff};
655  TString effName[kNcounts-1] = {"BendPlane", "NonBendPlane", "BothPlanes"};
656  for ( Int_t itype=0; itype<3; itype++ ) {
657  for ( Int_t icount=0; icount<kNcounts-1; icount++ ){
658  TString canName = Form("efficiencyPer%s_%s",baseName[itype].Data(),effName[icount].Data());
659  TCanvas* can = new TCanvas(canName.Data(),canName.Data(),10*(1+kNcounts*itype+icount),10*(1+kNcounts*itype+icount),310,310);
660  can->SetFillColor(10); can->SetHighLightColor(10);
661  can->SetLeftMargin(0.15); can->SetBottomMargin(0.15);
662  if ( itype > 0 )
663  can->Divide(2,2);
664 
665  for ( Int_t ich=-1; ich<4; ich++ ) {
666  histoName = GetHistoName(baseIndex[itype], icount, ich, -1, -1, -1);
667  num = (TH1*)fList->FindObject(histoName.Data());
668  histoName = GetHistoName(baseIndex[itype], kNcounts-1, ich, -1, -1, -1);
669  den = (TH1*)fList->FindObject(histoName.Data());
670  if ( ! num || ! den ) continue;
671  effGraph = new TGraphAsymmErrors(num, den, "e0");
672  effGraph->GetYaxis()->SetRangeUser(0., 1.1);
673  effGraph->GetYaxis()->SetTitle("Efficiency");
674  effGraph->GetXaxis()->SetTitle(baseName[itype].Data());
675  can->cd(ich+1);
676  effGraph->Draw("AP");
677  if ( itype == 0 ) break;
678  } // loop on chamber
679  } // loop on count types
680  } // loop on histo
681  }
682 
683 
684  if ( ! outFileOpt.IsNull() ) {
685  TObjArray* outFileOptList = outFileOpt.Tokenize("?");
686  AliInfo(Form("Creating file %s", outFileOptList->At(0)->GetName()));
687  TList* effList = GetEffHistoList(outFileOptList->At(1)->GetName(), outFileOptList->At(2)->GetName(), outFileOptList->At(3)->GetName(), outFileOptList->At(4)->GetName());
688  effList->SetName(GetOutputSlot(2)->GetContainer()->GetName());
689  if ( effList ->GetEntries() == 0 ) {
690  printf("\nWarning: no histograms satisfying the requested conditions.\n(%s %s %s %s).\nOutput %s not created.\n", outFileOptList->At(1)->GetName(), outFileOptList->At(2)->GetName(), outFileOptList->At(3)->GetName(), outFileOptList->At(4)->GetName(),outFileOptList->At(0)->GetName());
691  }
692  else {
693  TFile* outFile = TFile::Open(outFileOptList->At(0)->GetName(), "RECREATE");
694  effList->Write(effList->GetName(),TObject::kSingleKey);
695  outFile->Close();
696  }
697  delete effList;
698  delete outFileOptList;
699  }
700 }
TObjArray * fTrackSelKeys
Selection names.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void ProcessEvent(TString physSel, const TObjArray &selectTrigClasses, TString centrality)
Hit pattern from tracker track extrapolation.
TObjArray * fHistoTypeKeys
Base histogram name.
Check rejected tracks per board.
Check rejected tracks per board.
TObjArray * fMatchTrigKeys
Match trigger names.
TList * GetEffHistoList(TString physSel, TString trigClassNames, TString centrality, TString trackSelection)
TObjArray * fCountTypeKeys
Count type keys.
Counts per slat histogram index.
Counts per board histogram index.
Total number of track selection.
TString GetHistoName(Int_t itype, Int_t icount, Int_t ichamber, Int_t itrackSel, Int_t imatch, Int_t imethod)
Bool_t FillEffHistoList(TString physSel, TString trigClassNames, TString centrality, TString trackSelection, TList *outList=0x0)
Counts per cathode histogram index.
TList * fList
TList output object.
TObjArray * fEffMethodKeys
Efficiency methods keys.
Total number of efficiency methods.