CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhysicsTGraphPayload.cc
Go to the documentation of this file.
2 
4 
5 #include <iomanip>
6 
8  : numPoints_(0)
9 {}
10 
12  : numPoints_(0)
13 {
14  if ( graph.GetN() >= 1 ) {
15  name_ = graph.GetName();
16  numPoints_ = graph.GetN();
17  x_.resize(numPoints_);
18  y_.resize(numPoints_);
19  for ( int iPoint = 0; iPoint < numPoints_; ++iPoint ) {
20  Double_t xPoint, yPoint;
21  graph.GetPoint(iPoint, xPoint, yPoint);
22  x_[iPoint] = xPoint;
23  y_[iPoint] = yPoint;
24  }
25  }
26 }
27 
29 {
30  if ( numPoints_ >= 1 ) {
31  TGraph graph(numPoints_);
32  graph.SetName(name_.data());
33  for ( int iPoint = 0; iPoint < numPoints_; ++iPoint ) {
34  graph.SetPoint(iPoint, x_[iPoint], y_[iPoint]);
35  }
36  return graph;
37  } else {
38  throw cms::Exception("PhysicsTGraphPayload")
39  << "Invalid TGraph object !!\n";
40  }
41 }
42 
43 void PhysicsTGraphPayload::print(std::ostream& stream) const
44 {
45  stream << "<PhysicsTGraphPayload::print (name = " << name_ << ")>:" << std::endl;
46  for ( int iPoint = 0; iPoint < numPoints_; ++iPoint ) {
47  stream << "point #" << iPoint << ": x = " << x_[iPoint] << ", y = " << y_[iPoint] << std::endl;
48  }
49 }
std::vector< float > y_
PhysicsTGraphPayload()
default constructor
void print(std::ostream &stream) const
print points of TGraph object
std::vector< float > x_
Definition: adjgraph.h:12