CMS 3D CMS Logo

Utils Class Reference

Utility functions. More...

#include <RecoParticleFlow/PFBlockAlgo/interface/Utils.h>

List of all members.

Static Public Member Functions

static std::string Date ()
 returns the date
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 double mpi_pi (double angle)
 returns angle between mpi and pi
static std::vector< std::string > myGlob (const char *pattern)
 get all files matching pattern
static bool StringMatch (const char *string, const char *pattern)
 match a string to a regexp
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

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 62 of file Utils.cc.

References date(), in, and HLT_VtxMuL3::result.

00062                      {
00063   string date("date +%d%b%Y_%H%M%S");
00064   FILE *in = popen(date.c_str(), "r");
00065   char result[100];
00066   if(fscanf(in,"%s",result) != EOF) {
00067     return string(result);
00068   }
00069   else return string("");
00070 }

string Utils::date (  )  [static]

returns the date

Definition at line 41 of file Utils.cc.

References in, and HLT_VtxMuL3::result.

Referenced by Date().

00041                      {
00042   string date("date +%d%b%Y_%H%M%S");
00043   FILE *in = popen(date.c_str(), "r");
00044   char result[100];
00045   if(fscanf(in,"%s",result) != EOF) {
00046     return string(result);
00047   }
00048   else return string("");
00049 }

TCanvas * Utils::DivideCanvas ( TCanvas *  cv,
int  nPads 
) [static]

divide a TCanvas in a nice way

Definition at line 30 of file Utils.cc.

References int, and funct::sqrt().

00030                                                      {  
00031   if( !cv ) return 0;
00032   
00033   if( nPads<=1 ) return cv;
00034   int sqnP = (unsigned int) (sqrt( nPads ));
00035   int nC = sqnP;
00036   int nL = sqnP;
00037   
00038   while( nC*nL < nPads ) 
00039     if( nC < nL ) nC++;
00040     else nL++;
00041   
00042   cv->Divide( nC, nL, 0.005, 0.005, 0 );
00043   return cv;
00044 }

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 bookConverter::results.

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

00046                                                {
00047 
00048   glob_t globbuf;
00049 
00050   globbuf.gl_offs = 2;
00051   glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, NULL, &globbuf);
00052 
00053   vector<string> results;
00054   for(unsigned i=0; i<globbuf.gl_pathc; i++) {
00055     results.push_back(globbuf.gl_pathv[i]);
00056   }
00057   
00058   globfree(&globbuf);
00059   return results;
00060 }

double Utils::mpi_pi ( double  angle  )  [static]

returns angle between mpi and pi

Definition at line 52 of file Utils.cc.

References pi, and pi2.

Referenced by PFBlockAlgo::computeChi2(), and PFBlockAlgo::testPSAndECAL().

00052                                    {
00053 
00054   const double pi = 3.14159265358979323;
00055   const double pi2 = pi*2.;
00056   while(angle>pi) angle -= pi2;
00057   while(angle<-pi) angle += pi2;
00058   return angle;
00059 }

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 bookConverter::results.

00025                                                  {
00026 
00027   glob_t globbuf;
00028 
00029   globbuf.gl_offs = 2;
00030   glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, NULL, &globbuf);
00031 
00032   vector<string> results;
00033   for(unsigned i=0; i<globbuf.gl_pathc; i++) {
00034     results.push_back(globbuf.gl_pathv[i]);
00035   }
00036   
00037   globfree(&globbuf);
00038   return results;
00039 }

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 StDecayID::status.

00013                                                             {
00014   int    status;
00015   regex_t    re;
00016   
00017   if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 )
00018     return false;
00019   
00020   status = regexec(&re, str, (size_t)0, NULL, 0);
00021   regfree(&re);
00022   
00023   if (status != 0)
00024     return false;
00025   
00026   return true;
00027 }

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 StDecayID::status.

00009                                                             {
00010   int    status;
00011   regex_t    re;
00012   
00013   if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 )
00014     return false;
00015   
00016   status = regexec(&re, str, (size_t)0, NULL, 0);
00017   regfree(&re);
00018   
00019   if (status != 0)
00020     return false;
00021   
00022   return true;
00023 }

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 funct::exp(), theta, and muonGeometry::TVector3().

Referenced by PFRootEventManager::tauBenchmark().

00073                                                        {
00074   TVector3 posxyz(1,1,1); // to be called before a SetMag
00075   posxyz.SetMag( posepr.Z() );
00076   double theta = 2*atan( exp( - posepr.X() ) );
00077   posxyz.SetTheta( theta );
00078   posxyz.SetPhi( posepr.Y() );  
00079 
00080   return posxyz;
00081 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:51 2009 for CMSSW by  doxygen 1.5.4