JHUGen MELA  v2.4.1
Matrix element calculations as used in JHUGen. MELA is an important tool that was used for the Higgs boson discovery and for precise measurements of its structure and interactions. Please see the website https://spin.pha.jhu.edu/ and papers cited there for more details, and kindly cite those papers when using this code.
Public Member Functions | Protected Attributes | List of all members
MELAOutputStreamer Class Reference

#include <MELAOutputStreamer.h>

Public Member Functions

 MELAOutputStreamer (const char *fname, std::ios_base::openmode fmode=std::ios_base::out, bool printError=false)
 
 ~MELAOutputStreamer ()
 
template<typename T >
MELAOutputStreameroperator<< (T const &val)
 
template<typename T , typename U >
MELAOutputStreameroperator<< (std::pair< T, U > const &val)
 
template<typename T >
MELAOutputStreameroperator<< (std::vector< T > const &val)
 
MELAOutputStreameroperator<< (std::ostream &(*fcn)(std::ostream &))
 
MELAOutputStreameroperator<< (std::ios &(*fcn)(std::ios &))
 
MELAOutputStreameroperator<< (std::ios_base &(*fcn)(std::ios_base &))
 
std::streamsize width () const
 
std::streamsize width (std::streamsize wide)
 
char fill () const
 
char fill (char fillch)
 
void open (const char *fname, std::ios_base::openmode fmode=std::ios_base::out)
 
void close ()
 
template<typename T >
void writeCentered (const T &val, char fillch=' ', std::streamsize gapsize=0)
 

Protected Attributes

std::ofstream theFile
 
std::ostream * stdout_ptr
 

Detailed Description

Definition at line 21 of file MELAOutputStreamer.h.

Constructor & Destructor Documentation

◆ MELAOutputStreamer()

MELAOutputStreamer::MELAOutputStreamer ( const char *  fname,
std::ios_base::openmode  fmode = std::ios_base::out,
bool  printError = false 
)

Definition at line 7 of file MELAOutputStreamer.cc.

7  :
8 theFile(fname, fmode)
9 {
10  if (!printError) stdout_ptr = &std::cout;
11  else stdout_ptr = &std::cerr;
12 }

◆ ~MELAOutputStreamer()

MELAOutputStreamer::~MELAOutputStreamer ( )

Definition at line 13 of file MELAOutputStreamer.cc.

13 { this->close(); }

Member Function Documentation

◆ close()

void MELAOutputStreamer::close ( )

Definition at line 145 of file MELAOutputStreamer.cc.

145  {
146  theFile.close();
147 }

◆ fill() [1/2]

char MELAOutputStreamer::fill ( ) const

Definition at line 139 of file MELAOutputStreamer.cc.

139 { return theFile.fill(); }

◆ fill() [2/2]

char MELAOutputStreamer::fill ( char  fillch)

Definition at line 140 of file MELAOutputStreamer.cc.

140  {
141  if (stdout_ptr) stdout_ptr->fill(fillch);
142  return theFile.fill(fillch);
143 }

◆ open()

void MELAOutputStreamer::open ( const char *  fname,
std::ios_base::openmode  fmode = std::ios_base::out 
)

Definition at line 148 of file MELAOutputStreamer.cc.

148  {
149  this->close();
150  theFile.open(fname, fmode);
151 }

◆ operator<<() [1/6]

MELAOutputStreamer & MELAOutputStreamer::operator<< ( std::ios &(*)(std::ios &)  fcn)

Definition at line 20 of file MELAOutputStreamer.cc.

20  {
21  fcn(theFile);
22  if (stdout_ptr) fcn(*stdout_ptr);
23  return *this;
24 }

◆ operator<<() [2/6]

MELAOutputStreamer & MELAOutputStreamer::operator<< ( std::ios_base &(*)(std::ios_base &)  fcn)

Definition at line 25 of file MELAOutputStreamer.cc.

25  {
26  fcn(theFile);
27  if (stdout_ptr) fcn(*stdout_ptr);
28  return *this;
29 }

◆ operator<<() [3/6]

MELAOutputStreamer & MELAOutputStreamer::operator<< ( std::ostream &(*)(std::ostream &)  fcn)

Definition at line 15 of file MELAOutputStreamer.cc.

15  {
16  fcn(theFile);
17  if (stdout_ptr) fcn(*stdout_ptr);
18  return *this;
19 }

◆ operator<<() [4/6]

template<typename T , typename U >
MELAOutputStreamer & MELAOutputStreamer::operator<< ( std::pair< T, U > const &  val)

Definition at line 90 of file MELAOutputStreamer.h.

90  {
91  *this << "(" << val.first << ", " << val.second << ")";
92  return *this;
93 }

◆ operator<<() [5/6]

template<typename T >
MELAOutputStreamer & MELAOutputStreamer::operator<< ( std::vector< T > const &  val)

Definition at line 97 of file MELAOutputStreamer.h.

97  {
98  for (typename std::vector<T>::const_iterator it=val.cbegin(); it!=val.cend(); it++){
99  *this << *it;
100  if (it!=val.cend()-1) *this << ", ";
101  }
102  return *this;
103 }

◆ operator<<() [6/6]

template<typename T >
MELAOutputStreamer & MELAOutputStreamer::operator<< ( T const &  val)

Definition at line 50 of file MELAOutputStreamer.h.

50  {
51  theFile << val;
52  if (stdout_ptr) *stdout_ptr << val;
53  return *this;
54 }

◆ width() [1/2]

std::streamsize MELAOutputStreamer::width ( ) const

Definition at line 133 of file MELAOutputStreamer.cc.

133 { return theFile.width(); }

◆ width() [2/2]

std::streamsize MELAOutputStreamer::width ( std::streamsize  wide)

Definition at line 134 of file MELAOutputStreamer.cc.

134  {
135  if (stdout_ptr) stdout_ptr->width(wide);
136  return theFile.width(wide);
137 }

◆ writeCentered()

template<typename T >
template void MELAOutputStreamer::writeCentered< TString > ( const T &  val,
char  fillch = ' ',
std::streamsize  gapsize = 0 
)

Definition at line 131 of file MELAOutputStreamer.h.

131  {
132  char deffillch = this->fill(fillch);
133 
134  std::stringstream tmpss;
135  tmpss << val;
136  std::string tmpstr = tmpss.str();
137  std::streamsize strlength = (std::streamsize) tmpstr.length();
138 
139  if (strlength>gapsize) *this << std::setw(gapsize) << "";
140  else{
141  std::streamsize leftgap = (gapsize+strlength)/2;
142  std::streamsize rightgap = gapsize-leftgap;
143  *this << std::setw(leftgap) << tmpstr << std::setw(rightgap) << "";
144  }
145 
146  this->fill(deffillch);
147 }

Member Data Documentation

◆ stdout_ptr

std::ostream* MELAOutputStreamer::stdout_ptr
protected

Definition at line 24 of file MELAOutputStreamer.h.

◆ theFile

std::ofstream MELAOutputStreamer::theFile
protected

Definition at line 23 of file MELAOutputStreamer.h.


The documentation for this class was generated from the following files:
MELAOutputStreamer::fill
char fill() const
Definition: MELAOutputStreamer.cc:139
MELAOutputStreamer::close
void close()
Definition: MELAOutputStreamer.cc:145
MELAOutputStreamer::theFile
std::ofstream theFile
Definition: MELAOutputStreamer.h:23
MELAOutputStreamer::stdout_ptr
std::ostream * stdout_ptr
Definition: MELAOutputStreamer.h:24
dd_global::cout
integer cout
Definition: DD_global.F90:21