otsdaq_components  v2_04_01
DACsConfigurationBase.cc
1 #include "otsdaq-core/ConfigurationDataFormats/DACsTableBase.h"
2 
3 #include <iostream>
4 
5 using namespace ots;
6 
7 //==============================================================================
8 DACsTableBase::DACsTableBase(std::string configurationName,
9  unsigned int rocNameColumn,
10  unsigned int firstDAC,
11  unsigned int lastDAC)
12  : TableBase(configurationName)
13  , rocNameColumn_(rocNameColumn)
14  , firstDAC_(firstDAC)
15  , lastDAC_(lastDAC)
16 {
17 }
18 
19 //==============================================================================
20 DACsTableBase::~DACsTableBase(void) {}
21 
22 //==============================================================================
23 void DACsTableBase::init(ConfigurationManager* configManager)
24 {
25  nameToROCDACsMap_.clear();
26 
27  std::string tmpDetectorID;
28  std::string tmpDACName;
29  unsigned int tmpDACValue;
30  for(unsigned int row = 0; row < TableBase::activeTableView_->getNumberOfRows(); row++)
31  {
32  TableBase::activeTableView_->getValue(tmpDetectorID, row, rocNameColumn_);
33  nameToROCDACsMap_[tmpDetectorID] = ROCDACs();
34  ROCDACs& aROCDACs = nameToROCDACsMap_[tmpDetectorID];
35  for(unsigned int col = firstDAC_; col <= lastDAC_; col++)
36  {
37  TableBase::activeTableView_->getValue(tmpDACValue, row, col);
38  tmpDACName = TableBase::activeTableView_->getColumnInfo(col).getName();
39  aROCDACs.setDAC(tmpDACName, dacNameToDACAddress_[tmpDACName], tmpDACValue);
40  // std::cout << __COUT_HDR_FL__ << "DAC. Name: " << tmpDACName << " addr: " <<
41  // dacNameToDACAddress_[tmpDACName] << " val: " << tmpDACValue << std::endl;
42  }
43  }
44 }
45 
46 //==============================================================================
47 const ROCDACs& DACsTableBase::getROCDACs(std::string rocName) const
48 {
49  // FIXME This check should be removed when you are sure you don't have inconsistencies
50  // between configurations
51  if(nameToROCDACsMap_.find(rocName) == nameToROCDACsMap_.end())
52  {
53  std::cout << __COUT_HDR_FL__ << "ROC named " << rocName
54  << " doesn't exist in any DAC configuration." << std::endl;
55  assert(0);
56  }
57  //
58  // for(ots::DACList::const_iterator it =
59  // nameToROCDACsMap_.find(rocName)->second.getDACList().begin(); it !=
60  // nameToROCDACsMap_.find(rocName)->second.getDACList().end(); ++it) std::cout <<
61  //__COUT_HDR_FL__ << "DAC Name :" << it->first << ", value: " << it->second.second <<
62  // std::endl;
63  return nameToROCDACsMap_.find(rocName)->second;
64 }