CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/FWCore/Framework/src/TriggerNamesService.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Implementation:
00004 //
00005 // Original Author:  Jim Kowalkowski
00006 //
00007 
00008 #include "FWCore/Framework/interface/TriggerNamesService.h"
00009 #include "DataFormats/Common/interface/TriggerResults.h"
00010 #include "FWCore/ParameterSet/interface/Registry.h"
00011 #include "FWCore/Utilities/interface/ThreadSafeRegistry.h"
00012 #include "FWCore/Utilities/interface/Exception.h"
00013 #include "FWCore/Utilities/interface/EDMException.h"
00014 #include "FWCore/Utilities/interface/Algorithms.h"
00015 
00016 
00017 namespace edm {
00018   namespace service {
00019 
00020     TriggerNamesService::TriggerNamesService(const ParameterSet& pset) {
00021 
00022       trigger_pset_ = 
00023         pset.getParameterSet("@trigger_paths");
00024 
00025       trignames_ = trigger_pset_.getParameter<Strings>("@trigger_paths");
00026       end_names_ = pset.getParameter<Strings>("@end_paths");
00027 
00028       ParameterSet defopts;
00029       ParameterSet const& opts = 
00030         pset.getUntrackedParameterSet("options", defopts);
00031       wantSummary_ =
00032         opts.getUntrackedParameter("wantSummary", false);
00033 
00034       process_name_ = pset.getParameter<std::string>("@process_name");
00035 
00036       loadPosMap(trigpos_,trignames_);
00037       loadPosMap(end_pos_,end_names_);
00038 
00039       const unsigned int n(trignames_.size());
00040       for(unsigned int i=0;i!=n;++i) {
00041         modulenames_.push_back(pset.getParameter<Strings>(trignames_[i]));
00042       }
00043       for(unsigned int i = 0; i != end_names_.size(); ++i) {
00044         end_modulenames_.push_back(pset.getParameter<Strings>(end_names_[i]));
00045       }
00046     }
00047 
00048     bool
00049     TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
00050                                       Strings& trigPaths,
00051                                       bool& fromPSetRegistry) {
00052 
00053       // Get the parameter set containing the trigger names from the parameter set registry
00054       // using the ID from TriggerResults as the key used to find it.
00055       ParameterSet const* pset=0;
00056       pset::Registry* psetRegistry = pset::Registry::instance();
00057       if (0 != (pset=psetRegistry->getMapped(triggerResults.parameterSetID()))) {
00058 
00059         // Check to make sure the parameter set contains
00060         // a Strings parameter named "trigger_paths".
00061         // We do not want to throw an exception if it is not there
00062         // for reasons of backward compatibility
00063         Strings const & psetNames = pset->getParameterNamesForType<Strings>();
00064         std::string name("@trigger_paths");
00065         if (search_all(psetNames, name)) {
00066           // It is there, get it
00067           trigPaths = pset->getParameter<Strings>("@trigger_paths");
00068 
00069           // This should never happen
00070           if (trigPaths.size() != triggerResults.size()) {
00071             throw edm::Exception(edm::errors::Unknown)
00072               << "TriggerNamesService::getTrigPaths, Trigger names vector and\n"
00073                  "TriggerResults are different sizes.  This should be impossible,\n"
00074                  "please send information to reproduce this problem to\n"
00075                  "the edm developers.\n";
00076           }
00077 
00078           fromPSetRegistry = true;
00079           return true;
00080         }
00081       }
00082 
00083       fromPSetRegistry = false;
00084 
00085       // In older versions of the code the the trigger names were stored
00086       // inside of the TriggerResults object.  This will provide backward
00087       // compatibility.
00088       if (triggerResults.size() == triggerResults.getTriggerNames().size()) {
00089         trigPaths = triggerResults.getTriggerNames();
00090         return true;
00091       }
00092 
00093       return false;
00094     }
00095 
00096     bool
00097     TriggerNamesService::getTrigPaths(TriggerResults const& triggerResults,
00098                                       Strings& trigPaths) {
00099       bool dummy;
00100       return getTrigPaths(triggerResults, trigPaths, dummy);
00101     }
00102   }
00103 }