CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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.10 2007/09/27 14:30:24 paterno 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       size_type find (PosMap const& posmap, std::string const& name) const {
00098         PosMap::const_iterator const pos(posmap.find(name));
00099         if (pos == posmap.end()) {
00100           return posmap.size();
00101         } else {
00102           return pos->second;
00103         }
00104       }
00105 
00106       void loadPosMap(PosMap& posmap, Strings const& names) {
00107         size_type const n(names.size());
00108         for (size_type i = 0; i != n; ++i) {
00109           posmap[names[i]] = i;
00110         }
00111       }
00112       
00113       std::string const& getProcessName() const { return process_name_; }
00114       bool wantSummary() const { return wantSummary_; }
00115 
00116       // Parameter set containing the trigger paths
00117       edm::ParameterSet const& getTriggerPSet() const { return trigger_pset_; }
00118 
00119     private:
00120 
00121       edm::ParameterSet trigger_pset_;
00122 
00123       Strings trignames_;
00124       PosMap  trigpos_;
00125       Strings end_names_;
00126       PosMap  end_pos_;
00127 
00128       std::vector<Strings> modulenames_; // of modules on trigger paths
00129 
00130       std::string process_name_;
00131       bool wantSummary_;
00132     };
00133   }
00134 }
00135 
00136 #endif