19 #include <Riostream.h>
20 #include "TObjString.h"
21 #include "TObjArray.h"
28 #include "TDirectory.h"
34 #include "TGridResult.h"
35 #include "TGraphAsymmErrors.h"
45 #include "TFileMerger.h"
46 #include "TFitResultPtr.h"
49 #include "AliMergeableCollection.h"
50 #include "AliCounterCollection.h"
52 #include "AliAnalysisMuonUtility.h"
55 #include "AliCDBManager.h"
56 #include "AliCDBStorage.h"
58 #include "AliCDBEntry.h"
59 #include "AliMUONCDB.h"
60 #include "AliMUONTriggerEfficiencyCells.h"
109 return SetCondition(physSel, trigClassName, centrality, itrackSel, imatch, imethod, kFALSE);
117 if ( ! trigOut->GetMergeableCollection() ) {
118 AliError(Form(
"Cannot find %s in %s\n",outputName,filename));
128 effHistoList->SetName(filename);
129 TString currRun = AliAnalysisMuonUtility::GetRunNumberAsString(filename);
130 effHistoList->SetUniqueID(currRun.Atoi());
150 if ( irpc == 0 || irpc == 9 ) {
151 Int_t arr[] = {26,27,28,29,48,49,50,51,68,69,84,85,100,101,113};
152 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
153 boards.Set(nBoards,arr);
155 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
157 else if ( irpc == 1 || irpc == 8 ) {
158 Int_t arr[] = {9,10,11,30,31,32,33,52,53,54,55,70,71,86,87,102,103,114};
159 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
160 boards.Set(nBoards,arr);
162 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
164 else if ( irpc == 2 || irpc == 7 ) {
165 Int_t arr[] = {12,13,34,35,56,57,72,73,88,89,104,105,115};
166 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
167 boards.Set(nBoards,arr);
169 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
171 else if ( irpc == 3 || irpc == 6 ) {
172 Int_t arr[] = {14,15,36,37,58,59,74,75,90,91,106,107,116};
173 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
174 boards.Set(nBoards,arr);
176 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
178 else if ( irpc == 4 || irpc == 5 ) {
179 Int_t arr[] = {16,38,60,76,92,108,117};
180 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
181 boards.Set(nBoards,arr);
183 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
185 else if ( irpc == 17 || irpc == 10 ) {
186 Int_t arr[] = {6,7,8,22,23,24,25,44,45,46,47,66,67,82,83,98,99,112};
187 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
188 boards.Set(nBoards,arr);
190 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
192 else if ( irpc == 16 || irpc == 11 ) {
193 Int_t arr[] = {4,5,20,21,42,43,64,65,80,81,96,97,111};
194 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
195 boards.Set(nBoards,arr);
197 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
199 else if ( irpc == 15 || irpc == 12 ) {
200 Int_t arr[] = {2,3,18,19,40,41,62,63,78,79,94,95,110};
201 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
202 boards.Set(nBoards,arr);
204 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
206 else if ( irpc == 14 || irpc == 13 ) {
207 Int_t arr[] = {1,17,39,61,77,93,109};
208 Int_t nBoards =
sizeof(arr)/
sizeof(arr[0]);
209 boards.Set(nBoards,arr);
211 for (
Int_t iboard=0; iboard<nBoards; iboard++ ) boards[iboard] += 117;
222 if ( srcs.Contains(
"raw://") ) {
223 AliError(
"The method assumes that the specified storage is a SpecificStorage. Hence, please replace raw:// with the actual path in alien, e.g.: alien://folder=/alice/data/<year>/OCDB");
226 TObjArray* sourceList = srcs.Tokenize(
",");
228 effMapList.SetOwner();
230 TString trigEffCDBdir =
"MUON/Calib/TriggerEfficiency";
232 TIter next(sourceList);
233 TObjString* src = 0x0;
234 while ( (src = static_cast<TObjString*>(next())) ) {
235 TString currSrc = src->String();
236 if ( currSrc.BeginsWith(
"alien") && ! gGrid ) TGrid::Connect(
"alien://");
238 AliMUONTriggerEfficiencyCells* effMap = 0x0;
239 if ( currSrc.EndsWith(
".root") ) effMap =
new AliMUONTriggerEfficiencyCells(currSrc.Data());
241 TObjArray* dirRun = currSrc.Tokenize(
"?");
243 TString runNum = ( dirRun->GetEntriesFast() > 1 ) ? dirRun->UncheckedAt(1)->GetName() :
"";
244 AliCDBManager* mgr = AliCDBManager::Instance();
245 if ( ! mgr->GetDefaultStorage() ) mgr->SetDefaultStorage(
"local://$ALICE_ROOT/OCDB");
246 if ( mgr->GetSpecificStorage(trigEffCDBdir.Data()) ) mgr->UnloadFromCache(trigEffCDBdir.Data());
247 mgr->SetSpecificStorage(trigEffCDBdir.Data(),cdbPath.Data());
249 if ( runNum.IsNull() ) {
250 cout <<
"Please enter run number: " << endl;
253 else runNumber = runNum.Atoi();
254 mgr->SetRun(runNumber);
255 AliCDBEntry* cdbEntry = mgr->Get(trigEffCDBdir.Data());
259 effMap =
static_cast<AliMUONTriggerEfficiencyCells*
>(cdbEntry->GetObject()->Clone());
261 if ( ! effMap )
continue;
262 effMapList.Add(effMap);
274 TObjArray* titleList = sTitles.Tokenize(
",");
278 Int_t nLists = effMapList->GetEntriesFast();
280 TString sCanvasNameSuffix(canvasNameSuffix);
281 if ( ! sCanvasNameSuffix.IsNull() && ! sCanvasNameSuffix.BeginsWith(
"_") ) sCanvasNameSuffix.Prepend(
"_");
284 enum {kEff, kDiff, kPull};
289 if ( sOpt.Contains(
"diff") ) {
291 yTitle =
"Eff. - (ref.Eff)";
293 else if ( sOpt.Contains(
"pull") ) {
295 yTitle =
"(Eff - (ref.Eff)) / err";
299 Bool_t needsLegend = ( nLists > 1 );
302 Int_t colors[] = {kBlack, kRed, kSpring, kTeal, kBlue, kViolet, kMagenta, kOrange, kGray};
303 Int_t ncolors =
sizeof(colors)/
sizeof(colors[0]);
305 Int_t hTypes[2] = {AliMUONTriggerEfficiencyCells::kHboardCount,AliMUONTriggerEfficiencyCells::kHslatCount};
306 Int_t countTypes[3] = {AliMUONTriggerEfficiencyCells::kBendingEff,AliMUONTriggerEfficiencyCells::kNonBendingEff,AliMUONTriggerEfficiencyCells::kBothPlanesEff};
310 for (
Int_t itype=0; itype<2; itype++ ) {
311 TString xTitle = ( hTypes[itype] == AliMUONTriggerEfficiencyCells::kHslatCount ) ?
"RPC" :
"Board";
312 for (
Int_t icount=0; icount<3; icount++ ) {
314 for (
Int_t ich=0; ich<4; ich++ ) {
319 for (
Int_t ilist=0; ilist<nLists; ilist++ ) {
320 TString currTitle = titleList->At(ilist)->GetName();
321 AliMUONTriggerEfficiencyCells* effMap =
static_cast<AliMUONTriggerEfficiencyCells*
>(effMapList->UncheckedAt(ilist));
322 currName = effMap->GetHistoName(hTypes[itype],AliMUONTriggerEfficiencyCells::kAllTracks,ich);
323 TH1* histoDen =
static_cast<TH1*
>(effMap->GetHistoList()->FindObject(currName.Data()));
324 currName = effMap->GetHistoName(hTypes[itype],countTypes[icount],ich);
325 TH1* histoNum =
static_cast<TH1*
>(effMap->GetHistoList()->FindObject(currName.Data()));
327 currName = histoNum->GetName();
328 currName.ReplaceAll(
"Count",
"Eff");
329 currName.Append(Form(
"_%s",currTitle.Data()));
330 graph->SetName(currName.Data());
332 if ( iopt != kEff ) {
334 for (
Int_t ipt=0; ipt<graph->GetN(); ipt++ ) {
335 refGraph->GetPoint(ipt,xref,yref);
336 graph->GetPoint(ipt,xpt,ypt);
338 if ( TMath::Abs(diff) > 1.e-4 ) nDiffs++;
339 if ( iopt == kDiff ) graph->SetPoint(ipt,xpt,diff);
340 else if ( iopt == kPull ) {
341 Double_t err =
GetError(graph->GetErrorYlow(ipt),graph->GetErrorYhigh(ipt));
342 Double_t pull = ( err > 0. ) ? diff/err : 0.;
343 graph->SetPoint(ipt,xpt,pull);
354 currName = graph->GetName();
355 currName.Remove(currName.Length()-currTitle.Length()-5);
356 currName += sCanvasNameSuffix;
357 can =
new TCanvas(currName.Data(),currName.Data(),20*ican,20*ican,600,600);
361 if ( needsLegend && ! leg ) {
362 leg =
new TLegend(0.35, 0.15, 0.65, 0.45);
363 if ( refGraph ) leg->SetHeader(Form(
"Ref.: %s",titleList->At(0)->GetName()));
367 Int_t icolor = ( ilist < ncolors ) ? colors[ilist] : 20+ilist;
368 graph->SetLineColor(icolor);
369 graph->SetMarkerColor(icolor);
370 graph->SetMarkerStyle(20+ilist);
371 graph->SetMarkerSize(0.5);
372 graph->GetXaxis()->SetTitle(xTitle.Data());
373 graph->GetYaxis()->SetTitle(yTitle.Data());
374 graph->Draw((gPad->GetListOfPrimitives()->GetEntries()==0)?
"ap":
"p");
375 if ( leg ) leg->AddEntry(graph,titleList->At(ilist)->GetName(),
"lp");
377 if (leg ) leg->Draw();
393 AliWarning(
"No condition found! Please specify the default efficiency condition with SetEffConditions and then add additional tests with AddSystematicCondition");
402 condTitle.SetOwner();
407 effMapList.SetOwner();
409 for (
Int_t icond=0; icond<nConditions; icond++ ) {
413 AliMUONTriggerEfficiencyCells* effMap =
new AliMUONTriggerEfficiencyCells(effList);
414 effMapList.Add(effMap);
415 titles += Form(
"%s,",condTitle.At(icond)->GetName());
418 titles.Remove(TString::kTrailing,
',');
432 effMapList.SetOwner();
436 while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
438 AliMUONTriggerEfficiencyCells* effMap =
new AliMUONTriggerEfficiencyCells(effList);
439 effMapList.Add(effMap);
440 titles += Form(
"%s,",trigOut->GetName());
442 titles.Remove(TString::kTrailing,
',');
489 TDirectory *savdir = gDirectory;
490 TDirectory *adir = savdir->mkdir(source->GetName());
494 TIter nextkey(source->GetListOfKeys());
495 while ((key = (TKey*)nextkey())) {
496 const char *classname = key->GetClassName();
497 TClass *cl = gROOT->GetClass(classname);
499 if (cl->InheritsFrom(TDirectory::Class())) {
500 source->cd(key->GetName());
501 TDirectory *subdir = gDirectory;
505 }
else if (cl->InheritsFrom(TTree::Class())) {
508 TTree *newT = T->CloneTree(-1,
"fast");
514 obj->Write(obj->GetName(),TObject::kSingleKey);
518 adir->SaveSelf(kTRUE);
530 Bool_t isGrid = (! sPattern.IsNull());
532 if ( sOutDir.IsNull() ) {
534 TString data = sPath(TRegexp(
"/data/"));
535 TString year = sPath(TRegexp(
"/20[0-9][0-9]/"));
536 TString period = sPath(TRegexp(
"/LHC[0-9][0-9][a-z]"));
539 TString pass = AliAnalysisMuonUtility::GetPassName(path);
540 if ( pass.IsNull() ) pass = AliAnalysisMuonUtility::GetPassName(pattern);
541 sOutDir = data+year+period+pass;
542 sOutDir.ReplaceAll(
"//",
"/");
543 sOutDir.Remove(TString::kTrailing,
'/');
544 sOutDir.Remove(TString::kLeading,
'/');
546 else sOutDir = sPath;
547 sOutDir.Remove(TString::kTrailing,
'/');
548 sOutDir.Remove(TString::kLeading,
'/');
551 TGridResult* res = 0x0;
553 if ( ! gGrid ) TGrid::Connect(
"alien://");
554 res = gGrid->Query(path,pattern);
559 ofstream outFile(localFileList);
562 Bool_t overwrite = kFALSE;
563 for (
Int_t irun=0; irun<rl->GetEntries(); irun++ ) {
564 TString run =
static_cast<TObjString*
>(rl->At(irun))->String();
565 TString dest = Form(
"%s/%09i/QAresults.root",sOutDir.Data(),run.Atoi());
567 if (
gSystem->AccessPathName(destDir.Data()) )
ExecCommand(Form(
"mkdir -p %s",destDir.Data()),kFALSE);
570 if (
gSystem->AccessPathName(dest) == 0 ) {
573 cout <<
"Local file " << dest.Data() <<
" already exist: overwrite? [y/n/ya/na (a=use decision for all)]" << endl;
575 if ( decision.EndsWith(
"a") ) prompt = kFALSE;
576 if ( decision.BeginsWith(
"y") ) overwrite = kTRUE;
577 else overwrite = kFALSE;
579 copyFile = overwrite;
584 for (
Int_t ifile=0; ifile<res->GetEntries(); ifile++ ) {
585 TString inFilename = res->GetKey(ifile,
"turl");
586 if ( inFilename.Contains(run.Data()) ) {
591 if ( src.IsNull() ) {
592 AliWarning(Form(
"Cannot find output for run %s",run.Data()));
596 TFile* outFile = TFile::Open(dest,
"RECREATE");
597 TFile* inFile = TFile::Open(src);
599 TDirectory* dir =
static_cast<TDirectory*
>(inFile->Get(directory));
604 else isFileOk = kFALSE;
610 src = Form(
"http://aliqamu.web.cern.ch/aliqamu/%s",dest.Data());
611 isFileOk = TFile::Cp(src.Data(),dest.Data());
615 if ( isFileOk ) outFile <<
gSystem->pwd() <<
"/" << dest.Data() << endl;
627 TString baseNames[3] = {
"Chamber",
"RPC",
"Board"};
628 TString base = baseNames[itype] +
"Eff";
631 AliWarning(
"Please specify RPC");
634 base += Form(
"InRPC%i",irpc);
654 for (
Int_t ich=0; ich<nCh; ich++ ) {
657 TCanvas* can =
new TCanvas(canName.Data(),canName.Data(),25*ich,25*ich,width,height);
658 can->Divide(nColumns,nRows,0,0);
661 for (
Int_t idetelem=0; idetelem<nDetEl; idetelem++ ) {
665 Int_t detElemId = idetelem;
670 TLegend* leg =
new TLegend(0.2,0.15,0.8,0.4);
671 leg->SetHeader(title.Data());
672 for (
Int_t icount=0; icount<2; icount++ ) {
674 gr->SetLineColor(icount+1);
675 gr->SetMarkerColor(icount+1);
676 gr->SetMarkerStyle(24+2*icount);
677 gr->GetYaxis()->SetRangeUser(minEff,maxEff);
681 gr->Draw(icount==0?
"ap":
"p");
682 TString legTitle = ( icount==0 ) ?
"bending plane" :
"non-bending plane";
683 leg->AddEntry(gr,legTitle.Data(),
"lp");
684 if ( maxNsigmaOutliers > 0. ) {
686 outliers->SetLineColor(6+icount);
687 outliers->SetMarkerColor(6+icount);
688 outliers->SetMarkerStyle(20+2*icount);
689 outliers->SetLineWidth(2);
691 legTitle.ReplaceAll(
"plane",
"outliers");
692 leg->AddEntry(outliers,legTitle.Data(),
"lp");
706 AliWarning(
"This function is valid only for itype 1 and 2");
710 TString baseNames[3] = {
"Chamber",
"RPC",
"Board"};
711 TString base = baseNames[itype] +
"Stat";
714 AliWarning(
"Please specify RPC");
717 base += Form(
"InRPC%i",irpc);
730 for (
Int_t ich=0; ich<nCh; ich++ ) {
732 TH1* sumHistos = 0x0;
733 for (
Int_t idetelem=0; idetelem<nDetEl; idetelem++ ) {
734 Int_t detElemId = idetelem;
737 histos[idetelem]->SetName(Form(
"%s_stat",histos[idetelem]->GetName()));
738 histos[idetelem]->SetStats(0);
739 if ( sumHistos ) sumHistos->Add(histos[idetelem]);
740 else sumHistos =
static_cast<TH1*
>(histos[idetelem]->Clone(
"sumHistos"));
744 TCanvas* can =
new TCanvas(canName.Data(),canName.Data(),25*ich,25*ich,width,height);
745 can->Divide(nColumns,nRows,0,0);
746 for (
Int_t idetelem=0; idetelem<nDetEl; idetelem++ ) {
750 Int_t detElemId = idetelem;
753 TLegend* leg =
new TLegend(0.2,0.65,0.8,0.9);
754 leg->SetHeader(title.Data());
756 gr->SetHistogram(static_cast<TH1F*>(histos[idetelem]));
758 gr->SetMarkerStyle(24);
759 gr->SetMarkerSize(0.5);
760 gr->GetYaxis()->SetRangeUser(minY,maxY);
761 gr->GetYaxis()->SetTitle(Form(
"Tracks in %s / Sum of tracks of %ss in %s",baseNames[itype].
Data(),baseNames[itype].
Data(),baseNames[itype-1].
Data()));
766 if ( maxNsigmaOutliers > 0. ) {
768 outliers->SetLineColor(6);
769 outliers->SetMarkerColor(6);
770 outliers->SetMarkerStyle(20);
771 outliers->SetLineWidth(2);
773 legTitle =
"outliers";
774 leg->AddEntry(outliers,legTitle.Data(),
"lp");
789 Int_t colors[] = {kBlack, kRed, kSpring, kTeal, kBlue, kViolet, kMagenta, kOrange, kGray};
790 Int_t ncolors =
sizeof(colors)/
sizeof(colors[0]);
792 Int_t itype = ( perRPC ) ? AliMUONTriggerEfficiencyCells::kHslatCount : AliMUONTriggerEfficiencyCells::kHboardCount;
793 Int_t countTypes[2] = {AliMUONTriggerEfficiencyCells::kBendingEff,AliMUONTriggerEfficiencyCells::kNonBendingEff};
798 condTitle.SetOwner();
806 while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
817 for (
Int_t iplane=0; iplane<8; iplane++ ) {
818 effGraphs[iplane].SetOwner();
822 effMapList.SetOwner();
823 for (
Int_t icond=0; icond<nConditions; icond++ ) {
827 AliMUONTriggerEfficiencyCells* effMap =
new AliMUONTriggerEfficiencyCells(effList);
828 effMapList.Add(effMap);
829 titles += Form(
"%s,",condTitle.At(icond)->GetName());
831 for (
Int_t ich=0; ich<4; ich++ ) {
832 TString currName = effMap->GetHistoName(itype,AliMUONTriggerEfficiencyCells::kAllTracks,ich);
833 TH1* histoDen =
static_cast<TH1*
>(effMap->GetHistoList()->FindObject(currName.Data()));
834 for (
Int_t icount=0; icount<2; icount++ ) {
835 Int_t iplane = 4*icount+ich;
837 if ( histoDen->GetEntries() > 0 ) {
838 currName = effMap->GetHistoName(itype,countTypes[icount],ich);
839 TH1* histoNum =
static_cast<TH1*
>(effMap->GetHistoList()->FindObject(currName.Data()));
842 effGraphs[iplane].AddAtAndExpand(gr,icond);
846 AliWarning(Form(
"No entries in count %i and ch %i for %s\n",icount,ich,condTitle.At(icond)->GetName()));
852 titles.Remove(TString::kTrailing,
',');
856 TString canName = Form(
"EffSyst_%s",trigOut->GetName());
857 Int_t pos = 25*(imerged+1);
858 TCanvas* can =
new TCanvas(canName.Data(),canName.Data(),pos,pos,1200,800);
859 can->Divide(4,2,0,0);
861 for (
Int_t icount=0; icount<2; icount++ ) {
862 for (
Int_t ich=0; ich<4; ich++ ) {
863 Int_t iplane = 4*icount+ich;
867 TLegend* leg =
new TLegend(0.15,0.7,0.9,0.9);
868 leg->SetHeader(trigOut->
GetHistoName(-1,icount,ich,-1,-1,-1));
870 for (
Int_t icond=1; icond<nConditions; icond++ ) {
871 if ( isEmpty[icond] == 1 )
continue;
872 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);
873 histo->GetXaxis()->SetTitle(
"Eff.-(ref.Eff.)");
874 histo->GetYaxis()->SetTitle(
"1/#sigma^{2}");
878 for (
Int_t ipt=0; ipt<gr->GetN(); ipt++ ) {
879 gr->GetPoint(ipt,xpt,ypt);
881 Double_t invErr2 = ( err > 0. ) ? 1./(err*err) : 0.;
882 grRef->GetPoint(ipt,xref,yref);
885 histo->Fill(diff,invErr2);
889 sumHisto =
static_cast<TH1*
>(histo->Clone(Form(
"syst_%s_plane%i_ch%i",trigOut->GetName(),icount,11+ich)));
890 sumHisto->SetLineColor(1);
892 leg->AddEntry(sumHisto,
"All systematics",
"l");
894 else sumHisto->Add(histo);
895 Int_t icolor = ( icond < ncolors ) ? colors[icond] : 20+icond;
896 histo->SetLineColor(icolor);
898 leg->AddEntry(histo,condTitle[icond]->GetName(),
"l");
905 canName = Form(
"TriggerEff_3outOf4_syst_%s",trigOut->GetName());
907 TCanvas* canSyst =
new TCanvas(canName.Data(),canName.Data(),pos,pos,600,600);
909 TLegend* leg =
new TLegend(0.15,0.7,0.9,0.4);
911 TH1* histo[nConditions];
912 for (
Int_t icond=0; icond<nConditions; icond++ ) {
913 if ( isEmpty[icond] == 1 )
continue;
914 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);
915 histo[icond]->GetXaxis()->SetTitle(
"Trig. prob. - (ref. trig. prob)");
916 histo[icond]->GetYaxis()->SetTitle(
"1/#sigma^{2}");
919 for (
Int_t ipt=0; ipt<
nDE; ipt++ ) {
921 for (
Int_t icond=0; icond<nConditions; icond++ ) {
922 if ( isEmpty[icond] == 1 )
continue;
923 Double_t trigProb = 1., trigProbErr2 = 0.;
924 for (
Int_t icount=0; icount<2; icount++ ) {
925 for (
Int_t ich=0; ich<4; ich++ ) {
926 Int_t iplane = 4*icount+ich;
928 gr->GetPoint(ipt,xpt,ypt);
930 effErr[ich] =
GetError(gr->GetErrorYlow(ipt),gr->GetErrorYhigh(ipt));
935 trigProbErr2 += effErr34*effErr34;
939 refTrigProb = trigProb;
943 Double_t invErr2 = ( trigProbErr2>0. ) ? 1./trigProbErr2 : 0.;
944 histo[icond]->Fill(trigProb-refTrigProb,invErr2);
949 for (
Int_t icond=0; icond<nConditions; icond++ ) {
950 if ( isEmpty[icond] == 1 )
continue;
951 TString title = ( icond == 0 ) ?
"All systematics" : condTitle[icond]->GetName();
952 Int_t icolor = ( icond < ncolors ) ? colors[icond] : 20+icond;
953 histo[icond]->SetLineColor(icolor);
954 histo[icond]->Draw((icond == 0)?
"":
"same");
955 leg->AddEntry(histo[icond],title.Data(),
"l");
956 if ( icond>0 ) histo[0]->Add(histo[icond]);
969 if ( gROOT->IsBatch() ) prompt = kFALSE;
972 cout << command.Data() <<
" ? [y/n]" << endl;
977 if ( decision ==
"y" ) {
978 cout <<
"Executing: " << command.Data() << endl;
998 Int_t nChanges = par[0];
1000 Int_t matchChange = -1;
1001 for (
Int_t iknot=0; iknot<nChanges; iknot++ ) {
1002 Int_t iparChange = 2*(iknot+1);
1003 Double_t diff = xx - par[iparChange];
1004 if ( diff >= 0. && diff < matchDiff ) {
1006 matchChange = iparChange;
1009 if ( matchChange >= 0 ) val = par[matchChange+1];
1017 TH1* statHisto = 0x0;
1023 TList* effHistoList = 0x0;
1024 while ( (effHistoList = static_cast<TList*>(next()) ) ) {
1025 UInt_t run = effHistoList->GetUniqueID();
1026 if ( run < uFirstRun || run > uLastRun )
continue;
1029 if ( statHisto ) statHisto->Add(histo);
1030 else statHisto =
static_cast<TH1*
>(histo->Clone(
"tmpStatHisto"));
1033 if ( ! statHisto )
return 0.;
1038 Int_t excludeBoardsHalf[] = {1, 17, 39, 61, 77, 93,109,
1039 16, 38, 60, 76, 92, 108, 117,
1040 110, 111, 112, 113, 114, 115, 116};
1041 Int_t nExcludedHalf =
sizeof(excludeBoardsHalf)/
sizeof(excludeBoardsHalf[0]);
1042 for (
Int_t ibin=1; ibin<=statHisto->GetNbinsX(); ibin++ ) {
1044 for (
Int_t iexcl=0; iexcl<nExcludedHalf; iexcl++ ) {
1045 if ( ibin == excludeBoardsHalf[iexcl] || ibin == excludeBoardsHalf[iexcl]+117 ) {
1050 if ( skip )
continue;
1051 statPerDE += statHisto->GetBinContent(ibin);
1056 statPerDE = statHisto->Integral();
1057 nDe = (
Double_t)statHisto->GetNbinsX();
1059 statPerDE = nDe > 0. ? statPerDE/nDe : -1.;
1069 Int_t itrackSel =
static_cast<TObjString*
>(condition->At(3))->String().Atoi();
1070 Int_t imatch =
static_cast<TObjString*
>(condition->At(4))->String().Atoi();
1071 Int_t imethod =
static_cast<TObjString*
>(condition->At(5))->String().Atoi();
1073 return trigOut->
GetEffHistoList(condition->At(0)->GetName(),condition->At(1)->GetName(),condition->At(2)->GetName(),itrackSel,imatch,imethod);
1080 return TMath::Max(errLow,errHigh);
1088 return static_cast<TH1*
>(effHistoList->At(ihisto));
1098 TH1F* hRunChangeCount =
new TH1F(
"runChangeCount",
"Number of RPCs changing efficiency per run",nRuns,-0.5,-0.5+(
Double_t)nRuns);
1099 hRunChangeCount->SetXTitle(
"Run num.");
1100 hRunChangeCount->SetYTitle(
"Num. of RPCs with change in eff.");
1101 for (
Int_t irun=0; irun<nRuns; irun++ ) {
1102 hRunChangeCount->GetXaxis()->SetBinLabel(irun+1,Form(
"%i",
GetRunNumber(irun)));
1107 Int_t nCanvas = perRPC ? 4 : 18;
1110 for (
Int_t irpc=0; irpc<18; irpc++ ) {
1113 Int_t firstDetEl = perRPC ? irpc : 0;
1114 Int_t lastDetEl = perRPC ? irpc : boards.GetSize()-1;
1116 for (
Int_t ich=0; ich<4; ich++ ) {
1117 Int_t ican = perRPC ? ich : irpc;
1118 TCanvas* can =
static_cast<TCanvas*
>(canList.At(ican));
1120 TString canName = perRPC ? Form(
"testRanges_ch%i",11+ich) : Form(
"testRanges_RPC%i",irpc);
1121 can =
new TCanvas(canName.Data(),canName.Data(),10*ich,10*ich,1200,800);
1122 can->Divide(6,3,0,0);
1123 can->SetMargin(0.,0.,0.,0.);
1124 canList.AddAt(can,ican);
1127 for (
Int_t idetel=firstDetEl; idetel<=lastDetEl; idetel++ ) {
1128 Int_t currDE = ( perRPC ) ? idetel : boards[idetel];
1132 trendGraph->GetYaxis()->SetRangeUser(minEff,maxEff);
1135 gPad->SetTicks(1,1);
1136 gPad->SetMargin(0.08,0.,0.08,0.);
1137 TString drawOpt = ( gPad->GetListOfPrimitives()->GetEntries() == 0 ) ?
"ap" :
"p";
1139 TString legendName = Form(
"%s_%i",can->GetName(),currDE);
1140 TLegend* leg =
static_cast<TLegend*
>(gPad->GetListOfPrimitives()->FindObject(legendName.Data()));
1142 leg =
new TLegend(0.2,0.15,0.8,0.4);
1143 leg->SetHeader(Form(
"%s %i",perRPC?
"RPC":
"Board",currDE));
1144 leg->SetName(legendName.Data());
1148 Int_t icolor = ich+1;
1149 trendGraph->SetLineColor(icolor);
1150 trendGraph->SetMarkerColor(icolor);
1151 trendGraph->SetMarkerStyle(24+ich);
1152 TF1* func =
static_cast<TF1*
>(trendGraph->GetListOfFunctions()->At(0));
1154 func->SetLineWidth(2);
1155 func->SetLineColor(icolor);
1158 trendGraph->GetXaxis()->SetLabelSize(0.07);
1159 trendGraph->SetTitle(
"");
1161 trendGraph->Draw(drawOpt.Data());
1162 leg->AddEntry(trendGraph,Form(
"Chamber %i",11+ich),
"lp");
1164 for (
Int_t ichange=2; ichange<range.GetSize(); ichange++ ) {
1166 if ( ichange%2 == 1 )
continue;
1167 Int_t runIdx = range[ichange];
1169 TLine* line =
new TLine(runIdx,minEff,runIdx,maxEff);
1170 line->SetLineStyle(2);
1175 hRunChangeCount->Fill(runIdx);
1176 if ( hRunChangeCount->GetBinContent(runIdx+1) == 1 ) {
1177 TString infoMsg = Form(
"Efficiency change in %i triggered by ch %i RPC %i",
GetRunNumber(runIdx),11+ich,irpc);
1178 if ( ! perRPC ) infoMsg += Form(
" Board %i",currDE);
1179 AliInfo(infoMsg.Data());
1188 TArrayI runChangeClust(nRuns);
1191 for (
Int_t irun=0; irun<=nRuns; irun++ ) {
1192 if ( irun == nRuns || hRunChangeCount->GetBinContent(irun+1) == 0 ) {
1193 if ( sumWgt > 0. ) {
1194 Int_t averageRun = TMath::Nint(sumWgtRun / sumWgt);
1195 AliDebug(2,Form(
"Average run: %i => %i\n",averageRun,
GetRunNumber(averageRun)));
1196 runChangeClust[averageRun]++;
1201 if ( irun == nRuns )
break;
1203 AliDebug(2,Form(
"irun %i => %i: wgt %g",irun,
GetRunNumber(irun),hRunChangeCount->GetBinContent(irun+1)));
1206 Double_t wgt = hRunChangeCount->GetBinContent(irun+1);
1207 if ( forcedChanges ) {
1208 for (
Int_t ichange=0; ichange<forcedChanges->GetSize(); ichange++ ) {
1209 if (
GetRunNumber(irun) == forcedChanges->At(ichange) ) wgt *= 10.;
1216 TCanvas* summaryCan =
new TCanvas(
"effChangeSummary",
"effChangeSummary",50,50,600,600);
1217 summaryCan->SetLogy();
1218 hRunChangeCount->GetXaxis()->LabelsOption(
"v");
1219 hRunChangeCount->Draw();
1224 for (
Int_t irun=1; irun<nRuns; irun++ ) {
1225 if ( runChangeClust[irun] > 0 ) {
1231 runRanges.Set(ientry);
1244 if ( forcedChanges ) {
1245 forcedChangesBin.Set(forcedChanges->GetSize());
1246 for (
Int_t ichange=0; ichange<forcedChanges->GetSize(); ichange++ ) {
1248 if ( idx >= 0 ) forcedChangesBin[nForced++] = (
Double_t)idx;
1249 else AliWarning(Form(
"Cannot find run %i\n",forcedChanges->At(ichange)));
1254 Int_t minNormChi2Step = -1;
1260 for (
Int_t istep=0; istep<maxNRanges; istep++ ) {
1261 Int_t nPars = 2*(istep+1);
1262 Double_t xMin = trendGraph->GetXaxis()->GetXmin();
1263 Double_t xMax = trendGraph->GetXaxis()->GetXmax();
1265 func->FixParameter(0,istep);
1266 for (
Int_t ipar=1; ipar<nPars; ipar++ ) {
1274 func->SetParameter(ipar,val);
1275 if ( ipar%2 == 0 ) func->SetParLimits(ipar,xMin,xMax);
1278 TFitResultPtr fitResult = trendGraph->Fit(func,fitOpt.Data());
1281 if ( forcedChanges ) {
1282 Bool_t hasFixedPars = kFALSE;
1283 for (
Int_t iforced=0; iforced<nForced; iforced++ ) {
1284 for (
Int_t jstep=0; jstep<istep; jstep++ ) {
1285 Int_t ipar = 2*(jstep+1);
1286 if ( TMath::Abs(forcedChangesBin[iforced]-func->GetParameter(ipar)) > 2. )
continue;
1287 func->FixParameter(ipar,forcedChangesBin[iforced]);
1288 hasFixedPars = kTRUE;
1291 if ( hasFixedPars ) fitResult = trendGraph->Fit(func,fitOpt.Data());
1299 if ( normChi2 < minNormChi2 ) {
1300 minNormChi2 = normChi2;
1301 minNormChi2Step = istep;
1304 if ( normChi2 < chi2Cut )
break;
1310 trendGraph->GetListOfFunctions()->Add(func->Clone());
1316 Int_t nPoints = nSteps+1;
1319 for (
Int_t ipar=0; ipar<func->GetNpar(); ipar++ ) {
1320 Int_t istep = ipar/2;
1321 if ( ipar%2 == 0 ) parRunIdx[istep] = func->GetParameter(ipar);
1322 else parEff[istep] = func->GetParameter(ipar);
1326 TMath::Sort(nPoints,parRunIdx.GetArray(),sortIdx.GetArray(),kFALSE);
1328 runRanges.Set(2*nPoints);
1331 for (
Int_t ipoint=1; ipoint<nPoints; ipoint++ ) {
1332 Double_t deltaEff = TMath::Abs(parEff[sortIdx[ipoint]]-parEff[sortIdx[ipoint-1]]);
1334 if ( deltaEff < minEffVariation ) {
1335 AliWarning(Form(
"Efficiency variation for %s is %g => consider uniform",trendGraph->GetName(),deltaEff));
1338 Int_t runChangeIdx = TMath::Nint(parRunIdx[sortIdx[ipoint]]);
1339 AliDebug(1,Form(
"Change run: %s => %g => %i %i",trendGraph->GetName(),parRunIdx[sortIdx[ipoint]],runChangeIdx,
GetRunNumber(runChangeIdx)));
1340 runRanges[irun++] = returnIndex ? runChangeIdx-1 :
GetRunNumber(runChangeIdx-1);
1341 runRanges[irun++] = returnIndex ? runChangeIdx :
GetRunNumber(runChangeIdx);
1343 Int_t lastPt = trendGraph->GetN()-1;
1344 runRanges[irun++] = returnIndex ? lastPt :
GetRunNumber(lastPt);
1345 runRanges.Set(irun);
1348 AliWarning(Form(
"Fit did not converge for %s (minimum chi2 %g for step %i)",trendGraph->GetName(),minNormChi2,minNormChi2Step));
1363 TString identifier = Form(
"/%s/%s/%s/",condition->At(0)->GetName(),condition->At(1)->GetName(),condition->At(2)->GetName());
1364 Int_t itrackSel =
static_cast<TObjString*
>(condition->At(3))->String().Atoi();
1365 Int_t imatch =
static_cast<TObjString*
>(condition->At(4))->String().Atoi();
1366 Int_t imethod =
static_cast<TObjString*
>(condition->At(5))->String().Atoi();
1367 TString objName = trigOut->
GetHistoName(itype, icount, ichamber, itrackSel, imatch, imethod);
1368 identifier += objName;
1376 for (
Int_t ipt=0; ipt<
fOutputs->GetEntriesFast(); ipt++ ) {
1378 if ( run == runNumber )
return ipt;
1389 outliers->SetHistogram(static_cast<TH1F*>(graph->GetHistogram()->Clone(Form(
"%s_outliers",graph->GetHistogram()->GetName()))));
1391 if ( graph->GetListOfFunctions()->GetEntries() == 0 ) graph->Fit(
"pol0",
"Q0");
1392 TF1* func =
static_cast<TF1*
>(graph->GetListOfFunctions()->At(0));
1396 for (
Int_t ipt=0; ipt<graph->GetN(); ipt++ ) {
1397 graph->GetPoint(ipt,xpt,ypt);
1398 Double_t diff = ypt - func->Eval(xpt);
1399 Double_t err = ( diff > 0. ) ? graph->GetErrorYlow(ipt) : graph->GetErrorYhigh(ipt);
1400 if ( err < 0. || TMath::Abs(diff)/err > maxNsigmas )
continue;
1401 outliers->RemovePoint(ipt-nremoved);
1412 if ( ipt < 0 || ipt >=
fOutputs->GetEntriesFast() )
return -1;
1413 return fOutputs->UncheckedAt(ipt)->GetUniqueID();
1423 if (
gSystem->AccessPathName(sRunList) || sRunList.EndsWith(
".root") ) {
1424 sRunList.ReplaceAll(
",",
" ");
1425 if ( sRunList.IsDigit() ) {
1426 TObjArray* arr = sRunList.Tokenize(
" ");
1427 for (
Int_t iarr=0; iarr<arr->GetEntries(); iarr++ ) {
1428 rl->Add(
new TObjString(arr->At(iarr)->GetName()));
1434 ifstream inFile(sRunList.Data());
1436 while ( ! inFile.eof() ) {
1437 currLine.ReadLine(inFile);
1438 TString currRun = AliAnalysisMuonUtility::GetRunNumberAsString(currLine);
1439 if ( ! currRun.IsNull() ) rl->Add(
new TObjString(currRun));
1455 for (
Int_t icond=0; icond<nConditions; icond++ ) {
1459 refCondition = condition;
1460 title = condition->GetName();
1462 for (
Int_t ic=0; ic<condition->GetEntriesFast(); ic++ ) {
1463 TString currCond =
static_cast<TObjString*
>(condition->UncheckedAt(ic))->String();
1464 TString refCond =
static_cast<TObjString*
>(refCondition->UncheckedAt(ic))->String();
1465 if ( currCond == refCond )
continue;
1467 if ( ic == 3 ) add = trigOut->
GetHistoName(-1,-1,-1,currCond.Atoi(),-1,-1);
1468 else if ( ic == 4 ) add = trigOut->
GetHistoName(-1,-1,-1,-1,currCond.Atoi(),-1);
1469 else if ( ic == 5 ) add = trigOut->
GetHistoName(-1,-1,-1,-1,-1,currCond.Atoi());
1470 title += Form(
"_%s",add.Data());
1472 title.Remove(TString::kLeading,
'_');
1473 title.ReplaceAll(
",",
"|");
1474 condTitles.AddAt(
new TObjString(title),icond);
1484 Int_t itrackSel =
static_cast<TObjString*
>(condition->At(3))->String().Atoi();
1485 Int_t imatch =
static_cast<TObjString*
>(condition->At(4))->String().Atoi();
1486 Int_t imethod =
static_cast<TObjString*
>(condition->At(5))->String().Atoi();
1487 TString objName = trigOut->
GetHistoName(itype, icount, ichamber, itrackSel, imatch, imethod);
1488 return static_cast<TH1*
>(trigOut->GetSum(condition->At(0)->GetName(),condition->At(1)->GetName(),condition->At(2)->GetName(),objName));
1496 if ( idetelem < 0 && ichamber >=0 ) idetelem = 11+ichamber;
1498 TH1* outHisto = 0x0;
1501 TList* effHistoList = 0x0;
1503 while ( (effHistoList = static_cast<TList*>(next()) ) ) {
1508 TString outName = Form(
"histo_type%i_count%i_ch%i_",itype,icount,11+ichamber);
1510 outName += Form(
"%i_trend",idetelem);
1512 outHisto->SetDirectory(0);
1513 outHisto->GetXaxis()->SetTitle(
"Run num.");
1515 UInt_t run = effHistoList->GetUniqueID();
1516 outHisto->GetXaxis()->SetBinLabel(ibin,Form(
"%u",run));
1517 TH1* histo =
GetHisto(effHistoList,itype,icount,ichamber);
1518 Int_t currBin = histo->GetXaxis()->FindBin(idetelem);
1519 outHisto->SetBinContent(ibin,histo->GetBinContent(currBin));
1520 outHisto->SetBinError(ibin,histo->GetBinError(currBin));
1522 if ( outHisto ) outHisto->GetXaxis()->LabelsOption(
"v");
1531 AliWarning(
"Chose either bending plane, non-bending plane or both planes");
1534 TH1* histoNum =
GetTrend(itype,icount,ichamber,idetelem);
1538 histoNum->SetStats(kFALSE);
1539 graph->SetHistogram(static_cast<TH1F*>(histoNum));
1540 graph->GetYaxis()->SetTitle(
"Efficiency");
1541 graph->SetMarkerSize(0.5);
1556 for (
Int_t jch=-1; jch<4; jch++ ) {
1559 for (
Int_t ich=0; ich<4; ich++ ) {
1560 Double_t currEff = ( ich == jch ) ? 1.-eff[ich] : eff[ich];
1562 Double_t relErr = ( currEff>0. ) ? effErr[ich]/currEff : 0.;
1563 prodErr2 += relErr*relErr;
1565 binomialEff += prodEff;
1566 sumErr2 += prodEff*prodEff*prodErr2;
1568 probErr = TMath::Sqrt(sumErr2);
1577 AliError(
"You first need to merge efficiency objects with MergeOutput");
1588 if ( runRanges.GetSize()%2 == 1 ) {
1589 AliError(
"Run ranges expected in the form: start_period1,end_period1,start_period2,end_period2... => even number expected");
1595 Int_t nRanges = mergedRanges.GetSize()/2;
1604 TList* effHistoList = 0x0;
1605 for (
Int_t irange=0; irange<nRanges; irange++ ) {
1606 Int_t firstRun = mergedRanges[2*irange];
1607 Int_t lastRun = mergedRanges[2*irange+1];
1618 TFileMerger fileMerger;
1619 while ( (effHistoList = static_cast<TList*>(next()) ) ) {
1620 UInt_t run = effHistoList->GetUniqueID();
1621 if ( run < uFirstRun || run > uLastRun )
continue;
1622 filename = effHistoList->GetName();
1623 if ( firstRun == lastRun )
continue;
1624 fileMerger.AddFile(filename.Data(),kFALSE);
1627 TString sRange = Form(
"%i_%i",firstRun,lastRun);
1628 TString mergedFilename = Form(
"mergedTrigEff_runs_%s.root",sRange.Data());
1630 if ( firstRun == lastRun ) TFile::Cp(filename.Data(),mergedFilename.Data(),kFALSE);
1632 fileMerger.OutputFile(mergedFilename.Data());
1636 trigOut->SetName(sRange.Data());
1645 if ( averageStatError <= 0. || averageStatError >= 1. )
return runRanges;
1653 Double_t averageStatNeeded = effForStatCalc*(1.-effForStatCalc)/(averageStatError*averageStatError);
1655 AliInfo(Form(
"Average statistics needed to reach precision of %g : %g",averageStatError,averageStatNeeded));
1657 Int_t nRanges = runRanges.GetSize()/2;
1661 for (
Int_t irange=0; irange<nRanges; irange++ ) {
1663 fullStat += averageStat[irange];
1666 TArrayI mergedRanges(runRanges.GetSize());
1668 mergedRanges[imerged++] = runRanges[0];
1669 Double_t mergedAverageStat = 0., remainingStat = fullStat;
1670 for (
Int_t irange=0; irange<nRanges; irange++ ) {
1671 Int_t istart = 2*irange;
1672 Int_t iend = istart+1;
1673 mergedAverageStat += averageStat[irange];
1674 remainingStat -= averageStat[irange];
1676 AliInfo(Form(
"%i - %i => stat %g",runRanges[2*irange],runRanges[2*irange+1],averageStat[irange]));
1678 if ( ( mergedAverageStat >= averageStatNeeded && remainingStat >= averageStatNeeded ) || iend == runRanges.GetSize()-1 ) {
1679 mergedRanges[imerged++] = runRanges[iend];
1680 AliInfo(Form(
" merged range %i - %i => stat %g",mergedRanges[imerged-2],mergedRanges[imerged-1],mergedAverageStat));
1681 mergedAverageStat = 0.;
1682 Int_t nextRun = iend+1;
1683 if ( nextRun < runRanges.GetSize() ) mergedRanges[imerged++] = runRanges[nextRun];
1686 mergedRanges.Set(imerged);
1687 return mergedRanges;
1699 TString sCondition = Form(
"%s;%s;%s;%i;%i;%i",physSel,trigClassName,centrality,itrackSel,imatch,imethod);
1705 if ( foundCondition ) {
1707 if ( foundCondition == basicCondition )
return kFALSE;
1710 addCondition = foundCondition;
1714 AliInfo(
"Systematic condition already added");
1719 addCondition = sCondition.Tokenize(
";");
1720 addCondition->SetName(sCondition.Data());
1725 if ( basicCondition ) {
1726 AliInfo(Form(
"Changing current eff. condition: %s\n",basicCondition->GetName()));
1728 delete basicCondition;
1737 TIter next(tmpOutputs);
1738 TList* effHistiList = 0x0;
1739 while ( (effHistiList = static_cast<TList*>(next())) ) {
1762 return SetCondition(physSel, trigClassName, centrality, itrackSel, imatch, imethod, kTRUE);
1773 gSystem->ExpandPathName(filename);
1774 if (
gSystem->AccessPathName(filename.Data()) ) {
1775 AliWarning(Form(
"Cannot find %s",filename.Data()));
1778 if ( filename.EndsWith(
".root") )
return AddToList(filename.Data(),outputName);
1781 ifstream inFile(filename.Data());
1783 while ( ! inFile.eof() ) {
1784 currLine.ReadLine(inFile);
1785 if ( currLine.IsNull() )
continue;
1786 if (
gSystem->AccessPathName(currLine.Data()) )
continue;
1787 if ( !
AddToList(currLine.Data(), outputName) ) isOk = kFALSE;
1798 CopyLocally(runList,path,pattern,localFileList,outDir,directory);
1806 CopyLocally(runList,path,
"",localFileList,outDir,directory);
1816 if ( outCDBdir.Contains(
"://") && ! outCDBdir.BeginsWith(
"local") ) {
1817 AliError(
"A local directory is required to store the information");
1820 outCDBdir.ReplaceAll(
"local://",
"");
1821 if (
gSystem->AccessPathName(outCDBdir.Data()) ) {
1822 if ( !
ExecCommand(Form(
"mkdir -p %s",outCDBdir.Data()), kTRUE) ) {
1823 AliError(Form(
"Failed to create directory %s",outCDBdir.Data()));
1828 outCDB.Prepend(
"local://");
1830 AliCDBManager* mgr = AliCDBManager::Instance();
1831 if ( ! mgr->GetDefaultStorage() ) mgr->SetDefaultStorage(
"local://$ALICE_ROOT/OCDB");
1833 TString trigEffCDBdir =
"MUON/Calib/TriggerEfficiency";
1835 mgr->SetSpecificStorage(trigEffCDBdir.Data(),outCDB.Data());
1837 AliCDBStorage* specificStorage = mgr->GetSpecificStorage(trigEffCDBdir.Data());
1843 while ( (trigOut = static_cast<AliTrigChEffOutput*>(next())) ) {
1845 TString runRange = trigOut->GetName();
1856 TObjArray* currRange = runRange.Tokenize(
"_");
1857 Int_t firstRun =
static_cast<TObjString*
>(currRange->UncheckedAt(0))->String().Atoi();
1858 Int_t lastRun =
static_cast<TObjString*
>(currRange->UncheckedAt(1))->String().Atoi();
1862 for (
Int_t irun=0; irun<2; irun++ ) {
1863 Int_t runnr = ( irun == 0 ) ? firstRun : lastRun;
1864 specificStorage->QueryCDB(runnr);
1865 TObjArray* allIdsForRun = specificStorage->GetQueryCDBList();
1866 TIter nextId(allIdsForRun);
1868 while ((
id = dynamic_cast<AliCDBId*>(nextId()))) {
1870 Int_t foundFirst =
id->GetFirstRun();
1871 Int_t foundLast =
id->GetLastRun();
1872 Int_t version =
id->GetVersion();
1873 Int_t subversion =
id->GetSubVersion();
1874 TString locPath = Form(
"%s/%s/Run%d_%d_v%d_s%d.root",outCDBdir.Data(),path.Data(),foundFirst,foundLast,version,subversion);
1875 if ( !
gSystem->AccessPathName(locPath.Data()) ) {
1882 AliMUONTriggerEfficiencyCells* effMap =
new AliMUONTriggerEfficiencyCells(effList);
1883 AliMUONCDB::WriteToCDB(effMap,
"MUON/Calib/TriggerEfficiency", firstRun, lastRun,
"Measured efficiencies");
Counts per cathode histogram index.
Int_t GetIndexFromRun(UInt_t runNumber) const
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
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
TGraphAsymmErrors * GetTrendEff(Int_t itype, Int_t icount, Int_t ichamber, Int_t idetelem) const
TArrayI MergeRangesForStat(TArrayI runRanges, Double_t averageStatError, Bool_t excludePeriphericBoards=kTRUE) const
Counts per slat histogram index.
Int_t CompareEfficiencies(const char *sources, const char *titles, const char *opt, const char *canvasNameSuffix="") const
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")
UShort_t T(UShort_t m, UShort_t t)
TList * GetEffHistoList(AliTrigChEffOutput *trigOut, TObjArray *condition) const
Bool_t AddToList(const char *filename, const char *outputName)
TObjArray * fMergedOutputs
!<! List of conditions for trigger efficiency
virtual ~AliMTRChEffAnalysis()
Int_t CompareEfficiencyMethods(const char *source, const char *opt, const char *canvasNameSuffix="") const
Output for Trig chamber effieincy.
TArrayI GetHomogeneousRanges(Double_t chi2Cut=3, Int_t maxNRanges=4, Double_t minEffVariation=0.005, Bool_t perRPC=kTRUE, TArrayI *forcedChanges=0x0, Double_t minEff=0.85, Double_t maxEff=1.01)
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.
void DrawStatContribution(Int_t itype, Int_t irpc, Double_t maxNsigmaOutliers=-1., Double_t minY=0., Double_t maxY=0.15) const
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)
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)
TH1 * GetHisto(TList *effHistoList, Int_t itype, Int_t icount, Int_t ichamber) const
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
Bool_t GetShortConditionTitles(AliTrigChEffOutput *trigOut, TObjArray &condTitles) const
TList * GetRunList(const char *runList) const
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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
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 DrawSystematicEnvelope(Bool_t perRPC=kFALSE) const
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)
Bool_t SetDefaultEffConditions()
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