/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 | Static Public Member Functions
IDaqRunInfoSvc Class Reference

#include <IDaqRunInfoSvc.h>

Inheritance diagram for IDaqRunInfoSvc:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual int runNumber (const string fileName)=0
virtual const DaqRawDataFileInfoGetFileInfo (const string filename)=0
virtual const DaqRunInfoGetRunInfo (const int runNo)=0
virtual const DaqCalibRunInfoGetCalibRunInfo (const int runNo)=0
virtual const
DaqCalibRunInfoVector
GetCalibRunInfoVector (const int runNo)=0
virtual int dbRecordVector (const int runNo, DatabaseRecordVector &vec)=0
virtual int fullRunConfigList (const int runNo, vector< DayaBay::DaqRunConfig > &vec)=0
virtual int simpRunConfigList (const int runNo, vector< DayaBay::DaqRunConfig > &vec)=0
virtual int findHWList (vector< DayaBay::DaqRunConfig > cV, vector< string > &dets, vector< string > &crates, vector< string > &ltbs, vector< string > &fees)=0
virtual int findFEEThreshold (string runType, vector< DayaBay::DaqRunConfig > cv, vector< string > fees, map< string, string > &th_obj, map< string, bool > &isuni, map< string, int > &thres_uni, map< string, map< string, int > > &thres)=0
virtual int findLtbTrigger (string runType, vector< DayaBay::DaqRunConfig > cv, vector< string > ltbs, map< string, string > &mode, map< string, int > &source, map< string, string > &trig_name, map< string, map< string, int > > &trig_thres)=0
virtual string GetRunType (const int runNo)=0

Static Public Member Functions

static const InterfaceID & interfaceID ()

Detailed Description

Definition at line 41 of file IDaqRunInfoSvc.h.


Member Function Documentation

static const InterfaceID& IDaqRunInfoSvc::interfaceID ( ) [inline, static]

Definition at line 45 of file IDaqRunInfoSvc.h.

                                         {
    return IID_IDaqRunInfoSvc;
  }
int DaqRunInfoSvc::runNumber ( const string  fileName) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 126 of file DaqRunInfoSvc.cc.

{
  MsgStream log( msgSvc(), name() );
  const DaqRawDataFileInfo* file = GetFileInfo(fileName);
  if(!file){
    log << MSG::WARNING <<"Can not find "<<fileName<<" in table DaqRawDataFileInfo."<<endreq;
    return 0;
  }

  return file->GetRunNo();
}
const DaqRawDataFileInfo * DaqRunInfoSvc::GetFileInfo ( const string  filename) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 76 of file DaqRunInfoSvc.cc.

{
  MsgStream log( msgSvc(), name() );

  //Get all the raw data files
  DbiSqlContext vc("1=1"); //WHERE clause
  DbiResultPtr<DaqRawDataFileInfo> rp("DaqRawDataFileInfo", vc);

  // Check number of entries in result set
  unsigned int numRows = rp.GetNumRows();
  if (numRows < 1){
    log << MSG::WARNING <<"==> No records is found in table DaqRawDataFileInfo."<<endreq;
    return 0;
  }
  const DaqRawDataFileInfo* row;
  for (unsigned int idx=0; idx < numRows; idx++){
    row = rp.GetRow(idx);
    if(fileName == row->GetFileName())
      return row;
  }
 
  log << MSG::WARNING <<fileName <<" is not found in table DaqRawDataFileInfo."<<endreq;
  return 0;
}
const DaqRunInfo * DaqRunInfoSvc::GetRunInfo ( const int  runNo) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 101 of file DaqRunInfoSvc.cc.

{
  MsgStream log( msgSvc(), name() );

  //Get all the raw data files
  DbiSqlContext vc("1=1"); //WHERE clause
  DbiResultPtr<DaqRunInfo> rp("DaqRunInfo", vc);

  // Check number of entries in result set
  unsigned int numRows = rp.GetNumRows();
  if (numRows < 1){
    log << MSG::WARNING <<"No records is found in table DaqRunInfo."<<endreq;
    return 0;
  }
  const DaqRunInfo* row;
  for (unsigned int idx=0; idx < numRows; idx++){
    row = rp.GetRow(idx);
    if(runNo == row->GetRunNo())
      return row;
  }
 
  log << MSG::WARNING <<"runNo: "<<runNo<<" is not found in table DaqRunInfo."<<endreq;
  return 0;
}
const DaqCalibRunInfo * DaqRunInfoSvc::GetCalibRunInfo ( const int  runNo) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 139 of file DaqRunInfoSvc.cc.

{
  MsgStream log( msgSvc(), name() );

  //Get all the raw data files
  DbiSqlContext vc("1=1"); //WHERE clause
  DbiResultPtr<DaqCalibRunInfo> rp("DaqCalibRunInfo", vc);

  // Check number of entries in result set
  unsigned int numRows = rp.GetNumRows();
  if (numRows < 1){
    log << MSG::WARNING <<"No records found in table DaqCalibRunInfo."<<endreq;
    return 0;
  }
  const DaqCalibRunInfo* row;
  for (unsigned int idx=0; idx < numRows; idx++){
    row = rp.GetRowByIndex(idx); 
    if(runNo == row->GetRunNo() && row->GetDuration()>0){
      return row;
    }
  }
 
  log << MSG::WARNING <<"runNo: "<<runNo<<" is not found in table DaqCalibRunInfo."<<endreq;
  return 0;
}
const DaqCalibRunInfoVector * DaqRunInfoSvc::GetCalibRunInfoVector ( const int  runNo) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 165 of file DaqRunInfoSvc.cc.

{
  MsgStream log( msgSvc(), name() );

  //Get all the raw data files
  DbiSqlContext vc("1=1"); //WHERE clause
  DbiResultPtr<DaqCalibRunInfo> rp("DaqCalibRunInfo", vc);

  //prepare output vector
  DaqCalibRunInfoVector* outvec = new DaqCalibRunInfoVector();

  // Check number of entries in result set
  unsigned int numRows = rp.GetNumRows();
  if (numRows < 1){
    log << MSG::WARNING <<"No records found in table DaqCalibRunInfo."<<endreq;
    return outvec;
  }
  const DaqCalibRunInfo* row;
  for (unsigned int idx=0; idx < numRows; idx++){
    row = rp.GetRowByIndex(idx); 
    if(runNo == row->GetRunNo()){
      DaqCalibRunInfo tosave(*row);
      outvec->add(tosave);
    }
  }
  if(outvec->size()>0) return outvec;
 
  log << MSG::WARNING <<"runNo: "<<runNo<<" is not found in table DaqCalibRunInfo."<<endreq;
  return outvec;
}
int DaqRunInfoSvc::dbRecordVector ( const int  runNo,
DatabaseRecordVector vec 
) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 196 of file DaqRunInfoSvc.cc.

{
  stringstream ss_runNo;
  ss_runNo<<runNo;

  string sql;
  sql = "SELECT t1.*"; 
  sql += " FROM DaqRunConfig as t1, DaqRunInfo as t2";
  sql += " WHERE t2.runNo = " + ss_runNo.str();
  sql += " AND t1.schemaVersion = t2.schemaVersion";
  sql += " AND ( t1.dataVersion = t2.dataVersion OR t1.dataVersion = t2.baseVersion AND t1.creationVersion <= t2.dataVersion )";
  sql += " ORDER BY t1.creationVersion DESC, className, objectId, name";
  // ordered by the version of data
         
  DatabaseRecordVector pre_vec;
  m_dbSvc->query(m_dbName, sql, pre_vec);
  
  // filter the pre_vec to ignore the run information of old version
  DatabaseRecordVector::iterator itr;
  DatabaseRecordVector::iterator it;
  for( itr = pre_vec.begin(); itr != pre_vec.end(); itr++){
    bool flag = true;
    if(vec.size() == 0) {
      vec.push_back((*itr));
      continue;
    }
    for( it = vec.begin(); it != vec.end(); it++){
      if((*it)["className"] == (*itr)["className"]
         && (*it)["objectId"] == (*itr)["objectId"]
         && (*it)["name"] == (*itr)["name"]
         && (*it)["parentPosition"] == (*itr)["parentPosition"]){
          flag = false;
          break;
      } // ignore the old version of data
    }
    if(flag) vec.push_back((*itr));
  }
  return 1;
}
int DaqRunInfoSvc::fullRunConfigList ( const int  runNo,
vector< DayaBay::DaqRunConfig > &  vec 
) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 236 of file DaqRunInfoSvc.cc.

{
  DatabaseRecordVector dbRV;
  dbRecordVector(runNo, dbRV);
  
  MsgStream log( msgSvc(), name() );
  log << MSG::DEBUG <<dbRV.size()<<" rows are selected for runNo="<<runNo<<endreq;
  
  DatabaseRecordVector::iterator it ;
  for( it=dbRV.begin(); it != dbRV.end(); it++){
    DayaBay::DaqRunConfig config;
    config.m_SchemaVersion = atoi((*it)["schemaVersion"].c_str());
    config.m_DataVersion = atoi((*it)["dataVersion"].c_str());
    config.m_CreationVersion = atoi((*it)["creationVersion"].c_str());
    config.m_ClassName = (*it)["className"];
    config.m_ObjectId = (*it)["objectId"];
    config.m_Name = (*it)["name"];
    config.m_ParentPosition = atoi((*it)["parentPosition"].c_str());
    config.m_IntValue = atoi((*it)["intValue"].c_str());
    config.m_FloatValue = atof((*it)["floatValue"].c_str());
    config.m_StringValue = (*it)["stringValue"];

    vec.push_back(config);

  }

  return 1;
}
int DaqRunInfoSvc::simpRunConfigList ( const int  runNo,
vector< DayaBay::DaqRunConfig > &  vec 
) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 265 of file DaqRunInfoSvc.cc.

{
  MsgStream log( msgSvc(), name() );

  string runType = GetRunType(runNo);
  DatabaseRecordVector dbRV;
  dbRecordVector(runNo, dbRV);
  DatabaseRecordVector::iterator itr;

  // find objects of detectors, crates, ltbs, fees
  vector<string> dets;
  vector<string> crates;
  vector<string> ltbs;
  vector<string> fees;
  findHWList(dbRV, dets, crates, ltbs, fees);

  // find object of threshld
  vector<string> thrs;
  for( itr = dbRV.begin(); itr != dbRV.end(); itr++){
    if( (*itr)["className"] == "FEE" && stringInVector((*itr)["objectId"], fees) && (*itr)["name"] == "childObjectId_FEEDACThreshold" && (*itr)["stringValue"].find(runType) != string::npos)
        thrs.push_back((*itr)["stringValue"]);
  }
  // find whether the DACSelect=UniformVal
  vector<bool> uniform;
  for( itr = dbRV.begin(); itr != dbRV.end(); itr++){
    if( (*itr)["className"] == "FEEDACThreshold" && stringInVector((*itr)["objectId"], thrs) && (*itr)["name"] == "DACSelect" ){
       if( (*itr)["stringValue"] == "UniformVal" ) 
         uniform.push_back(true);
       else 
         uniform.push_back(false);
    }
  }  
  
  for( itr=dbRV.begin(); itr != dbRV.end(); itr++){
    DayaBay::DaqRunConfig config;
    config.m_SchemaVersion = atoi((*itr)["schemaVersion"].c_str());
    config.m_DataVersion = atoi((*itr)["dataVersion"].c_str());
    config.m_CreationVersion = atoi((*itr)["creationVersion"].c_str());
    config.m_ClassName = (*itr)["className"];
    if(config.m_ClassName == "Partition" 
       || config.m_ClassName == "ROSApplication"
       || config.m_ClassName == "Segment" )
      continue;
    config.m_ObjectId = (*itr)["objectId"];
    if(config.m_ClassName == "FEEDACThreshold" || config.m_ClassName == "LTB_variableReg"){
       if(config.m_ObjectId.find(runType) == string::npos)
         continue;
    } 
    if(config.m_ClassName == "Detector"){
      if(stringInVector(config.m_ObjectId, dets) == 0)
        continue;
    }
    if(config.m_ClassName == "Crate"){
      if(stringInVector(config.m_ObjectId, crates) == 0)
        continue;
    }
    if(config.m_ClassName == "LTB"){
      if(stringInVector(config.m_ObjectId, ltbs) == 0)
        continue;
    }
    if(config.m_ClassName == "FEE"){
      if(stringInVector(config.m_ObjectId, fees) == 0)
        continue;
    }
    if(config.m_ClassName == "FEEDACThreshold"){
      if(stringInVector(config.m_ObjectId, thrs) == 0 )
        continue;
      //if(uniform[stringInVector(config.m_ObjectId, thrs)-1] && (*itr)["name"].find("DACVal_Chanel") != string::npos) 
      //  continue;
    }
 
    config.m_Name = (*itr)["name"];
    if(config.m_Name.find("childClassName") != string::npos)
      continue;
    config.m_ParentPosition = atoi((*itr)["parentPosition"].c_str());
    config.m_IntValue = atoi((*itr)["intValue"].c_str());
    config.m_FloatValue = atof((*itr)["floatValue"].c_str());
    config.m_StringValue = (*itr)["stringValue"];
    bool flag = true; 

    // use the latest version of data.
    if(flag) vec.push_back(config);

  }

  return 1;
}
virtual int IDaqRunInfoSvc::findHWList ( vector< DayaBay::DaqRunConfig cV,
vector< string > &  dets,
vector< string > &  crates,
vector< string > &  ltbs,
vector< string > &  fees 
) [pure virtual]

Implemented in DaqRunInfoSvc.

int DaqRunInfoSvc::findFEEThreshold ( string  runType,
vector< DayaBay::DaqRunConfig cv,
vector< string >  fees,
map< string, string > &  th_obj,
map< string, bool > &  isuni,
map< string, int > &  thres_uni,
map< string, map< string, int > > &  thres 
) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 372 of file DaqRunInfoSvc.cc.

{
  vector<DayaBay::DaqRunConfig>::iterator it;
  for ( it = cv.begin(); it != cv.end(); it++){ 
    if(it->m_ClassName == "FEE" && stringInVector(it->m_ObjectId, fees) && it->m_Name == "childObjectId_FEEDACThreshold" && it->m_StringValue.find(runType) != string::npos)
      th_obj[it->m_ObjectId] = it->m_StringValue;
  }

  map<string, string>::iterator itr;
  for(itr = th_obj.begin(); itr != th_obj.end(); itr++){
    for ( it = cv.begin(); it != cv.end(); it++){
      if(it->m_ClassName == "FEEDACThreshold" && it->m_ObjectId == itr->second && it->m_Name == "DACSelect"){
        if(it->m_StringValue == "UniformVal")
          isuni[itr->first] = true;
        else
          isuni[itr->first] = false;
      }
    }
    map<string, int> amap;
    for ( it = cv.begin(); it != cv.end(); it++){
      if(it->m_ClassName == "FEEDACThreshold" && it->m_ObjectId == itr->second && it->m_Name == "DACUniformVal" && isuni[itr->first])
        thres_uni[itr->first] = it->m_IntValue;
      if(it->m_ClassName == "FEEDACThreshold" && it->m_ObjectId == itr->second && it->m_Name.find("DACVal_Chanel") != string::npos){
        amap[it->m_Name] = it->m_IntValue;
      }
    }
    thres[itr->first] = amap;
  }
  return 1;
}
int DaqRunInfoSvc::findLtbTrigger ( string  runType,
vector< DayaBay::DaqRunConfig cv,
vector< string >  ltbs,
map< string, string > &  mode,
map< string, int > &  source,
map< string, string > &  trig_name,
map< string, map< string, int > > &  trig_thres 
) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 403 of file DaqRunInfoSvc.cc.

{
  vector<DayaBay::DaqRunConfig>::iterator it;
  for ( it = cv.begin(); it != cv.end(); it++){
    if(it->m_ClassName == "LTB" && stringInVector(it->m_ObjectId, ltbs) && it->m_Name == "childObjectId_LTB_variableReg" && it->m_StringValue.find(runType) != string::npos)
      mode[it->m_ObjectId] = it->m_StringValue;
  }

  const int kMANUAL = 1;
  const int kCROSS = 2;
  const int kPERIODIC = 4;
  const int kMULTIPLICITY = 256;
  const int kESUM_ADC = 512;
  const int kHIGH_ESUM_COMP = 1024;
  const int kLOW_ESUM_COMP = 2048;
  const int kALL_ESUM_COMP = 4096;

  map<string, string>::iterator itr;
  for(itr = mode.begin(); itr != mode.end(); itr++){
    std::string name = "";
    map<string, int> threshold;
    for ( it = cv.begin(); it != cv.end(); it++){
      if(it->m_ClassName == "LTB_variableReg" && it->m_Name == "LTB_triggerSource" && it->m_ObjectId == itr->second){
        source[itr->first] = it->m_IntValue;
        if(kMANUAL & it->m_IntValue)
          name += "MANUAL_TRIGGER[1]  ";
        if(kCROSS & it->m_IntValue)
          name += "CROSS_TRIGGER_IN[2]  ";
        if(kPERIODIC & it->m_IntValue)
          name += "PERIODIC_TRIGGER[4]  ";
        if(kMULTIPLICITY & it->m_IntValue)
          name += "MULTIPLICITY_TRIGGER[256]  ";
        if(kESUM_ADC & it->m_IntValue)
          name += "ESUM_ADC_TRG[512]  ";
        if(kHIGH_ESUM_COMP & it->m_IntValue)
          name += "HIGH_ESUM_COMP_TRG[1024]  ";
        if(kLOW_ESUM_COMP & it->m_IntValue)
          name += "LOW_ESUM_COMP_TRG[2048]  ";
        if(kALL_ESUM_COMP & it->m_IntValue)
          name += "ALL_ESUM_COMP_TRG[4096]  ";
      }
    }
    trig_name[itr->first] = name;

    for (it = cv.begin(); it != cv.end(); it++){
      if(it->m_ClassName == "LTB_variableReg" && it->m_ObjectId == itr->second){
        if(trig_name[itr->first].find("MULTIPLICITY_TRIGGER") != string::npos && it->m_Name == "HSUM_trigger_threshold")
          threshold["MULTIPLICITY_TRIGGER"] = it->m_IntValue; 
        if(trig_name[itr->first].find("ESUM_ADC_TRG") != string::npos && it->m_Name == "ESUM_adc_trigger_threshold")
          threshold["ESUM_ADC_TRG"] = it->m_IntValue; 
        if(trig_name[itr->first].find("HIGH_ESUM_COMP_TRG") != string::npos && it->m_Name == "DAC_half_value")
          threshold["HIGH_ESUM_COMP_TRG"] = it->m_IntValue; 
        if(trig_name[itr->first].find("LOW_ESUM_COMP_TRG") != string::npos && it->m_Name == "DAC_half_value")
          threshold["LOW_ESUM_COMP_TRG"] = it->m_IntValue; 
        if(trig_name[itr->first].find("ALL_ESUM_COMP_TRG") != string::npos && it->m_Name == "DAC_total_value")
          threshold["ALL_ESUM_COMP_TRG"] = it->m_IntValue;
      }
    }
    trig_thres[itr->first] = threshold;
  }
  return 1;
}
string DaqRunInfoSvc::GetRunType ( const int  runNo) [pure virtual]

Implemented in DaqRunInfoSvc.

Definition at line 486 of file DaqRunInfoSvc.cc.

{
  // find the runType
  stringstream ss_runNo;
  ss_runNo<<runNo;
  string sql = "select runType from DaqRunInfo where runNo = " + ss_runNo.str(); 
  DatabaseRecordVector runVec;
  m_dbSvc->query(m_dbName, sql, runVec);
  DatabaseRecord runRecord = runVec[0]; // runNo is unique
  string runType = runRecord["runType"];

  return runType;
}

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:05 for DaqRunInfoSvc by doxygen 1.7.4