Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:17

0001 #include "CondFormats/HLTObjects/interface/AlCaRecoTriggerBits.h"
0002 
0003 AlCaRecoTriggerBits::AlCaRecoTriggerBits() {}
0004 AlCaRecoTriggerBits::~AlCaRecoTriggerBits() {}
0005 
0006 const std::string::value_type AlCaRecoTriggerBits::delimeter_ = ';';  // separator
0007 
0008 //_____________________________________________________________________
0009 std::string AlCaRecoTriggerBits::compose(const std::vector<std::string> &paths) const {
0010   std::string mergedPaths;
0011   for (std::vector<std::string>::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath) {
0012     if (iPath != paths.begin())
0013       mergedPaths += delimeter_;
0014     if (iPath->find(delimeter_) != std::string::npos) {
0015       // What to do in CondFormats?
0016       // cms::Exception? std::cerr? edm::LogError?
0017     }
0018     mergedPaths += *iPath;
0019   }
0020 
0021   // Special case: DB cannot store empty strings, see e.g.
0022   // https://hypernews.cern.ch/HyperNews/CMS/get/database/674.html ,
0023   // so choose delimeter_ for that - it cannot appear in a path anyway.
0024   if (mergedPaths.empty())
0025     mergedPaths = delimeter_;
0026 
0027   return mergedPaths;
0028 }
0029 
0030 //_____________________________________________________________________
0031 std::vector<std::string> AlCaRecoTriggerBits::decompose(const std::string &s) const {
0032   // decompose 's' into its parts that are separated by 'delimeter_'
0033   // (similar as in
0034   //  Alignment/CommonAlignmentAlgorithm/src/AlignmentParameterSelector.cc)
0035 
0036   std::vector<std::string> result;
0037   if (!(s.size() == 1 && s[0] == delimeter_)) {
0038     // delimeter_ only indicates an empty list as DB cannot store empty strings
0039     std::string::size_type previousPos = 0;
0040     while (true) {
0041       const std::string::size_type delimiterPos = s.find(delimeter_, previousPos);
0042       if (delimiterPos == std::string::npos) {
0043         result.push_back(s.substr(previousPos));  // until end
0044         break;
0045       }
0046       result.push_back(s.substr(previousPos, delimiterPos - previousPos));
0047       previousPos = delimiterPos + 1;  // +1: skip delim
0048     }
0049   }
0050 
0051   return result;
0052 }