CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Fireworks/Core/src/FWHLTValidator.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWHLTValidator
00005 // $Id: FWHLTValidator.cc,v 1.8 2011/02/18 17:38:42 amraktad Exp $
00006 //
00007 
00008 // system include files
00009 #include <algorithm>
00010 #include <cstring>
00011 #include <boost/regex.hpp>
00012 
00013 // user include files
00014 #include "Fireworks/Core/interface/FWHLTValidator.h"
00015 #include "Fireworks/Core/interface/FWGUIManager.h"
00016 #include "Fireworks/Core/interface/fwLog.h"
00017 
00018 #include "DataFormats/Common/interface/Handle.h"
00019 #include "DataFormats/Common/interface/TriggerResults.h"
00020 
00021 #include "FWCore/Common/interface/TriggerNames.h"
00022 #include "FWCore/Common/interface/EventBase.h"
00023 
00024 void
00025 FWHLTValidator::fillOptions(const char* iBegin, const char* iEnd,
00026                             std::vector<std::pair<boost::shared_ptr<std::string>, std::string> >& oOptions) const
00027 {
00028    oOptions.clear();
00029    std::string part(iBegin,iEnd);
00030    part = boost::regex_replace(part,boost::regex(".*?(\\&\\&|\\|\\||\\s)+"),"");
00031 
00032    if (m_triggerNames.empty()){
00033      edm::Handle<edm::TriggerResults> hTriggerResults;
00034      edm::TriggerNames const* triggerNames(0);
00035      try
00036      {
00037        edm::InputTag tag("TriggerResults", "", m_process.c_str());
00038        const edm::EventBase* event = FWGUIManager::getGUIManager()->getCurrentEvent();
00039        event->getByLabel(tag, hTriggerResults);
00040        triggerNames = & event->triggerNames(*hTriggerResults);
00041      } catch (...){
00042         fwLog(fwlog::kWarning) << " no trigger results with process name "<< m_process <<"  is available" << std::endl;
00043        return;
00044      }
00045      for(unsigned int i=0; i<triggerNames->size(); ++i)
00046        m_triggerNames.push_back(triggerNames->triggerName(i));
00047      std::sort(m_triggerNames.begin(),m_triggerNames.end());
00048    }
00049 
00050    //only use add items which begin with the part of the member we are trying to match
00051    unsigned int part_size = part.size();
00052    for(std::vector<std::string>::const_iterator trigger = m_triggerNames.begin();
00053        trigger != m_triggerNames.end(); ++trigger)
00054      if(part == trigger->substr(0,part_size) ) {
00055        oOptions.push_back(std::make_pair(boost::shared_ptr<std::string>(new std::string(*trigger)),
00056                                          trigger->substr(part_size,trigger->size()-part_size)));
00057      }
00058 }
00059 
00060 //
00061 // static member functions
00062 //