StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
spectra.C
1 #include "commonmacro/common.h"
2 #include "commonmacro/histutil.h"
3 #include "common/Name.cc"
4 
5 void spectra(const char* inName=
6  "links/P01hi.minbias.2000.hist/hianalysis_1000.hist.root",
7  const char* psDir="ps",
8  int cut = 1,
9  const char* outDir="./",
10  const char* more = "west",
11  float extraValue = 0)
12 {
13  cout << "--------------------------" << endl;
14  cout << "in name=" << inName << endl
15  << "ps dir=" << psDir << endl
16  << "cut=" << cut << endl;
17  cout << "--------------------------" << endl;
18 
19 
20 
21  TFile* inRoot;
22  inRoot = new TFile(inName);
23  if(!inRoot){
24  cout << "cannot find the infile" << endl;
25  return;
26  }
27 
28  TH1* h1[2]; TH1* ha[2]; TH1* hRatio;
29  TGraphAsymmErrors* g;
30 
31  TCanvas c1("c1","c1",400,500);
32  float minpt=2,maxpt=6;
33  //---------------------------------------------------
34  // histogram ratios
35  const int nBin=2; const int nBase=1; const int nCharge=3;
36  char* baseName[] = {"gSpecCorrected","gSpecCorrected" };
37  char* baseTitle[] = { "raw","corrected"};
38  char* charge[] = { 0,"Plus","Minus"};
39  int markerStyle[] = {4,8,2};
40  float min=1e-5,max=10.;
41 
42  gStyle->SetOptStat(0);
43  gStyle->SetTitleBorderSize(0);
44  for(int iBin=0; iBin<nBin; iBin++){
45  for(int iCharge=0; iCharge<nCharge; iCharge++){
46 
47  sprintf(title,"bin %d %s (cut %d)",
48  iBin,charge[iCharge],cut);
49  // Divide(&c1,1,1,title,inName);
50 
51  c1.Clear();c1.cd(1); gPad->SetTickx(); gPad->SetTicky();
52  gPad->SetGridx(); gPad->SetGridy();
53  gPad->SetLogy();
54 
55  for(int iBase=0; iBase<nBase; iBase++){
56  setName(name,baseName[iBase],iBin,charge[iCharge]);
57  g=(TGraphAsymmErrors*)inRoot->Get(name);
58  g->SetMinimum(min); g->SetMaximum(max);
59  sTitle=g->GetTitle();
60  g->SetTitle(title);
61  g->Draw("ap");
62  }
63  sprintf(title,"%s",g->GetTitle());
64  Print(&c1,psDir,sTitle.Data());
65 
66  }
67  }
68 }
69