StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
merge_chi2.C
1 
2 //____________________________________________________________________________________________________
3 void merge_chi2_npp_k(const Char_t* inputFileList = "file_chi2.list")
4 {
5  ifstream fin(inputFileList);
6  if(!fin){
7  Error("merge_chi2", "can't open %s", inputFileList);
8  return;
9  }
10 
11  // 200 GeV
12  // const Int_t nppbin = 20 ;
13  // const Double_t nppmin = 2.18 ;
14  // const Double_t nppmax = 2.38 ;
15  // const Int_t kbin = 100 ;
16  // const Double_t kmin = 0.30 ;
17  // const Double_t kmax = 1.30 ;
18  // const Int_t nppbin = 40 ;
19  // const Double_t nppmin = 2.00 ;
20  // const Double_t nppmax = 2.40 ;
21  // const Int_t kbin = 30 ;
22  // const Double_t kmin = 0.50 ;
23  // const Double_t kmax = 3.50 ;
24 
25  // 39 GeV
26  // const Int_t nppbin = 10 ;
27  // const Int_t nppbin = 50 ;
28  // const Double_t nppmin = 1.1 ;
29  // const Double_t nppmax = 1.6 ;
30  // const Double_t nppmin = 1.3 ;
31  // const Double_t nppmax = 1.8 ;
32  // const Double_t nppmin = 1.45 ;
33  // const Double_t nppmax = 1.55 ;
34 
35  // 39 GeV
36  // const Int_t kbin = 31 ;
37  // const Double_t kmin = 0.50 ;
38  // const Double_t kmax = 3.50 ;
39  // const Int_t kbin = 40 ;
40  // const Int_t kbin = 20 ;
41  // const Double_t kmin = 1.00 ;
42  // const Double_t kmax = 3.00 ;
43 
44  // 11.5 GeV
45  // const Int_t nppbin = 20 ;
46  // const Double_t nppmin = 1.0 ;
47  // const Double_t nppmax = 1.2 ;
48  // const Int_t kbin = 10 ;
49  // const Double_t kmin = 1.00 ;
50  // const Double_t kmax = 2.00 ;
51  // const Int_t kbin = 50 ;
52  // const Double_t kmin = 0.50 ;
53  // const Double_t kmax = 3.00 ;
54 
55  // 7.7 GeV
56  const Int_t nppbin = 30 ;
57  const Double_t nppmin = 0.7 ;
58  const Double_t nppmax = 1.0 ;
59  const Int_t kbin = 30 ;
60  const Double_t kmin = 0.50 ;
61  const Double_t kmax = 3.50 ;
62 
63  TH2* hChi2 = new TH2D("hchi2Merge", "", nppbin, nppmin, nppmax, kbin, kmin, kmax);
64  hChi2->SetXTitle("n_{pp}");
65  hChi2->SetYTitle("k");
66 
67  Int_t ifile = 0 ;
68  Double_t nevents = 0 ;
69  TString name("");
70  while( fin >> name ){
71  TFile* file = TFile::Open(name);
72  if(!file || !file->IsOpen()){
73  Error("merge_chi2", "can't open %s", name.Data());
74  return;
75  }
76  cout << "OPEN " << file->GetName() << endl;
77 
78  TH3* hchi2 = (TH3D*) file->Get("hChi2");
79  nevents += hchi2->GetEntries() ;
80  for(Int_t x=0; x<hchi2->GetNbinsX(); x++){
81  const Int_t y = ifile ;
82  hChi2->SetBinContent(x+1, y+1, hchi2->GetBinContent(x+1, 1, 1));
83  }
84 
85  ifile++;
86  }
87 
88  hChi2->SetEntries(nevents);
89 
90  TFile* output = TFile::Open("chi2_merge.root", "recreate");
91  hChi2->Write();
92  output->Close();
93 }
94 
95 
96 //____________________________________________________________________________________________________
97 void merge_chi2_npp_x(const Char_t* inputFileList = "file_chi2.list")
98 {
99  ifstream fin(inputFileList);
100  if(!fin){
101  Error("merge_chi2", "can't open %s", inputFileList);
102  return;
103  }
104 
105  const Int_t nppbin = 50 ;
106  // const Double_t nppmin = 1.1 ;
107  // const Double_t nppmax = 1.6 ;
108  const Double_t nppmin = 1.3 ;
109  const Double_t nppmax = 1.8 ;
110  // const Int_t xbin = 11 ;
111  // const Double_t xmin = 0.08 ;
112  // const Double_t xmax = 0.19 ;
113  const Int_t xbin = 70 ;
114  const Double_t xmin = 0.08 ;
115  const Double_t xmax = 0.15 ;
116 
117  TH2* hChi2 = new TH2D("hchi2Merge", "", nppbin, nppmin, nppmax, xbin, xmin, xmax);
118  hChi2->SetXTitle("n_{pp}");
119  hChi2->SetYTitle("x");
120 
121  Int_t ifile = 0 ;
122  Double_t nevents = 0 ;
123  TString name("");
124  while( fin >> name ){
125  TFile* file = TFile::Open(name);
126  if(!file || !file->IsOpen()){
127  Error("merge_chi2", "can't open %s", name.Data());
128  return;
129  }
130  cout << "OPEN " << file->GetName() << " nfile=[" << ifile << "]" << endl;
131 
132  TH3* hchi2 = (TH3D*) file->Get("hChi2");
133  nevents += hchi2->GetEntries() ;
134  for(Int_t x=0; x<hchi2->GetNbinsX(); x++){
135  const Int_t z = ifile ;
136  hChi2->SetBinContent(x+1, z+1, hchi2->GetBinContent(x+1, 1, 1));
137  }
138 
139  ifile++;
140  }
141  hChi2->SetEntries(nevents);
142 
143  TFile* output = TFile::Open("chi2_merge_x_vs_npp.root", "recreate");
144  hChi2->Write();
145  output->Close();
146 }
147 
148 //____________________________________________________________________________________________________
149 void merge_chi2_eff(const Char_t* inputFileList = "file_chi2.list")
150 {
151  ifstream fin(inputFileList);
152  if(!fin){
153  Error("merge_chi2", "can't open %s", inputFileList);
154  return;
155  }
156 
157  // 39 GeV
158  // const Int_t kbin = 30 ;
159  // const Double_t kmin = 0.50 ;
160  // const Double_t kmax = 3.50 ;
161  const Int_t nppbin = 50 ;
162  const Double_t nppmin = 0.70 ;
163  const Double_t nppmax = 1.20 ;
164 
165  // 11.5 GeV
166  const Int_t nppbin = 20 ;
167  const Double_t nppmin = 1.00 ;
168  const Double_t nppmax = 1.20 ;
169 
170  // For constant efficiency, 7.7 GeV
171  // const Int_t effbin = 40 ;
172  // const Double_t effmin = 0.60 ;
173  // const Double_t effmax = 1.00 ;
174 
175  // For mult-dep efficiency, 7.7 GeV
176  // const Int_t effbin = 60 ;
177  // const Double_t effmin = 0.00 ;
178  // const Double_t effmax = 0.60 ;
179  // const Double_t effmin = 0.10 ;
180  // const Double_t effmax = 0.31 ;
181 
182  // 11.5 GeV (mult-dep)
183  const Int_t effbin = 30 ;
184  const Double_t effmin = 0.05 ;
185  const Double_t effmax = 0.35 ;
186 
187  // TH2* hChi2 = new TH2D("hchi2Merge", "", kbin, kmin, kmax, effbin, effmin, effmax);
188  // hChi2->SetXTitle("k");
189  TH2* hChi2 = new TH2D("hchi2Merge", "", nppbin, nppmin, nppmax, effbin, effmin, effmax);
190  hChi2->SetXTitle("n_{pp}");
191  hChi2->SetYTitle("#varepsilon");
192 
193  Int_t ifile = 0 ;
194  Double_t nevents = 0 ;
195  TString name("");
196  while( fin >> name ){
197  TFile* file = TFile::Open(name);
198  if(!file || !file->IsOpen()){
199  Error("merge_chi2", "can't open %s", name.Data());
200  return;
201  }
202  cout << "OPEN " << file->GetName() << endl;
203 
204  TH3* hchi2 = (TH3D*) file->Get("hChi2");
205  // TH1* hchi2k = (TH1D*) hchi2->Project3D("y");
206  TH1* hchi2npp = (TH1D*) hchi2->Project3D("x");
207  nevents += hchi2->GetEntries() ;
208  // for(Int_t x=0; x<hchi2k->GetNbinsX(); x++){
209  for(Int_t x=0; x<hchi2npp->GetNbinsX(); x++){
210  const Int_t z = ifile ;
211  // hChi2->SetBinContent(x+1, z+1, hchi2k->GetBinContent(x+1));
212  hChi2->SetBinContent(x+1, z+1, hchi2npp->GetBinContent(x+1));
213  }
214 
215  ifile++;
216  file->Close();
217  }
218  hChi2->SetEntries(nevents);
219 
220  TFile* output = TFile::Open("chi2_merge.root", "recreate");
221  hChi2->Write();
222  output->Close();
223  }
224 
225 
Definition: FJcore.h:367