32 #include <THnSparse.h>
35 #include <TObjString.h>
36 #include <Riostream.h>
40 #include <TGraphAsymmErrors.h>
44 #include <THashList.h>
45 #include <TParameter.h>
101 TString fileNameData =
"AnalysisResults.root",
102 TString fileNameSave =
"efficiency_new.root")
106 gObjNameExtension = objNameExtension;
141 printf(
"plotting efficiency versus %s...\n", var.Data());
144 if (var ==
"centrality") xDim = 1;
145 else if (var ==
"pt") xDim = 2;
146 else if (var ==
"y") xDim = 3;
147 else if (var ==
"phi") xDim = 4;
148 else if (var ==
"charge") xDim = 5;
150 printf(
"incorrect variable. Choices are centrality, pt, y, phi and charge.\n");
155 TFile *
file =
new TFile(fileNameData.Data(),
"read");
156 if (!file || !file->IsOpen()) {
157 printf(
"cannot open file %s \n",fileNameData.Data());
160 TList *listTT =
static_cast<TList*
>(file->FindObjectAny(Form(
"TotalTracksPerChamber%s", gObjNameExtension.Data())));
161 TList *listTD =
static_cast<TList*
>(file->FindObjectAny(Form(
"TracksDetectedPerChamber%s", gObjNameExtension.Data())));
162 THnSparse *TT =
static_cast<THnSparse*
>(listTT->At(10));
163 THnSparse *TD =
static_cast<THnSparse*
>(listTD->At(10));
167 TString nameAdd[3] = {
"",
"Low",
"Up"};
168 TString titleAdd[3] = {
"",
" - lower limit",
" - upper limit"};
169 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
170 effVsX[i] =
CreateGraph(Form(
"trackingEffVs%s%s",var.Data(),nameAdd[i].Data()),
171 Form(
"Measured tracking efficiency versus %s%s",var.Data(),titleAdd[i].Data()));
183 for (
Int_t ix = 1; ix <= TT->GetAxis(xDim)->GetNbins(); ix++) {
185 if (print) cout << var.Data() <<
" " << TT->GetAxis(xDim)->GetBinLowEdge(ix) <<
"-" << TT->GetAxis(xDim)->GetBinUpEdge(ix) <<
":" << endl;
188 TT->GetAxis(xDim)->SetRange(ix, ix);
189 TD->GetAxis(xDim)->SetRange(ix, ix);
196 GetTrackingEfficiency(chEff, chEffErr, dummy, effVsX, ix-1, TT->GetAxis(xDim)->GetBinCenter(ix), print);
201 effVsX[0]->SetPoint(ix-1,TT->GetAxis(xDim)->GetBinCenter(ix),1.);
202 effVsX[0]->SetPointError(ix-1,0.,0.,1.,0.);
207 effVsX[1]->SetPoint(ix-1,TT->GetAxis(xDim)->GetBinCenter(ix),0.);
208 effVsX[1]->SetPointError(ix-1,0.,0.,0.,0.);
211 effVsX[2]->SetPoint(ix-1,TT->GetAxis(xDim)->GetBinCenter(ix),1.);
212 effVsX[2]->SetPointError(ix-1,0.,0.,0.,0.);
224 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i)
BeautifyGraph(*effVsX[i], var.Data(),
"efficiency");
227 new TCanvas(Form(
"cTrackingEffVs%s",var.Data()), Form(
"Measured tracking efficiency versus %s",var.Data()),1000,400);
228 effVsX[0]->DrawClone(
"ap");
232 file =
new TFile(fileNameSave.Data(),
"update");
233 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) effVsX[i]->Write(0x0, TObject::kOverwrite);
237 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i)
delete effVsX[i];
248 printf(
"plotting integrated efficiency versus %s...\n", var.Data());
253 printf(
"Cannot compute integrated efficiency without run-by-run weights\n");
258 ifstream inFile(runList.Data());
259 if (!inFile.is_open()) {
260 printf(
"cannot open file %s\n",runList.Data());
266 Form(
"Integrated tracking efficiency versus %s",var.Data()));
275 while (!inFile.eof()) {
279 currRun.ReadLine(inFile,kTRUE);
280 if(currRun.IsNull() || !currRun.IsDec())
continue;
281 Int_t run = currRun.Atoi();
283 printf(
"run %d: ", run);
286 TString dataFile = Form(
"runs/%d/%s", run, fileNameData.Data());
287 TString outFile = Form(
"runs/%d/%s", run, fileNameSave.Data());
293 printf(
"weight not found for run %s\n", currRun.Data());
300 TFile *
file =
new TFile(outFile.Data(),
"read");
301 if (!file || !file->IsOpen()) {
302 printf(
"cannot open file\n");
306 effVsX[0] =
static_cast<TGraphAsymmErrors*
>(file->FindObjectAny(Form(
"trackingEffVs%sLow",var.Data())));
307 effVsX[1] =
static_cast<TGraphAsymmErrors*
>(file->FindObjectAny(Form(
"trackingEffVs%sUp",var.Data())));
308 if (!effVsX[0] || !effVsX[1]) {
309 printf(
"trackingEffVs%sLow(Up) object not found\n", var.Data());
315 n = effVsX[0]->GetN();
316 x.Set(n, effVsX[0]->GetX());
317 for (
Int_t i = 0; i < 2; ++i) {
321 }
else if (n != effVsX[0]->GetN()) {
322 printf(
"number of points in graph trackingEffVs%sLow(Up) for run %d is different than from previous runs\n", var.Data(), run);
328 for (
Int_t ix = 0; ix < n; ++ix) {
329 Double_t ieffErr[2] = {effVsX[0]->GetErrorYlow(ix), effVsX[1]->GetErrorYhigh(ix)};
330 for (
Int_t i = 0; i < 2; ++i) {
331 rec[i][ix] += w*effVsX[i]->GetY()[ix];
332 effErr[i][ix] += w2*ieffErr[i]*ieffErr[i];
346 for (
Int_t ix = 0; ix < n; ++ix) {
348 intEffVsX->SetPoint(ix, x[ix], rec[1][ix]/gen);
349 intEffVsX->SetPointError(ix, 0., 0., (rec[1][ix]-rec[0][ix]+TMath::Sqrt(effErr[0][ix]))/gen, TMath::Sqrt(effErr[1][ix])/gen);
355 for (
Int_t ix = 0; ix < n; ++ix) {
357 printf(
"impossible to integrate, all weights = 0 or unknown ?!?\n");
359 intEffVsX->SetPoint(ix, x[ix], -1.);
360 intEffVsX->SetPointError(ix, 0., 0., 0., 0.);
370 new TCanvas(Form(
"cIntegratedTrackingEffVs%s",var.Data()), Form(
"Integrated tracking efficiency versus %s",var.Data()),1000,400);
371 intEffVsX->DrawClone(
"ap");
375 TFile *
file =
new TFile(fileNameSave.Data(),
"update");
376 intEffVsX->Write(0x0, TObject::kOverwrite);
390 printf(
"plotting efficiency versus %s/%s...\n", xVar.Data(), yVar.Data());
393 if (xVar ==
"centrality") xDim = 1;
394 else if (xVar ==
"pt") xDim = 2;
395 else if (xVar ==
"y") xDim = 3;
396 else if (xVar ==
"phi") xDim = 4;
397 else if (xVar ==
"charge") xDim = 5;
399 printf(
"incorrect variable. Choices are centrality, pt, y, phi and charge.\n");
403 if (yVar ==
"centrality") yDim = 1;
404 else if (yVar ==
"pt") yDim = 2;
405 else if (yVar ==
"y") yDim = 3;
406 else if (yVar ==
"phi") yDim = 4;
407 else if (yVar ==
"charge") yDim = 5;
409 printf(
"incorrect variable. Choices are centrality, pt, y, phi and charge.\n");
414 TFile *
file =
new TFile(fileNameData.Data(),
"read");
415 if (!file || !file->IsOpen()) {
416 printf(
"cannot open file %s\n",fileNameData.Data());
419 TList *listTT =
static_cast<TList*
>(file->FindObjectAny(Form(
"TotalTracksPerChamber%s", gObjNameExtension.Data())));
420 TList *listTD =
static_cast<TList*
>(file->FindObjectAny(Form(
"TracksDetectedPerChamber%s", gObjNameExtension.Data())));
421 THnSparse *TT =
static_cast<THnSparse*
>(listTT->At(10));
422 THnSparse *TD =
static_cast<THnSparse*
>(listTD->At(10));
425 Int_t nxBins = TT->GetAxis(xDim)->GetNbins();
426 Int_t nyBins = TT->GetAxis(yDim)->GetNbins();
427 TH2F *effVsXY =
new TH2F(Form(
"trackingEffVs%s-%s",xVar.Data(),yVar.Data()),
428 Form(
"Measured tracking efficiency versus %s and %s",xVar.Data(),yVar.Data()),
429 nxBins, TT->GetAxis(xDim)->GetBinLowEdge(1), TT->GetAxis(xDim)->GetBinUpEdge(nxBins),
430 nyBins, TT->GetAxis(yDim)->GetBinLowEdge(1), TT->GetAxis(yDim)->GetBinUpEdge(nyBins));
431 effVsXY->SetDirectory(0);
442 for (
Int_t ix = 1; ix <= nxBins; ++ix) {
445 TT->GetAxis(xDim)->SetRange(ix, ix);
446 TD->GetAxis(xDim)->SetRange(ix, ix);
448 for (
Int_t iy = 1; iy <= nyBins; ++iy) {
451 TT->GetAxis(yDim)->SetRange(iy, iy);
452 TD->GetAxis(yDim)->SetRange(iy, iy);
462 effVsXY->Fill(TT->GetAxis(xDim)->GetBinCenter(ix),TT->GetAxis(yDim)->GetBinCenter(iy),chEff[0]);
463 effVsXY->SetBinError(ix,iy,TMath::Max(chEffErr[0][0], chEffErr[1][0]));
468 effVsXY->Fill(TT->GetAxis(xDim)->GetBinCenter(ix),TT->GetAxis(yDim)->GetBinCenter(iy),0.);
469 effVsXY->SetBinError(ix,iy,1.);
481 effVsXY->GetXaxis()->SetTitle(xVar.Data());
482 effVsXY->GetXaxis()->CenterTitle(kTRUE);
483 effVsXY->GetXaxis()->SetLabelFont(22);
484 effVsXY->GetXaxis()->SetTitleFont(22);
485 effVsXY->GetYaxis()->SetTitle(yVar.Data());
486 effVsXY->GetYaxis()->CenterTitle(kTRUE);
487 effVsXY->GetYaxis()->SetLabelFont(22);
488 effVsXY->GetYaxis()->SetTitleFont(22);
489 effVsXY->GetZaxis()->SetTitle(
"efficiency");
490 effVsXY->GetZaxis()->SetLabelFont(22);
491 effVsXY->GetZaxis()->SetTitleFont(22);
494 new TCanvas(Form(
"cTrackingEffVs%s-%s",xVar.Data(),yVar.Data()), Form(
"Measured tracking efficiency versus %s and %s",xVar.Data(),yVar.Data()),700,600);
495 effVsXY->DrawClone(
"surf1");
499 file =
new TFile(fileNameSave.Data(),
"update");
500 effVsXY->Write(0x0, TObject::kOverwrite);
503 if (yDim == 3 && rap) {
506 TString rapName = Form(
"trackingEffVs%s-%sRapBins", xVar.Data(), yVar.Data());
507 TString rapTitle = Form(
"Measured tracking efficiency versus %s and %s", xVar.Data(), yVar.Data());
508 effVsXYrap->SetTitle(rapTitle.Data());
509 effVsXYrap->SetName(rapName.Data());
512 for (
Int_t xbin = 0; xbin <= nxBins; ++xbin)
513 xBinEdge[xbin] = effVsXY->GetXaxis()->GetBinLowEdge(xbin+1);
516 for (
Int_t ybin = 0; ybin <= nyBins; ++ybin)
517 yBinEdge[ybin] = 2*TMath::ATan(TMath::Exp((effVsXY->GetYaxis()->GetBinLowEdge(ybin+1))));
519 effVsXYrap->SetBins(nxBins, xBinEdge, nyBins, yBinEdge);
521 for (
Int_t xbin = 1; xbin <= nxBins; ++xbin)
522 for (
Int_t ybin = 1; ybin <= nyBins; ++ybin)
523 effVsXYrap->SetBinContent(xbin, ybin, effVsXY->GetBinContent(xbin,ybin));
525 effVsXYrap->Write(0x0, TObject::kOverwrite);
544 printf(
"plotting efficiency...\n");
547 TFile *
file =
new TFile(fileNameData.Data(),
"read");
548 if (!file || !file->IsOpen()) {
549 printf(
"cannot open file %s \n",fileNameData.Data());
552 TList *listTT =
static_cast<TList*
>(file->FindObjectAny(Form(
"TotalTracksPerChamber%s", gObjNameExtension.Data())));
553 TList *listTD =
static_cast<TList*
>(file->FindObjectAny(Form(
"TracksDetectedPerChamber%s", gObjNameExtension.Data())));
554 THnSparse *TT =
static_cast<THnSparse*
>(listTT->At(10));
555 THnSparse *TD =
static_cast<THnSparse*
>(listTD->At(10));
560 TString nameAdd[3] = {
"",
"Low",
"Up"};
561 TString titleAdd[3] = {
"",
" - lower limit",
" - upper limit"};
562 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
564 Form(
"Measured efficiency per chamber (0 = spectro)%s",titleAdd[i].
Data()));
566 Form(
"Measured efficiency per station (6 = st4&5)%s",titleAdd[i].
Data()));
587 effVsCh[0]->SetPoint(0,0.,1.);
588 effVsCh[0]->SetPointError(0,0.,0.,1.,0.);
590 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
591 effVsSt[0]->SetPoint(iSt,iSt+1,1.);
592 effVsSt[0]->SetPointError(iSt,0.,0.,1.,0.);
598 effVsCh[1]->SetPoint(0,0.,0.);
599 effVsCh[1]->SetPointError(0,0.,0.,0.,0.);
602 effVsCh[2]->SetPoint(0,0.,1.);
603 effVsCh[2]->SetPointError(0,0.,0.,0.,0.);
605 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
607 effVsSt[1]->SetPoint(iSt,iSt+1,0.);
608 effVsSt[1]->SetPointError(iSt,0.,0.,0.,0.);
610 effVsSt[2]->SetPoint(iSt,iSt+1,1.);
611 effVsSt[2]->SetPointError(iSt,0.,0.,0.,0.);
620 for (
Int_t iCh = 1; iCh < 11; iCh++) {
621 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
622 effVsCh[i]->SetPoint(iCh,iCh,chEff[iCh]);
623 effVsCh[i]->SetPointError(iCh,0.,0.,chEffErr[0][iCh],chEffErr[1][iCh]);
631 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
632 effVsCh[i]->GetXaxis()->Set(12, -0.5, 10.5);
633 effVsCh[i]->GetXaxis()->SetNdivisions(11);
635 effVsSt[i]->GetXaxis()->Set(7, 0.5, 6.5);
636 effVsSt[i]->GetXaxis()->SetNdivisions(6);
641 TCanvas *
c =
new TCanvas(
"cEfficiency",
"Measured tracking efficiency" , 1000, 400);
643 gROOT->SetSelectedPad(c->cd(1));
644 effVsCh[0]->DrawClone(
"ap");
645 gROOT->SetSelectedPad(c->cd(2));
646 effVsSt[0]->DrawClone(
"ap");
650 file =
new TFile(fileNameSave.Data(),
"update");
651 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) effVsCh[i]->Write(0x0, TObject::kOverwrite);
652 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) effVsSt[i]->Write(0x0, TObject::kOverwrite);
656 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
669 printf(
"plotting efficiency versus run...\n");
672 ifstream inFile(runList.Data());
673 if (!inFile.is_open()) {
674 printf(
"cannot open file %s\n",runList.Data());
680 chamberVsRunGraphs.SetOwner(kTRUE);
681 for (
Int_t iCh = 1; iCh < 11; ++iCh)
682 chamberVsRunGraphs.Add(
CreateGraph(
"effCh%dVsRun",
"Measured efficiency for chamber %d versus run",iCh));
686 TString nameAdd[3] = {
"",
"Low",
"Up"};
687 TString titleAdd[3] = {
"",
" - lower limit",
" - upper limit"};
688 for (
Int_t i = 0; i < 3; ++i) {
690 stationVsRunGraphs[i].SetOwner(kTRUE);
691 for (
Int_t iSt = 1; iSt < 6; ++iSt)
692 stationVsRunGraphs[i].Add(
CreateGraph(Form(
"effSt%%dVsRun%s",nameAdd[i].
Data()),
693 Form(
"Measured efficiency for station %%d versus run%s",titleAdd[i].
Data()),iSt));
694 stationVsRunGraphs[i].Add(
CreateGraph(Form(
"effSt4&5VsRun%s",nameAdd[i].
Data()),
695 Form(
"Measured efficiency for station 4&5 versus run%s",titleAdd[i].
Data())));
697 trkVsRun[i] =
CreateGraph(Form(
"trackingEffVsRun%s",nameAdd[i].
Data()),
698 Form(
"Measured tracking efficiency versus run%s", titleAdd[i].
Data()));
707 while (!inFile.eof()) {
711 currRun.ReadLine(inFile,kTRUE);
712 if(currRun.IsNull())
continue;
713 runs.AddLast(
new TObjString(currRun));
716 Int_t run = currRun.Atoi();
718 printf(
"run %d: ", run);
721 TString dataFile = Form(
"runs/%d/%s", run, fileNameData.Data());
722 TString outFile = Form(
"runs/%d/%s", run, fileNameSave.Data());
725 TFile *
file =
new TFile(outFile.Data(),
"read");
726 if (!file || !file->IsOpen()) {
727 printf(
"cannot open file\n");
732 for (
Int_t i = 0; i < 3; ++i) {
737 effVsCh =
static_cast<TGraphAsymmErrors*
>(file->FindObjectAny(Form(
"chamberEff%s",nameAdd[i].
Data())));
738 effVsSt =
static_cast<TGraphAsymmErrors*
>(file->FindObjectAny(Form(
"stationEff%s",nameAdd[i].
Data())));
739 if (!effVsCh || !effVsSt) {
740 printf(
"efficiency graph not found\n");
745 if (i == 0)
for (
Int_t iCh = 0; iCh < 10; ++iCh) {
747 g->SetPoint(irun,irun,effVsCh->GetY()[iCh+1]);
748 g->SetPointError(irun,0.,0.,effVsCh->GetErrorYlow(iCh+1),effVsCh->GetErrorYhigh(iCh+1));
752 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
754 g->SetPoint(irun,irun,effVsSt->GetY()[iSt]);
755 g->SetPointError(irun,0.,0.,effVsSt->GetErrorYlow(iSt),effVsSt->GetErrorYhigh(iSt));
759 trkVsRun[i]->SetPoint(irun,irun,effVsCh->GetY()[0]);
760 trkVsRun[i]->SetPointError(irun,0.,0.,effVsCh->GetErrorYlow(0),effVsCh->GetErrorYhigh(0));
773 for (
Int_t i = 0; i < 3; ++i) {
781 new TCanvas(
"cTrackingEffVsRun",
"Tracking efficiency versus run",1000,400);
782 trkVsRun[0]->DrawClone(
"ap");
786 TFile*
file =
new TFile(fileNameSave.Data(),
"update");
787 chamberVsRunGraphs.Write(
"ChamberEffVsRun", TObject::kOverwrite | TObject::kSingleKey);
788 for (
Int_t i = 0; i < 3; ++i)
789 stationVsRunGraphs[i].Write(Form(
"StationEffVsRun%s",nameAdd[i].
Data()), TObject::kOverwrite | TObject::kSingleKey);
790 for (
Int_t i = 0; i < 3; ++i) trkVsRun[i]->Write(0x0, TObject::kOverwrite);
794 for (
Int_t i = 0; i < 3; ++i)
delete trkVsRun[i];
804 printf(
"plotting integrated efficiency...\n");
809 printf(
"Cannot compute integrated efficiency without run-by-run weights\n");
814 TFile *
file =
new TFile(fileNameSave.Data(),
"update");
815 if (!file || !file->IsOpen()) {
816 printf(
"cannot open file\n");
819 TObjArray *chamberVsRunGraphs =
static_cast<TObjArray*
>(file->FindObjectAny(
"ChamberEffVsRun"));
821 stationVsRunGraphs[0] =
static_cast<TObjArray*
>(file->FindObjectAny(
"StationEffVsRunLow"));
822 stationVsRunGraphs[1] =
static_cast<TObjArray*
>(file->FindObjectAny(
"StationEffVsRunUp"));
824 trkVsRun[0] =
static_cast<TGraphAsymmErrors*
>(file->FindObjectAny(
"trackingEffVsRunLow"));
825 trkVsRun[1] =
static_cast<TGraphAsymmErrors*
>(file->FindObjectAny(
"trackingEffVsRunUp"));
826 if (!chamberVsRunGraphs || !stationVsRunGraphs[0] || !stationVsRunGraphs[1] || !trkVsRun[0] || !trkVsRun[1]) {
827 printf(
"object not found --> you must first plot the efficiency versus run\n");
839 for (
Int_t iCh = 0; iCh < 10; ++iCh) {
845 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
853 for (
Int_t iCh = 1; iCh < 11; ++iCh) {
854 cout <<
"Efficiency chamber " << iCh <<
" : ";
855 cout << effVsCh->GetY()[iCh] <<
" + " << effVsCh->GetErrorYhigh(iCh) <<
" - " << effVsCh->GetErrorYlow(iCh) << endl;
857 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
858 if (iSt < 5) cout <<
"Station " << iSt+1 <<
" = ";
859 else cout <<
"Station 45 = ";
860 cout << effVsSt->GetY()[iSt] <<
" + " << effVsSt->GetErrorYhigh(iSt) <<
" - " << effVsSt->GetErrorYlow(iSt) << endl;
862 cout <<
"Total tracking efficiency : ";
863 cout << effVsCh->GetY()[0] <<
" + " << effVsCh->GetErrorYhigh(0) <<
" - " << effVsCh->GetErrorYlow(0) << endl << endl;
867 effVsCh->GetXaxis()->Set(12, -0.5, 10.5);
868 effVsCh->GetXaxis()->SetNdivisions(11);
870 effVsSt->GetXaxis()->Set(7, 0.5, 6.5);
871 effVsSt->GetXaxis()->SetNdivisions(6);
875 TCanvas *
c =
new TCanvas(
"cIntegratedEfficiency",
"Integrated tracking efficiency" , 1000, 400);
877 gROOT->SetSelectedPad(c->cd(1));
878 effVsCh->DrawClone(
"ap");
879 gROOT->SetSelectedPad(c->cd(2));
880 effVsSt->DrawClone(
"ap");
884 effVsCh->Write(0x0, TObject::kOverwrite);
885 effVsSt->Write(0x0, TObject::kOverwrite);
900 printf(
"plotting efficiency per DE...\n");
903 TFile *
file =
new TFile(fileNameData.Data(),
"read");
904 if (!file || !file->IsOpen()) {
905 printf(
"cannot open file %s \n",fileNameData.Data());
908 TList *listTT =
static_cast<TList*
>(file->FindObjectAny(Form(
"TotalTracksPerChamber%s", gObjNameExtension.Data())));
909 TList *listTD =
static_cast<TList*
>(file->FindObjectAny(Form(
"TracksDetectedPerChamber%s", gObjNameExtension.Data())));
913 chamberVsDEGraphs.SetOwner(kTRUE);
917 TString nameAdd[3] = {
"",
"Low",
"Up"};
918 TString titleAdd[3] = {
"",
" - lower limit",
" - upper limit"};
919 for (
Int_t i = 0; i < 3; ++i) stationVsDEGraphs[i].SetOwner(kTRUE);
921 for (
Int_t iSt = 0; iSt < 6; ++iSt)
for (
Int_t i = 0; i < 3; ++i) gSt[iSt][i] = 0x0;
924 for (
Int_t iCh = 0; iCh < 10; ++iCh) {
927 chamberVsDEGraphs.Add(
CreateGraph(
"effCh%dVsDE",
"Measured efficiency for chamber %d per DE",iCh+1));
931 THnSparse *TT =
static_cast<THnSparse*
>(listTT->At(iCh));
932 THnSparse *TD =
static_cast<THnSparse*
>(listTD->At(iCh));
952 for (
Int_t iSt = 0; iSt < 3; ++iSt) {
955 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
956 stationVsDEGraphs[i].Add(
CreateGraph(Form(
"effSt%%dVsDE%s",nameAdd[i].
Data()),
957 Form(
"Measured efficiency for station %%d per DE%s",titleAdd[i].
Data()),iSt+1));
958 gSt[iSt][i] =
static_cast<TGraphAsymmErrors*
>(stationVsDEGraphs[i].UncheckedAt(iSt));
963 for (
Int_t iDE = 0; iDE <
nDE; ++iDE) {
966 for (
Int_t iCh = 0; iCh < 2; ++iCh) {
967 chEff[2*iSt+iCh+1] = gCh[2*iSt+iCh]->GetY()[iDE];
968 chEffErr[0][2*iSt+iCh+1] = gCh[2*iSt+iCh]->GetErrorYlow(iDE);
969 chEffErr[1][2*iSt+iCh+1] = gCh[2*iSt+iCh]->GetErrorYhigh(iDE);
980 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
981 for (
Int_t iSt = 3; iSt < 5; ++iSt) {
982 stationVsDEGraphs[i].Add(
CreateGraph(Form(
"effSt%%dVsDE%s",nameAdd[i].
Data()),
983 Form(
"Measured efficiency for station %%d per DE%s",titleAdd[i].
Data()),iSt+1));
984 gSt[iSt][i] =
static_cast<TGraphAsymmErrors*
>(stationVsDEGraphs[i].UncheckedAt(iSt));
986 stationVsDEGraphs[i].Add(
CreateGraph(Form(
"effSt4&5VsDE%s",nameAdd[i].
Data()),
987 Form(
"Measured efficiency for station 4&5 per DE%s",titleAdd[i].
Data())));
988 gSt[5][i] =
static_cast<TGraphAsymmErrors*
>(stationVsDEGraphs[i].UncheckedAt(5));
993 for (
Int_t iDE = 0; iDE <
nDE; ++iDE) {
996 for (
Int_t iCh = 6; iCh < 10; ++iCh) {
997 chEff[iCh+1] = gCh[iCh]->GetY()[iDE];
998 chEffErr[0][iCh+1] = gCh[iCh]->GetErrorYlow(iDE);
999 chEffErr[1][iCh+1] = gCh[iCh]->GetErrorYhigh(iDE);
1011 for (
Int_t iCh = 0; iCh < 10; ++iCh) {
1012 Int_t nDE = gCh[iCh]->GetN();
1013 gCh[iCh]->GetXaxis()->Set(nDE+1, -0.5, nDE-0.5);
1014 gCh[iCh]->GetXaxis()->SetNdivisions(nDE);
1016 BeautifyGraphs(chamberVsDEGraphs,
"Detection Element",
"efficiency");
1017 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i) {
1018 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1019 Int_t nDE = gSt[iSt][i]->GetN();
1020 gSt[iSt][i]->GetXaxis()->Set(nDE+1, -0.5, nDE-0.5);
1021 gSt[iSt][i]->GetXaxis()->SetNdivisions(nDE);
1023 BeautifyGraphs(stationVsDEGraphs[i],
"Detection Element",
"efficiency");
1028 file =
new TFile(fileNameSave.Data(),
"update");
1029 chamberVsDEGraphs.Write(
"ChamberEffVsDE", TObject::kOverwrite | TObject::kSingleKey);
1030 for (
Int_t i = 0; i < 1 || (saveEdges && i < 3); ++i)
1031 stationVsDEGraphs[i].Write(Form(
"StationEffVsDE%s",nameAdd[i].
Data()), TObject::kOverwrite | TObject::kSingleKey);
1042 printf(
"plotting efficiency per DE versus run...\n");
1045 ifstream inFile(runList.Data());
1046 if (!inFile.is_open()) {
1047 printf(
"cannot open file %s\n",runList.Data());
1053 deVsRunGraphs.SetOwner(kTRUE);
1055 TString nameAdd[3] = {
"",
"Low",
"Up"};
1056 TString titleAdd[3] = {
"",
" - lower limit",
" - upper limit"};
1057 for (
Int_t i = 0; i < 3; ++i) stDEVsRunGraphs[i].SetOwner(kTRUE);
1058 Bool_t createGraph = kTRUE;
1065 while (!inFile.eof()) {
1069 currRun.ReadLine(inFile,kTRUE);
1070 if(currRun.IsNull())
continue;
1071 runs.AddLast(
new TObjString(currRun));
1074 Int_t run = currRun.Atoi();
1076 printf(
"run %d: ", run);
1079 TString dataFile = Form(
"runs/%d/%s", run, fileNameData.Data());
1080 TString outFile = Form(
"runs/%d/%s", run, fileNameSave.Data());
1083 TFile *
file =
new TFile(outFile.Data(),
"read");
1084 if (!file || !file->IsOpen()) {
1085 printf(
"cannot open file\n");
1090 TObjArray *chamberVsDEGraphs =
static_cast<TObjArray*
>(file->FindObjectAny(
"ChamberEffVsDE"));
1091 if (!chamberVsDEGraphs) {
1092 printf(
"efficiency graph not found\n");
1096 Int_t currentDE = 0;
1099 for (
Int_t iCh = 0; iCh < 10; ++iCh) {
1106 for (
Int_t iDE = 0; iDE <
nDE; ++iDE) {
1109 if (createGraph) deVsRunGraphs.Add(
CreateGraph(
"effDE%dVsRun",
"Measured efficiency for DE %d versus run",100*(iCh+1)+iDE));
1113 gDE->SetPoint(irun,irun,g->GetY()[iDE]);
1114 gDE->SetPointError(irun,0.,0.,g->GetErrorYlow(iDE),g->GetErrorYhigh(iDE));
1121 for (
Int_t i = 0; i < 3; ++i) {
1124 TObjArray *stationVsDEGraphs =
static_cast<TObjArray*
>(file->FindObjectAny(Form(
"StationEffVsDE%s",nameAdd[i].
Data())));
1125 if (!stationVsDEGraphs) {
1126 printf(
"efficiency graph not found\n");
1130 Int_t currentStDE = 0;
1133 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1140 for (
Int_t iDE = 0; iDE <
nDE; ++iDE) {
1144 TString sSt = (iSt<5) ? Form(
"%d",iSt+1) :
"4&5";
1145 stDEVsRunGraphs[i].Add(
CreateGraph(Form(
"effSt%sDE%%dVsRun%s",sSt.Data(),nameAdd[i].Data()),
1146 Form(
"Measured efficiency for DE %%d in station %s versus run%s",sSt.Data(),titleAdd[i].Data()),iDE));
1151 gDE->SetPoint(irun,irun,g->GetY()[iDE]);
1152 gDE->SetPointError(irun,0.,0.,g->GetErrorYlow(iDE),g->GetErrorYhigh(iDE));
1162 createGraph = kFALSE;
1171 for (
Int_t i = 0; i < 3; ++i) {
1177 TFile*
file =
new TFile(fileNameSave.Data(),
"update");
1178 deVsRunGraphs.Write(
"DEEffVsRun", TObject::kOverwrite | TObject::kSingleKey);
1179 for (
Int_t i = 0; i < 3; ++i)
1180 stDEVsRunGraphs[i].Write(Form(
"DEEffPerStationVsRun%s",nameAdd[i].
Data()), TObject::kOverwrite | TObject::kSingleKey);
1191 printf(
"plotting integrated efficiency per DE...\n");
1196 printf(
"Cannot compute integrated efficiency without run-by-run weights\n");
1201 TFile *
file =
new TFile(fileNameSave.Data(),
"update");
1202 if (!file || !file->IsOpen()) {
1203 printf(
"cannot open file\n");
1206 TObjArray *deVsRunGraphs =
static_cast<TObjArray*
>(file->FindObjectAny(
"DEEffVsRun"));
1208 stDEVsRunGraphs[0] =
static_cast<TObjArray*
>(file->FindObjectAny(
"DEEffPerStationVsRunLow"));
1209 stDEVsRunGraphs[1] =
static_cast<TObjArray*
>(file->FindObjectAny(
"DEEffPerStationVsRunUp"));
1210 if (!deVsRunGraphs || !stDEVsRunGraphs[0] || !stDEVsRunGraphs[1]) {
1211 printf(
"object not found --> you must first plot the efficiency versus run\n");
1217 chamberVsDEGraphs.SetOwner(kTRUE);
1218 for (
Int_t iCh = 0; iCh < 10; ++iCh)
1219 chamberVsDEGraphs.Add(
CreateGraph(
"integratedEffCh%dVsDE",
"Integrated efficiency for chamber %d per DE",iCh+1));
1222 stationVsDEGraphs.SetOwner(kTRUE);
1223 for (
Int_t iSt = 0; iSt < 5; ++iSt)
1224 stationVsDEGraphs.Add(
CreateGraph(
"integratedEffSt%dVsDE",
"Integrated efficiency for station %d per DE",iSt+1));
1225 stationVsDEGraphs.Add(
CreateGraph(
"integratedEffSt4&5VsDE",
"Integrated efficiency for station 4&5 per DE"));
1228 TIter nextDE(deVsRunGraphs);
1230 while ((gDE = static_cast<TGraphAsymmErrors*>(nextDE()))) {
1234 sscanf(gDE->GetName(),
"effDE%dVsRun", &deId);
1235 Int_t iCh = deId/100-1;
1236 Int_t iDE = deId%100;
1245 Int_t ng = stDEVsRunGraphs[0]->GetEntries();
1246 for (
Int_t ig = 0; ig < ng; ++ig) {
1253 if (strstr(gDELow->GetName(),
"4&5")) {
1255 sscanf(gDELow->GetName(),
"effSt4&5DE%dVsRunLow", &iDE);
1257 sscanf(gDELow->GetName(),
"effSt%dDE%dVsRunLow", &iSt, &iDE);
1268 for (
Int_t iCh = 0; iCh < 10; ++iCh) {
1271 g->GetXaxis()->Set(nDE+1, -0.5, nDE-0.5);
1272 g->GetXaxis()->SetNdivisions(nDE);
1274 BeautifyGraphs(chamberVsDEGraphs,
"Detection Element",
"efficiency");
1275 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1278 g->GetXaxis()->Set(nDE+1, -0.5, nDE-0.5);
1279 g->GetXaxis()->SetNdivisions(nDE);
1281 BeautifyGraphs(stationVsDEGraphs,
"Detection Element",
"efficiency");
1284 chamberVsDEGraphs.Write(
"IntegratedChamberEffVsDE", TObject::kOverwrite | TObject::kSingleKey);
1285 stationVsDEGraphs.Write(
"IntegratedStationEffVsDE", TObject::kOverwrite | TObject::kSingleKey);
1298 TH1D *TTdraw = TT.Projection(0,
"e");
1299 TH1D *TDdraw = TD.Projection(0,
"e");
1303 Bool_t ok = (efficiency);
1308 Bool_t missingEff = kFALSE;
1310 for (
Int_t i = 0; i < 10; i++) {
1312 if (TTdraw->GetBinContent(i+1) > 0) {
1314 chEff[i+1] = efficiency->GetY()[i];
1315 chEffErr[0][i+1] = efficiency->GetErrorYlow(i);
1316 chEffErr[1][i+1] = efficiency->GetErrorYhigh(i);
1321 chEffErr[0][i+1] = 0.;
1322 chEffErr[1][i+1] = 0.;
1330 if (missingEff && printError) cout <<
"efficiency partially unknown" << endl;
1334 for (
Int_t i = 0; i < 10; i++) {
1337 chEffErr[0][i+1] = 0.;
1338 chEffErr[1][i+1] = 0.;
1342 if (printError) cout <<
"efficiency unknown" << endl << endl;
1362 TH1D *TTdraw = TT.Projection(0,
"e");
1363 TH1D *TDdraw = TD.Projection(0,
"e");
1371 for (
Int_t iDE = 0; iDE <
nDE; ++iDE) {
1373 if (TTdraw->GetBinContent(iDE+1) > 0) {
1375 effVsDE.SetPoint(iDE,iDE,efficiency->GetY()[iDE]);
1376 effVsDE.SetPointError(iDE,0,0,efficiency->GetErrorYlow(iDE),efficiency->GetErrorYhigh(iDE));
1380 effVsDE.SetPoint(iDE,iDE,-1);
1381 effVsDE.SetPointError(iDE,0,0,0,0);
1389 for (
Int_t iDE = 0; iDE <
nDE; ++iDE) {
1391 effVsDE.SetPoint(iDE,iDE,-1);
1392 effVsDE.SetPointError(iDE,0,0,0,0);
1411 stEff = 1.-(1.-chEff[2*iSt+1])*(1.-chEff[2*iSt+2]);
1413 Double_t d1 = (1. - chEff[2*iSt+2]); d1 *= d1;
1414 Double_t d2 = (1. - chEff[2*iSt+1]); d2 *= d2;
1416 for (
Int_t i = 0; i < 2; ++i) {
1417 Double_t s1 = chEffErr[i][2*iSt+1] * chEffErr[i][2*iSt+1];
1418 Double_t s2 = chEffErr[i][2*iSt+2] * chEffErr[i][2*iSt+2];
1419 stEffErr[i] = TMath::Sqrt(d1*s1 + d2*s2 + s1*s2);
1422 stEffErr[0] = TMath::Min(stEff, stEffErr[0]);
1423 stEffErr[1] = TMath::Min(1.-stEff, stEffErr[1]);
1433 if (chEff[2*iSt+1] >= 0 && chEff[2*iSt+2] >= 0) {
1440 for (
Int_t i = 0; i < 3; ++i) {
1442 effVsX[i]->SetPoint(ip,xp,stEff);
1443 effVsX[i]->SetPointError(ip,0.,0.,stEffErr[0],stEffErr[1]);
1454 for (
Int_t i = 0; i < 2; ++i) {
1457 chEffEdge[i].Set(11);
1458 for (
Int_t iCh = 1; iCh < 3; ++iCh) chEffEdge[i][2*iSt+iCh] = (chEff[2*iSt+iCh] < 0) ? edge[i] : chEff[2*iSt+iCh];
1465 effVsX[i+1]->SetPoint(ip,xp,stEffEdge[i]);
1466 effVsX[i+1]->SetPointError(ip,0.,0.,stEffEdgeErr[i][0],stEffEdgeErr[i][1]);
1473 effVsX[0]->SetPoint(ip,xp,stEffEdge[1]);
1474 effVsX[0]->SetPointError(ip,0.,0.,stEffEdge[1]-stEffEdge[0]+stEffEdgeErr[0][0],stEffEdgeErr[1][1]);
1487 st45Eff = chEff[7]*chEff[8]*chEff[9] + chEff[7]*chEff[8]*chEff[10] + chEff[7]*chEff[9]*chEff[10] + chEff[8]*chEff[9]*chEff[10] - 3.*chEff[7]*chEff[8]*chEff[9]*chEff[10];
1489 Double_t d1 = chEff[8]*chEff[9] + chEff[8]*chEff[10] + chEff[9]*chEff[10] - 3.*chEff[8]*chEff[9]*chEff[10]; d1 *= d1;
1490 Double_t d2 = chEff[7]*chEff[9] + chEff[7]*chEff[10] + chEff[9]*chEff[10] - 3.*chEff[7]*chEff[9]*chEff[10]; d2 *= d2;
1491 Double_t d3 = chEff[7]*chEff[8] + chEff[7]*chEff[10] + chEff[8]*chEff[10] - 3.*chEff[7]*chEff[8]*chEff[10]; d3 *= d3;
1492 Double_t d4 = chEff[7]*chEff[8] + chEff[7]*chEff[9] + chEff[8]*chEff[9] - 3.*chEff[7]*chEff[8]*chEff[9]; d4 *= d4;
1493 Double_t d12 = chEff[9] + chEff[10] - 3.*chEff[9]*chEff[10]; d12 *= d12;
1494 Double_t d13 = chEff[8] + chEff[10] - 3.*chEff[8]*chEff[10]; d13 *= d13;
1495 Double_t d14 = chEff[8] + chEff[9] - 3.*chEff[8]*chEff[9]; d14 *= d14;
1496 Double_t d23 = chEff[7] + chEff[10] - 3.*chEff[7]*chEff[10]; d23 *= d23;
1497 Double_t d24 = chEff[7] + chEff[9] - 3.*chEff[7]*chEff[9]; d24 *= d24;
1498 Double_t d34 = chEff[7] + chEff[8] - 3.*chEff[7]*chEff[8]; d34 *= d34;
1499 Double_t d123 = 1. - 3.*chEff[10]; d123 *= d123;
1500 Double_t d124 = 1. - 3.*chEff[9]; d124 *= d124;
1501 Double_t d134 = 1. - 3.*chEff[8]; d134 *= d134;
1502 Double_t d234 = 1. - 3.*chEff[7]; d234 *= d234;
1503 Double_t d1234 = - 3.; d1234 *= d1234;
1505 for (
Int_t i = 0; i < 2; ++i) {
1506 Double_t s1 = chEffErr[i][7] * chEffErr[i][7];
1507 Double_t s2 = chEffErr[i][8] * chEffErr[i][8];
1508 Double_t s3 = chEffErr[i][9] * chEffErr[i][9];
1509 Double_t s4 = chEffErr[i][10] * chEffErr[i][10];
1510 st45EffErr[i] = TMath::Sqrt(d1*s1 + d2*s2 + d3*s3 + d4*s4 + d12*s1*s2 + d13*s1*s3 + d14*s1*s4 + d23*s2*s3 + d24*s2*s4 + d34*s3*s4 + d123*s1*s2*s3 + d124*s1*s2*s4 + d134*s1*s3*s4 + d234*s2*s3*s4 + d1234*s1*s2*s3*s4);
1513 st45EffErr[0] = TMath::Min(st45Eff, st45EffErr[0]);
1514 st45EffErr[1] = TMath::Min(1.-st45Eff, st45EffErr[1]);
1524 if (chEff[7] >= 0 && chEff[8] >= 0 && chEff[9] >= 0 && chEff[10] >= 0) {
1531 for (
Int_t i = 0; i < 3; ++i) {
1533 effVsX[i]->SetPoint(ip,xp,stEff);
1534 effVsX[i]->SetPointError(ip,0.,0.,stEffErr[0],stEffErr[1]);
1545 for (
Int_t i = 0; i < 2; ++i) {
1548 chEffEdge[i].Set(11);
1549 for (
Int_t iCh = 7; iCh < 11; ++iCh) chEffEdge[i][iCh] = (chEff[iCh] < 0) ? edge[i] : chEff[iCh];
1556 effVsX[i+1]->SetPoint(ip,xp,stEffEdge[i]);
1557 effVsX[i+1]->SetPointError(ip,0.,0.,stEffEdgeErr[i][0],stEffEdgeErr[i][1]);
1564 effVsX[0]->SetPoint(ip,xp,stEffEdge[1]);
1565 effVsX[0]->SetPointError(ip,0.,0.,stEffEdge[1]-stEffEdge[0]+stEffEdgeErr[0][0],stEffEdgeErr[1][1]);
1579 for (
Int_t iSt = 0; iSt < 6; iSt++) de[iSt][0] = stEff[iSt]*stEff[iSt];
1583 spectroEff = stEff[0] * stEff[1] * stEff[2] * stEff[3] * stEff[4];
1585 for (
Int_t i = 0; i < 2; i++) {
1587 for (
Int_t iSt = 0; iSt < 6; iSt++) de[iSt][1] = stEffErr[iSt][i]*stEffErr[iSt][i];
1589 spectroEffErr[i] = 0.;
1590 for (
Int_t j = 1; j < 32; j++) {
1592 for (
Int_t iSt = 0; iSt < 5; iSt++) sigmaAdd *= de[iSt][TESTBIT(j,iSt)];
1593 spectroEffErr[i] += sigmaAdd;
1595 spectroEffErr[i] = TMath::Sqrt(spectroEffErr[i]);
1601 spectroEff = stEff[0] * stEff[1] * stEff[2] * stEff[5];
1603 for (
Int_t i = 0; i < 2; i++) {
1605 for (
Int_t iSt = 0; iSt < 6; iSt++) de[iSt][1] = stEffErr[iSt][i]*stEffErr[iSt][i];
1607 spectroEffErr[i] = 0.;
1608 for (
Int_t j = 1; j < 16; j++) {
1609 Double_t sigmaAdd = de[5][TESTBIT(j,3)];
1610 for (
Int_t iSt = 0; iSt < 3; iSt++) sigmaAdd *= de[iSt][TESTBIT(j,iSt)];
1611 spectroEffErr[i] += sigmaAdd;
1613 spectroEffErr[i] = TMath::Sqrt(spectroEffErr[i]);
1619 spectroEffErr[0] = TMath::Min(spectroEff, spectroEffErr[0]);
1620 spectroEffErr[1] = TMath::Min(1.-spectroEff, spectroEffErr[1]);
1635 Bool_t allEffKnown = kTRUE;
1636 for (
Int_t iCh = 1; iCh < 11 && allEffKnown; ++iCh)
if (chEff[iCh] < 0) allEffKnown = kFALSE;
1645 Double_t spectroEff, spectroEffErr[2];
1647 chEff[0] = spectroEff;
1648 chEffErr[0][0] = spectroEffErr[0];
1649 chEffErr[1][0] = spectroEffErr[1];
1652 for (
Int_t i = 0; i < 3; ++i) {
1654 effVsX[i]->SetPoint(ip,xp,chEff[0]);
1655 effVsX[i]->SetPointError(ip,0.,0.,chEffErr[0][0],chEffErr[1][0]);
1657 if (effVsSt[i])
for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1658 effVsSt[i]->SetPoint(iSt,iSt+1,stEff[iSt]);
1659 effVsSt[i]->SetPointError(iSt,0.,0.,stEffErr[iSt][0],stEffErr[iSt][1]);
1669 Double_t spectroEffEdge[2], spectroEffEdgeErr[2][2];
1671 for (
Int_t i = 0; i < 2; ++i) {
1674 chEffEdge[i].Set(11);
1675 for (
Int_t iCh = 1; iCh < 11; ++iCh) chEffEdge[i][iCh] = (chEff[iCh] < 0) ? edge[i] : chEff[iCh];
1686 effVsX[i+1]->SetPoint(ip,xp,spectroEffEdge[i]);
1687 effVsX[i+1]->SetPointError(ip,0.,0.,spectroEffEdgeErr[i][0],spectroEffEdgeErr[i][1]);
1689 if (effVsSt[i+1])
for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1690 effVsSt[i+1]->SetPoint(iSt,iSt+1,stEffEdge[i][iSt]);
1691 effVsSt[i+1]->SetPointError(iSt,0.,0.,stEffEdgeErr[i][iSt][0],stEffEdgeErr[i][iSt][1]);
1697 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1698 stEff[iSt] = stEffEdge[1][iSt];
1699 stEffErr[iSt][0] = stEffEdge[1][iSt] - stEffEdge[0][iSt] + stEffEdgeErr[0][iSt][0];
1700 stEffErr[iSt][1] = stEffEdgeErr[1][iSt][1];
1704 chEff[0] = spectroEffEdge[1];
1705 chEffErr[0][0] = spectroEffEdge[1] - spectroEffEdge[0] + spectroEffEdgeErr[0][0];
1706 chEffErr[1][0] = spectroEffEdgeErr[1][1];
1710 effVsX[0]->SetPoint(ip,xp,chEff[0]);
1711 effVsX[0]->SetPointError(ip,0.,0.,chEffErr[0][0],chEffErr[1][0]);
1713 if (effVsSt[0])
for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1714 effVsSt[0]->SetPoint(iSt,iSt+1,stEff[iSt]);
1715 effVsSt[0]->SetPointError(iSt,0.,0.,stEffErr[iSt][0],stEffErr[iSt][1]);
1722 for (
Int_t iCh = 1; iCh < 11; ++iCh) {
1723 cout <<
"Efficiency chamber " << iCh <<
" : ";
1724 cout << chEff[iCh] <<
" + " << chEffErr[1][iCh] <<
" - " << chEffErr[0][iCh] << endl;
1726 for (
Int_t iSt = 0; iSt < 6; ++iSt) {
1727 if (iSt < 5) cout <<
"Station " << iSt+1 <<
" = ";
1728 else cout <<
"Station 45 = ";
1729 cout << stEff[iSt] <<
" + " << stEffErr[iSt][1] <<
" - " << stEffErr[iSt][0] << endl;
1731 cout <<
"Total tracking efficiency : ";
1732 cout << chEff[0] <<
" + " << chEffErr[1][0] <<
" - " << chEffErr[0][0] << endl << endl;
1746 effVsX.SetPoint(ip,xp,-1.);
1747 effVsX.SetPointError(ip,0.,0.,0.,0.);
1758 Int_t nRuns = effVsRunLow.GetN();
1759 for (
Int_t iRun = 0; iRun < nRuns; ++iRun) {
1762 TString sRun = effVsRunLow.GetXaxis()->GetBinLabel(iRun+1);
1765 printf(
"weight not found for run %s\n", sRun.Data());
1772 Double_t eff[2] = {effVsRunLow.GetY()[iRun], effVsRunUp.GetY()[iRun]};
1773 Double_t effErr[2] = {effVsRunLow.GetErrorYlow(iRun), effVsRunUp.GetErrorYhigh(iRun)};
1774 if (eff[0] < 0. || eff[1] < 0.) {
1775 printf(
"no efficiency measurement --> use 0(1) ± 0 as lower(upper) limit\n");
1784 for (
Int_t i = 0; i < 2; ++i) {
1786 intEffErr[i] += w2*effErr[i]*effErr[i];
1792 if (gen > 0. && ok) {
1794 effVsX.SetPoint(ip,xp,rec[1]/gen);
1795 effVsX.SetPointError(ip,0.,0.,(rec[1]-rec[0]+TMath::Sqrt(intEffErr[0]))/gen,TMath::Sqrt(intEffErr[1])/gen);
1799 if (gen <= 0.) printf(
"impossible to integrate, all weights = 0 or unknown ?!?\n");
1800 else printf(
"efficiency never measured --> return -1 ± 0\n");
1802 effVsX.SetPoint(ip,xp,-1.);
1803 effVsX.SetPointError(ip,0.,0.,0.,0.);
1819 ifstream inFile(fileName.Data());
1820 if (!inFile.is_open()) {
1821 printf(
"cannot open file %s\n", fileName.Data());
1829 while (! inFile.eof() ) {
1831 line.ReadLine(inFile,kTRUE);
1832 if(line.IsNull())
continue;
1835 if (param->GetEntries() != 2) {
1836 printf(
"bad input line %s", line.Data());
1840 Int_t run = ((TObjString*)param->UncheckedAt(0))->String().Atoi();
1842 printf(
"invalid run number: %d", run);
1846 Float_t weight = ((TObjString*)param->UncheckedAt(1))->String().Atof();
1848 printf(
"invalid weight: %g", weight);
1869 printf(
"Wrong Pt range, ptMax must be higher than ptMin\n");
1873 if (charge < -1 || charge > 1) {
1874 printf(
"Selected charge must be 0, 1 or -1\n");
1882 Int_t lowBin = SparseData.GetAxis(1)->FindBin(
centMin);
1884 SparseData.GetAxis(1)->SetRange(lowBin, upBin);
1887 lowBin = SparseData.GetAxis(2)->FindBin(
ptMin);
1888 if (
ptMax == -1) { upBin = SparseData.GetAxis(2)->GetNbins()+1; }
1889 else { upBin = SparseData.GetAxis(2)->FindBin(
ptMax);}
1890 SparseData.GetAxis(2)->SetRange(lowBin, upBin);
1894 lowBin = SparseData.GetAxis(5)->FindBin(
charge);
1895 SparseData.GetAxis(5)->SetRange(lowBin, lowBin);
1910 g->SetName(Form(name,value));
1911 g->SetTitle(Form(title,value));
1933 g.SetMarkerStyle(20);
1934 g.SetMarkerSize(0.7);
1935 g.SetMarkerColor(2);
1937 g.GetXaxis()->SetTitle(xAxisName);
1938 g.GetXaxis()->CenterTitle(kTRUE);
1939 g.GetXaxis()->SetLabelFont(22);
1940 g.GetXaxis()->SetTitleFont(22);
1942 g.GetYaxis()->SetTitle(yAxisName);
1943 g.GetYaxis()->CenterTitle(kTRUE);
1944 g.GetYaxis()->SetLabelFont(22);
1945 g.GetYaxis()->SetTitleFont(22);
1955 for (
Int_t i = 0; i <= array.GetLast(); ++i)
1956 BeautifyGraph(*static_cast<TGraphAsymmErrors*>(array.UncheckedAt(i)), xAxisName, yAxisName);
1966 g.GetXaxis()->Set(irun+1, -0.5, irun+0.5);
1968 TIter nextRun(&runs);
1969 TObjString *srun = 0x0;
1971 while ((srun = static_cast<TObjString*>(nextRun()))) {
1972 g.GetXaxis()->SetBinLabel(iirun, srun->GetName());
1984 for (
Int_t i = 0; i <= array.GetLast(); ++i)
1985 SetRunLabel(*static_cast<TGraphAsymmErrors*>(array.UncheckedAt(i)), irun, runs);
void ComputeStationEfficiency(TArrayD &chEff, TArrayD chEffErr[2], Int_t iSt, Double_t &stEff, Double_t stEffErr[2])
void MuonTrackingEfficiency(TString runList="runList.txt", TString fileNameWeights="", TString objNameExtension="", TString fileNameData="AnalysisResults.root", TString fileNameSave="efficiency_new.root")
void GetStationEfficiency(TArrayD &chEff, TArrayD chEffErr[2], Int_t iSt, TGraphAsymmErrors *effVsX[3], Int_t ip, Double_t xp)
void GetTrackingEfficiency(TArrayD &chEff, TArrayD chEffErr[2], TGraphAsymmErrors *effVsSt[3], TGraphAsymmErrors *effVsX[3], Int_t ip, Double_t xp, Bool_t print=kFALSE)
void ComputeTrackingEfficiency(Double_t stEff[6], Double_t stEffErr[6][2], Double_t &spectroEff, Double_t spectroEffErr[2])
void IntegrateMuonEfficiency(TGraphAsymmErrors &effVsRunLow, TGraphAsymmErrors &effVsRunUp, TGraphAsymmErrors &effVsX, Int_t ip, Double_t xp)
void PlotMuonEfficiencyVsRun(TString runList, TString fileNameData, TString fileNameSave, Bool_t print, Bool_t draw)
void PlotMuonEfficiency(TString fileNameData, TString fileNameSave, Bool_t saveEdges, Bool_t print, Bool_t draw)
void PlotIntegratedMuonEfficiency(TString fileNameWeights, TString fileNameSave, Bool_t print, Bool_t draw)
void PlotMuonEfficiencyVsXY(TString xVar, TString yVar, TString fileNameData, TString fileNameSave, Bool_t draw, Bool_t rap=kFALSE)
Bool_t moreTrackCandidates
void LoadRunWeights(TString fileName)
void GetDEEfficiency(THnSparse &TT, THnSparse &TD, TGraphAsymmErrors &effVsDE)
TString gObjNameExtension
void SetRunLabel(TGraphAsymmErrors &g, Int_t irun, const TList &runs)
void PlotIntegratedMuonEfficiencyVsX(TString var, TString runList, TString fileNameWeights, TString fileNameData, TString fileNameSave, Bool_t print, Bool_t draw)
void BeautifyGraphs(TObjArray &array, const char *xAxisName, const char *yAxisName)
TGraphAsymmErrors * CreateGraph(const char *name, const char *title, int value=-1)
void PlotIntegratedMuonEfficiencyPerDE(TString fileNameWeights, TString fileNameSave)
void ComputeStation45Efficiency(TArrayD &chEff, TArrayD chEffErr[2], Double_t &st45Eff, Double_t st45EffErr[2])
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)
const Char_t * effErrMode
void BeautifyGraph(TGraphAsymmErrors &g, const char *xAxisName, const char *yAxisName)
void PlotMuonEfficiencyVsX(TString var, TString fileNameData, TString fileNameSave, Bool_t saveEdges, Bool_t print, Bool_t draw)
TFile * file
TList with histograms for a given trigger.
void PlotMuonEfficiencyPerDE(TString fileNameData, TString fileNameSave, Bool_t saveEdges)
void PlotMuonEfficiencyPerDEVsRun(TString runList, TString fileNameData, TString fileNameSave)
void GetStation45Efficiency(TArrayD &chEff, TArrayD chEffErr[2], TGraphAsymmErrors *effVsX[3], Int_t ip, Double_t xp)
Bool_t GetChamberEfficiency(THnSparse &TT, THnSparse &TD, TArrayD &chEff, TArrayD chEffErr[2], Bool_t printError=kFALSE)
void SetCentPtCh(THnSparse &SparseData)