convert_geant_tables_to_BPF.C
Go to the documentation of this file.
1 //
2 // This macro will read in the text files generated by the g4nova/PrintTables.cxx code and print
3 // them to the screen so that they can more easily be cut and pasted into the BPF dEdxTables.cxx
4 // code.
5 //
6 
8 
9  std::ifstream in;
10  in.open(filename.c_str());
11 
12  std::string junk;
13 
14  double val;
15  std::vector<double> T;
16  std::vector<double> dedx;
17 
18  // throw away the first 2 lines (12 entries) in the file
19  for(unsigned int i = 0; i < 12; ++i) in >> junk;
20 
21  // read in the tables
22  int filesize = 90;
23  int count = 0;
24  while(count < filesize) {
25 
26  if(!in.good()) break;
27 
28  in >> val;
29  T.push_back(val);
30 
31  in >> val;
32  dedx.push_back(val);
33 
34  count++;
35 
36  }
37 
38  std::cout << "\n\n\n========== Tables for material: " << material << " ==========\n\n";
39 
40  std::cout << "static const double T[] = {";
41  for(unsigned int i = 0; i < (T.size()-1); ++i) {
42  if(i%10 == 0) std::cout << "\n ";
43  std::cout << T[i] << ", ";
44  }
45  std::cout << T[T.size()-1];
46  std::cout << "\n};\n";
47 
48  std::cout << "static const double dEdx[] = {";
49  for(unsigned int i = 0; i < (dedx.size()-1); ++i) {
50  if(i%10 == 0) std::cout << "\n ";
51  std::cout << dedx[i] << ", ";
52  }
53  std::cout << dedx[dedx.size()-1];
54  std::cout << "\n};\n";
55 
56  return;
57 
58 }
59 
61 
62  std::cout << "\n\n\nMAKE SURE TO CHECK THAT THE NUMBER OF ENTRIES IN THE TEXT FILE IS 90!\n"
63  << "Otherwise the expected number of entries will need to be updated in the PrintTable function...";
64 
65  PrintTable("g4nova-muon-dedx-PVC.txt","PVC");
66  PrintTable("g4nova-muon-dedx-Steel.txt","Steel");
67  PrintTable("g4nova-muon-dedx-Scintillator.txt","Scintillator");
68  PrintTable("g4nova-muon-dedx-Glue.txt","Glue");
69 
70  std::cout << "\n\n\n";
71 
72 }
string filename
Definition: shutoffs.py:106
string material
Definition: eplot.py:19
OStream cout
Definition: OStream.cxx:6
void PrintTable(std::string filename, std::string material)
ifstream in
Definition: comparison.C:7
void convert_geant_tables_to_BPF()
double T
Definition: Xdiff_gwt.C:5
enum BeamMode string