AliPhysics  v5-07-15-01 (b3d7633)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliMTRChEffAnalysis.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 #include "AliMTRChEffAnalysis.h"
17 
18 // ROOT includes
19 #include <Riostream.h>
20 #include "TObjString.h"
21 #include "TObjArray.h"
22 #include "TList.h"
23 #include "TSystem.h"
24 #include "TROOT.h"
25 #include "TPRegexp.h"
26 #include "TRegexp.h"
27 #include "TFile.h"
28 #include "TDirectory.h"
29 #include "TTree.h"
30 #include "TKey.h"
31 #include "TArrayI.h"
32 #include "TArrayD.h"
33 #include "TGrid.h"
34 #include "TGridResult.h"
35 #include "TGraphAsymmErrors.h"
36 #include "TH1.h"
37 #include "TH2.h"
38 #include "TAxis.h"
39 #include "TF1.h"
40 #include "TMath.h"
41 #include "TCanvas.h"
42 #include "TLegend.h"
43 #include "TLine.h"
44 #include "TLatex.h"
45 
46 #include "AliLog.h"
47 #include "AliMergeableCollection.h"
48 #include "AliCounterCollection.h"
49 
50 #include "AliAnalysisMuonUtility.h"
51 #include "AliTrigChEffOutput.h"
52 
53 #include "AliCDBManager.h"
54 #include "AliCDBStorage.h"
55 #include "AliCDBId.h"
56 #include "AliCDBEntry.h"
57 #include "AliMUONCDB.h"
58 #include "AliMUONTriggerEfficiencyCells.h"
59 
61 ClassImp(AliMTRChEffAnalysis) // Class implementation in ROOT context
63 
64 using std::cout;
65 using std::endl;
66 using std::cin;
67 using std::ofstream;
68 using std::ifstream;
69 
70 //________________________________________________________________________
72  TObject(),
73  fOutputs(0x0),
74  fConditions(0x0),
75  fMergedOutputs(0x0)
76 {
78 
79 }
80 
81 //________________________________________________________________________
82 AliMTRChEffAnalysis::AliMTRChEffAnalysis ( const char *localFileList, const char* outputName ) :
83  TObject(),
84  fOutputs(0x0),
85  fConditions(0x0),
86  fMergedOutputs(0x0)
87 {
89  SetOutList(localFileList,outputName);
90 }
91 
92 //________________________________________________________________________
94 {
95  //
97  //
98  delete fOutputs;
99  delete fConditions;
100  delete fMergedOutputs;
101 }
102 
103 //________________________________________________________________________
104 Bool_t AliMTRChEffAnalysis::AddSystematicCondition ( const char* physSel, const char* trigClassName, const char* centrality, Int_t itrackSel, Int_t imatch, Int_t imethod )
105 {
107  return SetCondition(physSel, trigClassName, centrality, itrackSel, imatch, imethod, kFALSE);
108 }
109 
110 //________________________________________________________________________
111 Bool_t AliMTRChEffAnalysis::AddToList ( const char *filename, const char *outputName )
112 {
114  AliTrigChEffOutput* trigOut = new AliTrigChEffOutput(filename,outputName);
115  if ( ! trigOut->GetMergeableCollection() ) {
116  AliError(Form("Cannot find %s in %s\n",outputName,filename));
117  return kFALSE;
118  }
119 
120  TString currRun = AliAnalysisMuonUtility::GetRunNumberAsString(filename);
121  trigOut->SetUniqueID(currRun.Atoi());
122 
123 // // Delete counter collection to save memory
124 // trigOut->RemoveFromList(trigOut->GetCounterCollection());
125  // Just keep counter and mergeable collections
126  TObjArray* out = trigOut->GetOutput();
127  while ( out->GetEntries() > 2 ) {
128  TObject* removedObj = out->Last();
129  AliDebug(1,Form("Run %u : remove %s",trigOut->GetUniqueID(),removedObj->GetName()));
130  trigOut->RemoveFromList(removedObj);
131  }
132 
133  if ( ! fOutputs ) {
134  fOutputs = new TObjArray();
135  fOutputs->SetOwner();
136  }
137  fOutputs->Add(trigOut);
138  return kTRUE;
139 }
140 
141 //________________________________________________________________________
142 TArrayI AliMTRChEffAnalysis::BoardsInRPC ( Int_t irpc ) const
143 {
145 
146  // FIXME: ugly and hardcoded, but avoid loading the mapping
147 
148  TArrayI boards;
149  if ( irpc == 0 || irpc == 9 ) {
150  Int_t arr[] = {26,27,28,29,48,49,50,51,68,69,84,85,100,101,113};
151  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
152  boards.Set(nBoards,arr);
153  if ( irpc == 9 )
154  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
155  }
156  else if ( irpc == 1 || irpc == 8 ) {
157  Int_t arr[] = {9,10,11,30,31,32,33,52,53,54,55,70,71,86,87,102,103,114};
158  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
159  boards.Set(nBoards,arr);
160  if ( irpc == 8 )
161  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
162  }
163  else if ( irpc == 2 || irpc == 7 ) {
164  Int_t arr[] = {12,13,34,35,56,57,72,73,88,89,104,105,115};
165  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
166  boards.Set(nBoards,arr);
167  if ( irpc == 7 )
168  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
169  }
170  else if ( irpc == 3 || irpc == 6 ) {
171  Int_t arr[] = {14,15,36,37,58,59,74,75,90,91,106,107,116};
172  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
173  boards.Set(nBoards,arr);
174  if ( irpc == 6 )
175  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
176  }
177  else if ( irpc == 4 || irpc == 5 ) {
178  Int_t arr[] = {16,38,60,76,92,108,117};
179  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
180  boards.Set(nBoards,arr);
181  if ( irpc == 5 )
182  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
183  }
184  else if ( irpc == 17 || irpc == 10 ) {
185  Int_t arr[] = {6,7,8,22,23,24,25,44,45,46,47,66,67,82,83,98,99,112};
186  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
187  boards.Set(nBoards,arr);
188  if ( irpc == 10 )
189  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
190  }
191  else if ( irpc == 16 || irpc == 11 ) {
192  Int_t arr[] = {4,5,20,21,42,43,64,65,80,81,96,97,111};
193  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
194  boards.Set(nBoards,arr);
195  if ( irpc == 11 )
196  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
197  }
198  else if ( irpc == 15 || irpc == 12 ) {
199  Int_t arr[] = {2,3,18,19,40,41,62,63,78,79,94,95,110};
200  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
201  boards.Set(nBoards,arr);
202  if ( irpc == 12 )
203  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
204  }
205  else if ( irpc == 14 || irpc == 13 ) {
206  Int_t arr[] = {1,17,39,61,77,93,109};
207  Int_t nBoards = sizeof(arr)/sizeof(arr[0]);
208  boards.Set(nBoards,arr);
209  if ( irpc == 13 )
210  for ( Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
211  }
212 
213  return boards;
214 }
215 
216 //________________________________________________________________________
217 void AliMTRChEffAnalysis::CompareEfficiencies ( const char* sources, const char* titles, const char* opt ) const
218 {
220  TString srcs(sources);
221  TObjArray* sourceList = srcs.Tokenize(",");
222  TObjArray effMapList;
223  effMapList.SetOwner();
224 
225  TString trigEffCDBdir = "MUON/Calib/TriggerEfficiency";
226 
227  TIter next(sourceList);
228  TObjString* src = 0x0;
229  while ( (src = static_cast<TObjString*>(next())) ) {
230  TString currSrc = src->String();
231  if ( currSrc.BeginsWith("alien") && ! gGrid ) TGrid::Connect("alien://");
232 
233  AliMUONTriggerEfficiencyCells* effMap = 0x0;
234  if ( currSrc.EndsWith(".root") ) effMap = new AliMUONTriggerEfficiencyCells(currSrc.Data());
235  else {
236  TObjArray* dirRun = currSrc.Tokenize("?");
237  TString cdbPath = dirRun->UncheckedAt(0)->GetName();
238  TString runNum = ( dirRun->GetEntriesFast() > 1 ) ? dirRun->UncheckedAt(1)->GetName() : "";
239  AliCDBManager* mgr = AliCDBManager::Instance();
240  if ( ! mgr->GetDefaultStorage() ) mgr->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
241  mgr->SetSpecificStorage(trigEffCDBdir.Data(),cdbPath.Data());
242  Int_t runNumber = 0;
243  if ( runNum.IsNull() ) {
244  cout << "Please enter run number: " << endl;
245  cin >> runNumber;
246  }
247  else runNumber = runNum.Atoi();
248  mgr->SetRun(runNumber);
249  AliCDBEntry* cdbEntry = mgr->Get(trigEffCDBdir.Data());
250 
251  effMap = static_cast<AliMUONTriggerEfficiencyCells*>(cdbEntry->GetObject());
252  }
253  if ( ! effMap ) continue;
254  effMapList.Add(effMap);
255  }
256 
257  CompareEfficiencies(&effMapList, titles, opt);
258 }
259 
260 //________________________________________________________________________
261 void AliMTRChEffAnalysis::CompareEfficiencies ( TObjArray* effMapList, const char* titles, const char* opt ) const
262 {
264 
265  TString sTitles(titles);
266  TObjArray* titleList = sTitles.Tokenize(",");
267 
268  Int_t nLists = effMapList->GetEntriesFast();
269 
270  Double_t xpt, ypt, xref, yref;
271  enum {kEff, kDiff, kPull};
272  TString sOpt(opt);
273  sOpt.ToLower();
274  Int_t iopt = kEff;
275  TString yTitle = "Eff.";
276  if ( sOpt.Contains("diff") ) {
277  iopt = kDiff;
278  yTitle = "Eff. - (ref.Eff)";
279  }
280  else if ( sOpt.Contains("pull") ) {
281  iopt = kPull;
282  yTitle = "(Eff - (ref.Eff)) / err";
283  }
284 
285  Bool_t needsLegend = ( nLists > 1 );
286 // if ( iopt != kEff ) needsLegend = nLists > 2;
287 
288  Int_t colors[] = {kBlack, kRed, kSpring, kTeal, kBlue, kViolet, kMagenta, kOrange, kGray};
289  Int_t ncolors = sizeof(colors)/sizeof(colors[0]);
290 
291  Int_t hTypes[2] = {AliMUONTriggerEfficiencyCells::kHboardCount,AliMUONTriggerEfficiencyCells::kHslatCount};
292  Int_t countTypes[3] = {AliMUONTriggerEfficiencyCells::kBendingEff,AliMUONTriggerEfficiencyCells::kNonBendingEff,AliMUONTriggerEfficiencyCells::kBothPlanesEff};
293 
294  TString currName = "";
295  Int_t ican = 0;
296  for ( Int_t itype=0; itype<2; itype++ ) {
297  TString xTitle = ( hTypes[itype] == AliMUONTriggerEfficiencyCells::kHslatCount ) ? "RPC" : "Board";
298  for ( Int_t icount=0; icount<3; icount++ ) {
299  TCanvas* can = 0x0;
300  for ( Int_t ich=0; ich<4; ich++ ) {
301  TLegend* leg = 0x0;
302 // Int_t hrefIdx = AliTrigChEffOutput::kNcounts + AliTrigChEffOutput::kNcounts*4*(itype-1) + 4*AliTrigChEffOutput::kAllTracks + ich;
303 // Int_t hIdx = AliTrigChEffOutput::kNcounts + AliTrigChEffOutput::kNcounts*4*(itype-1) + 4*icount + ich;
304  TGraphAsymmErrors* refGraph = 0x0;
305  for ( Int_t ilist=0; ilist<nLists; ilist++ ) {
306  TString currTitle = titleList->At(ilist)->GetName();
307  AliMUONTriggerEfficiencyCells* effMap = static_cast<AliMUONTriggerEfficiencyCells*>(effMapList->UncheckedAt(ilist));
308  currName = effMap->GetHistoName(hTypes[itype],AliMUONTriggerEfficiencyCells::kAllTracks,ich);
309  TH1* histoDen = static_cast<TH1*>(effMap->GetHistoList()->FindObject(currName.Data()));
310  currName = effMap->GetHistoName(hTypes[itype],countTypes[icount],ich);
311  TH1* histoNum = static_cast<TH1*>(effMap->GetHistoList()->FindObject(currName.Data()));
312  TGraphAsymmErrors* graph = new TGraphAsymmErrors(histoNum,histoDen,"e0");
313  currName = histoNum->GetName();
314  currName.ReplaceAll("Count","Eff");
315  currName.Append(Form("_%s",currTitle.Data()));
316  graph->SetName(currName.Data());
317 
318  if ( iopt != kEff ) {
319  if ( refGraph ) {
320  for ( Int_t ipt=0; ipt<graph->GetN(); ipt++ ) {
321  refGraph->GetPoint(ipt,xref,yref);
322  graph->GetPoint(ipt,xpt,ypt);
323  if ( iopt == kDiff ) graph->SetPoint(ipt,xpt,ypt-yref);
324  else if ( iopt == kPull ) {
325  Double_t err = GetError(graph->GetErrorYlow(ipt),graph->GetErrorYhigh(ipt));
326  Double_t pull = ( err > 0. ) ? (ypt-yref)/err : 0.;
327  graph->SetPoint(ipt,xpt,pull);
328  }
329  } // loop on points
330  }
331  else {
332  refGraph = graph;
333  continue;
334  }
335  }
336 
337  if ( ! can ) {
338  currName = graph->GetName();
339  currName.Remove(currName.Length()-currTitle.Length()-5);
340  can = new TCanvas(currName.Data(),currName.Data(),20*ican,20*ican,600,600);
341  can->Divide(2,2);
342  ican++;
343  }
344  if ( needsLegend && ! leg ) {
345  leg = new TLegend(0.35, 0.15, 0.65, 0.45);
346  if ( refGraph ) leg->SetHeader(Form("Ref.: %s",titleList->At(0)->GetName()));
347  }
348  can->cd(ich+1);
349  gPad->SetGridy();
350  Int_t icolor = ( ilist < ncolors ) ? colors[ilist] : 20+ilist;
351  graph->SetLineColor(icolor);
352  graph->SetMarkerColor(icolor);
353  graph->SetMarkerStyle(20+ilist);
354  graph->SetMarkerSize(0.5);
355  graph->GetXaxis()->SetTitle(xTitle.Data());
356  graph->GetYaxis()->SetTitle(yTitle.Data());
357  graph->Draw((gPad->GetListOfPrimitives()->GetEntries()==0)?"ap":"p");
358  if ( leg ) leg->AddEntry(graph,titleList->At(ilist)->GetName(),"lp");
359  } // loop on lists
360  if (leg ) leg->Draw();
361  delete refGraph;
362  } // loop on chambers
363  } // loop on counts
364  } // loop on types
365 
366  delete titleList;
367 }
368 
369 //________________________________________________________________________
371 {
372  if ( ! HasMergedResults() ) return;
373 
374  TObjArray* condition = static_cast<TObjArray*>(fConditions->At(0));
375  TString titles = "";
376 
377  TObjArray effMapList;
378  effMapList.SetOwner();
379 
380  AliTrigChEffOutput* trigOut = 0x0;
381  TIter next(fMergedOutputs);
382  while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
383  TList* effList = GetEffHistoList(trigOut, condition);
384  AliMUONTriggerEfficiencyCells* effMap = new AliMUONTriggerEfficiencyCells(effList);
385  effMapList.Add(effMap);
386  titles += Form("%s,",trigOut->GetName());
387  }
388  titles.Remove(TString::kTrailing,',');
389 
390  CompareEfficiencies(&effMapList, titles.Data(), opt);
391 }
392 
393 
394 //________________________________________________________________________
395 //TArrayI AliMTRChEffAnalysis::CheckHomogeneity ( const TGraphAsymmErrors* trendGraph, Double_t nSigmas, Bool_t revert ) const
396 //{
397 // /// Check efficiency homogeneity
398 // TArrayI ranges(trendGraph->GetN());
399 // Double_t xpt=0., ypt=0.;
400 //
401 // Double_t sumEffOverSigma2 = -10.;
402 // Double_t sumInvSimga2 = 0.001;
403 // Int_t irange = 0;
404 // Int_t npt = trendGraph->GetN();
405 // for ( Int_t ipt=0; ipt<npt; ipt++ ) {
406 // Int_t currPt = ( revert ) ? npt-1-ipt : ipt;
407 // trendGraph->GetPoint(currPt,xpt,ypt);
408 // Double_t err = GetError(trendGraph->GetErrorYlow(currPt),trendGraph->GetErrorYhigh(currPt));
409 // Double_t invSigma2 = 1./(err*err);
410 // Double_t effOverSigma2 = ypt*invSigma2;
411 //
412 // Double_t meanEff = sumEffOverSigma2 / sumInvSimga2;
413 // Double_t diff = ypt - meanEff;
414 // Double_t diffErr = TMath::Sqrt(err*err+1./sumInvSimga2);
416 // if ( TMath::Abs(diff)/diffErr > nSigmas ) {
417 // TString run = trendGraph->GetXaxis()->GetBinLabel(currPt+1);
418 // ranges[irange++] = run.Atoi();
419 // sumEffOverSigma2 = 0.;
420 // sumInvSimga2 = 0.;
421 // }
422 // sumEffOverSigma2 += effOverSigma2;
423 // sumInvSimga2 += invSigma2;
424 // }
425 // TString run = trendGraph->GetXaxis()->GetBinLabel(trendGraph->GetN());
426 // ranges[irange++] = run.Atoi();
427 // ranges.Set(irange);
428 // return ranges;
429 //}
430 
431 //________________________________________________________________________
432 void AliMTRChEffAnalysis::CopyDir(TDirectory *source) const
433 {
435  TDirectory *savdir = gDirectory;
436  TDirectory *adir = savdir->mkdir(source->GetName());
437  adir->cd();
438  //loop on all entries of this directory
439  TKey *key;
440  TIter nextkey(source->GetListOfKeys());
441  while ((key = (TKey*)nextkey())) {
442  const char *classname = key->GetClassName();
443  TClass *cl = gROOT->GetClass(classname);
444  if (!cl) continue;
445  if (cl->InheritsFrom(TDirectory::Class())) {
446  source->cd(key->GetName());
447  TDirectory *subdir = gDirectory;
448  adir->cd();
449  CopyDir(subdir);
450  adir->cd();
451  } else if (cl->InheritsFrom(TTree::Class())) {
452  TTree *T = (TTree*)source->Get(key->GetName());
453  adir->cd();
454  TTree *newT = T->CloneTree(-1,"fast");
455  newT->Write();
456  } else {
457  source->cd();
458  TObject *obj = key->ReadObj();
459  adir->cd();
460  obj->Write(obj->GetName(),TObject::kSingleKey);
461  delete obj;
462  }
463  }
464  adir->SaveSelf(kTRUE);
465  savdir->cd();
466 }
467 
468 
469 //________________________________________________________________________
470 Bool_t AliMTRChEffAnalysis::CopyLocally ( const char* runList, const char* path, const char* pattern, const char* localFileList, const char* outDir, const char* directory ) const
471 {
473  TString sPattern(pattern);
474  TString sOutDir(outDir);
475  TString sPath(path);
476  Bool_t isGrid = (! sPattern.IsNull());
477 
478  if ( sOutDir.IsNull() ) {
479  if ( isGrid ) {
480  TString data = sPath(TRegexp("/data/"));
481  TString year = sPath(TRegexp("/20[0-9][0-9]/"));
482  TString period = sPath(TRegexp("/LHC[0-9][0-9][a-z]"));
483  period.Append("/");
484  // TPRegexp re("/(muon|pass).*?/");
485  TString pass = AliAnalysisMuonUtility::GetPassName(path);
486  if ( pass.IsNull() ) pass = AliAnalysisMuonUtility::GetPassName(pattern);
487  sOutDir = data+year+period+pass;
488  sOutDir.ReplaceAll("//","/");
489  sOutDir.Remove(TString::kTrailing,'/');
490  sOutDir.Remove(TString::kLeading,'/');
491  }
492  else sOutDir = sPath;
493  sOutDir.Remove(TString::kTrailing,'/');
494  sOutDir.Remove(TString::kLeading,'/');
495  }
496 
497  TGridResult* res = 0x0;
498  if ( isGrid ) {
499  if ( ! gGrid ) TGrid::Connect("alien://");
500  res = gGrid->Query(path,pattern);
501  }
502 
503  TList* rl = GetRunList(runList);
504 
505  ofstream outFile(localFileList);
506  Bool_t allOk = kTRUE;
507  Bool_t prompt = kTRUE;
508  Bool_t overwrite = kFALSE;
509  for ( Int_t irun=0; irun<rl->GetEntries(); irun++ ) {
510  TString run = static_cast<TObjString*>(rl->At(irun))->String();
511  TString dest = Form("%s/%09i/QAresults.root",sOutDir.Data(),run.Atoi());
512  TString destDir = gSystem->DirName(dest.Data());
513  if ( gSystem->AccessPathName(destDir.Data()) ) ExecCommand(Form("mkdir -p %s",destDir.Data()),kFALSE);
514  Bool_t copyFile = kTRUE;
515  Bool_t isFileOk = kTRUE;
516  if ( gSystem->AccessPathName(dest) == 0 ) {
517  if ( prompt ) {
518  TString decision = "";
519  cout << "Local file " << dest.Data() << " already exist: overwrite? [y/n/ya/na (a=use decision for all)]" << endl;
520  cin >> decision;
521  if ( decision.EndsWith("a") ) prompt = kFALSE;
522  if ( decision.BeginsWith("y") ) overwrite = kTRUE;
523  else overwrite = kFALSE;
524  }
525  copyFile = overwrite;
526  }
527  if ( copyFile ) {
528  TString src = "";
529  if ( isGrid ) {
530  for ( Int_t ifile=0; ifile<res->GetEntries(); ifile++ ) {
531  TString inFilename = res->GetKey(ifile,"turl");
532  if ( inFilename.Contains(run.Data()) ) {
533  src = inFilename;
534  break;
535  }
536  }
537  if ( src.IsNull() ) {
538  AliWarning(Form("Cannot find output for run %s",run.Data()));
539  isFileOk = kFALSE;
540  }
541  else {
542  TFile* outFile = TFile::Open(dest,"RECREATE");
543  TFile* inFile = TFile::Open(src);
544  inFile->cd();
545  TDirectory* dir = static_cast<TDirectory*>(inFile->Get(directory));
546  if ( dir ) {
547  outFile->cd();
548  CopyDir(dir);
549  }
550  else isFileOk = kFALSE;
551  delete inFile;
552  delete outFile;
553  }
554  }
555  else {
556  src = Form("http://aliqamu.web.cern.ch/aliqamu/%s",dest.Data());
557  isFileOk = TFile::Cp(src.Data(),dest.Data());
558  }
559  }
560 
561  if ( isFileOk ) outFile << gSystem->pwd() << "/" << dest.Data() << endl;
562  else allOk = kFALSE;
563  }
564  delete rl;
565  outFile.close();
566  return allOk;
567 }
568 
569 //________________________________________________________________________
570 void AliMTRChEffAnalysis::DrawEffTrend ( Int_t itype, Int_t irpc, Double_t maxNsigmaOutliers, Double_t minEff, Double_t maxEff ) const
571 {
573  TString baseNames[3] = {"Chamber","RPC","Board"};
574  TString base = baseNames[itype] + "Eff";
575  if ( itype == AliTrigChEffOutput::kHboardEff ) {
576  if ( irpc < 0 ) {
577  AliWarning("Please specify RPC");
578  return;
579  }
580  base += Form("InRPC%i",irpc);
581  }
582 
583  Int_t nColumns = 2;
584  Int_t nRows = 2;
585  Int_t width = 600;
586  Int_t height = 600;
587  Int_t nDetEl = 4;
588  Int_t nCh = 1;
589  if ( itype != AliTrigChEffOutput::kHchamberEff ) {
590  nColumns = 6;
591  nRows = 3;
592  width = 1200;
593  height = 800;
594  nDetEl = 18;
595  nCh = 4;
596  }
597  TArrayI boards = BoardsInRPC(irpc);
598  if ( itype == AliTrigChEffOutput::kHboardEff ) nDetEl = boards.GetSize();
599 
600  for ( Int_t ich=0; ich<nCh; ich++ ) {
601  TString canName = base;
602  if ( itype != AliTrigChEffOutput::kHchamberEff ) canName += Form("Ch%i",11+ich);
603  TCanvas* can = new TCanvas(canName.Data(),canName.Data(),25*ich,25*ich,width,height);
604  can->Divide(nColumns,nRows,0,0);
605 // can->SetTopMargin(0.03);
606 // can->SetBottomMargin(0.1);
607  for ( Int_t idetelem=0; idetelem<nDetEl; idetelem++ ) {
608  can->cd(idetelem+1);
609  gPad->SetTicks(1,1);
610  Int_t detElemId = idetelem;
611  if ( itype == AliTrigChEffOutput::kHchamberEff ) detElemId = 11+idetelem;
612  else if ( itype == AliTrigChEffOutput::kHboardEff ) detElemId = boards[idetelem];
613 
614  TString title = Form("%s %i",baseNames[itype].Data(),detElemId);
615  TLegend* leg = new TLegend(0.2,0.15,0.8,0.4);
616  leg->SetHeader(title.Data());
617  for ( Int_t icount=0; icount<2; icount++ ) {
618  TGraphAsymmErrors* gr = GetTrendEff(itype, icount, ich, detElemId);
619  gr->SetLineColor(icount+1);
620  gr->SetMarkerColor(icount+1);
621  gr->SetMarkerStyle(24+2*icount);
622  gr->GetYaxis()->SetRangeUser(minEff,maxEff);
623 // gr->GetYaxis()->SetLabelSize(0.025*nRows);
624 // gr->GetXaxis()->SetLabelSize(0.025*nColumns);
625  gr->SetTitle("");
626  gr->Draw(icount==0?"ap":"p");
627  leg->AddEntry(gr,icount==0?"bending plane":"non-bending plane","lp");
628  if ( maxNsigmaOutliers > 0. ) {
629  TGraphAsymmErrors* outliers = GetOutliers(gr,maxNsigmaOutliers);
630  outliers->SetLineColor(6+icount);
631  outliers->SetMarkerColor(6+icount);
632  outliers->SetMarkerStyle(20+2*icount);
633  outliers->SetLineWidth(2);
634  outliers->Draw("p");
635  }
636  }
637  leg->Draw();
638  }
639  if ( itype == AliTrigChEffOutput::kHchamberEff ) break;
640  }
641 }
642 
643 //________________________________________________________________________
644 Bool_t AliMTRChEffAnalysis::DrawSystematicEnvelope ( Bool_t perRPC, Double_t miny, Double_t maxy ) const
645 {
647  if ( ! HasMergedResults() ) return kFALSE;
648 
650 
651  Int_t colors[] = {kBlack, kRed, kSpring, kTeal, kBlue, kViolet, kMagenta, kOrange, kGray};
652  Int_t ncolors = sizeof(colors)/sizeof(colors[0]);
653 
654  Int_t nConditions = fConditions->GetEntriesFast();
655 
656 
657  TObjArray* refCondition = 0x0;
658  TObjArray condTitle(nConditions);
659  condTitle.SetOwner();
660 
661  Double_t xpt, ypt, xref, yref;
662  TArrayD eff(4), effErr(4);
663 
664  AliTrigChEffOutput* trigOut = 0x0;
665  TIter next(fMergedOutputs);
666  Int_t imerged = -1;
667  while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
668  imerged++;
669 
670  // Get meaningful short titles for each systematic
671  if ( imerged == 0 ) {
672  for ( Int_t icond=0; icond<nConditions; icond++ ) {
673  TObjArray* condition = static_cast<TObjArray*>(fConditions->UncheckedAt(icond));
674  if ( icond == 0 ) refCondition = condition;
675  TString title = "";
676  for ( Int_t ic=0; ic<condition->GetEntriesFast(); ic++ ) {
677  TString currCond = static_cast<TObjString*>(condition->UncheckedAt(ic))->String();
678  TString refCond = static_cast<TObjString*>(refCondition->UncheckedAt(ic))->String();
679  if ( currCond == refCond ) continue;
680  TString add = currCond;
681  if ( ic == 3 ) add = trigOut->GetHistoName(-1,-1,-1,currCond.Atoi(),-1,-1);
682  else if ( ic == 4 ) add = trigOut->GetHistoName(-1,-1,-1,-1,currCond.Atoi(),-1);
683  else if ( ic == 5 ) add = trigOut->GetHistoName(-1,-1,-1,-1,-1,currCond.Atoi());
684  title += Form("_%s",add.Data());
685  }
686  title.Remove(TString::kLeading,'_');
687  condTitle.AddAt(new TObjString(title),icond);
688  }
689  }
690 
691  // First get the needed graphs
692  Int_t nDE = 0;
693  TObjArray effGraphs[8];
694  for ( Int_t iplane=0; iplane<8; iplane++ ) {
695  effGraphs[iplane].SetOwner();
696  }
697  for ( Int_t icond=0; icond<nConditions; icond++ ) {
698  TObjArray* condition = static_cast<TObjArray*>(fConditions->UncheckedAt(icond));
699  for ( Int_t icount=0; icount<2; icount++ ) {
700  for ( Int_t ich=0; ich<4; ich++ ) {
701  Int_t iplane = 4*icount+ich;
702  TH1* histoNum = GetSum(trigOut,condition,itype,icount,ich);
703  TH1* histoDen = GetSum(trigOut,condition,itype,AliTrigChEffOutput::kAllTracks,ich);
704  TGraphAsymmErrors* gr = new TGraphAsymmErrors(histoNum,histoDen,"e0");
705  nDE = gr->GetN();
706  effGraphs[iplane].Add(gr);
707  delete histoNum;
708  delete histoDen;
709  }
710  }
711  }
712 
713  // Draw average dispersion per plane
714  TString canName = Form("EffSyst_%s",trigOut->GetName());
715  Int_t pos = 25*(imerged+1);
716  TCanvas* can = new TCanvas(canName.Data(),canName.Data(),pos,pos,1200,800);
717  can->Divide(4,2,0,0);
718 
719  TObjArray* refCond = static_cast<TObjArray*>(fConditions->UncheckedAt(0));
720  for ( Int_t icount=0; icount<2; icount++ ) {
721  for ( Int_t ich=0; ich<4; ich++ ) {
722  Int_t iplane = 4*icount+ich;
723  can->cd(iplane+1);
724  gPad->SetTicks(1,1);
725  gPad->SetLogy();
726  TLegend* leg = new TLegend(0.15,0.7,0.9,0.9);
727  leg->SetHeader(trigOut->GetHistoName(-1,icount,ich,-1,-1,-1));
728  TH1* sumHisto = 0x0;
729  for ( Int_t icond=1; icond<nConditions; icond++ ) {
730  TH1* histo = new TH1D(Form("syst_%s_%s_plane%i_ch%i",trigOut->GetName(),condTitle[icond]->GetName(),icount,11+ich),"",200,-0.1,0.1);
731  histo->GetXaxis()->SetTitle("Eff.-(ref.Eff.)");
732 // histo->GetXaxis()->SetTitle("1/#sigma^{2}");
733 
734  TGraphAsymmErrors* gr = static_cast<TGraphAsymmErrors*>(effGraphs[iplane].UncheckedAt(icond));
735  TGraphAsymmErrors* grRef = static_cast<TGraphAsymmErrors*>(effGraphs[iplane].UncheckedAt(0));
736  for ( Int_t ipt=0; ipt<gr->GetN(); ipt++ ) {
737  gr->GetPoint(ipt,xpt,ypt);
738  Double_t err = GetError(gr->GetErrorYlow(ipt),gr->GetErrorYhigh(ipt));
739  Double_t invErr2 = ( err > 0. ) ? 1./(err*err) : 0.;
740  grRef->GetPoint(ipt,xref,yref);
741 
742  Double_t diff = ypt-yref;
743  histo->Fill(diff,invErr2);
744  }
745 
746  if ( ! sumHisto ) {
747  sumHisto = static_cast<TH1*>(histo->Clone(Form("syst_%s_plane%i_ch%i",trigOut->GetName(),icount,11+ich)));
748  sumHisto->SetLineColor(1);
749  sumHisto->Draw();
750  leg->AddEntry(sumHisto,"All systematics","l");
751  }
752  else sumHisto->Add(histo);
753  Int_t icolor = ( icond < ncolors ) ? colors[icond] : 20+icond;
754  histo->SetLineColor(icolor);
755  histo->Draw("same");
756  leg->AddEntry(histo,condTitle[icond]->GetName(),"l");
757  } // loop on conditions
758  leg->Draw();
759  } // loop on chambers
760  } // loop on counts
761 
762 
763  canName = Form("TriggerEff_3outOf4_syst_%s",trigOut->GetName());
764  pos += 50;
765  TCanvas* canSyst = new TCanvas(canName.Data(),canName.Data(),pos,pos,600,600);
766  canSyst->SetLogy();
767  TLegend* leg = new TLegend(0.15,0.7,0.9,0.4);
768 // leg->SetHeader(trigOut->GetHistoName(-1,icount,ich,-1,-1,-1));
769  TH1* sumHisto = 0x0;
770  TH1* histo[nConditions];
771  for ( Int_t icond=0; icond<nConditions; icond++ ) {
772  histo[icond] = new TH1D(Form("TriggerEff_syst_%s_%s",condTitle[icond]->GetName(),trigOut->GetName()),"Dispersion of trigger probability (3/4)",200,-0.1,0.1);
773  histo[icond]->GetXaxis()->SetTitle("Trig. prob. - (ref. trig. prob)");
774  }
775 
776  for ( Int_t ipt=0; ipt<nDE; ipt++ ) {
777  Double_t refTrigProb = 0.; // refTrigProbErr = 0.;
778  for ( Int_t icond=0; icond<nConditions; icond++ ) {
779  Double_t trigProb = 1., trigProbErr2 = 0.;
780  for ( Int_t icount=0; icount<2; icount++ ) {
781  for ( Int_t ich=0; ich<4; ich++ ) {
782  Int_t iplane = 4*icount+ich;
783  TGraphAsymmErrors* gr = static_cast<TGraphAsymmErrors*>(effGraphs[iplane].UncheckedAt(icond));
784  gr->GetPoint(ipt,xpt,ypt);
785  eff[ich] = ypt;
786  effErr[ich] = GetError(gr->GetErrorYlow(ipt),gr->GetErrorYhigh(ipt));
787  } // loop on chambers
788  Double_t effErr34 = 0.;
789  Double_t eff34 = GetThreeOfFour(eff,effErr,effErr34);
790  trigProb *= eff34;
791  trigProbErr2 += effErr34*effErr34;
792  } // loop on counts
793 
794  if ( icond == 0 ) {
795  refTrigProb = trigProb;
796 // refTrigProbErr = trigProbErr;
797  }
798  else {
799  Double_t invErr2 = ( trigProbErr2>0. ) ? 1./trigProbErr2 : 0.;
800  histo[icond]->Fill(trigProb-refTrigProb,invErr2);
801  }
802  } // loop on conditions
803  } // loop on points
804 
805  for ( Int_t icond=0; icond<nConditions; icond++ ) {
806  TString title = ( icond == 0 ) ? "All systematics" : condTitle[icond]->GetName();
807  Int_t icolor = ( icond < ncolors ) ? colors[icond] : 20+icond;
808  histo[icond]->SetLineColor(icolor);
809  histo[icond]->Draw((icond == 0)?"":"same");
810  leg->AddEntry(histo[icond],title.Data(),"l");
811  if ( icond>0 ) histo[0]->Add(histo[icond]);
812  }
813  leg->Draw();
814  } // loop on merged output
815  return kTRUE;
816 }
817 
818 
819 //________________________________________________________________________
820 Double_t AliMTRChEffAnalysis::FitRangesFunc ( Double_t* x, Double_t* par )
821 {
828 
829  Double_t xx = x[0];
830  Double_t val = par[1];
831  Int_t nChanges = par[0];
832  for ( Int_t iknot=0; iknot<nChanges; iknot++ ) {
833  if ( xx > par[2*(iknot+1)] ) val = par[2*(iknot+1)+1];
834  }
835  return val;
836 }
837 
838 
839 //________________________________________________________________________
840 Bool_t AliMTRChEffAnalysis::ExecCommand ( TString command, Bool_t prompt ) const
841 {
843  TString decision = "y";
844 
845  if ( gROOT->IsBatch() ) prompt = kFALSE; // To run with crontab
846 
847  if ( prompt ) {
848  cout << command.Data() << " ? [y/n]" << endl;
849  cin >> decision;
850  }
851 
852  decision.ToLower();
853  if ( decision == "y" ) {
854  cout << "Executing: " << command.Data() << endl;
855  gSystem->Exec(command.Data());
856  return kTRUE;
857  }
858 
859  return kFALSE;
860 }
861 
862 //________________________________________________________________________
863 Double_t AliMTRChEffAnalysis::GetAverageStat ( Int_t firstRun, Int_t lastRun, Int_t itype,Bool_t excludePeriphericBoard ) const
864 {
865  TH1* statHisto = 0x0;
866  TObjArray* condition = static_cast<TObjArray*>(fConditions->At(0));
867 
868  TIter next(fOutputs);
869  AliTrigChEffOutput* trigOut = 0x0;
870  while ( (trigOut = static_cast<AliTrigChEffOutput*>(next()) ) ) {
871  UInt_t run = trigOut->GetUniqueID();
872  if ( run < firstRun || run > lastRun ) continue;
873  TH1* histo = GetSum(trigOut,condition,itype,AliTrigChEffOutput::kAllTracks,0);
874  if ( ! histo ) continue;
875  if ( statHisto ) statHisto->Add(histo);
876  else statHisto = static_cast<TH1*>(histo->Clone("tmpStatHisto"));
877  delete histo;
878  }
879  if ( ! statHisto ) return 0.;
880 
881  Double_t statPerDE = 0.;
882  Double_t nDe = 0.;
883  if ( itype == AliTrigChEffOutput::kHboardEff && excludePeriphericBoard ) {
884  Int_t excludeBoardsHalf[] = {1, 17, 39, 61, 77, 93,109,
885  16, 38, 60, 76, 92, 108, 117,
886  110, 111, 112, 113, 114, 115, 116};
887  Int_t nExcludedHalf = sizeof(excludeBoardsHalf)/sizeof(excludeBoardsHalf[0]);
888  for ( Int_t ibin=1; ibin<=statHisto->GetNbinsX(); ibin++ ) {
889  Bool_t skip = kFALSE;
890  for ( Int_t iexcl=0; iexcl<nExcludedHalf; iexcl++ ) {
891  if ( ibin == excludeBoardsHalf[iexcl] || ibin == excludeBoardsHalf[iexcl]+117 ) {
892  skip = kTRUE;
893  break;
894  }
895  }
896  if ( skip ) continue;
897  statPerDE += statHisto->GetBinContent(ibin);
898  nDe += 1.;
899  }
900  }
901  else {
902  statPerDE = statHisto->Integral();
903  nDe = (Double_t)statHisto->GetNbinsX();
904  }
905  statPerDE = nDe > 0. ? statPerDE/nDe : -1.;
906 
907  delete statHisto;
908  return statPerDE;
909 }
910 
911 //________________________________________________________________________
912 TList* AliMTRChEffAnalysis::GetEffHistoList ( AliTrigChEffOutput* trigOut, TObjArray* condition ) const
913 {
915  Int_t itrackSel = static_cast<TObjString*>(condition->At(3))->String().Atoi();
916  Int_t imatch = static_cast<TObjString*>(condition->At(4))->String().Atoi();
917  Int_t imethod = static_cast<TObjString*>(condition->At(5))->String().Atoi();
918 
919  return trigOut->GetEffHistoList(condition->At(0)->GetName(),condition->At(1)->GetName(),condition->At(2)->GetName(),itrackSel,imatch,imethod);
920 }
921 
922 //________________________________________________________________________
923 Double_t AliMTRChEffAnalysis::GetError ( Double_t errLow, Double_t errHigh ) const
924 {
926  return TMath::Max(errLow,errHigh);
927 }
928 
929 //________________________________________________________________________
930 TArrayI AliMTRChEffAnalysis::GetHomogeneusRanges ( Double_t chi2Cut, Int_t maxNRanges, Double_t minEffVariation, Double_t minEff, Double_t maxEff )
931 {
933 
934  Int_t nRuns = fOutputs->GetEntriesFast();
935 
936  TArrayI runChangeCount(nRuns);
937  for ( Int_t ich=0; ich<4; ich++ ) {
938  TString canName = Form("testRanges_ch%i",11+ich);
939  TCanvas* can = new TCanvas(canName.Data(),canName.Data(),10*ich,10*ich,1200,800);
940  can->Divide(6,3,0,0);
941  for ( Int_t irpc=0; irpc<18; irpc++ ) {
942  Int_t icount = AliTrigChEffOutput::kBothPlanesEff;
943  can->cd(irpc+1);
944  gPad->SetTicks(1,1);
945 // for ( Int_t icount=0; icount<2; icount++ ) {
946  TGraphAsymmErrors* trendGraph = GetTrendEff(AliTrigChEffOutput::kHslatEff,icount,ich,irpc);
947  TArrayI range = GetHomogeneusRanges(trendGraph,chi2Cut,maxNRanges,minEffVariation,kTRUE);
948  trendGraph->GetYaxis()->SetRangeUser(minEff,maxEff);
949  trendGraph->Draw("ap");
950  for ( Int_t ichange=0; ichange<range.GetSize(); ichange++ ) {
951  // Store only the run when the change applies
952  if ( ichange%2 == 1 ) continue;
953  Int_t runIdx = range[ichange];
954  if ( ichange != 0 ) {
955  TLine* line = new TLine(runIdx,minEff,runIdx,maxEff);
956  line->SetLineStyle(2);
957  line->Draw("same");
958  TLatex text;
959  text.DrawLatex((Double_t)(runIdx-3),maxEff-0.1*(maxEff-minEff)*(Double_t)(ichange/2),Form("%i",GetRunNumber(runIdx)));
960  }
961  runChangeCount[runIdx]++;
962  if ( runChangeCount[runIdx] == 1 ) {
963  AliInfo(Form("Efficiency change in %i triggered by ch %i RPC %i",GetRunNumber(runIdx),11+ich,irpc));
964  }
965  }
966 // }
967  }
968  }
969 
970  // Clusterize contiguous runs
971  TArrayI runChangeClust(nRuns);
972  Double_t sumWgtRun = 0.;
973  Double_t sumWgt = 0;
974  for ( Int_t irun=0; irun<=nRuns; irun++ ) {
975  if ( irun == nRuns || runChangeCount[irun] == 0 ) {
976  if ( sumWgt > 0. ) {
977  Int_t averageRun = TMath::Nint(sumWgtRun / sumWgt);
978  AliDebug(2,Form("Average run: %i => %i\n",averageRun,GetRunNumber(averageRun)));
979  runChangeClust[averageRun]++;
980  sumWgtRun = 0.;
981  sumWgt = 0.;
982  }
983  }
984  if ( irun == nRuns ) break;
985 
986  AliDebug(2,Form("irun %i => %i: wgt %i",irun,GetRunNumber(irun),runChangeCount[irun]));
987 
988  Double_t wgt = (Double_t)runChangeCount[irun];
989  sumWgtRun += wgt*(Double_t)irun;
990  sumWgt += wgt;
991  }
992 
993  Int_t ientry = 0;
994  TArrayI runRanges(nRuns);
995  for ( Int_t irun=0; irun<nRuns; irun++ ) {
996  if ( runChangeClust[irun] > 0 ) {
997  if ( irun > 0 ) runRanges[ientry++] = GetRunNumber(irun-1);
998  runRanges[ientry++] = GetRunNumber(irun);
999  }
1000  }
1001  runRanges[ientry++] = GetRunNumber(nRuns-1);
1002  runRanges.Set(ientry);
1003  return runRanges;
1004 }
1005 
1006 //________________________________________________________________________
1007 TArrayI AliMTRChEffAnalysis::GetHomogeneusRanges ( TGraphAsymmErrors* trendGraph, Double_t chi2Cut, Int_t maxNRanges, Double_t minEffVariation, Bool_t returnIndex )
1008 {
1010 
1011  TArrayI runRanges;
1012  TF1* func = 0x0;
1013 // TString canName = "fitTestCan";
1014 
1015  for ( Int_t istep=0; istep<maxNRanges; istep++ ) {
1016  Int_t nPars = 2*(istep+1);
1017  Double_t xMin = trendGraph->GetXaxis()->GetXmin();
1018  Double_t xMax = trendGraph->GetXaxis()->GetXmax();
1019  func = new TF1("rangeFunc",this,&AliMTRChEffAnalysis::FitRangesFunc,xMin,xMax,nPars,"AliMTRChEffAnalysis","FitRanges");
1020  func->FixParameter(0,istep);
1021  for ( Int_t ipar=1; ipar<nPars; ipar++ ) {
1022  Double_t val = ( ipar%2 == 1 ) ? 0.95 : (xMax-xMin) * (Double_t)(ipar/2)/((Double_t)(istep+1));
1023  func->SetParameter(ipar,val);
1024  }
1025 // trendGraph->Draw("ap");
1026  trendGraph->Fit(func,"NQ0");
1027 // func->DrawCopy("same");
1028  Double_t normChi2 = func->GetChisquare() / ((Double_t)func->GetNDF());
1029 // printf("normChi2 %g\n",normChi2);
1030  if ( normChi2 < chi2Cut ) break;
1031  delete func;
1032  func = 0x0;
1033  }
1034 
1035  if ( func ) {
1036  trendGraph->GetListOfFunctions()->Add(func->Clone());
1037  Int_t nSteps = func->GetParameter(0);
1038  runRanges.Set(2*(nSteps+1));
1039  Int_t irun = 0;
1040  runRanges[irun++] = returnIndex ? 0 : GetRunNumber(0);
1041  for ( Int_t istep=0; istep<nSteps; istep++ ) {
1042  Int_t ipar = 2*(istep+1);
1043  Double_t deltaEff = TMath::Abs(func->GetParameter(ipar-1)-func->GetParameter(ipar+1));
1044  if ( deltaEff < minEffVariation ) {
1045  AliWarning(Form("Efficiency variation for %s is %g => consider uniform",trendGraph->GetName(),deltaEff));
1046  continue;
1047  }
1048  Int_t ibin = trendGraph->GetXaxis()->FindBin(func->GetParameter(ipar));
1049  runRanges[irun++] = returnIndex ? ibin - 1 : GetRunNumber(ibin-1);
1050  runRanges[irun++] = returnIndex ? ibin : GetRunNumber(ibin);
1051  }
1052  Int_t lastPt = trendGraph->GetN()-1;
1053  runRanges[irun++] = returnIndex ? lastPt : GetRunNumber(trendGraph->GetN()-1);
1054  runRanges.Set(irun);
1055 // for ( Int_t irange=0; irange<runRanges.GetSize()/2; irange++ ) {
1056 // printf("%i - %i\n",runRanges[2*irange],runRanges[2*irange+1]);
1057 // }
1058  }
1059  return runRanges;
1060 }
1061 
1062 //________________________________________________________________________
1063 TString AliMTRChEffAnalysis::GetIdentifier ( AliTrigChEffOutput* trigOut, TObjArray* condition, Int_t itype, Int_t icount, Int_t ichamber ) const
1064 {
1066 // AliTrigChEffOutput* trigOut = static_cast<AliTrigChEffOutput*>(fOutputs->At(0));
1067 // if ( ! trigOut ) {
1068 // AliWarning("No output object found!");
1069 // delete arr;
1070 // return "";
1071 // }
1072  TString identifier = Form("/%s/%s/%s/",condition->At(0)->GetName(),condition->At(1)->GetName(),condition->At(2)->GetName());
1073  Int_t itrackSel = static_cast<TObjString*>(condition->At(3))->String().Atoi();
1074  Int_t imatch = static_cast<TObjString*>(condition->At(4))->String().Atoi();
1075  Int_t imethod = static_cast<TObjString*>(condition->At(5))->String().Atoi();
1076  TString objName = trigOut->GetHistoName(itype, icount, ichamber, itrackSel, imatch, imethod);
1077  identifier += objName;
1078  return identifier;
1079 }
1080 
1081 //________________________________________________________________________
1082 TGraphAsymmErrors* AliMTRChEffAnalysis::GetOutliers ( TGraphAsymmErrors* graph, Double_t maxNsigmas ) const
1083 {
1085 // TGraphAsymmErrors* outliers = new TGraphAsymmErrors();
1086  TGraphAsymmErrors* outliers = new TGraphAsymmErrors(*graph);
1087  outliers->SetHistogram(static_cast<TH1F*>(graph->GetHistogram()->Clone(Form("%s_outliers",graph->GetHistogram()->GetName()))));
1088 // outliers->SetLineColor(graph->GetLineColor()+1);
1089  if ( graph->GetListOfFunctions()->GetEntries() == 0 ) graph->Fit("pol0","Q0");
1090  TF1* func = static_cast<TF1*>(graph->GetListOfFunctions()->At(0));
1091 
1092  Double_t xpt, ypt;
1093  Int_t nremoved = 0;
1094  for ( Int_t ipt=0; ipt<graph->GetN(); ipt++ ) {
1095  graph->GetPoint(ipt,xpt,ypt);
1096  Double_t diff = ypt - func->Eval(xpt);
1097  Double_t err = ( diff < 0 ) ? graph->GetErrorYlow(ipt) : graph->GetErrorYhigh(ipt);
1098  if ( err < 0. || diff/err > maxNsigmas ) continue;
1099  outliers->RemovePoint(ipt-nremoved);
1100  nremoved++;
1101 // outliers->SetPoint(iopt,xpt,ypt);
1102  }
1103  return outliers;
1104 }
1105 
1106 //________________________________________________________________________
1107 Int_t AliMTRChEffAnalysis::GetRunNumber ( Int_t ipt ) const
1108 {
1110  if ( ipt < 0 && ipt >= fOutputs->GetEntriesFast() ) return -1;
1111  return fOutputs->UncheckedAt(ipt)->GetUniqueID();
1112 }
1113 
1114 //________________________________________________________________________
1115 TList* AliMTRChEffAnalysis::GetRunList ( const char* runList ) const
1116 {
1118  TList* rl = new TList;
1119  rl->SetOwner();
1120  TString sRunList = gSystem->ExpandPathName(runList);
1121  if ( gSystem->AccessPathName(sRunList) || sRunList.EndsWith(".root") ) {
1122  sRunList.ReplaceAll(","," ");
1123  if ( sRunList.IsDigit() ) {
1124  TObjArray* arr = sRunList.Tokenize(" ");
1125  for ( Int_t iarr=0; iarr<arr->GetEntries(); iarr++ ) {
1126  rl->Add(new TObjString(arr->At(iarr)->GetName()));
1127  }
1128  delete arr;
1129  }
1130  }
1131  else {
1132  ifstream inFile(sRunList.Data());
1133  TString currLine = "";
1134  while ( ! inFile.eof() ) {
1135  currLine.ReadLine(inFile);
1136  TString currRun = AliAnalysisMuonUtility::GetRunNumberAsString(currLine);
1137  if ( ! currRun.IsNull() ) rl->Add(new TObjString(currRun));
1138  }
1139  inFile.close();
1140  }
1141  rl->Sort();
1142  return rl;
1143 }
1144 
1145 //________________________________________________________________________
1146 TH1* AliMTRChEffAnalysis::GetSum ( AliTrigChEffOutput* trigOut, TObjArray* condition, Int_t itype, Int_t icount, Int_t ichamber ) const
1147 {
1149  Int_t itrackSel = static_cast<TObjString*>(condition->At(3))->String().Atoi();
1150  Int_t imatch = static_cast<TObjString*>(condition->At(4))->String().Atoi();
1151  Int_t imethod = static_cast<TObjString*>(condition->At(5))->String().Atoi();
1152  TString objName = trigOut->GetHistoName(itype, icount, ichamber, itrackSel, imatch, imethod);
1153  return static_cast<TH1*>(trigOut->GetSum(condition->At(0)->GetName(),condition->At(1)->GetName(),condition->At(2)->GetName(),objName));
1154 }
1155 
1156 //________________________________________________________________________
1157 TH1* AliMTRChEffAnalysis::GetTrend ( Int_t itype, Int_t icount, Int_t ichamber, Int_t idetelem ) const
1158 {
1160  if ( itype == AliTrigChEffOutput::kHchamberEff ) {
1161  if ( idetelem < 0 && ichamber >=0 ) idetelem = 11+ichamber;
1162  }
1163  TH1* outHisto = 0x0;
1164  TObjArray* condition = static_cast<TObjArray*>(fConditions->At(0));
1165 
1166  TIter next(fOutputs);
1167  AliTrigChEffOutput* trigOut = 0x0;
1168  Int_t ibin = 0;
1169  while ( (trigOut = static_cast<AliTrigChEffOutput*>(next()) ) ) {
1170  ibin++;
1171  TString identifier = GetIdentifier(trigOut,condition,itype,icount,ichamber);
1172  if ( ! outHisto ) {
1173  TString outName = identifier;
1174  outName.ReplaceAll("/","_");
1175  outName += Form("%i_trend",idetelem);
1176  outHisto = new TH1D(outName.Data(),outName.Data(),fOutputs->GetEntriesFast(),0.,(Double_t)fOutputs->GetEntriesFast());
1177  outHisto->SetDirectory(0);
1178  outHisto->GetXaxis()->SetTitle("Run num.");
1179  }
1180  UInt_t run = trigOut->GetUniqueID();
1181  outHisto->GetXaxis()->SetBinLabel(ibin,Form("%u",run));
1182  TH1* histo = GetSum(trigOut,condition,itype,icount,ichamber);
1183  if ( ! histo ) {
1184  AliWarning(Form("Run %u: cannot find %s",run,identifier.Data()));
1185  continue;
1186  }
1187  Int_t currBin = histo->GetXaxis()->FindBin(idetelem);
1188  outHisto->SetBinContent(ibin,histo->GetBinContent(currBin));
1189  outHisto->SetBinError(ibin,histo->GetBinError(currBin));
1190  }
1191  if ( outHisto ) outHisto->GetXaxis()->LabelsOption("v");
1192  return outHisto;
1193 }
1194 
1195 //________________________________________________________________________
1196 TGraphAsymmErrors* AliMTRChEffAnalysis::GetTrendEff ( Int_t itype, Int_t icount, Int_t ichamber, Int_t idetelem ) const
1197 {
1199  if ( icount == AliTrigChEffOutput::kAllTracks ) {
1200  AliWarning("Chose either bending plane, non-bending plane or both planes");
1201  return NULL;
1202  }
1203  TH1* histoNum = GetTrend(itype,icount,ichamber,idetelem);
1204  TH1* histoDen = GetTrend(itype,AliTrigChEffOutput::kAllTracks,ichamber,idetelem);
1205  TGraphAsymmErrors* graph = new TGraphAsymmErrors(histoNum,histoDen,"e0");
1206  histoNum->Reset();
1207  histoNum->SetStats(kFALSE);
1208  graph->SetHistogram(static_cast<TH1F*>(histoNum));
1209  graph->GetYaxis()->SetTitle("Efficiency");
1210  graph->SetMarkerSize(0.5);
1211 // for ( Int_t ibin=1; ibin<=histoNum->GetXaxis()->GetNbins(); ibin++ ) {
1212 // graph->GetXaxis()->SetBinLabel(ibin,histoNum->GetXaxis()->GetBinLabel(ibin));
1213 // }
1214 // delete histoNum;
1215  delete histoDen;
1216  return graph;
1217 }
1218 
1219 //________________________________________________________________________
1220 Double_t AliMTRChEffAnalysis::GetThreeOfFour ( TArrayD eff, TArrayD effErr, Double_t &probErr ) const
1221 {
1223  Double_t binomialEff = 0.;
1224  Double_t sumErr2 = 0.;
1225  for ( Int_t jch=-1; jch<4; jch++ ) {
1226  Double_t prodEff = 1.;
1227  Double_t prodErr2 = 0.;
1228  for ( Int_t ich=0; ich<4; ich++ ) {
1229  Double_t currEff = ( ich == jch ) ? 1.-eff[ich] : eff[ich];
1230  prodEff *= currEff;
1231  Double_t relErr = ( currEff>0. ) ? effErr[ich]/currEff : 0.;
1232  prodErr2 += relErr*relErr;
1233  }
1234  binomialEff += prodEff;
1235  sumErr2 += prodEff*prodEff*prodErr2;
1236  }
1237  probErr = TMath::Sqrt(sumErr2);
1238  return binomialEff;
1239 }
1240 
1241 //________________________________________________________________________
1243 {
1245  if ( ! fMergedOutputs || fMergedOutputs->IsEmpty() ) {
1246  AliError("You first need to merge efficiency objects with MergeOutput");
1247  return kFALSE;
1248  }
1249  return kTRUE;
1250 }
1251 
1252 //________________________________________________________________________
1253 Bool_t AliMTRChEffAnalysis::MergeOutput ( TArrayI runRanges, Double_t averageStatError, Bool_t isIndex )
1254 {
1256 
1257  if ( runRanges.GetSize()%2 == 1 ) {
1258  AliError("Run ranges expected in the form: start_period1,end_period1,start_period2,end_period2... => even number expected");
1259  return kFALSE;
1260  }
1261 
1262  TArrayI mergedRanges = MergeRangesForStat(runRanges, averageStatError);
1263 
1264  Int_t nRanges = mergedRanges.GetSize()/2;
1265 
1266 
1267  if ( fMergedOutputs ) fMergedOutputs->Delete();
1268  else {
1269  fMergedOutputs = new TObjArray(nRanges);
1270  fMergedOutputs->SetOwner();
1271  }
1272 
1273  AliTrigChEffOutput* trigOut = 0x0;
1274  for ( Int_t irange=0; irange<nRanges; irange++ ) {
1275  Int_t firstRun = mergedRanges[2*irange];
1276  Int_t lastRun = mergedRanges[2*irange+1];
1277  if ( isIndex ) {
1278  firstRun = GetRunNumber(firstRun);
1279  lastRun = GetRunNumber(lastRun);
1280  }
1281 
1282  TObjArray* mergedOut = 0x0;
1283  TList list;
1284  TIter next(fOutputs);
1285  while ( (trigOut = static_cast<AliTrigChEffOutput*>(next()) ) ) {
1286  UInt_t run = trigOut->GetUniqueID();
1287  if ( run < firstRun || run > lastRun ) continue;
1288  if ( mergedOut ) list.Add(trigOut->GetOutput());
1289  else mergedOut = static_cast<TObjArray*>(trigOut->GetOutput()->Clone());
1290  }
1291  mergedOut->Merge(&list);
1292  trigOut = new AliTrigChEffOutput(mergedOut,Form("%i_%i",firstRun,lastRun));
1293  trigOut->SetOwner();
1294  fMergedOutputs->Add(trigOut);
1295  }
1296  return kTRUE;
1297 }
1298 
1299 //________________________________________________________________________
1300 TArrayI AliMTRChEffAnalysis::MergeRangesForStat ( TArrayI runRanges, Double_t averageStatError, Bool_t excludePeriphericBoards ) const
1301 {
1302  if ( averageStatError <= 0. || averageStatError >= 1. ) return runRanges;
1303 
1304  Double_t averageStatNeeded = 1./(averageStatError*averageStatError);
1305 
1306  AliInfo(Form("Average statistics needed to reach precision of %g : %g",averageStatError,averageStatNeeded));
1307 
1308  Int_t nRanges = runRanges.GetSize()/2;
1309 
1310  TArrayD averageStat(nRanges);
1311  Double_t fullStat = 0.;
1312  for ( Int_t irange=0; irange<nRanges; irange++ ) {
1313  averageStat[irange] = GetAverageStat(runRanges[2*irange],runRanges[2*irange+1],AliTrigChEffOutput::kHboardEff,excludePeriphericBoards);
1314  fullStat += averageStat[irange];
1315  }
1316 
1317  TArrayI mergedRanges(runRanges.GetSize());
1318  Int_t imerged = 0;
1319  mergedRanges[imerged++] = runRanges[0];
1320  Double_t mergedAverageStat = 0., remainingStat = fullStat;
1321  for ( Int_t irange=0; irange<nRanges; irange++ ) {
1322  Int_t istart = 2*irange;
1323  Int_t iend = istart+1;
1324  mergedAverageStat += averageStat[irange];
1325  remainingStat -= averageStat[irange];
1326 
1327  AliInfo(Form("%i - %i => stat %g",runRanges[2*irange],runRanges[2*irange+1],averageStat[irange]));
1328 
1329  if ( ( mergedAverageStat >= averageStatNeeded && remainingStat >= averageStatNeeded ) || iend == runRanges.GetSize()-1 ) {
1330  mergedRanges[imerged++] = runRanges[iend];
1331  AliInfo(Form(" merged range %i - %i => stat %g",mergedRanges[imerged-2],mergedRanges[imerged-1],mergedAverageStat));
1332  mergedAverageStat = 0.;
1333  Int_t nextRun = iend+1;
1334  if ( nextRun < runRanges.GetSize() ) mergedRanges[imerged++] = runRanges[nextRun];
1335  }
1336  }
1337  mergedRanges.Set(imerged);
1338  return mergedRanges;
1339 }
1340 
1341 //________________________________________________________________________
1342 Bool_t AliMTRChEffAnalysis::SetCondition ( const char* physSel, const char* trigClassName, const char* centrality, Int_t itrackSel, Int_t imatch, Int_t imethod, Bool_t isBasic )
1343 {
1345  if ( ! fConditions ) {
1346  fConditions = new TObjArray();
1347  fConditions->SetOwner();
1348  }
1349 
1350  TString sCondition = Form("%s;%s;%s;%i;%i;%i",physSel,trigClassName,centrality,itrackSel,imatch,imethod);
1351  TObjArray* foundCondition = static_cast<TObjArray*>(fConditions->FindObject(sCondition.Data()));
1352  TObjArray* basicCondition = static_cast<TObjArray*>(fConditions->At(0));
1353 
1354  TObjArray* addCondition = 0x0;
1355 
1356  if ( foundCondition ) {
1357  if ( isBasic ) {
1358  if ( foundCondition == basicCondition ) return kFALSE;
1359  else {
1360  fConditions->Remove(foundCondition);
1361  addCondition = foundCondition;
1362  }
1363  }
1364  else {
1365  AliInfo("Systematic condition already added");
1366  return kFALSE;
1367  }
1368  }
1369  else {
1370  addCondition = sCondition.Tokenize(";");
1371  addCondition->SetName(sCondition.Data());
1372  }
1373 
1374 
1375  if ( isBasic ) {
1376  if ( basicCondition ) {
1377  AliInfo(Form("Changing current eff. condition: %s\n",basicCondition->GetName()));
1378  fConditions->Remove(basicCondition);
1379  delete basicCondition;
1380  }
1381  fConditions->AddAt(addCondition,0);
1382  fConditions->Compress();
1383  }
1384  else fConditions->Add(addCondition);
1385 
1386  return kTRUE;
1387 }
1388 
1389 //________________________________________________________________________
1391 {
1394 }
1395 
1396 
1397 //________________________________________________________________________
1398 Bool_t AliMTRChEffAnalysis::SetEffConditions ( const char* physSel, const char* trigClassName, const char* centrality, Int_t itrackSel, Int_t imatch, Int_t imethod )
1399 {
1401  return SetCondition(physSel, trigClassName, centrality, itrackSel, imatch, imethod, kTRUE);
1402 }
1403 
1404 //________________________________________________________________________
1405 Bool_t AliMTRChEffAnalysis::SetOutList ( const char *localFileList, const char *outputName )
1406 {
1408 
1409  TString filename(localFileList);
1410  gSystem->ExpandPathName(filename);
1411  if ( gSystem->AccessPathName(filename.Data()) ) {
1412  AliWarning(Form("Cannot find %s",filename.Data()));
1413  return kFALSE;
1414  }
1415  if ( filename.EndsWith(".root") ) return AddToList(filename.Data(),outputName);
1416 
1417  Bool_t isOk = kTRUE;
1418  ifstream inFile(filename.Data());
1419  TString currLine = "";
1420  while ( ! inFile.eof() ) {
1421  currLine.ReadLine(inFile);
1422  if ( currLine.IsNull() ) continue;
1423  if ( gSystem->AccessPathName(currLine.Data()) ) continue;
1424  if ( ! AddToList(currLine.Data(), outputName) ) isOk = kFALSE;
1425  }
1426  inFile.close();
1427 
1429 
1430  return isOk;
1431 }
1432 
1433 //________________________________________________________________________
1434 Bool_t AliMTRChEffAnalysis::SetResultsFromGrid ( const char *runList, const char *path, const char *pattern, const char* localFileList, const char* outDir, const char *directory, const char* outputName )
1435 {
1437  CopyLocally(runList,path,pattern,localFileList,outDir,directory);
1438  return SetOutList(localFileList,outputName);
1439 }
1440 
1441 //________________________________________________________________________
1442 Bool_t AliMTRChEffAnalysis::SetResultsFromWeb ( const char *runList, const char *path, const char* localFileList, const char* outDir, const char *directory, const char* outputName )
1443 {
1445  CopyLocally(runList,path,"",localFileList,outDir,directory);
1446  return SetOutList(localFileList,outputName);
1447 }
1448 
1449 //________________________________________________________________________
1450 Bool_t AliMTRChEffAnalysis::WriteMergedToOCDB ( const char* outputCDB ) const
1451 {
1453  if ( ! HasMergedResults() ) return kFALSE;
1454  TString outCDBdir(outputCDB);
1455  if ( outCDBdir.Contains("://") && ! outCDBdir.BeginsWith("local") ) {
1456  AliError("A local directory is required to store the information");
1457  return kFALSE;
1458  }
1459  outCDBdir.ReplaceAll("local://","");
1460  if ( gSystem->AccessPathName(outCDBdir.Data()) ) {
1461  if ( ! ExecCommand(Form("mkdir -p %s",outCDBdir.Data()), kTRUE) ) {
1462  AliError(Form("Failed to create directory %s",outCDBdir.Data()));
1463  return kFALSE;
1464  }
1465  }
1466  TString outCDB = outCDBdir;
1467  outCDB.Prepend("local://");
1468 
1469  AliCDBManager* mgr = AliCDBManager::Instance();
1470  if ( ! mgr->GetDefaultStorage() ) mgr->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
1471 
1472  TString trigEffCDBdir = "MUON/Calib/TriggerEfficiency";
1473 
1474  mgr->SetSpecificStorage(trigEffCDBdir.Data(),outCDB.Data());
1475 
1476  AliCDBStorage* specificStorage = mgr->GetSpecificStorage(trigEffCDBdir.Data());
1477 
1478  TObjArray* condition = static_cast<TObjArray*>(fConditions->At(0));
1479 
1480  AliTrigChEffOutput* trigOut = 0x0;
1481  TIter next(fMergedOutputs);
1482  while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
1483  TList* effList = GetEffHistoList(trigOut,condition);
1484  TString runRange = trigOut->GetName();
1485 
1486  // Write full merged output in file
1487  TFile* file = TFile::Open(Form("mergedTrigEff_runs_%s.root",runRange.Data()),"RECREATE");
1488  effList->Write("triggerChamberEff",TObject::kSingleKey);
1489  trigOut->GetOutput()->Write(trigOut->GetOutput()->GetName(),TObject::kSingleKey);
1490  file->Close();
1491  delete file;
1492 
1493 
1494  // Write OCDB object
1495  TObjArray* currRange = runRange.Tokenize("_");
1496  Int_t firstRun = static_cast<TObjString*>(currRange->UncheckedAt(0))->String().Atoi();
1497  Int_t lastRun = static_cast<TObjString*>(currRange->UncheckedAt(1))->String().Atoi();
1498  delete currRange;
1499 
1500  // If an object is already there, ask to remove it or keep it
1501  for ( Int_t irun=0; irun<2; irun++ ) {
1502  Int_t runnr = ( irun == 0 ) ? firstRun : lastRun;
1503  specificStorage->QueryCDB(runnr);
1504  TObjArray* allIdsForRun = specificStorage->GetQueryCDBList();
1505  TIter nextId(allIdsForRun);
1506  AliCDBId* id = 0x0;
1507  while ((id = dynamic_cast<AliCDBId*>(nextId()))) {
1508  TString path(id->GetPath());
1509  Int_t foundFirst = id->GetFirstRun();
1510  Int_t foundLast = id->GetLastRun();
1511  Int_t version = id->GetVersion();
1512  Int_t subversion = id->GetSubVersion();
1513  TString locPath = Form("%s/%s/Run%d_%d_v%d_s%d.root",outCDBdir.Data(),path.Data(),foundFirst,foundLast,version,subversion);
1514  if ( ! gSystem->AccessPathName(locPath.Data()) ) {
1515  ExecCommand(Form("rm %s",locPath.Data()), kTRUE);
1516  }
1517  }
1518  }
1519 
1520  // Save the CDB object in the specific storage
1521  AliMUONTriggerEfficiencyCells* effMap = new AliMUONTriggerEfficiencyCells(effList);
1522  AliMUONCDB::WriteToCDB(effMap, "MUON/Calib/TriggerEfficiency", firstRun, lastRun, "Measured efficiencies");
1523  delete effMap; // CAVEAT: effMap is owner of efflist
1524  }
1525  return kTRUE;
1526 }
1527 
1528 //___________________________________________________________________________
1529 //Bool_t AliMTRChEffAnalysis::WriteMerged() const
1530 //{
1531 // /// Write merged efficiencies on file
1532 // if ( ! HasMergedResults ) return kFALSE;
1533 //
1534 // TObjArray* condition = static_cast<TObjArray*>(fConditions->At(0));
1535 //
1536 // AliTrigChEffOutput* trigOut = 0x0;
1537 // TIter next(fMergedOutputs);
1538 // while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
1539 // TFile* file = TFile::Open(Form("mergedTrigEff_runs_%s.root",trigOut->GetName()),"RECREATE");
1540 // TList* effList = GetEffHistoList(trigOut,condition);
1541 // effList->Write("triggerChamberEff",TObject::kSingleKey);
1542 // trigOut->GetOutput()->Write(trigOut->GetOutput()->GetName(),TObject::kSingleKey);
1543 // file->Close();
1544 // delete file;
1545 // delete effList;
1546 // }
1547 // return kTRUE;
1548 //}
void CompareEfficiencies(const char *sources, const char *titles, const char *opt) const
Counts per cathode histogram index.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TList * GetEffHistoList(TString physSel, TString trigClassNames, TString centrality, Int_t itrackSel, Int_t imatch, Int_t imethod)
void CompareMergedEfficiencies(const char *opt) const
void CopyDir(TDirectory *source) const
Double_t GetError(Double_t errLow, Double_t errHigh) const
Bool_t DrawSystematicEnvelope(Bool_t perRPC=kFALSE, Double_t miny=-0.03, Double_t maxy=0.03) const
const char * title
Definition: MakeQAPdf.C:26
tracks used for calculation
Bool_t CopyLocally(const char *runList, const char *path, const char *pattern, const char *localFileList, const char *outDir, const char *directory) const
Hit pattern from tracker track extrapolation.
Double_t GetThreeOfFour(TArrayD eff, TArrayD effErr, Double_t &probErr) const
TSystem * gSystem
TGraphAsymmErrors * GetTrendEff(Int_t itype, Int_t icount, Int_t ichamber, Int_t idetelem) const
centrality
TList * list
TArrayI MergeRangesForStat(TArrayI runRanges, Double_t averageStatError, Bool_t excludePeriphericBoards=kTRUE) const
Counts per slat histogram index.
Bool_t SetResultsFromGrid(const char *runList, const char *path, const char *pattern, const char *localFileList="localFileList.txt", const char *outDir="", const char *directory="MTR_ChamberEffMap", const char *outputName="testMTRChamberEff")
Int_t nDE
TList * GetEffHistoList(AliTrigChEffOutput *trigOut, TObjArray *condition) const
Bool_t AddToList(const char *filename, const char *outputName)
TObjArray * fMergedOutputs
!<! List of conditions for trigger efficiency
Output for Trig chamber effieincy.
Bool_t SetEffConditions(const char *physSel, const char *trigClassName, const char *centrality, Int_t itrackSel, Int_t imatch, Int_t imethod)
Output for Trig chamber effieincy.
Double_t GetAverageStat(Int_t firstRun, Int_t lastRun, Int_t itype=AliTrigChEffOutput::kHboardEff, Bool_t excludePeriphericBoards=kTRUE) const
Bool_t SetOutList(const char *localFileList, const char *outputName)
TArrayI GetHomogeneusRanges(Double_t chi2Cut=3, Int_t maxNRanges=4, Double_t minEffVariation=0.005, Double_t minEff=0.85, Double_t maxEff=1.01)
TString GetIdentifier(AliTrigChEffOutput *trigOut, TObjArray *condition, Int_t itype, Int_t icount, Int_t ichamber) const
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 SetCondition(const char *physSel, const char *trigClassName, const char *centrality, Int_t itrackSel, Int_t imatch, Int_t imethod, Bool_t isBasic)
Bool_t WriteMergedToOCDB(const char *outputCDB="CDB") const
TList * GetRunList(const char *runList) const
Int_t GetRunNumber(Int_t ipt) const
Bool_t HasMergedResults() const
Bool_t ExecCommand(TString command, Bool_t prompt) const
TArrayI BoardsInRPC(Int_t irpc) const
TFile * file
Double_t FitRangesFunc(Double_t *x, Double_t *par)
Counts per board histogram index.
void DrawEffTrend(Int_t itype, Int_t irpc, Double_t maxNsigmasOutliers=-1., Double_t minEff=0.8, Double_t maxEff=1.01) const
TObjArray * fConditions
!<! List of outputs
TGraphAsymmErrors * GetOutliers(TGraphAsymmErrors *graph, Double_t maxNsigmas=3.) const
Bool_t AddSystematicCondition(const char *physSel, const char *trigClassName, const char *centrality, Int_t itrackSel, Int_t imatch, Int_t imethod)
Bool_t SetResultsFromWeb(const char *runList, const char *path, const char *localFileList="localFileList.txt", const char *outDir="", const char *directory="MTR_ChamberEffMap", const char *outputName="testMTRChamberEff")
Bool_t MergeOutput(TArrayI runRanges, Double_t averageStatError=0.01, Bool_t isIndex=kFALSE)
TString GetHistoName(Int_t itype, Int_t icount, Int_t ichamber, Int_t itrackSel, Int_t imatch, Int_t imethod)
TH1 * GetSum(AliTrigChEffOutput *trigOut, TObjArray *condition, Int_t itype, Int_t icount, Int_t ichamber) const
TH1 * GetTrend(Int_t itype, Int_t icount, Int_t ichamber, Int_t idetelem) const