Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:56

0001 #ifndef DataFormats_PatCandidates_TriggerCondition_h
0002 #define DataFormats_PatCandidates_TriggerCondition_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    PatCandidates
0007 // Class:      pat::TriggerCondition
0008 //
0009 //
0010 /**
0011   \class    pat::TriggerCondition TriggerCondition.h "DataFormats/PatCandidates/interface/TriggerCondition.h"
0012   \brief    Analysis-level L1 trigger condition class
0013 
0014    TriggerCondition implements a container for trigger conditions' information within the 'pat' namespace.
0015    For detailed information, consult
0016    https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATTrigger#TriggerCondition
0017 
0018   \author   Volker Adler
0019 */
0020 
0021 #include <string>
0022 #include <vector>
0023 
0024 #include "FWCore/Utilities/interface/InputTag.h"
0025 #include "DataFormats/Common/interface/Ref.h"
0026 #include "DataFormats/Common/interface/RefProd.h"
0027 #include "DataFormats/Common/interface/RefVector.h"
0028 #include "DataFormats/Common/interface/RefVectorIterator.h"
0029 #include "DataFormats/L1GlobalTrigger/interface/L1GtDefinitions.h"
0030 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0031 
0032 namespace pat {
0033 
0034   class TriggerCondition {
0035     /// Data Members
0036 
0037     /// Name of the condition
0038     std::string name_;
0039     /// Did condition succeed?
0040     bool accept_;
0041     /// L1 condition category as defined in CondFormats/L1TObjects/interface/L1GtFwd.h
0042     L1GtConditionCategory category_;
0043     /// L1 condition type as defined in CondFormats/L1TObjects/interface/L1GtFwd.h
0044     L1GtConditionType type_;
0045     /// Special identifiers for the used trigger object type as defined in
0046     /// DataFormats/HLTReco/interface/TriggerTypeDefs.h
0047     /// translated from L1GtObject type (DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h)
0048     std::vector<trigger::TriggerObjectType> triggerObjectTypes_;
0049     /// Indeces of trigger objects from succeeding combinations in pat::TriggerObjectCollection in event
0050     /// as produced together with the pat::TriggerAlgorithmCollection
0051     std::vector<unsigned> objectKeys_;
0052 
0053   public:
0054     /// Constructors and Desctructor
0055 
0056     /// Default constructor
0057     TriggerCondition();
0058     /// Constructor from condition name "only"
0059     TriggerCondition(const std::string& name);
0060     /// Constructor from values
0061     TriggerCondition(const std::string& name, bool accept);
0062 
0063     /// Destructor
0064     virtual ~TriggerCondition() {}
0065 
0066     /// Methods
0067 
0068     /// Set the condition name
0069     void setName(const std::string& name) { name_ = name; };
0070     /// Set the success flag
0071     void setAccept(bool accept) { accept_ = accept; };
0072     /// Set the condition category
0073     void setCategory(L1GtConditionCategory category) { category_ = category; };
0074     void setCategory(int category) { category_ = L1GtConditionCategory(category); };
0075     /// Set the condition type
0076     void setType(L1GtConditionType type) { type_ = type; };
0077     void setType(int type) { type_ = L1GtConditionType(type); };
0078     /// Add a new trigger object type
0079     void addTriggerObjectType(trigger::TriggerObjectType triggerObjectType) {
0080       triggerObjectTypes_.push_back(triggerObjectType);
0081     };  // explicitely NOT checking for existence
0082     void addTriggerObjectType(int triggerObjectType) {
0083       addTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0084     };
0085     /// Add a new trigger object collection index
0086     void addObjectKey(unsigned objectKey) {
0087       if (!hasObjectKey(objectKey))
0088         objectKeys_.push_back(objectKey);
0089     };
0090     /// Get the filter label
0091     const std::string& name() const { return name_; };
0092     /// Get the success flag
0093     bool wasAccept() const { return accept_; };
0094     /// Get the condition category
0095     int category() const { return int(category_); };
0096     /// Get the condition type
0097     int type() const { return int(type_); };
0098     /// Get the trigger object types
0099     std::vector<int> triggerObjectTypes() const;
0100     /// Checks, if a certain trigger object type is assigned
0101     bool hasTriggerObjectType(trigger::TriggerObjectType triggerObjectType) const;
0102     bool hasTriggerObjectType(int triggerObjectType) const {
0103       return hasTriggerObjectType(trigger::TriggerObjectType(triggerObjectType));
0104     };
0105     /// Get all trigger object collection indeces
0106     const std::vector<unsigned>& objectKeys() const { return objectKeys_; };
0107     /// Checks, if a certain trigger object collection index is assigned
0108     bool hasObjectKey(unsigned objectKey) const;
0109   };
0110 
0111   /// Collection of TriggerCondition
0112   typedef std::vector<TriggerCondition> TriggerConditionCollection;
0113   /// Persistent reference to an item in a TriggerConditionCollection
0114   typedef edm::Ref<TriggerConditionCollection> TriggerConditionRef;
0115   /// Persistent reference to a TriggerConditionCollection product
0116   typedef edm::RefProd<TriggerConditionCollection> TriggerConditionRefProd;
0117   /// Vector of persistent references to items in the same TriggerConditionCollection
0118   typedef edm::RefVector<TriggerConditionCollection> TriggerConditionRefVector;
0119   /// Const iterator over vector of persistent references to items in the same TriggerConditionCollection
0120   typedef edm::RefVectorIterator<TriggerConditionCollection> TriggerConditionRefVectorIterator;
0121 
0122 }  // namespace pat
0123 
0124 #endif