Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:23

0001 #include "L1TriggerConfig/L1ScalesProducers/interface/ScaleRecordHelper.h"
0002 #include <sstream>
0003 
0004 using namespace std;
0005 
0006 ScaleRecordHelper::ScaleRecordHelper(const std::string& binPrefix, unsigned int maxBin) {
0007   binPrefix_ = binPrefix;
0008   maxBin_ = maxBin;
0009 }
0010 
0011 void ScaleRecordHelper::extractScales(l1t::OMDSReader::QueryResults& record, vector<double>& destScales) {
0012   const coral::AttributeList& row = record.attributeLists()[0];
0013   /* The <= in the next line is of crucial importance, since putting the intuitive < 
0014      there will lead to a world of pain (because the scale then has a max entry of 0,
0015      and very bad things happen). See RFC968.
0016    */
0017   for (unsigned int i = 0; i <= maxBin_; ++i) {
0018     /* We actually would like double values, but CORAL thinks that the DB contains
0019        float, so we have to eat that. 
0020        Also: This assumes that there are no other columns than the ones we added,
0021        maybe this should be made more explicit by handling the whole query in here? */
0022     destScales.push_back(row[i].data<float>());
0023   }
0024 }
0025 
0026 void ScaleRecordHelper::pushColumnNames(vector<string>& columns) {
0027   for (unsigned int i = 0; i <= maxBin_; ++i) {
0028     columns.push_back(columnName(i));
0029   }
0030 }
0031 
0032 const string ScaleRecordHelper::columnName(unsigned int bin) {
0033   ostringstream name;
0034   name << binPrefix_ << '_' << bin;
0035   return name.str();
0036 }