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 {
15  TFile *f_in = TFile::Open(fileName.c_str());
16  if (f_in == nullptr)
17  throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << ".";
18 
19  std::vector<TGraph*> graphs(nFunctions);
20  for (unsigned int fi = 0; fi < nFunctions; ++fi)
21  {
23  if (fi == evx) tag = "v_x";
24  else if (fi == eLx) tag = "L_x";
25  else if (fi == e14) tag = "E_14";
26  else if (fi == exd) tag = "x_D";
27  else if (fi == evpx) tag = "vp_x";
28  else if (fi == eLpx) tag = "Lp_x";
29  else if (fi == e24) tag = "E_24";
30  else if (fi == expd) tag = "xp_D";
31  else if (fi == e32) tag = "E_32";
32  else if (fi == evy) tag = "v_y";
33  else if (fi == eLy) tag = "L_y";
34  else if (fi == eyd) tag = "y_D";
35  else if (fi == e42) tag = "E_42";
36  else if (fi == evpy) tag = "vp_y";
37  else if (fi == eLpy) tag = "Lp_y";
38  else if (fi == eypd) tag = "yp_D";
39  else
40  throw cms::Exception("LHCOpticalFunctionsSet") << "Invalid tag for optical functions: \"" << fi << "\"";
41 
42  std::string objPath = directoryName + "/g_" + tag + "_vs_xi";
43  auto gr_obj = dynamic_cast<TGraph*>( f_in->Get(objPath.c_str()) );
44  if (!gr_obj)
45  throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << objPath << " from file " << fileName << ".";
46 
47  graphs[fi] = gr_obj;
48  }
49 
50  const unsigned int num_xi_vals = graphs[0]->GetN();
51  m_xi_values.resize(num_xi_vals);
52 
53  m_fcn_values.resize(nFunctions);
54 
55  for (unsigned int fi = 0; fi < nFunctions; ++fi)
56  m_fcn_values[fi].resize(num_xi_vals);
57 
58  for (unsigned int pi = 0; pi < num_xi_vals; ++pi)
59  {
60  const double xi = graphs[0]->GetX()[pi];
61  m_xi_values[pi] = xi;
62 
63  for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi)
64  m_fcn_values[fi][pi] = graphs[fi]->Eval(xi);
65  }
66 
67  delete f_in;
68 }
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:962