PixelEnableMasks.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/DAQConfig/PixelEnableMasks.h>
2 #include <DatabaseUtils/DAQConfig/DBColumnParams.h>
3 #include <DatabaseUtils/DAQConfig/NamedConfigUtils.h>
4 #include <algorithm>
5 
6 namespace dbutils {
7 namespace daqconfig {
8 
11  std::vector<std::string> dcmList)
12 {
13  std::vector<int64_t> subsystemConfigIdList;
15  getSubsystemConfigIdAncestry(nameSpec, subsystemConfigIdList);
16  if (! status) {return;}
17  std::sort(dcmList.begin(), dcmList.end());
18 
19  {
20  ConfigDataSelector cfgSelector;
22  dcmList[0], dcmList[dcmList.size()-1]);
23  //std::cout << dcmList[0] << std::endl;
24 
25  std::vector<std::string> dataColumnsOfInterest;
26  dataColumnsOfInterest.push_back("mask");
27 
28  std::string fname("NovaDatabase/tables/DAQConfig/FEBEnableMasks.xml");
30  reset(new ConfigDataTree(fname, subsystemConfigIdList, cfgSelector,
31  dataColumnsOfInterest));
32  }
33 
34  {
35  ConfigDataSelector cfgSelector;
37  dcmList[0], dcmList[dcmList.size()-1]);
39 
40  std::vector<std::string> dataColumnsOfInterest;
41  dataColumnsOfInterest.push_back("mask");
42 
43  std::string fname("NovaDatabase/tables/DAQConfig/PixelEnableMasks.xml");
45  reset(new ConfigDataTree(fname, subsystemConfigIdList, cfgSelector,
46  dataColumnsOfInterest));
47  }
48 
49  _hasValidData = _febEnableMaskDataSet.get() != 0 &&
50  _febEnableMaskDataSet->hasValidData() &&
51  _pixelEnableDataSet.get() != 0 &&
52  _pixelEnableDataSet->hasValidData();
53 }
54 
56 PixelEnableMasks(const int64_t& globalConfigId,
57  std::vector<std::string> dcmList)
58 {
59  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL, IDSpec::DAQ);
60  std::vector<int64_t> subsystemConfigIdList;
64  DCM_SUBSYSTEM_NAME,
66  HARDWARE_CONFIG_TYPE,
67  subsystemConfigIdList);
68  if (! status) {return;}
69  std::sort(dcmList.begin(), dcmList.end());
70 
71  {
72  ConfigDataSelector cfgSelector;
74  dcmList[0], dcmList[dcmList.size()-1]);
75  //std::cout << dcmList[0] << std::endl;
76 
77  std::vector<std::string> dataColumnsOfInterest;
78  dataColumnsOfInterest.push_back("mask");
79 
80  std::string fname("NovaDatabase/tables/DAQConfig/FEBEnableMasks.xml");
82  reset(new ConfigDataTree(fname, subsystemConfigIdList, cfgSelector,
83  dataColumnsOfInterest));
84  }
85 
86  {
87  ConfigDataSelector cfgSelector;
89  dcmList[0], dcmList[dcmList.size()-1]);
91 
92  std::vector<std::string> dataColumnsOfInterest;
93  dataColumnsOfInterest.push_back("mask");
94 
95  std::string fname("NovaDatabase/tables/DAQConfig/PixelEnableMasks.xml");
97  reset(new ConfigDataTree(fname, subsystemConfigIdList, cfgSelector,
98  dataColumnsOfInterest));
99  }
100 
101  _hasValidData = _febEnableMaskDataSet.get() != 0 &&
102  _febEnableMaskDataSet->hasValidData() &&
103  _pixelEnableDataSet.get() != 0 &&
104  _pixelEnableDataSet->hasValidData();
105 }
106 
109 {
110  int count = 0;
111  for (int ifeb = 0; ifeb < 64; ++ifeb) {
112  count += getEnabledPixelCountForFEB(dcmName, ifeb);
113  }
114  return count;
115 }
116 
118 getFEBEnableMask(const std::string& dcmName, int64_t& febMask)
119 {
120  if (_febEnableMaskDataSet.get() == 0) {return false;}
121  return _febEnableMaskDataSet->getEffectiveValueFor1Key(dcmName, "mask",
122  febMask);
123 }
124 
126 febIsEnabled(const std::string& dcmName, const int& febId)
127 {
128  if (_febEnableMaskDataSet.get() == 0) {return false;}
129  int64_t febMask;
130  if (! _febEnableMaskDataSet->getEffectiveValueFor1Key(dcmName, "mask",
131  febMask)) {
132  return false;
133  }
134 
135  int64_t _64BitOne = 1;
136  return ((febMask & (_64BitOne << febId)) != 0);
137 }
138 
141  const int& febId)
142 {
143  if (! this->febIsEnabled(dcmName, febId)) {return 0;}
144 
145  if (_pixelEnableDataSet.get() == 0) {return 0;}
146  int32_t pixelMask;
147  if (! _pixelEnableDataSet->getEffectiveValueFor2Keys(dcmName, febId,
148  "mask", pixelMask)) {
149  return 0;
150  }
151 
152  int count = 0;
153  for (int ipix = 0; ipix < 32; ++ipix) {
154  if ((pixelMask & (1 << ipix)) != 0) {
155  ++count;
156  }
157  }
158  return count;
159 }
160 
163  const int& febId, int32_t& pixelMask)
164 {
165  if (_pixelEnableDataSet.get() == 0) {return false;}
166  return _pixelEnableDataSet->getEffectiveValueFor2Keys(dcmName, febId,
167  "mask", pixelMask);
168 }
169 
171 pixelIsEnabled(const std::string& dcmName,const int& febId,const int& pixelId)
172 {
173  if (_pixelEnableDataSet.get() == 0) {return false;}
174  int32_t pixelMask;
175  if (! _pixelEnableDataSet->getEffectiveValueFor2Keys(dcmName, febId,
176  "mask", pixelMask)) {
177  return false;
178  }
179 
180  return ((pixelMask & (1 << pixelId)) != 0);
181 }
182 
183 } // end of namespace daqconfig
184 } // end of namespace dbutils
void addSelectionColumn(std::string columnName)
int status
Definition: fabricate.py:1613
bool getFEBEnableMask(const std::string &dcmName, int64_t &febMask)
boost::shared_ptr< ConfigDataTree > _pixelEnableDataSet
PixelEnableMasks(const SubsystemNameSpec &nameSpec, std::vector< std::string > dcmList)
static bool getSubsystemConfigIdAncestry(const SubsystemNameSpec &subsystemNameSpec, std::vector< int64_t > &idList, const std::string &subsystemNamesTableFile=DEFAULT_SUBSYSTEM_NAMES_TABLE_FILE)
bool getPixelEnableMask(const std::string &dcmName, const int &febId, int32_t &pixelMask)
bool pixelIsEnabled(const std::string &dcmName, const int &febId, const int &pixelId)
boost::shared_ptr< ConfigDataTree > _febEnableMaskDataSet
int getEnabledPixelCountForFEB(const std::string &dcmName, const int &febId)
bool febIsEnabled(const std::string &dcmName, const int &febId)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
static const std::string DCMID_COLUMN_NAME
static const std::string FEBID_COLUMN_NAME
int getEnabledPixelCountForDCM(const std::string &dcmName)
static bool getSubsystemConfigIdAncestryFromGlobalId(const IDSpec &globalConfigId, const std::string &subsystemName, const std::string &subsystemConfigType, std::vector< int64_t > &idList, const std::string &globalNamesTableFile=DEFAULT_GLOBAL_NAMES_TABLE_FILE, const std::string &subsystemNamesTableFile=DEFAULT_SUBSYSTEM_NAMES_TABLE_FILE)