CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/EventFilter/StorageManager/interface/TriggerSelector.h

Go to the documentation of this file.
00001 // $Id: TriggerSelector.h,v 1.7 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_TriggerSelector_h
00005 #define EventFilter_StorageManager_TriggerSelector_h
00006 
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "DataFormats/Common/interface/HLTPathStatus.h"
00009 #include "DataFormats/Common/interface/TriggerResults.h"
00010 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00011 #include "FWCore/Framework/interface/EventSelector.h"
00012 
00013 #include "boost/shared_ptr.hpp"
00014 
00015 #include <vector>
00016 #include <string>
00017 
00018 namespace stor
00019 {
00020 
00029   class TriggerSelector
00030   {
00031     public:
00032 
00033       typedef std::vector<std::string> Strings;
00034 
00038       TriggerSelector(Strings const& pathspecs,
00039           Strings const& names);
00040 
00045       TriggerSelector(edm::ParameterSet const& pset,
00046           Strings const& triggernames, bool old_ = false);
00047 
00051       TriggerSelector(std::string const& expression, Strings const& triggernames);
00052 
00053       ~TriggerSelector() {};
00054 
00058       bool wantAll() const { 
00059         //if (useOld_) return eventSelector_->wantAll();
00060         return acceptAll_; 
00061       }
00062 
00066       bool acceptEvent(edm::TriggerResults const&) const;
00067 
00068       /*
00069        * Takes array of trigger results and a number of triggers in array and returns
00070        * if it passes selection
00071        */
00072       bool acceptEvent(unsigned char const*, int) const;
00073 
00074       /*
00075        * Returns if HLTGlobalStatus passes selection
00076        */
00077       bool returnStatus(edm::HLTGlobalStatus const& trStatus) const {
00078         return masterElement_->returnStatus(trStatus);
00079       }
00080 
00081       /*
00082        * Does XMl compatible formatting of the selection string
00083        */
00084       static std::string makeXMLString(std::string const& input);
00085 
00086       /*
00087        * Obsolete: Returns SelectedEvents vector from ParameterSet
00088        */
00089       static std::vector<std::string>
00090         getEventSelectionVString(edm::ParameterSet const& pset);
00091 
00092     private:
00093 
00094       bool acceptAll_;
00095 
00096       /*
00097        * Starts parsing selection string
00098        */
00099       void init(std::string const& path, Strings const& triggernames);
00100 
00101       /* 
00102        * Removes extra spaces from string
00103        */
00104       static std::string trim(std::string input);
00105 
00106       /*
00107        * Class used for storing internal representation of the selection string
00108        */
00109       class TreeElement {
00110 
00111         enum TreeOperator {
00112           NonInit = 0,
00113           AND = 1,
00114           OR  = 2,
00115           NOT = 3,
00116           BR = 4
00117         };
00118 
00119         public:
00120 
00121         /*
00122          * Parser of selection string. Splits string into tokens and initializes new elements to parse them.
00123          */
00124         TreeElement(std::string const& inputString,Strings const& tr,TreeElement* parentElement = NULL);
00125         ~TreeElement();
00126 
00127         /*
00128          * Returns selection status of current element calculated recursively from it's child elements
00129          */
00130         bool returnStatus(edm::HLTGlobalStatus const& trStatus) const;
00131 
00132         /*
00133          * Returns operator type of the element
00134          */
00135         TreeOperator op() const {return op_;}
00136 
00137         /*
00138          * Returns parent element
00139          */
00140         TreeElement * parent() const {return parent_;}
00141 
00142         private:
00143 
00144         TreeElement * parent_;
00145         std::vector<TreeElement*> children_;
00146         TreeOperator op_;
00147         int trigBit_;
00148       };
00149 
00150       boost::shared_ptr<TreeElement> masterElement_;
00151 
00152       //keep a copy of initialization string
00153       std::string expression_;
00154 
00155       boost::shared_ptr<edm::EventSelector> eventSelector_;
00156       bool useOld_;
00157 
00158       static const bool debug_ = false;
00159 
00160   };
00161 
00162   typedef boost::shared_ptr<TriggerSelector> TriggerSelectorPtr;
00163 
00164 } // namespace stor
00165 
00166 #endif // EventFilter_StorageManager_TriggerSelector_h
00167 
00168