CMS 3D CMS Logo

LHCOpticalFunctionsSet.cc
Go to the documentation of this file.
1 // Original Author: Jan Kašpar
2 
4 
6 
7 #include "TFile.h"
8 #include "TGraph.h"
9 
10 //----------------------------------------------------------------------------------------------------
11 
13  : m_z(z) {
14  TFile *f_in = TFile::Open(fileName.c_str());
15  if (f_in == nullptr)
16  throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << ".";
17 
18  std::vector<TGraph *> graphs(nFunctions);
19  for (unsigned int fi = 0; fi < nFunctions; ++fi) {
21  if (fi == evx)
22  tag = "v_x";
23  else if (fi == eLx)
24  tag = "L_x";
25  else if (fi == e14)
26  tag = "E_14";
27  else if (fi == exd)
28  tag = "x_D";
29  else if (fi == evpx)
30  tag = "vp_x";
31  else if (fi == eLpx)
32  tag = "Lp_x";
33  else if (fi == e24)
34  tag = "E_24";
35  else if (fi == expd)
36  tag = "xp_D";
37  else if (fi == e32)
38  tag = "E_32";
39  else if (fi == evy)
40  tag = "v_y";
41  else if (fi == eLy)
42  tag = "L_y";
43  else if (fi == eyd)
44  tag = "y_D";
45  else if (fi == e42)
46  tag = "E_42";
47  else if (fi == evpy)
48  tag = "vp_y";
49  else if (fi == eLpy)
50  tag = "Lp_y";
51  else if (fi == eypd)
52  tag = "yp_D";
53  else
54  throw cms::Exception("LHCOpticalFunctionsSet") << "Invalid tag for optical functions: \"" << fi << "\"";
55 
56  std::string objPath = directoryName + "/g_" + tag + "_vs_xi";
57  auto gr_obj = dynamic_cast<TGraph *>(f_in->Get(objPath.c_str()));
58  if (!gr_obj)
59  throw cms::Exception("LHCOpticalFunctionsSet")
60  << "Cannot load object " << objPath << " from file " << fileName << ".";
61 
62  graphs[fi] = gr_obj;
63  }
64 
65  const unsigned int num_xi_vals = graphs[0]->GetN();
66  m_xi_values.resize(num_xi_vals);
67 
68  m_fcn_values.resize(nFunctions);
69 
70  for (unsigned int fi = 0; fi < nFunctions; ++fi)
71  m_fcn_values[fi].resize(num_xi_vals);
72 
73  for (unsigned int pi = 0; pi < num_xi_vals; ++pi) {
74  const double xi = graphs[0]->GetX()[pi];
75  m_xi_values[pi] = xi;
76 
77  for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi)
78  m_fcn_values[fi][pi] = graphs[fi]->Eval(xi);
79  }
80 
81  delete f_in;
82 }
float float float z
const Double_t pi
LHCOpticalFunctionsSet()=default
std::vector< double > m_xi_values
std::vector< std::vector< double > > m_fcn_values
length unit cm
graphs
Definition: cuy.py:961