/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
LiveTimeSvc Class Reference

#include <LiveTimeSvc.h>

Inheritance diagram for LiveTimeSvc:
Inheritance graph
[legend]
Collaboration diagram for LiveTimeSvc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LiveTimeSvc (const std::string &name)
virtual ~LiveTimeSvc ()
virtual bool initialize ()
void initHist ()
virtual bool finalize ()
double wallTime () const
double daqTime () const
double liveTime (const int det) const
double evtTimeGap () const
void setWallTime (const double wallTime)
void setDaqTime (const double daqTime)
void setLiveTime (const int det, const double liveTime)
void setEvtTimeGap (const double evtTimeGap)
TTimeStamp & startTime ()
TTimeStamp & endTime ()
int nBins () const
double daqTimePerBin (const int bin)
double liveTimePerBin (const int det, const int bin)
void setDaqTimePerBin (const int bin, const double daqTime)
void setLiveTimePerBin (const int det, const int bin, const double liveTime)
double binWidth () const
int bin (TTimeStamp &time) const
TTimeStamp startTime (const int bin) const
TTimeStamp endTime (const int bin) const
TH1F * hDaqTime ()
TH1F * hLiveTime (const int det)
const std::string & name ()
bool setOption (const std::string &option, Type &var)

Protected Attributes

std::string m_name

Private Member Functions

int str2int (const std::string &str)

Private Attributes

double m_wallTime
double m_daqTime
double m_liveTime [4]
double m_evtTimeGap
TTimeStamp m_startTime
TTimeStamp m_endTime
int m_nBins
std::string m_startTimeStr
std::string m_endTimeStr
double m_binWidth
TH1F * m_hDaqTime
TH1F * m_hLiveTime [4]

Detailed Description

Definition at line 10 of file LiveTimeSvc.h.


Constructor & Destructor Documentation

LiveTimeSvc::LiveTimeSvc ( const std::string &  name)

Definition at line 12 of file LiveTimeSvc.cc.

: SvcBase(name),
  m_wallTime(0.),
  m_daqTime(0.),
  m_startTime(0),
  m_endTime(0),
  m_nBins(100),
  m_binWidth(0.)
{
  m_name = "LiveTimeSvc";  //to avoid naming confusion
  setOption("TimeGap",       m_evtTimeGap=1.); // 1 second
  setOption("StartTime",     m_startTimeStr="2011-08-15T00:00:00");
  setOption("EndTime",       m_endTimeStr="2012-08-15T00:00:00");
  setOption("NBins",         m_nBins=2196);
  setOption("BinWidth",      m_binWidth=0.);

  string strYear1(m_startTimeStr.substr(0,4));
  string strMonth1(m_startTimeStr.substr(5,2));
  string strDay1(m_startTimeStr.substr(8,2));
  string strHour1("00");
  string strMinute1("00");
  string strSecond1("00");

  if(m_startTimeStr.length() >= 13) {
    strHour1 = m_startTimeStr.substr(11,2);
  }
  if(m_startTimeStr.length() >= 16) {
    strMinute1 = m_startTimeStr.substr(14,2);
  }
  if(m_startTimeStr.length() >= 19) {
    strSecond1 = m_startTimeStr.substr(17,2);
  }

  string strYear2(m_endTimeStr.substr(0,4));
  string strMonth2(m_endTimeStr.substr(5,2));
  string strDay2(m_endTimeStr.substr(8,2));
  string strHour2("00");
  string strMinute2("00");
  string strSecond2("00");

  if(m_endTimeStr.length() >= 13) {
    strHour2 = m_endTimeStr.substr(11,2);
  }
  if(m_endTimeStr.length() >= 16) {
    strMinute2 = m_endTimeStr.substr(14,2);
  }
  if(m_endTimeStr.length() >= 19) {
    strSecond2 = m_endTimeStr.substr(17,2);
  }

  m_startTime = TTimeStamp(str2int(strYear1),str2int(strMonth1),str2int(strDay1),
      str2int(strHour1),str2int(strMinute1),str2int(strSecond1));
  m_endTime = TTimeStamp(str2int(strYear2),str2int(strMonth2),str2int(strDay2),
      str2int(strHour2),str2int(strMinute2),str2int(strSecond2));

  if(m_binWidth>0.) {
    m_nBins = (int)((m_endTime-m_startTime)/m_binWidth);
  } else {
    m_binWidth = (m_endTime-m_startTime)/(double)m_nBins;
  }

  LogInfo << "Time range for \"VS time\" histogram with " << m_nBins << " bins:" << endl;
  LogInfo << "Start time: " << m_startTime << endl;
  LogInfo << "End time: " << m_endTime << endl;
  LogInfo << "Bin width: " << binWidth() << "s" << endl;

  for(int det=1;det<=4;det++) {
    m_liveTime[det-1] = 0.;
  }

}
LiveTimeSvc::~LiveTimeSvc ( ) [virtual]

Definition at line 98 of file LiveTimeSvc.cc.

{
}

Member Function Documentation

bool LiveTimeSvc::initialize ( ) [virtual]

Implements SvcBase.

Definition at line 102 of file LiveTimeSvc.cc.

{
  return true;
}
void LiveTimeSvc::initHist ( )

Definition at line 84 of file LiveTimeSvc.cc.

{
  m_hDaqTime = new TH1F("DaqTime","DAQ time",
      m_nBins, m_startTime.AsDouble(), m_endTime.AsDouble()
      );
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    stringstream ss;
    ss << "AD" << det << "LiveTime";
    m_hLiveTime[det-1] = new TH1F(ss.str().c_str(),"Live time",
        m_nBins, m_startTime.AsDouble(), m_endTime.AsDouble()
      );
  }
}
bool LiveTimeSvc::finalize ( ) [virtual]

Implements SvcBase.

Definition at line 107 of file LiveTimeSvc.cc.

{
  return true;
}
double LiveTimeSvc::wallTime ( ) const [inline]

Definition at line 21 of file LiveTimeSvc.h.

{ return m_wallTime; }
double LiveTimeSvc::daqTime ( ) const [inline]

Definition at line 22 of file LiveTimeSvc.h.

{ return m_daqTime; }
double LiveTimeSvc::liveTime ( const int  det) const [inline]

Definition at line 23 of file LiveTimeSvc.h.

{ return m_liveTime[det-1]; }
double LiveTimeSvc::evtTimeGap ( ) const [inline]

Definition at line 24 of file LiveTimeSvc.h.

{ return m_evtTimeGap; }
void LiveTimeSvc::setWallTime ( const double  wallTime) [inline]

Definition at line 26 of file LiveTimeSvc.h.

void LiveTimeSvc::setDaqTime ( const double  daqTime) [inline]

Definition at line 27 of file LiveTimeSvc.h.

void LiveTimeSvc::setLiveTime ( const int  det,
const double  liveTime 
) [inline]

Definition at line 28 of file LiveTimeSvc.h.

{ m_liveTime[det-1] = liveTime; }
void LiveTimeSvc::setEvtTimeGap ( const double  evtTimeGap) [inline]

Definition at line 29 of file LiveTimeSvc.h.

TTimeStamp& LiveTimeSvc::startTime ( ) [inline]

Definition at line 31 of file LiveTimeSvc.h.

{ return m_startTime; }
TTimeStamp& LiveTimeSvc::endTime ( ) [inline]

Definition at line 32 of file LiveTimeSvc.h.

{ return m_endTime; }
int LiveTimeSvc::nBins ( ) const [inline]

Definition at line 33 of file LiveTimeSvc.h.

{ return m_nBins; }
double LiveTimeSvc::daqTimePerBin ( const int  bin)

Definition at line 141 of file LiveTimeSvc.cc.

{ 
  return m_hDaqTime->GetBinContent(bin+1); 
}
double LiveTimeSvc::liveTimePerBin ( const int  det,
const int  bin 
)

Definition at line 146 of file LiveTimeSvc.cc.

{ 
  return m_hLiveTime[det-1]->GetBinContent(bin+1); 
}
void LiveTimeSvc::setDaqTimePerBin ( const int  bin,
const double  daqTime 
)

Definition at line 151 of file LiveTimeSvc.cc.

{ 
  m_hDaqTime->Fill(startTime(bin) + binWidth()/2, daqTime);
}
void LiveTimeSvc::setLiveTimePerBin ( const int  det,
const int  bin,
const double  liveTime 
)

Definition at line 156 of file LiveTimeSvc.cc.

{ 
  m_hLiveTime[det-1]->Fill(startTime(bin) + binWidth()/2, liveTime);
}
double LiveTimeSvc::binWidth ( ) const [inline]

Definition at line 41 of file LiveTimeSvc.h.

{ return m_binWidth; }
int LiveTimeSvc::bin ( TTimeStamp &  time) const

Definition at line 112 of file LiveTimeSvc.cc.

{
  return (int)((time - m_startTime)/binWidth());
}
TTimeStamp LiveTimeSvc::startTime ( const int  bin) const

Definition at line 117 of file LiveTimeSvc.cc.

{
  TTimeStamp time(m_startTime);
  int ts = (int)(bin*binWidth());
  int tns = (int)((bin*binWidth() - ts)*1e9);
  TTimeStamp dt(ts,tns);
  time.Add(dt);
  return time;
}
TTimeStamp LiveTimeSvc::endTime ( const int  bin) const

Definition at line 127 of file LiveTimeSvc.cc.

{
  return startTime(bin+1);
}
TH1F* LiveTimeSvc::hDaqTime ( ) [inline]

Definition at line 46 of file LiveTimeSvc.h.

{ return m_hDaqTime; }
TH1F* LiveTimeSvc::hLiveTime ( const int  det) [inline]

Definition at line 47 of file LiveTimeSvc.h.

{ return m_hLiveTime[det-1]; }
int LiveTimeSvc::str2int ( const std::string &  str) [private]

Definition at line 132 of file LiveTimeSvc.cc.

{
  stringstream ss;
  ss << str;
  int temp;
  ss >> temp;
  return temp;
}

Member Data Documentation

double LiveTimeSvc::m_wallTime [private]

Definition at line 55 of file LiveTimeSvc.h.

double LiveTimeSvc::m_daqTime [private]

Definition at line 56 of file LiveTimeSvc.h.

double LiveTimeSvc::m_liveTime[4] [private]

Definition at line 57 of file LiveTimeSvc.h.

double LiveTimeSvc::m_evtTimeGap [private]

Definition at line 58 of file LiveTimeSvc.h.

TTimeStamp LiveTimeSvc::m_startTime [private]

Definition at line 61 of file LiveTimeSvc.h.

TTimeStamp LiveTimeSvc::m_endTime [private]

Definition at line 62 of file LiveTimeSvc.h.

int LiveTimeSvc::m_nBins [private]

Definition at line 63 of file LiveTimeSvc.h.

std::string LiveTimeSvc::m_startTimeStr [private]

Definition at line 64 of file LiveTimeSvc.h.

std::string LiveTimeSvc::m_endTimeStr [private]

Definition at line 65 of file LiveTimeSvc.h.

double LiveTimeSvc::m_binWidth [private]

Definition at line 66 of file LiveTimeSvc.h.

TH1F* LiveTimeSvc::m_hDaqTime [private]

Definition at line 69 of file LiveTimeSvc.h.

TH1F* LiveTimeSvc::m_hLiveTime[4] [private]

Definition at line 70 of file LiveTimeSvc.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:33 for LiveTimeSvc by doxygen 1.7.4