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