Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:15

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWHLTValidator
0005 //
0006 
0007 // system include files
0008 #include <algorithm>
0009 #include <cstring>
0010 #include <boost/regex.hpp>
0011 
0012 // user include files
0013 #include "Fireworks/Core/interface/FWHLTValidator.h"
0014 #include "Fireworks/Core/interface/FWGUIManager.h"
0015 #include "Fireworks/Core/interface/fwLog.h"
0016 
0017 #include "DataFormats/Common/interface/Handle.h"
0018 #include "DataFormats/Common/interface/TriggerResults.h"
0019 
0020 #include "FWCore/Common/interface/TriggerNames.h"
0021 #include "FWCore/Common/interface/EventBase.h"
0022 
0023 void FWHLTValidator::fillOptions(const char* iBegin,
0024                                  const char* iEnd,
0025                                  std::vector<std::pair<std::shared_ptr<std::string>, std::string> >& oOptions) const {
0026   oOptions.clear();
0027   std::string part(iBegin, iEnd);
0028   part = boost::regex_replace(part, boost::regex(".*?(\\&\\&|\\|\\||\\s)+"), "");
0029 
0030   if (m_triggerNames.empty()) {
0031     edm::Handle<edm::TriggerResults> hTriggerResults;
0032     edm::TriggerNames const* triggerNames(nullptr);
0033     try {
0034       edm::InputTag tag("TriggerResults", "", m_process.c_str());
0035       const edm::EventBase* event = FWGUIManager::getGUIManager()->getCurrentEvent();
0036       event->getByLabel(tag, hTriggerResults);
0037       triggerNames = &event->triggerNames(*hTriggerResults);
0038     } catch (...) {
0039       fwLog(fwlog::kWarning) << " no trigger results with process name " << m_process << "  is available" << std::endl;
0040       return;
0041     }
0042     for (unsigned int i = 0; i < triggerNames->size(); ++i)
0043       m_triggerNames.push_back(triggerNames->triggerName(i));
0044     std::sort(m_triggerNames.begin(), m_triggerNames.end());
0045   }
0046 
0047   //only use add items which begin with the part of the member we are trying to match
0048   unsigned int part_size = part.size();
0049   for (std::vector<std::string>::const_iterator trigger = m_triggerNames.begin(); trigger != m_triggerNames.end();
0050        ++trigger)
0051     if (part == trigger->substr(0, part_size)) {
0052       oOptions.push_back(std::make_pair(std::make_shared<std::string>(*trigger),
0053                                         trigger->substr(part_size, trigger->size() - part_size)));
0054     }
0055 }
0056 
0057 //
0058 // static member functions
0059 //