FairRoot/PandaRoot
Functions
histodivider.C File Reference
#include "histodivider.hh"

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 6 of file histodivider.C.

References c1, Double_t, file, filename, h2, next, printf(), and TString.

6  {
7  const char* filename="Geant4/RadMap_Out.root";
8  gStyle->SetOptStat(0);
9 
10  TFile* file = new TFile(filename);
11 
12  TH2D* signal = NULL;
13  TH2D* normal = NULL;
14  std::vector<TH2D*> H;
15 
16 
17 
18  TFile* ofile = new TFile("figures.root", "RECREATE");
19  // file->ls();
20  Double_t norm = 1000;
21 /*
22 
23  TDirectory* dir = NULL;
24  TH2D* htemps = NULL;
25  TH2D* htempb = NULL;
26 
27  dir = (TDirectory*)file->Get("EmcAllFluenceZX_ZY_14.3");
28  htemps = (TH2D*)dir->Get("EmcAllFluenceZX_Histo_ZY_14.3");
29  htempb = (TH2D*)dir->Get("EmcAllFluenceZX_StatHisto_ZY_14.3");
30  cout << "1 - " << dir << ' ' << htemps << ' ' << htempb
31  << endl;
32 
33 
34 
35 
36 
37 
38 
39  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
40  H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
41  "Z [cm]", "Y [cm]",
42  "Full particle fluence (at X=50cm) [1/cm^2]",
43  false, false, true,
44  -1, -1,
45  "figures.pdf"));
46 
47 
48 
49  delete htemps;
50  delete htempb;
51  delete dir;
52 
53  dir = (TDirectory*)file->Get("EmcNFluenceZX_ZY_14.3");
54  htemps = (TH2D*)dir->Get("EmcNFluenceZX_Histo_ZY_14.3");
55  htempb = (TH2D*)dir->Get("EmcNFluenceZX_StatHisto_ZY_14.3");
56 
57  cout << "2 - " << dir << ' ' << htemps << ' ' << htempb
58  << endl;
59 
60  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
61  H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
62  "Z [cm]", "Y [cm]",
63  "Neutron fluence (at X=50cm) [1/cm^2]",
64  false, false, true,
65  -1, -1,
66  "figures.pdf"));
67 
68 
69 
70  delete htemps;
71  delete htempb;
72  delete dir;
73 
74  dir = (TDirectory*)file->Get("EmcPFluenceZX_ZY_14.3");
75  htemps = (TH2D*)dir->Get("EmcPFluenceZX_Histo_ZY_14.3");
76  htempb = (TH2D*)dir->Get("EmcPFluenceZX_StatHisto_ZY_14.3");
77 
78  cout << "3 - " << dir << ' ' << htemps << ' ' << htempb
79  << endl;
80 
81  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
82  H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
83  "Z [cm]", "Y [cm]",
84  "Proton fluence (at X=50cm) [1/cm^2]",
85  false, false, true,
86  -1, -1,
87  "figures.pdf"));
88 
89 
90 
91  delete htemps;
92  delete htempb;
93  delete dir;
94 
95  dir = (TDirectory*)file->Get("EmcAllFluencePawelXY_XY_0");
96  htemps = (TH2D*)dir->Get("EmcAllFluencePawelXY_Histo_XY_0");
97  htempb = (TH2D*)dir->Get("EmcAllFluencePawelXY_StatHisto_XY_0");
98 
99  cout << "4 - " << dir << ' ' << htemps << ' ' << htempb
100  << endl;
101 
102  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
103  // H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
104  H.push_back(plot(htemps ,htempb , c1 , 0, 1.02e7/norm,
105  "Z [cm]", "Y [cm]",
106  "All Particle fluence (at X=50cm) [1/cm^2/event]",
107  false, false, true,
108  -1, -1,
109  "figures.pdf"));
110  Quater(H);
111 
112 
113 
114  delete htemps;
115  delete htempb;
116  delete dir;
117 
118  dir = (TDirectory*)file->Get("EmcCFluencePawelXY_XY_0");
119  htemps = (TH2D*)dir->Get("EmcCFluencePawelXY_Histo_XY_0");
120  htempb = (TH2D*)dir->Get("EmcCFluencePawelXY_StatHisto_XY_0");
121 
122  cout << "5 - " << dir << ' ' << htemps << ' ' << htempb
123  << endl;
124 
125  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
126  // H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
127  H.push_back(plot(htemps ,htempb , c1 , 0, 1.02e7/norm,
128  "Z [cm]", "Y [cm]",
129  "Charged fluence (at X=50cm) [1/cm^2/event]",
130  false, false, true,
131  -1, -1,
132  "figures.pdf"));
133  Quater(H);
134 
135 
136 
137  delete htemps;
138  delete htempb;
139  delete dir;
140 
141  dir = (TDirectory*)file->Get("EmcCnepFluencePawelXY_XY_0");
142  htemps = (TH2D*)dir->Get("EmcCnepFluencePawelXY_Histo_XY_0");
143  htempb = (TH2D*)dir->Get("EmcCnepFluencePawelXY_StatHisto_XY_0");
144 
145  cout << "6 - " << dir << ' ' << htemps << ' ' << htempb
146  << endl;
147 
148  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
149  // H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
150  H.push_back(plot(htemps ,htempb , c1 , 0, 1.02e7/norm,
151  "Z [cm]", "Y [cm]",
152  "Charged fluence (without e^{\pm})(at X=50cm) [1/cm^2/events]",
153  false, false, true,
154  -1, -1,
155  "figures.pdf"));
156  Quater(H);
157 
158 
159 
160  delete htemps;
161  delete htempb;
162  delete dir;
163 
164  dir = (TDirectory*)file->Get("EmcPFluencePawelXY_XY_0");
165  htemps = (TH2D*)dir->Get("EmcPFluencePawelXY_Histo_XY_0");
166  htempb = (TH2D*)dir->Get("EmcPFluencePawelXY_StatHisto_XY_0");
167 
168  cout << "7 - " << dir << ' ' << htemps << ' ' << htempb
169  << endl;
170 
171  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
172  // H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
173  H.push_back(plot(htemps ,htempb , c1 , 0, 1.02e7/norm,
174  "Z [cm]", "Y [cm]",
175  "Proton fluence (at X=50cm) [1/cm^2/events]",
176  false, false, true,
177  -1, -1,
178  "figures.pdf"));
179  Quater(H);
180 
181 
182 
183 
184  delete htemps;
185  delete htempb;
186  delete dir;
187 
188  dir = (TDirectory*)file->Get("EmcNFluencePawelXY_XY_0");
189  htemps = (TH2D*)dir->Get("EmcNFluencePawelXY_Histo_XY_0");
190  htempb = (TH2D*)dir->Get("EmcNFluencePawelXY_StatHisto_XY_0");
191 
192  cout << "8 - " << dir << ' ' << htemps << ' ' << htempb
193  << endl;
194 
195  // H.push_back(plot(htemps ,htempb , c1 , 0, 1.61e14/norm,
196  // H.push_back(plot(htemps ,htempb , c1 , 0, 1./norm,
197  H.push_back(plot(htemps ,htempb , c1 , 0, 1.02e7/norm,
198  "Z [cm]", "Y [cm]",
199  "Neutron fluence (at X=50cm) [1/cm^2/events]",
200  false, false, true,
201  -1, -1,
202  "figures.pdf"));
203  Quater(H);
204 
205 
206 
207 
208 //-------------------
209 //reaction rate ~1e7/s
210 //-------------------
211 
212 ofile->Write();
213 */
214  std::vector<TObjArray*> vto = ReadNames("names.dat");
215  std::cout << "in the file names.dat there eare " << vto.size() << " valid entries\n";
216  std::cout << vto.at(0)->GetSize() << std::endl;
217  // for(int i = 0; i < vto.at(0)->GetSize(); i++)
218  // std::cout << i << ' ' << vto.at(0)->At(i) << std::endl;
219 
220  TIter next(file->GetListOfKeys());
221  TKey *key;
222  std::vector<TDirectory*> Dirs;
223 
224  while ((key = (TKey*)next())) {
225  TClass *cl = gROOT->GetClass(key->GetClassName());
226  // if (cl->InheritsFrom("TH2")){
227  if (cl->InheritsFrom("TDirectory")){
228  Dirs.push_back((TDirectory*)key->ReadObj());
229  }
230  }
231  std::cout << "There are " << Dirs.size() << " directories in the file\n";
232 
233 
234  // std::string E = exec("find Geant4.15GeV/ -type f -name \"*Sim*.root\" | wc -l");
235  // Int_t norm = atoi(E.c_str());
236 
237  printf("%i file are created\n", norm);
238  Int_t u = 0;
239 
240 
241  for(unsigned int di = 0; di < Dirs.size(); di++){
242  TDirectory* dir = Dirs.at(di);
243  TString TS(dir->GetName());
244  unsigned int si = 9999;
245  for(unsigned int ii = 0; ii < vto.size(); ii++){
246  if(vto.at(ii)->At(0)){
247  // cout << di << '\t' << ii << '\t'
248  // << TS.Data() << '\t'
249  // << (dynamic_cast<TObjString*>(vto.at(ii)->At(0)))->String()// << " - " << (TS == ((TObjString)(vto.at(ii)->At(0))).String())
250  // << endl;
251  if(TS == (dynamic_cast<TObjString*>(vto.at(ii)->At(0)))->String()) si = ii;
252  }
253  }
254  std::cout << TS.Data() << ' ' << si << endl;
255  if(si < 9999){
256  TObjArray* TOA = TS.Tokenize("_");
257  TString Sbegin = (dynamic_cast<TObjString*>(TOA->At(0)))->String();
258  TString Send = (dynamic_cast<TObjString*>(TOA->At(1)))->String();
259  Send += "_";
260  Send += (dynamic_cast<TObjString*>(TOA->At(2)))->String();
261  // std::cout << Sbegin.Data() << ' ' << Send.Data() << endl;
262  TString HName = Sbegin + "_Histo_" + Send;
263  TString SHName = Sbegin + "_StatHisto_" + Send;
264  // std::cout << HName.Data() << ' ' << SHName.Data() << endl;
265 
266  signal = (TH2D*)dir->Get(HName.Data());
267  normal = (TH2D*)dir->Get(SHName.Data());
268 
269 
270  if(signal && normal){
271  // cout << atof((dynamic_cast<TObjString*>(vto.at(si)->At(4)))->String()) << ' '
272  // << (dynamic_cast<TObjString*>(vto.at(si)->At(2)))->String() << ' '
273  // << (dynamic_cast<TObjString*>(vto.at(si)->At(3)))->String() << ' '
274  // << (dynamic_cast<TObjString*>(vto.at(si)->At(1)))->String() << ' '
275  // << endl;
276 
277  TH2D* h2 = plot(signal ,normal , c1 , 0,
278  atof((dynamic_cast<TObjString*>(vto.at(si)->At(4)))->String())/norm,
279  (dynamic_cast<TObjString*>(vto.at(si)->At(2)))->String(),
280  (dynamic_cast<TObjString*>(vto.at(si)->At(3)))->String(),
281  (dynamic_cast<TObjString*>(vto.at(si)->At(1)))->String(),
282  false, false, true,
283  -1, -1,
284  "figures.pdf");
285 
286  H.push_back(h2);
287 // H.at(H.size()-1)->Write();
288  delete signal;
289  signal = NULL;
290  delete normal;
291  normal = NULL;
292  }
293  }
294  }
295  ofile->Write();
296  return 0;
297 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TFile * file
Double_t
c1
Definition: plot_dirc.C:35
static int next[96]
Definition: ranlxd.cxx:374
const string filename