JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
TUtilHelpers Namespace Reference

Functions

template<typename T >
void copyVector (std::vector< T > const &input, std::vector< T > &target)
 
template<typename T , typename U = T>
bool checkElementExists (T const &element, std::vector< U > const &elementlist)
 
template<typename T >
bool hasCommonElements (std::vector< T > const &v1, std::vector< T > const &v2)
 
void ExpandEnvironmentVariables (std::string &str)
 

Function Documentation

◆ checkElementExists()

template<typename T , typename U = T>
bool TUtilHelpers::checkElementExists ( T const &  element,
std::vector< U > const &  elementlist 
)

Definition at line 42 of file TUtilHelpers.hh.

42  {
43  for (U const& el:elementlist){ if (el==element) return true; }
44  return false;
45 }

◆ copyVector()

template<typename T >
void TUtilHelpers::copyVector ( std::vector< T > const &  input,
std::vector< T > &  target 
)

Definition at line 24 of file TUtilHelpers.hh.

24  {
25  std::copy(input.cbegin(), input.cend(), std::back_inserter(target));
26 }

◆ ExpandEnvironmentVariables()

void TUtilHelpers::ExpandEnvironmentVariables ( std::string &  str)

Definition at line 6 of file TUtilHelpers.cc.

6  {
7  // Take care of special characters
8  size_t ipos;
9  std::string strTakeOut, strPutIn;
10 
11  strTakeOut = ".oODOLLAROo.";
12  strPutIn = "$";
13  ipos = str.find(strTakeOut);
14  while (ipos!=std::string::npos){ str.replace(ipos, strTakeOut.length(), strPutIn.c_str()); ipos = str.find(strTakeOut); }
15  strTakeOut = ".oOOPEN_BRACKETOo.";
16  strPutIn = "{";
17  ipos = str.find(strTakeOut);
18  while (ipos!=std::string::npos){ str.replace(ipos, strTakeOut.length(), strPutIn.c_str()); ipos = str.find(strTakeOut); }
19  strTakeOut = ".oOCLOSE_BRACKETOo.";
20  strPutIn = "}";
21  ipos = str.find(strTakeOut);
22  while (ipos!=std::string::npos){ str.replace(ipos, strTakeOut.length(), strPutIn.c_str()); ipos = str.find(strTakeOut); }
23 
24  static std::regex env("\\$\\{([^}]+)\\}");
25  std::smatch match;
26  while (std::regex_search(str, match, env)){
27  const char* s = getenv(match[1].str().c_str());
28  const std::string var(s == NULL ? "" : s);
29  str.replace(match[0].first, match[0].second, var);
30  }
31 }

◆ hasCommonElements()

template<typename T >
bool TUtilHelpers::hasCommonElements ( std::vector< T > const &  v1,
std::vector< T > const &  v2 
)

Definition at line 63 of file TUtilHelpers.hh.

63  {
64  for (T const& el1:v1){
65  for (T const& el2:v2){
66  if (el1==el2) return true;
67  }
68  }
69  return false;
70 }
modparameters::second
real(8), parameter, public second
Definition: mod_Parameters.F90:105