CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FWCore/Framework/interface/TriggerNamesService.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_TriggerNamesService_h
00002 #define FWCore_Framework_TriggerNamesService_h
00003 
00004 // -*- C++ -*-
00005 /*
00006 
00007  Original Author:  Jim Kowalkowski 26-01-06
00008 
00009  $Id: TriggerNamesService.h,v 1.11 2011/12/02 08:33:02 fwyzard Exp $
00010 
00011  This service makes the trigger names available.  They are provided
00012  in the same order that the pass/fail status of these triggers is
00013  recorded in the TriggerResults object.  These trigger names are
00014  the names of the paths that appear in the configuration (excluding
00015  end paths).  The order is the same as in the configuration.
00016 
00017  There are also accessors for the end path names.  
00018 
00019  There are other accessors for other trigger related information from the
00020  job configuration: the process name, whether a report on trigger results
00021  was requested and the parameter set containing the list of trigger paths.
00022 
00023  Almost all the functions return information related to the current
00024  process only.  The second and third getTrigPaths functions are exceptions.
00025  They will return the trigger path names from previous processes.
00026 
00027  Unit tests for parts of this class are in FWCore/Integration/run_SelectEvents.sh
00028  and the code it invokes.
00029 
00030 */
00031 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 
00034 #include <string>
00035 #include <map>
00036 #include <vector>
00037 
00038 namespace edm {
00039 
00040   class TriggerResults;
00041 
00042   namespace service {
00043     class TriggerNamesService
00044     {
00045     public:
00046 
00047       typedef std::vector<std::string> Strings;
00048       typedef std::map<std::string, unsigned int> PosMap;
00049       typedef PosMap::size_type size_type;
00050 
00051       explicit TriggerNamesService(ParameterSet const& proc_pset);
00052       // Default copy, copy assignment, d'tor all do the right thing.
00053 
00054       // trigger names for the current process
00055 
00056       // Return the number of trigger paths in the current process.
00057       size_type size() const { return trignames_.size(); }
00058       Strings const& getTrigPaths() const { return trignames_; }
00059       std::string const&  getTrigPath(size_type const i) const { return trignames_.at(i);}
00060       size_type  findTrigPath(std::string const& name) const { return find(trigpos_,name);}
00061 
00062       // Get the ordered vector of trigger names that corresponds to the bits
00063       // in the TriggerResults object.  Unlike the other functions in this class,
00064       // the next two functions will retrieve the names for previous processes.
00065       // If the TriggerResults object is from the current process, this only
00066       // works for modules in end paths, because the TriggerResults object is
00067       // not created until the normal paths complete execution.
00068       // Returns false if it fails to find the trigger path names.
00069       bool getTrigPaths(TriggerResults const& triggerResults,
00070                         Strings& trigPaths);
00071 
00072       // This is the same as the previous function except the value returned in
00073       // the last argument indicates whether the results were retrieved from the
00074       // ParameterSet registry.  This will always be true except in old data where
00075       // the trigger names were stored inside of the TriggerResults object.
00076       bool getTrigPaths(TriggerResults const& triggerResults,
00077                         Strings& trigPaths,
00078                         bool& fromPSetRegistry);
00079 
00080       Strings const& getEndPaths() const { return end_names_; }
00081       std::string const&  getEndPath(size_type const i) const { return end_names_.at(i);}
00082       size_type  findEndPath(std::string const& name) const { return find(end_pos_,name);}
00083 
00084       Strings const& getTrigPathModules(std::string const& name) const {
00085         return modulenames_.at(find(trigpos_,name));
00086       }
00087       Strings const& getTrigPathModules(size_type const i) const {
00088         return modulenames_.at(i);
00089       }
00090       std::string const&  getTrigPathModule (std::string const& name, size_type const j) const {
00091         return (modulenames_.at(find(trigpos_,name))).at(j);
00092       }
00093       std::string const&  getTrigPathModule (size_type const i, size_type const j) const {
00094         return (modulenames_.at(i)).at(j);
00095       }
00096 
00097       Strings const& getEndPathModules(std::string const& name) const {
00098         return end_modulenames_.at(find(end_pos_,name));
00099       }
00100       Strings const& getEndPathModules(size_type const i) const {
00101         return end_modulenames_.at(i);
00102       }
00103       std::string const&  getEndPathModule (std::string const& name, size_type const j) const {
00104         return (end_modulenames_.at(find(end_pos_,name))).at(j);
00105       }
00106       std::string const&  getEndPathModule (size_type const i, size_type const j) const {
00107         return (end_modulenames_.at(i)).at(j);
00108       }
00109 
00110       size_type find (PosMap const& posmap, std::string const& name) const {
00111         PosMap::const_iterator const pos(posmap.find(name));
00112         if (pos == posmap.end()) {
00113           return posmap.size();
00114         } else {
00115           return pos->second;
00116         }
00117       }
00118 
00119       void loadPosMap(PosMap& posmap, Strings const& names) {
00120         size_type const n(names.size());
00121         for (size_type i = 0; i != n; ++i) {
00122           posmap[names[i]] = i;
00123         }
00124       }
00125       
00126       std::string const& getProcessName() const { return process_name_; }
00127       bool wantSummary() const { return wantSummary_; }
00128 
00129       // Parameter set containing the trigger paths
00130       edm::ParameterSet const& getTriggerPSet() const { return trigger_pset_; }
00131 
00132     private:
00133 
00134       edm::ParameterSet trigger_pset_;
00135 
00136       Strings trignames_;
00137       PosMap  trigpos_;
00138       Strings end_names_;
00139       PosMap  end_pos_;
00140 
00141       std::vector<Strings> modulenames_;        // modules on trigger paths
00142       std::vector<Strings> end_modulenames_;    // modules on endpaths
00143 
00144       std::string process_name_;
00145       bool wantSummary_;
00146     };
00147   }
00148 }
00149 
00150 #endif