ROOT logo
/**
 * @file 
 * 
 * Scripts to draw energy loss fits from correction object file 
 *
 * @ingroup pwglf_forward_scripts_corr
 */
/** 
 * Clear canvas 
 * 
 * @param c Canvas to clear 
 *
 * @ingroup pwglf_forward_scripts_corr
 */
void
ClearCanvas(TCanvas* c)
{
  c->SetLeftMargin(.1);
  c->SetRightMargin(.05);
  c->SetBottomMargin(.1);
  c->SetTopMargin(.05);
  c->Clear();
}

/** 
 * Draw energy loss fits to a multi-page PDF. 
 *
 * @par Input: 
 * The input file is expected to contain a AliFMDCorrELossFit object
 * named @c elossfits in the top level directory.
 * 
 * @par Output: 
 * A multi-page PDF.  Note, that the PDF generated by ROOT in this way
 * is broken (cannot be read by Acrobat Reader on Windows and MacOSX)
 * and one should pass it through a filter to correct these problems.
 * 
 * @param fname   File name 
 * @param option  Drawing options 
 *
 * @ingroup pwglf_forward_scripts_corr
 */
void
DrawCorrAcc2(const char* fname, const char* option="colz")
{
  //__________________________________________________________________
  // Load libraries and object 
  gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");

  TFile* file = TFile::Open(fname, "READ");
  if (!file) { 
    Error("DrawCorrAcc", "Failed to open %s", fname);
    return;
  }
  TString pname(fname);
  pname.ReplaceAll(".root", ".pdf");

  const char* objName = 
    AliForwardCorrectionManager::Instance()
    .GetObjectName(AliForwardCorrectionManager::kAcceptance);
  AliFMDCorrAcceptance* corr = 
    static_cast<AliFMDCorrAcceptance*>(file->Get(objName));
  if (!corr) { 
    Error("DrawCorrAcc", "Object '%s' not found in %s", objName, fname);
    return;
  }

  //__________________________________________________________________
  // Create a canvas
  // TCanvas* c = new TCanvas("c", "c", 800 / TMath::Sqrt(2), 800);
  TCanvas* c = new TCanvas("c", "c", 800, 800 / TMath::Sqrt(2));
  c->SetFillColor(0);
  c->SetBorderSize(0);
  c->SetBorderMode(0);
  
  gStyle->SetOptStat(0);
  gStyle->SetTitleColor(0);
  gStyle->SetTitleStyle(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleX(.5);
  gStyle->SetTitleY(1);
  gStyle->SetTitleW(.8);
  gStyle->SetTitleH(.09);
  gStyle->SetFrameFillColor(kWhite);
  gStyle->SetFrameBorderSize(1);
  gStyle->SetFrameBorderMode(1);
  gStyle->SetPalette(1);

  ClearCanvas(c);
  const TAxis& vtxAxis = corr->GetVertexAxis();
  Int_t        nVtx    = vtxAxis.GetNbins();
  c->Divide((nVtx+2)/3, 3, 0, 0);
  Int_t ipad = 0;

  //__________________________________________________________________
  // Draw all corrections
  for (UShort_t v = 1; v <= nVtx; v++) { 
    ipad++;
    if (ipad == 1 || ipad == 12) ipad++;

    TVirtualPad* p = c->cd(ipad);
    p->SetFillColor(kWhite);
        
    THStack* stack = new THStack(Form("vtx%02d", v),
				 Form("%+5.1f<v_{z}<%+5.1f",
				      vtxAxis.GetBinLowEdge(v),
				      vtxAxis.GetBinUpEdge(v)));
    for (UShort_t d = 1; d <= 3; d++) {
      UShort_t     nQ = (d == 1 ? 1 : 2);
      for (UShort_t q = 0; q < nQ; q++) { 
	Char_t r = (q == 0 ? 'I' : 'O');
	
	TH2* h1 = corr->GetCorrection(d, r, v);
	if (!h1) { 
	  Warning("DrawCorrAcc", "No correction for r=%c, v=%d", r, v);
	  continue;
	}
	Int_t nY = h1->GetNbinsY();
	TH1* hh = h1->ProjectionX(Form("FMD%d%c", d, r), 1, nY);
	hh->Scale(1. / nY);
	hh->SetDirectory(0);
	hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
	hh->SetLineColor(AliForwardUtil::RingColor(d, r));
	hh->SetFillColor(AliForwardUtil::RingColor(d, r));
	hh->SetFillStyle(3004);

	stack->Add(hh);
      }
    }
    stack->SetMaximum(1.2);
    stack->Draw("nostack");
  }
  //__________________________________________________________________
  // Close output file 
  c->SaveAs("acceptance.png");
}
//
// EOF
//
 DrawCorrAcc2.C:1
 DrawCorrAcc2.C:2
 DrawCorrAcc2.C:3
 DrawCorrAcc2.C:4
 DrawCorrAcc2.C:5
 DrawCorrAcc2.C:6
 DrawCorrAcc2.C:7
 DrawCorrAcc2.C:8
 DrawCorrAcc2.C:9
 DrawCorrAcc2.C:10
 DrawCorrAcc2.C:11
 DrawCorrAcc2.C:12
 DrawCorrAcc2.C:13
 DrawCorrAcc2.C:14
 DrawCorrAcc2.C:15
 DrawCorrAcc2.C:16
 DrawCorrAcc2.C:17
 DrawCorrAcc2.C:18
 DrawCorrAcc2.C:19
 DrawCorrAcc2.C:20
 DrawCorrAcc2.C:21
 DrawCorrAcc2.C:22
 DrawCorrAcc2.C:23
 DrawCorrAcc2.C:24
 DrawCorrAcc2.C:25
 DrawCorrAcc2.C:26
 DrawCorrAcc2.C:27
 DrawCorrAcc2.C:28
 DrawCorrAcc2.C:29
 DrawCorrAcc2.C:30
 DrawCorrAcc2.C:31
 DrawCorrAcc2.C:32
 DrawCorrAcc2.C:33
 DrawCorrAcc2.C:34
 DrawCorrAcc2.C:35
 DrawCorrAcc2.C:36
 DrawCorrAcc2.C:37
 DrawCorrAcc2.C:38
 DrawCorrAcc2.C:39
 DrawCorrAcc2.C:40
 DrawCorrAcc2.C:41
 DrawCorrAcc2.C:42
 DrawCorrAcc2.C:43
 DrawCorrAcc2.C:44
 DrawCorrAcc2.C:45
 DrawCorrAcc2.C:46
 DrawCorrAcc2.C:47
 DrawCorrAcc2.C:48
 DrawCorrAcc2.C:49
 DrawCorrAcc2.C:50
 DrawCorrAcc2.C:51
 DrawCorrAcc2.C:52
 DrawCorrAcc2.C:53
 DrawCorrAcc2.C:54
 DrawCorrAcc2.C:55
 DrawCorrAcc2.C:56
 DrawCorrAcc2.C:57
 DrawCorrAcc2.C:58
 DrawCorrAcc2.C:59
 DrawCorrAcc2.C:60
 DrawCorrAcc2.C:61
 DrawCorrAcc2.C:62
 DrawCorrAcc2.C:63
 DrawCorrAcc2.C:64
 DrawCorrAcc2.C:65
 DrawCorrAcc2.C:66
 DrawCorrAcc2.C:67
 DrawCorrAcc2.C:68
 DrawCorrAcc2.C:69
 DrawCorrAcc2.C:70
 DrawCorrAcc2.C:71
 DrawCorrAcc2.C:72
 DrawCorrAcc2.C:73
 DrawCorrAcc2.C:74
 DrawCorrAcc2.C:75
 DrawCorrAcc2.C:76
 DrawCorrAcc2.C:77
 DrawCorrAcc2.C:78
 DrawCorrAcc2.C:79
 DrawCorrAcc2.C:80
 DrawCorrAcc2.C:81
 DrawCorrAcc2.C:82
 DrawCorrAcc2.C:83
 DrawCorrAcc2.C:84
 DrawCorrAcc2.C:85
 DrawCorrAcc2.C:86
 DrawCorrAcc2.C:87
 DrawCorrAcc2.C:88
 DrawCorrAcc2.C:89
 DrawCorrAcc2.C:90
 DrawCorrAcc2.C:91
 DrawCorrAcc2.C:92
 DrawCorrAcc2.C:93
 DrawCorrAcc2.C:94
 DrawCorrAcc2.C:95
 DrawCorrAcc2.C:96
 DrawCorrAcc2.C:97
 DrawCorrAcc2.C:98
 DrawCorrAcc2.C:99
 DrawCorrAcc2.C:100
 DrawCorrAcc2.C:101
 DrawCorrAcc2.C:102
 DrawCorrAcc2.C:103
 DrawCorrAcc2.C:104
 DrawCorrAcc2.C:105
 DrawCorrAcc2.C:106
 DrawCorrAcc2.C:107
 DrawCorrAcc2.C:108
 DrawCorrAcc2.C:109
 DrawCorrAcc2.C:110
 DrawCorrAcc2.C:111
 DrawCorrAcc2.C:112
 DrawCorrAcc2.C:113
 DrawCorrAcc2.C:114
 DrawCorrAcc2.C:115
 DrawCorrAcc2.C:116
 DrawCorrAcc2.C:117
 DrawCorrAcc2.C:118
 DrawCorrAcc2.C:119
 DrawCorrAcc2.C:120
 DrawCorrAcc2.C:121
 DrawCorrAcc2.C:122
 DrawCorrAcc2.C:123
 DrawCorrAcc2.C:124
 DrawCorrAcc2.C:125
 DrawCorrAcc2.C:126
 DrawCorrAcc2.C:127
 DrawCorrAcc2.C:128
 DrawCorrAcc2.C:129
 DrawCorrAcc2.C:130
 DrawCorrAcc2.C:131
 DrawCorrAcc2.C:132
 DrawCorrAcc2.C:133
 DrawCorrAcc2.C:134
 DrawCorrAcc2.C:135
 DrawCorrAcc2.C:136
 DrawCorrAcc2.C:137
 DrawCorrAcc2.C:138
 DrawCorrAcc2.C:139