gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
Perf_Plot.hpp
Go to the documentation of this file.
1 
7 #include <iostream>
8 #include <fstream>
9 #include <vector>
10 #include <string>
11 #include <hdf5.h>
12 
13 using namespace std;
14 
15 namespace Gambit {
16  namespace ColliderBit {
17 
18 
19  class Perf_Plot {
20  private:
21 
22  string _outfilename;
23  size_t _numvariables;
24  vector<const char*> _variables;
25  vector<vector<double>> _values;
27 
28  public:
29 
31 
32  }
33 
34 
35  Perf_Plot(string outFileName, vector<const char*>* varNames) {
36 
37  string path = "ColliderBit/results/";
38  path.append(outFileName);
39  path.append(".hdf5");
40  _outfilename = path;
41 
42  _variables = *varNames;
43  _numvariables = _variables.size();
44  }
45 
46  void fill(vector<double>* varValues) {
47  _values.push_back(*varValues);
48  }
49 
50  void createFile(double luminosity=0., double xsec_per_event=0.) {
51 
52  H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
53 
54  size_t nvalues = _values.size();
55 
56  if (nvalues > 0) {
57  file = H5Fcreate(_outfilename.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
58 
59  for (size_t iVal=0;iVal<_numvariables;iVal++) {
60 
61  hid_t dataset, dataspace;
62  hsize_t dims[2];
63  // herr_t status;
64 
65  dims[0] = 1;
66  dims[1] = nvalues;
67  dataspace = H5Screate_simple(2, dims, NULL);
68 
69  dataset = H5Dcreate2(file, _variables.at(iVal), H5T_NATIVE_DOUBLE, dataspace, H5S_ALL, H5S_ALL, H5P_DEFAULT);
70 
71  double data[nvalues];
72  for (size_t iVal2=0;iVal2<nvalues;iVal2++) {
73  data[iVal2]=_values.at(iVal2).at(iVal);
74  }
75 
76  // status = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
77  H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
78 
79  H5Sclose(dataspace);
80  H5Dclose(dataset);
81 
82  }
83 
84  hid_t dataset_lum, dataspace_lum, dataset_xsec, dataspace_xsec;
85  hsize_t dims_lum[2], dims_xsec[2];
86  // herr_t status_lum, status_xsec;
87 
88  dims_lum[0] = 1;
89  dims_lum[1] = 1;
90  dataspace_lum = H5Screate_simple(2, dims_lum, NULL);
91 
92  dataset_lum = H5Dcreate2(file, "luminosity", H5T_NATIVE_DOUBLE, dataspace_lum, H5S_ALL, H5S_ALL, H5P_DEFAULT);
93 
94  double data_lum[1];
95  data_lum[0]=luminosity;
96 
97  // status_lum = H5Dwrite(dataset_lum, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_lum);
98  H5Dwrite(dataset_lum, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_lum);
99 
100  H5Sclose(dataspace_lum);
101  H5Dclose(dataset_lum);
102 
103  dims_xsec[0] = 1;
104  dims_xsec[1] = 1;
105  dataspace_xsec = H5Screate_simple(2, dims_xsec, NULL);
106 
107  dataset_xsec = H5Dcreate2(file, "xsec_per_event", H5T_NATIVE_DOUBLE, dataspace_xsec, H5S_ALL, H5S_ALL, H5P_DEFAULT);
108 
109  double data_xsec[1];
110  data_xsec[0]=xsec_per_event;
111 
112  // status_xsec = H5Dwrite(dataset_xsec, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_xsec);
113  H5Dwrite(dataset_xsec, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_xsec);
114 
115  H5Sclose(dataspace_xsec);
116  H5Dclose(dataset_xsec);
117 
118 
119  H5Fclose(file);
120 
121  }
122 
123  }
124 
125  };
126  }
127 }
greatScanData data
Definition: great.cpp:38
vector< const char * > _variables
Definition: Perf_Plot.hpp:24
STL namespace.
Perf_Plot(string outFileName, vector< const char *> *varNames)
Definition: Perf_Plot.hpp:35
void fill(vector< double > *varValues)
Definition: Perf_Plot.hpp:46
vector< vector< double > > _values
Definition: Perf_Plot.hpp:25
TODO: see if we can use this one:
Definition: Analysis.hpp:33
void createFile(double luminosity=0., double xsec_per_event=0.)
Definition: Perf_Plot.hpp:50