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 }
LHCOpticalFunctionsSet::eypd
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::evx
Definition: LHCOpticalFunctionsSet.h:16
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
LHCOpticalFunctionsSet::e14
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::m_fcn_values
std::vector< std::vector< double > > m_fcn_values
length unit cm
Definition: LHCOpticalFunctionsSet.h:36
LHCOpticalFunctionsSet::nFunctions
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::expd
Definition: LHCOpticalFunctionsSet.h:16
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
LHCOpticalFunctionsSet::exd
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::eLpx
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::eyd
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet.h
LHCOpticalFunctionsSet::evpx
Definition: LHCOpticalFunctionsSet.h:16
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
LHCOpticalFunctionsSet::eLpy
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::e32
Definition: LHCOpticalFunctionsSet.h:16
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
protons_cff.xi
xi
Definition: protons_cff.py:31
LHCOpticalFunctionsSet::eLy
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::evpy
Definition: LHCOpticalFunctionsSet.h:16
LHCOpticalFunctionsSet::evy
Definition: LHCOpticalFunctionsSet.h:16
Exception
Definition: hltDiff.cc:245
LHCOpticalFunctionsSet::e24
Definition: LHCOpticalFunctionsSet.h:16
Exception.h
LHCOpticalFunctionsSet::e42
Definition: LHCOpticalFunctionsSet.h:16
pi
const Double_t pi
Definition: trackSplitPlot.h:36
LHCOpticalFunctionsSet::LHCOpticalFunctionsSet
LHCOpticalFunctionsSet()=default
cuy.graphs
graphs
Definition: cuy.py:961
LHCOpticalFunctionsSet::m_xi_values
std::vector< double > m_xi_values
Definition: LHCOpticalFunctionsSet.h:35
LHCOpticalFunctionsSet::eLx
Definition: LHCOpticalFunctionsSet.h:16