/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 | Private Attributes
PrintAdTempAlg Class Reference

#include <PrintAdTempAlg.h>

Collaboration diagram for PrintAdTempAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PrintAdTempAlg (const string &name, ISvcLocator *pSvcLocator)
virtual ~PrintAdTempAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()

Private Attributes

IDaqRunInfoSvcm_daqRunInfoSvc
int m_runNo
string m_fileName
string m_outputFile
TimeStamp m_start
TimeStamp m_end

Detailed Description

Definition at line 11 of file PrintAdTempAlg.h.


Constructor & Destructor Documentation

PrintAdTempAlg::PrintAdTempAlg ( const string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 16 of file PrintAdTempAlg.cc.

:GaudiAlgorithm(name, pSvcLocator)
{
  declareProperty("runNo", m_runNo = 1576, "Input runNo to query the AD temperature"); //runNo=1576 is a long muon run
  declareProperty("fileName", m_fileName = "", "Name of input file to query the AD temperature data");
  declareProperty("outputFile", m_outputFile = "AdTemp.txt", "Name of file to print the AD temperature data");

}
PrintAdTempAlg::~PrintAdTempAlg ( ) [virtual]

Definition at line 25 of file PrintAdTempAlg.cc.

{
}

Member Function Documentation

StatusCode PrintAdTempAlg::initialize ( ) [virtual]

Definition at line 29 of file PrintAdTempAlg.cc.

{
  // Initialize the necessary services
  StatusCode sc = this->service("DaqRunInfoSvc", m_daqRunInfoSvc, true);
  if(sc.isFailure()){
      error() << "Failed to get service: " << "DaqRunInfoSvc" << endreq;
      return sc;
  }

  return StatusCode::SUCCESS;
}
StatusCode PrintAdTempAlg::execute ( ) [virtual]

Definition at line 41 of file PrintAdTempAlg.cc.

{
  return StatusCode::SUCCESS;
}
StatusCode PrintAdTempAlg::finalize ( ) [virtual]

Definition at line 46 of file PrintAdTempAlg.cc.

{
  // Get the time Start and End for a run
  const DaqRunInfo* aRun;
  aRun = m_daqRunInfoSvc->GetRunInfo(m_runNo);

  if ( m_fileName == ""){
    warning() << "No raw data file name is provided!"<<endreq;
    warning() << "Use run number to access the run information."<<endreq;

    DbiResult* res = aRun->GetOwner();
    const DbiValidityRec vr = res->GetValidityRec();
    const ContextRange cr = vr.GetContextRange();
    m_start = cr.GetTimeStart();
    m_end = cr.GetTimeEnd();
  }
  else{
    const DaqRawDataFileInfo* fileInfo;
    fileInfo = m_daqRunInfoSvc->GetFileInfo(m_fileName);
    
    // Get the ContextRange for fileInfo
    DbiResult* res = fileInfo->GetOwner();
    const DbiValidityRec vr = res->GetValidityRec();
    const ContextRange cr = vr.GetContextRange();

    m_start = cr.GetTimeStart();
    m_end = cr.GetTimeEnd();
  }

  ofstream output;
  output.open(m_outputFile.c_str());
  output<<"The Data of four temperature sensors in one AD is listed:\n"<<endl;

  // Test of loading all data
  //DbiSqlContext vc("1=1");
  //DbiResultPtr<DcsAdTemp> ptr1("DcsAdTemp", vc);

  //Query the AD temperature at start time
  Context startContext( Site::kDayaBay, SimFlag::kData, m_start);
  Dbi::SubSite subsite = 1;
  DbiResultPtr<DcsAdTemp> ptr1("DcsAdTemp", startContext, subsite);
  unsigned int numRows = ptr1.GetNumRows();
  const DcsAdTemp* row;
  output<<"The AD temperature at start time is:"<<endl;
  for (unsigned int idx=0; idx < numRows; idx++) {
    row = ptr1.GetRowByIndex(idx);
    output<<row->GetTemp1()<<"  "<<row->GetTemp2()<<"  "
          <<row->GetTemp3()<<"  "<<row->GetTemp4()<<endl;
  }

  //Query the AD temperature at end time
  Context endContext( Site::kDayaBay, SimFlag::kData, m_end);
  DbiResultPtr<DcsAdTemp> ptr2("DcsAdTemp",endContext, subsite);
  numRows = ptr2.GetNumRows();
  output<<"\nThe AD temperature at end time is:"<<endl;
  for (unsigned int idx=0; idx < numRows; idx++) {
    row = ptr2.GetRowByIndex(idx);
    output<<row->GetTemp1()<<"  "<<row->GetTemp2()<<"  "
          <<row->GetTemp3()<<"  "<<row->GetTemp4()<<endl;
  }
  
  //Query the AD temperature between start and end time
  Dbi::Task task = Dbi::kDefaultTask;
  DbiSqlContext sqlContext(DbiSqlContext::kWithin, m_start, m_end, Site::kDayaBay, SimFlag::kData);
  DbiResultPtr<DcsAdTemp> ptr3("DcsAdTemp", sqlContext, subsite, task);
  numRows = ptr3.GetNumRows();
  output<<"\nThe AD temperature between start and end time is:"<<endl;
  for (unsigned int idx=0; idx < numRows; idx++) {
    row = ptr3.GetRowByIndex(idx);
    output<<row->GetTemp1()<<"  "<<row->GetTemp2()<<"  "
          <<row->GetTemp3()<<"  "<<row->GetTemp4()<<endl;
  }

  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 24 of file PrintAdTempAlg.h.

int PrintAdTempAlg::m_runNo [private]

Definition at line 26 of file PrintAdTempAlg.h.

string PrintAdTempAlg::m_fileName [private]

Definition at line 27 of file PrintAdTempAlg.h.

string PrintAdTempAlg::m_outputFile [private]

Definition at line 28 of file PrintAdTempAlg.h.

Definition at line 30 of file PrintAdTempAlg.h.

Definition at line 31 of file PrintAdTempAlg.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:57:12 for DcsDataSvc by doxygen 1.7.4