ROOT logo
/**
 * @file   Draw123.C
 * @author Christian Holm Christensen <cholm@nbi.dk>
 * @date   Thu Nov 17 11:07:15 2011
 * 
 * @brief  This scripts draws the energy loss distribution for single,
 * double, and triple hits in the FMD as resolved by the sharing
 * filter 
 * 
 * @ingroup pwglf_forward_scripts_qa
 */
#ifndef __CINT__
# include <TH1.h>
# include <TH2.h>
# include <TList.h>
# include <TFile.h>
# include <TString.h>
# include <TError.h>
# include <TPad.h>
# include <TCanvas.h>
# include <TLine.h>
# include <TLatex.h>
# include <TStyle.h>
# include <TLegend.h>
#else
class TList;
#endif

/** 
 * Draw the energy loss spectra of single, double, and triple hits in
 * a particular ring 
 * 
 * @param p Parent list 
 * @param d Detector 
 * @param r Ring 
 *
 * @deprecated Use the QATrender instead
 * @ingroup pwglf_forward_scripts_qa
 */
void
DrawRing123(TList* p, UShort_t d, Char_t r)
{
  if (!p) return;

  TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
  if (!ring) { 
    Error("Draw123", "List FMD%d%c not found in %s",d,r,p->GetName());
    return;
  }
  
  TH1* one   = static_cast<TH1*>(ring->FindObject("singleEloss"));
  TH1* two   = static_cast<TH1*>(ring->FindObject("doubleEloss"));
  TH1* three = static_cast<TH1*>(ring->FindObject("tripleEloss"));
  if (!one || !two || !three) { 
    Error("DrawRing123", "Histograms of Eloss not found in FMD%d%c", d, r);
    return;
  }
  one->SetStats(0);
  one->SetTitle(Form("FMD%d%c", d, r));
  one->GetXaxis()->SetRangeUser(0, 8);

  gPad->SetLogy();
  gPad->SetFillColor(0);

  one->Draw();
  if (two)   two->Draw("same");
  if (three) three->Draw("same");

  TLegend* l = new TLegend(.6, .6, .95, 1);
  l->SetFillColor(0);
  l->SetBorderSize(0);
  l->AddEntry(one);
  if (two)   l->AddEntry(two);
  if (three) l->AddEntry(three);
  l->Draw();

  gPad->cd();
}


/** 
 * Draw the energy loss distribution of singles, doubles, and triples
 * as given by the sharing filter 
 * 
 * @param filename Input file name
 * @param folder   Input folder (TList) in input file
 *
 * @deprecated Use the QATrender instead
 * @ingroup pwglf_forward_scripts_qa
 */
void
Draw123(const char* filename="forward.root", 
	const char* folder="ForwardResults")
{
  gStyle->SetPalette(1);
  gStyle->SetOptFit(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(1);
  gStyle->SetTitleW(.4);
  gStyle->SetTitleH(.1);
  gStyle->SetTitleColor(0);
  gStyle->SetTitleStyle(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleX(.6);
  
  TFile* file = TFile::Open(filename, "READ");
  if (!file) { 
    Error("Draw123", "failed to open %s", filename);
    return;
  }

  TList* forward = static_cast<TList*>(file->Get(folder));
  if (!forward) { 
    Error("Draw123", "List %s not found in %s", folder, filename);
    return;
  }

  TList* sf = static_cast<TList*>(forward->FindObject("fmdSharingFilter"));
  if (!sf) { 
    Error("Draw123", "List fmdSharingFilter not found in Forward");
    return;
  }
  
  TCanvas* c = new TCanvas("123", 
			   "singles, doubles, and tripples", 900, 700);
  c->SetFillColor(0);
  c->SetBorderSize(0);
  c->SetLeftMargin(0.15);
  c->SetRightMargin(0.02);
  c->SetTopMargin(0.02);
  c->Divide(3, 2, 0, 0);
  
  c->cd(1); DrawRing123(sf, 1, 'I');
  c->cd(2); DrawRing123(sf, 2, 'I');
  c->cd(5); DrawRing123(sf, 2, 'O');
  c->cd(3); DrawRing123(sf, 3, 'I');
  c->cd(6); DrawRing123(sf, 3, 'O');
  TVirtualPad* p = c->cd(4);
  // p->SetTopMargin(0.05);
  p->SetRightMargin(0.15);
  p->SetFillColor(0);
  TH2D* highCuts = static_cast<TH2D*>(sf->FindObject("highCuts"));
  if (highCuts) highCuts->Draw("colz");
  c->cd();
  c->SaveAs("123.png");
}
 
//
// EOF
//
 Draw123.C:1
 Draw123.C:2
 Draw123.C:3
 Draw123.C:4
 Draw123.C:5
 Draw123.C:6
 Draw123.C:7
 Draw123.C:8
 Draw123.C:9
 Draw123.C:10
 Draw123.C:11
 Draw123.C:12
 Draw123.C:13
 Draw123.C:14
 Draw123.C:15
 Draw123.C:16
 Draw123.C:17
 Draw123.C:18
 Draw123.C:19
 Draw123.C:20
 Draw123.C:21
 Draw123.C:22
 Draw123.C:23
 Draw123.C:24
 Draw123.C:25
 Draw123.C:26
 Draw123.C:27
 Draw123.C:28
 Draw123.C:29
 Draw123.C:30
 Draw123.C:31
 Draw123.C:32
 Draw123.C:33
 Draw123.C:34
 Draw123.C:35
 Draw123.C:36
 Draw123.C:37
 Draw123.C:38
 Draw123.C:39
 Draw123.C:40
 Draw123.C:41
 Draw123.C:42
 Draw123.C:43
 Draw123.C:44
 Draw123.C:45
 Draw123.C:46
 Draw123.C:47
 Draw123.C:48
 Draw123.C:49
 Draw123.C:50
 Draw123.C:51
 Draw123.C:52
 Draw123.C:53
 Draw123.C:54
 Draw123.C:55
 Draw123.C:56
 Draw123.C:57
 Draw123.C:58
 Draw123.C:59
 Draw123.C:60
 Draw123.C:61
 Draw123.C:62
 Draw123.C:63
 Draw123.C:64
 Draw123.C:65
 Draw123.C:66
 Draw123.C:67
 Draw123.C:68
 Draw123.C:69
 Draw123.C:70
 Draw123.C:71
 Draw123.C:72
 Draw123.C:73
 Draw123.C:74
 Draw123.C:75
 Draw123.C:76
 Draw123.C:77
 Draw123.C:78
 Draw123.C:79
 Draw123.C:80
 Draw123.C:81
 Draw123.C:82
 Draw123.C:83
 Draw123.C:84
 Draw123.C:85
 Draw123.C:86
 Draw123.C:87
 Draw123.C:88
 Draw123.C:89
 Draw123.C:90
 Draw123.C:91
 Draw123.C:92
 Draw123.C:93
 Draw123.C:94
 Draw123.C:95
 Draw123.C:96
 Draw123.C:97
 Draw123.C:98
 Draw123.C:99
 Draw123.C:100
 Draw123.C:101
 Draw123.C:102
 Draw123.C:103
 Draw123.C:104
 Draw123.C:105
 Draw123.C:106
 Draw123.C:107
 Draw123.C:108
 Draw123.C:109
 Draw123.C:110
 Draw123.C:111
 Draw123.C:112
 Draw123.C:113
 Draw123.C:114
 Draw123.C:115
 Draw123.C:116
 Draw123.C:117
 Draw123.C:118
 Draw123.C:119
 Draw123.C:120
 Draw123.C:121
 Draw123.C:122
 Draw123.C:123
 Draw123.C:124
 Draw123.C:125
 Draw123.C:126
 Draw123.C:127
 Draw123.C:128
 Draw123.C:129
 Draw123.C:130
 Draw123.C:131
 Draw123.C:132
 Draw123.C:133
 Draw123.C:134
 Draw123.C:135
 Draw123.C:136
 Draw123.C:137
 Draw123.C:138
 Draw123.C:139
 Draw123.C:140
 Draw123.C:141
 Draw123.C:142
 Draw123.C:143
 Draw123.C:144
 Draw123.C:145
 Draw123.C:146
 Draw123.C:147
 Draw123.C:148
 Draw123.C:149
 Draw123.C:150
 Draw123.C:151