test
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
pftools::Utils Class Reference

#include <Utils.h>

Static Public Member Functions

static std::string Date ()
 returns the date More...
 
static TCanvas * DivideCanvas (TCanvas *cv, int nPads)
 divide a TCanvas in a nice way More...
 
static std::vector< std::string > Glob (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...
 
static TVector3 VectorEPRtoXYZ (const TVector3 &posepr)
 converts a vector (in eta,phi,R) to a vector in (x,y,z) More...
 

Detailed Description

Definition at line 16 of file Utils.h.

Member Function Documentation

string Utils::Date ( )
static

returns the date

Definition at line 62 of file Utils.cc.

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

62  {
63  string date("date +%d%b%Y_%H%M%S");
64  FILE *in = popen(date.c_str(), "r");
65  char result[100];
66  if(fscanf(in,"%s",result) != EOF) {
67  return string(result);
68  }
69  else return string("");
70 }
tuple result
Definition: mps_fire.py:83
TCanvas * Utils::DivideCanvas ( TCanvas *  cv,
int  nPads 
)
static

divide a TCanvas in a nice way

Definition at line 30 of file Utils.cc.

References cuy::cv, and mathSSE::sqrt().

30  {
31  if( !cv ) return 0;
32 
33  if( nPads<=1 ) return cv;
34  int sqnP = (unsigned int) (sqrt( nPads ));
35  int nC = sqnP;
36  int nL = sqnP;
37 
38  while( nC*nL < nPads )
39  if( nC < nL ) nC++;
40  else nL++;
41 
42  cv->Divide( nC, nL, 0.005, 0.005, 0 );
43  return cv;
44 }
T sqrt(T t)
Definition: SSEVec.h:18
dictionary cv
Definition: cuy.py:362
vector< string > Utils::Glob ( const char *  pattern)
static

get all files matching pattern

Definition at line 46 of file Utils.cc.

References i, NULL, and mps_update::results.

Referenced by pftools::IO::IO().

46  {
47 
48  glob_t globbuf;
49 
50  globbuf.gl_offs = 2;
51  glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, NULL, &globbuf);
52 
53  vector<string> results;
54  for(unsigned i=0; i<globbuf.gl_pathc; i++) {
55  results.push_back(globbuf.gl_pathv[i]);
56  }
57 
58  globfree(&globbuf);
59  return results;
60 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
tuple results
Definition: mps_update.py:44
bool Utils::StringMatch ( const char *  string,
const char *  pattern 
)
static

match a string to a regexp

Definition at line 13 of file Utils.cc.

References NULL, and mps_update::status.

13  {
14  int status;
15  regex_t re;
16 
17  if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 )
18  return false;
19 
20  status = regexec(&re, str, (size_t)0, NULL, 0);
21  regfree(&re);
22 
23  if (status != 0)
24  return false;
25 
26  return true;
27 }
#define NULL
Definition: scimark2.h:8
tuple status
Definition: mps_update.py:57
TVector3 Utils::VectorEPRtoXYZ ( const TVector3 &  posepr)
static

converts a vector (in eta,phi,R) to a vector in (x,y,z)

Definition at line 73 of file Utils.cc.

References create_public_lumi_plots::exp, and theta().

73  {
74  TVector3 posxyz(1,1,1); // to be called before a SetMag
75  posxyz.SetMag( posepr.Z() );
76  double theta = 2*atan( exp( - posepr.X() ) );
77  posxyz.SetTheta( theta );
78  posxyz.SetPhi( posepr.Y() );
79 
80  return posxyz;
81 }
Geom::Theta< T > theta() const