CMS 3D CMS Logo

Static Public Member Functions

pftools::Utils Class Reference

#include <Utils.h>

List of all members.

Static Public Member Functions

static std::string Date ()
 returns the date
static TCanvas * DivideCanvas (TCanvas *cv, int nPads)
 divide a TCanvas in a nice way
static std::vector< std::string > Glob (const char *pattern)
 get all files matching pattern
static bool StringMatch (const char *string, const char *pattern)
 match a string to a regexp
static TVector3 VectorEPRtoXYZ (const TVector3 &posepr)
 converts a vector (in eta,phi,R) to a vector in (x,y,z)

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, query::result, and AlCaHLTBitMon_QueryRunRegistry::string.

                     {
  string date("date +%d%b%Y_%H%M%S");
  FILE *in = popen(date.c_str(), "r");
  char result[100];
  if(fscanf(in,"%s",result) != EOF) {
    return string(result);
  }
  else return string("");
}
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().

                                                     {  
  if( !cv ) return 0;
  
  if( nPads<=1 ) return cv;
  int sqnP = (unsigned int) (sqrt( nPads ));
  int nC = sqnP;
  int nL = sqnP;
  
  while( nC*nL < nPads ) 
    if( nC < nL ) nC++;
    else nL++;
  
  cv->Divide( nC, nL, 0.005, 0.005, 0 );
  return cv;
}
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 python::entryComment::results.

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

                                               {

  glob_t globbuf;

  globbuf.gl_offs = 2;
  glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, NULL, &globbuf);

  vector<string> results;
  for(unsigned i=0; i<globbuf.gl_pathc; i++) {
    results.push_back(globbuf.gl_pathv[i]);
  }
  
  globfree(&globbuf);
  return results;
}
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 ntuplemaker::status.

                                                            {
  int    status;
  regex_t    re;
  
  if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 )
    return false;
  
  status = regexec(&re, str, (size_t)0, NULL, 0);
  regfree(&re);
  
  if (status != 0)
    return false;
  
  return true;
}
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().

                                                       {
  TVector3 posxyz(1,1,1); // to be called before a SetMag
  posxyz.SetMag( posepr.Z() );
  double theta = 2*atan( exp( - posepr.X() ) );
  posxyz.SetTheta( theta );
  posxyz.SetPhi( posepr.Y() );  

  return posxyz;
}