CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
Utils Class Reference

Utility functions. More...

#include <Utils.h>

Static Public Member Functions

static std::string date ()
 returns the date More...
 
static double mpi_pi (double angle)
 returns angle between mpi and pi More...
 
static std::vector< std::string > myGlob (const char *pattern)
 get all files matching pattern More...
 
static bool stringMatch (const char *string, const char *pattern)
 match a string to a regexp More...
 

Detailed Description

Utility functions.

Author
Colin Bernet
Date
January 2006

Definition at line 16 of file Utils.h.

Member Function Documentation

string Utils::date ( )
static

returns the date

Definition at line 41 of file Utils.cc.

References recoMuon::in, query::result, and AlCaHLTBitMon_QueryRunRegistry::string.

41  {
42  string date("date +%d%b%Y_%H%M%S");
43  FILE *in = popen(date.c_str(), "r");
44  char result[100];
45  if(fscanf(in,"%s",result) != EOF) {
46  return string(result);
47  }
48  else return string("");
49 }
tuple result
Definition: query.py:137
static std::string date()
returns the date
Definition: Utils.cc:41
double Utils::mpi_pi ( double  angle)
static

returns angle between mpi and pi

Definition at line 52 of file Utils.cc.

References angle(), pi, and pi2.

52  {
53 
54  const double pi = 3.14159265358979323;
55  const double pi2 = pi*2.;
56  while(angle>pi) angle -= pi2;
57  while(angle<-pi) angle += pi2;
58  return angle;
59 }
const double pi2
Definition: Thrust.cc:4
const Double_t pi
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
vector< string > Utils::myGlob ( const char *  pattern)
static

get all files matching pattern

Definition at line 25 of file Utils.cc.

References i, NULL, and python.entryComment::results.

25  {
26 
27  glob_t globbuf;
28 
29  globbuf.gl_offs = 2;
30  glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, NULL, &globbuf);
31 
32  vector<string> results;
33  for(unsigned i=0; i<globbuf.gl_pathc; i++) {
34  results.push_back(globbuf.gl_pathv[i]);
35  }
36 
37  globfree(&globbuf);
38  return results;
39 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
bool Utils::stringMatch ( const char *  string,
const char *  pattern 
)
static

match a string to a regexp

Definition at line 9 of file Utils.cc.

References NULL, and ntuplemaker::status.

9  {
10  int status;
11  regex_t re;
12 
13  if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 )
14  return false;
15 
16  status = regexec(&re, str, (size_t)0, NULL, 0);
17  regfree(&re);
18 
19  if (status != 0)
20  return false;
21 
22  return true;
23 }
#define NULL
Definition: scimark2.h:8
tuple status
Definition: ntuplemaker.py:245