StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
centralityData.C
1 void centralityData(const char* infile, int writeAscii=0, int makeGif=0) {
2 
3  // Display new centrality histograms, but not much else so far
4 
5  /* Files are:
6  KEY: TH1F hNEvent;1 dNevent/dNch - Centrality
7  KEY: TH1F hnt;1 dNevent/dNch - Ntrack
8  KEY: TH1F hvar;1 var bin
9  KEY: TH1F href;1 refMult
10  KEY: TH1F hnumPrim;1 Number of Good Primary Tracks
11  KEY: TH1D hctb;1 CTB Multiplicity
12  KEY: TH1F hnev14;1 centrality ^ 1/4
13  KEY: TH1F hnt14;1 Ntrack ^ 1/4
14  KEY: TH1F href14;1 refMult ^ 1/4
15  KEY: TH1F hnumPrim14;1 Primaries ^ 1/4
16  KEY: TH1D hctb14;1 CTB ^ 1/4
17  KEY: TH1F hmeanpt;1 mean pt
18  KEY: TH1F hmeanpt14;1 mean pt ^ 1/4
19  */
20 
21  tf = new TFile(infile);
22 
23  TH1F* hin[6];
24  TH1F* hin14[6];
25 
26  const char* names[] = {"hNEvent","hnt","href","hnumPrim","hctb","hmeanpt"};
27  const int NUM = 6;
28  TString name;
29  int i;
30 
31  for(i=0; i<NUM; i++) {
32  name = names[i];
33  hin[i] = (TH1F*)tf->Get(name);
34  if(!hin[i]) {
35  cout << " ERROR reading " << name << endl;
36  tf->ls();
37  return;
38  }
39 
40  if (i==0) name = "hnev";
41  name+="14";
42  hin14[i] = (TH1F*)tf->Get(name);
43  }
44 
45 
46  name = infile; name += ": centrality";
47  c1 = new TCanvas(name, name, 750, 500);
48  c1->Divide(3,2);
49  for(i=0; i<NUM; i++) {
50  c1->cd(i+1);
51  if(i!=5) {
52  gPad->SetLogx();
53  gPad->SetLogy();
54  }
55  hin[i]->Draw();
56  }
57  if(makeGif) c1->Print("cent.gif");
58 
59  name = infile; name += ": powerlaw";
60  c2 = new TCanvas(name, name, 750, 500);
61  c2->Divide(3,2);
62  for(i=0; i<NUM; i++) {
63  c2->cd(i+1);
64  hin14[i]->Draw();
65  }
66  if(makeGif) c2->Print("cent-power.gif");
67 
68 
69 
70  if(writeAscii) {
71 
72  const char* fnames[] = {"nch","ntrack","refMult","numPrim","ctb","meanpt"};
73 
74  for(i=0; i<6; i++) {
75  name = fnames[i]; name+=".txt";
76  cout << endl << name << endl;
77  cout << "Binning:\t" << hin[i]->GetNbinsX() << " bins\tmin=" << hin[i]->GetXaxis()->GetXmin() <<"\tmax=" << hin[i]->GetXaxis()->GetXmax() << endl;
78  ofstream out(name);
79  if (i>3) for(int j=1; j<=hin[i]->GetNbinsX(); j++) out << hin[i]->GetBinCenter(j) << "\t" << hin[i]->GetBinContent(j) << endl;
80  else for(int j=1; j<=hin[i]->GetNbinsX(); j++) out << (int)hin[i]->GetBinCenter(j) << "\t" << hin[i]->GetBinContent(j) << endl;
81  out.close();
82  out.clear();
83  }
84  for(i=0; i<6; i++) {
85  name = fnames[i]; name+="14.txt";
86  cout << endl << name << endl;
87  cout << "Binning:\t" << hin14[i]->GetNbinsX() << " bins\tmin=" << hin14[i]->GetXaxis()->GetXmin() <<"\tmax=" << hin14[i]->GetXaxis()->GetXmax() << endl;
88  ofstream out(name);
89  for(int j=1; j<=hin14[i]->GetNbinsX(); j++) out << hin14[i]->GetBinCenter(j) << "\t" << hin14[i]->GetBinContent(j) << endl;
90  out.close();
91  out.clear();
92  }
93 
94 
95 
96 
97 
98  }
99 
100 
101 }
102 
103 
104 
105 
106 
107 
108 
109 
110