CMS 3D CMS Logo

TriggerNames.h

Go to the documentation of this file.
00001 #ifndef Framework_TRIGGERNAMES_h
00002 #define Framework_TRIGGERNAMES_h
00003 
00004 // -*- C++ -*-
00005 /*
00006 
00007  Original Author:  W. David Dagenhart 1 June 2007
00008 
00009  $Id: TriggerNames.h,v 1.1 2007/06/15 18:41:46 wdd Exp $
00010 
00011  Used to access the names and indices of the triggers corresponding
00012  to a particular TriggerResults object.  Uses the TriggerNamesService
00013  to get those names.
00014 
00015  This class is smart enough to only update the names and index map
00016  when the ID stored in the TriggerResults object changes (and it lets
00017  you know when that happens).
00018 
00019  Should you use this class or the TriggerNamesService directly?  If
00020  you are interested in the names for the current process, it is
00021  better to use the service directly.  On the other hand for previous
00022  processes, the service will only return a vector with all the
00023  trigger names.  This class has accessors in that can return one
00024  name when given an index and vice versa. If you need those accessors
00025  then you might want to use this class.  The service won't do that
00026  for previous processes. But this class requires some additional
00027  memory and CPU overhead to build and store the trigger names and
00028  the map to indices (which is why they are not stored in the service
00029  to begin with, in some cases there might be many sets of trigger
00030  names).  The combination of this class and the service gives one
00031  options to optimize memory, CPU usage, and convenience for different
00032  use cases.
00033 
00034 */
00035 
00036 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00037 
00038 #include <string>
00039 #include <map>
00040 #include <vector>
00041 
00042 namespace edm {
00043 
00044   class TriggerResults;
00045 
00046   class TriggerNames {
00047 
00048   public:
00049 
00050     typedef std::vector<std::string> Strings;
00051     typedef std::map<std::string, unsigned int> IndexMap;
00052 
00053     TriggerNames();
00054     TriggerNames(TriggerResults const& triggerResults);
00055 
00056     // Returns true if the trigger names actually change.
00057     // If the ID stored in TriggerResults is the same
00058     // as the one from the previous call to init, then
00059     // the trigger names are also the same.  In this case,
00060     // this function immediately returns false and does not
00061     // waste any time or CPU cycles.
00062     bool init(TriggerResults const& triggerResults);
00063 
00064     Strings const& triggerNames() const;
00065 
00066     // Throws if the number is out of range.
00067     std::string const& triggerName(unsigned int index) const;
00068 
00069     // If the input name is not known, this returns a value
00070     // equal to the size.
00071     unsigned int triggerIndex(std::string const& name) const;
00072 
00073     // The number of trigger names.
00074     Strings::size_type size() const;
00075 
00076   private:
00077 
00078     bool psetID_valid_;
00079     ParameterSetID psetID_;
00080 
00081     Strings triggerNames_;
00082     IndexMap indexMap_;
00083 
00084   };
00085 }
00086 
00087 #endif

Generated on Tue Jun 9 17:35:52 2009 for CMSSW by  doxygen 1.5.4