Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:55

0001 #ifndef DataFormats_PatCandidates_TriggerAlgorithm_h
0002 #define DataFormats_PatCandidates_TriggerAlgorithm_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    PatCandidates
0007 // Class:      pat::TriggerAlgorithm
0008 //
0009 //
0010 /**
0011   \class    pat::TriggerAlgorithm TriggerAlgorithm.h "DataFormats/PatCandidates/interface/TriggerAlgorithm.h"
0012   \brief    Analysis-level L1 trigger algorithm class
0013 
0014    TriggerAlgorithm implements a container for L1 trigger algorithms' information within the 'pat' namespace.
0015    For detailed information, consult
0016    https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATTrigger#TriggerAlgorithm
0017 
0018   \author   Volker Adler
0019 */
0020 
0021 #include <string>
0022 #include <vector>
0023 
0024 #include "DataFormats/Common/interface/Ref.h"
0025 #include "DataFormats/Common/interface/RefProd.h"
0026 #include "DataFormats/Common/interface/RefVector.h"
0027 #include "DataFormats/Common/interface/RefVectorIterator.h"
0028 
0029 namespace pat {
0030 
0031   class TriggerAlgorithm {
0032     /// Data Members
0033 
0034     /// L1 algorithm name
0035     std::string name_;
0036     /// L1 algorithm alias
0037     std::string alias_;
0038     /// L1 algorithm logival expression
0039     std::string logic_;
0040     /// Flag for technical L1 algorithms
0041     bool tech_;
0042     /// L1 algorithm bit number
0043     unsigned bit_;
0044     /// L1 algorithm result as determined on the GTL board
0045     bool gtlResult_;
0046     /// L1 algorithm pre-scale
0047     unsigned prescale_;
0048     /// L1 algorithm mask
0049     bool mask_;
0050     /// L1 algorithm decision, not considering the mask
0051     bool decisionBeforeMask_;
0052     /// L1 algorithm decision, considering the mask
0053     bool decisionAfterMask_;
0054     /// Indeces of trigger conditions in pat::TriggerConditionCollection in event
0055     /// as produced together with the pat::TriggerAlgorithmCollection
0056     std::vector<unsigned> conditionKeys_;
0057 
0058   public:
0059     /// Constructors and Destructor
0060 
0061     /// Default constructor
0062     TriggerAlgorithm();
0063     /// Constructor from algorithm name only
0064     TriggerAlgorithm(const std::string& name);
0065     /// Constructors from values
0066     TriggerAlgorithm(const std::string& name,
0067                      const std::string& alias,
0068                      bool tech,
0069                      unsigned bit,
0070                      unsigned prescale,
0071                      bool mask,
0072                      bool decisionBeforeMask,
0073                      bool decisionAfterMask);  // for backward compatibility
0074     TriggerAlgorithm(const std::string& name,
0075                      const std::string& alias,
0076                      bool tech,
0077                      unsigned bit,
0078                      bool gtlResult,
0079                      unsigned prescale,
0080                      bool mask,
0081                      bool decisionBeforeMask,
0082                      bool decisionAfterMask);
0083 
0084     /// Destructor
0085     virtual ~TriggerAlgorithm(){};
0086 
0087     /// Methods
0088 
0089     /// Set L1 algorithm name
0090     void setName(const std::string& name) { name_ = name; };
0091     /// Set L1 algorithm alias
0092     void setAlias(const std::string& alias) { alias_ = alias; };
0093     /// Set L1 algorithm logical expression
0094     void setLogicalExpression(const std::string& expression) { logic_ = expression; };
0095     /// Set flag for technical L1 algorithms
0096     void setTechTrigger(bool tech) { tech_ = tech; };
0097     /// Set L1 algorithm bit number
0098     void setBit(unsigned bit) { bit_ = bit; };
0099     /// Set L1 algorithm GTL result
0100     void setGtlResult(bool gtlResult) { gtlResult_ = gtlResult; };
0101     /// Set L1 algorithm pre-scale
0102     void setPrescale(unsigned prescale) { prescale_ = prescale; };
0103     /// Set L1 algorithm mask
0104     void setMask(bool mask) { mask_ = mask; };
0105     /// Set L1 algorithm decision, not considering the mask
0106     void setDecisionBeforeMask(bool decisionBeforeMask) { decisionBeforeMask_ = decisionBeforeMask; };
0107     /// Set L1 algorithm decision, considering the mask
0108     void setDecisionAfterMas(bool decisionAfterMask) { decisionAfterMask_ = decisionAfterMask; };
0109     /// Add a new trigger condition collection index
0110     void addConditionKey(unsigned conditionKey) {
0111       if (!hasConditionKey(conditionKey))
0112         conditionKeys_.push_back(conditionKey);
0113     };
0114     /// Get L1 algorithm name
0115     const std::string& name() const { return name_; };
0116     /// Get L1 algorithm alias
0117     const std::string& alias() const { return alias_; };
0118     /// Get L1 algorithm logical expression
0119     const std::string& logicalExpression() const { return logic_; };
0120     /// Get flag for technical L1 algorithms
0121     bool techTrigger() const { return tech_; };
0122     /// Get L1 algorithm bit number
0123     unsigned bit() const { return bit_; };
0124     /// Get L1 algorithm GTL result
0125     bool gtlResult() const { return gtlResult_; };
0126     /// Get L1 algorithm pre-scale
0127     unsigned prescale() const { return prescale_; };
0128     /// Get L1 algorithm mask
0129     bool mask() const { return mask_; };
0130     /// Get L1 algorithm decision, not considering the mask
0131     bool decisionBeforeMask() const { return decisionBeforeMask_; };
0132     /// Get L1 algorithm decision, considering the mask
0133     bool decisionAfterMask() const { return decisionAfterMask_; };
0134     /// Get L1 algorithm decision as applied,
0135     /// identical to L1 algorithm decision, considering the mask
0136     bool decision() const { return decisionAfterMask(); };
0137     /// Get all trigger condition collection indeces
0138     const std::vector<unsigned>& conditionKeys() const { return conditionKeys_; };
0139     /// Checks, if a certain trigger condition collection index is assigned
0140     bool hasConditionKey(unsigned conditionKey) const;
0141   };
0142 
0143   /// Collection of TriggerAlgorithm
0144   typedef std::vector<TriggerAlgorithm> TriggerAlgorithmCollection;
0145   /// Persistent reference to an item in a TriggerAlgorithmCollection
0146   typedef edm::Ref<TriggerAlgorithmCollection> TriggerAlgorithmRef;
0147   /// Persistent reference to a TriggerAlgorithmCollection product
0148   typedef edm::RefProd<TriggerAlgorithmCollection> TriggerAlgorithmRefProd;
0149   /// Vector of persistent references to items in the same TriggerAlgorithmCollection
0150   typedef edm::RefVector<TriggerAlgorithmCollection> TriggerAlgorithmRefVector;
0151   /// Const iterator over vector of persistent references to items in the same TriggerAlgorithmCollection
0152   typedef edm::RefVectorIterator<TriggerAlgorithmCollection> TriggerAlgorithmRefVectorIterator;
0153 
0154 }  // namespace pat
0155 
0156 #endif