CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pos::PixelTimeFormatter Class Reference

#include <PixelTimeFormatter.h>

Public Member Functions

struct timeval getImSecTime (void)
 
struct tm * getITime (void)
 
 PixelTimeFormatter (std::string source)
 
void stopTimer (void)
 
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const
 
virtual ~PixelTimeFormatter ()=default
 

Static Public Member Functions

static std::string getmSecTime (void)
 
static std::string getTime (void)
 

Private Attributes

struct timeval endTime_
 
std::string origin_
 
struct timeval startTime_
 
bool verbose_
 

Detailed Description

Definition at line 26 of file PixelTimeFormatter.h.

Constructor & Destructor Documentation

◆ PixelTimeFormatter()

pos::PixelTimeFormatter::PixelTimeFormatter ( std::string  source)
inline

Definition at line 29 of file PixelTimeFormatter.h.

30  {
31  if (!USE_TIMER_)
32  return;
33  origin_ = source;
34  std::cout << "[PixelTimeFormatter::PixelTimeFormatter()]\t\t Time counter started for " << origin_
35  << std::endl;

References gather_cfg::cout, getImSecTime(), origin_, source, startTime_, and USE_TIMER_.

◆ ~PixelTimeFormatter()

virtual pos::PixelTimeFormatter::~PixelTimeFormatter ( )
virtualdefault

Member Function Documentation

◆ getImSecTime()

struct timeval pos::PixelTimeFormatter::getImSecTime ( void  )
inline

Definition at line 104 of file PixelTimeFormatter.h.

105  {
106  struct timeval msecTime;
107  gettimeofday(&msecTime, (struct timezone *)nullptr);
108 
109  return msecTime;

Referenced by PixelTimeFormatter(), and stopTimer().

◆ getITime()

struct tm* pos::PixelTimeFormatter::getITime ( void  )
inline

Definition at line 84 of file PixelTimeFormatter.h.

85  {
86  struct tm *thisTime;
87  time_t aclock;
88  time(&aclock);
89  thisTime = localtime(&aclock);
90  return thisTime;

References protons_cff::time.

◆ getmSecTime()

static std::string pos::PixelTimeFormatter::getmSecTime ( void  )
inlinestatic

◆ getTime()

static std::string pos::PixelTimeFormatter::getTime ( void  )
inlinestatic

Definition at line 60 of file PixelTimeFormatter.h.

61  {
62  constexpr size_t kBufferLength = 72;
63  char theDate[kBufferLength];
64  struct tm *thisTime;
65  time_t aclock;
67  time(&aclock);
68  thisTime = localtime(&aclock);
69 
70  snprintf(theDate,
71  kBufferLength,
72  "%d-%02d-%02d %02d:%02d:%02d",
73  thisTime->tm_year + 1900,
74  thisTime->tm_mon + 1,
75  thisTime->tm_mday,
76  thisTime->tm_hour,
77  thisTime->tm_min,
78  thisTime->tm_sec);
79  date = theDate;
80  //std::cout << "[PixelTimeFormatter::getTime()]\t\t\t\t Time: " << date << std::endl ;
81  return date;

References indexGen::date, AlCaHLTBitMon_QueryRunRegistry::string, and protons_cff::time.

Referenced by pos::PixelFEDCard::writeXML(), pos::PixelDetectorConfig::writeXML(), pos::PixelNameTranslation::writeXML(), pos::PixelTTCciConfig::writeXMLHeader(), pos::PixelMaxVsf::writeXMLHeader(), pos::PixelPortCardConfig::writeXMLHeader(), pos::PixelMaskAllPixels::writeXMLHeader(), pos::PixelLowVoltageMap::writeXMLHeader(), pos::PixelLTCConfig::writeXMLHeader(), pos::PixelGlobalDelay25::writeXMLHeader(), pos::PixelTBMSettings::writeXMLHeader(), pos::PixelTrimAllPixels::writeXMLHeader(), pos::PixelTKFECConfig::writeXMLHeader(), pos::PixelFEDConfig::writeXMLHeader(), pos::PixelFEDCard::writeXMLHeader(), pos::PixelDetectorConfig::writeXMLHeader(), pos::PixelPortcardMap::writeXMLHeader(), pos::PixelNameTranslation::writeXMLHeader(), pos::PixelDACSettings::writeXMLHeader(), and pos::PixelCalibConfiguration::writeXMLHeader().

◆ stopTimer()

void pos::PixelTimeFormatter::stopTimer ( void  )
inline

Definition at line 40 of file PixelTimeFormatter.h.

41  {
42  if (!USE_TIMER_)
43  return;
45  double start = startTime_.tv_sec + startTime_.tv_usec / 1000000.;
46  double stop = endTime_.tv_sec + endTime_.tv_usec / 1000000.;
47  std::cout << "[PixelTimeFormatter::stopTimer()]\t\t\t Elapsed time: " << stop - start << " seconds for "
48  << origin_ << std::endl;

References gather_cfg::cout, endTime_, getImSecTime(), origin_, startTime_, and USE_TIMER_.

◆ writeXMLHeader()

virtual void pos::PixelTimeFormatter::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
inlinevirtual

Definition at line 50 of file PixelTimeFormatter.h.

56  {
57  ;

Member Data Documentation

◆ endTime_

struct timeval pos::PixelTimeFormatter::endTime_
private

Definition at line 146 of file PixelTimeFormatter.h.

Referenced by stopTimer().

◆ origin_

std::string pos::PixelTimeFormatter::origin_
private

Definition at line 147 of file PixelTimeFormatter.h.

Referenced by PixelTimeFormatter(), and stopTimer().

◆ startTime_

struct timeval pos::PixelTimeFormatter::startTime_
private

Definition at line 145 of file PixelTimeFormatter.h.

Referenced by PixelTimeFormatter(), and stopTimer().

◆ verbose_

bool pos::PixelTimeFormatter::verbose_
private

Definition at line 148 of file PixelTimeFormatter.h.

pos::PixelTimeFormatter::getImSecTime
struct timeval getImSecTime(void)
Definition: PixelTimeFormatter.h:104
pos::PixelTimeFormatter::origin_
std::string origin_
Definition: PixelTimeFormatter.h:147
start
Definition: start.py:1
pos::PixelTimeFormatter::startTime_
struct timeval startTime_
Definition: PixelTimeFormatter.h:145
gather_cfg.cout
cout
Definition: gather_cfg.py:144
protons_cff.time
time
Definition: protons_cff.py:39
source
static const std::string source
Definition: EdmProvDump.cc:47
USE_TIMER_
#define USE_TIMER_
Definition: PixelTimeFormatter.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pos::PixelTimeFormatter::endTime_
struct timeval endTime_
Definition: PixelTimeFormatter.h:146
indexGen.date
date
Definition: indexGen.py:99