Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:27

0001 //
0002 //
0003 
0004 #include "DataFormats/PatCandidates/interface/TriggerFilter.h"
0005 
0006 using namespace pat;
0007 
0008 // Constructors and Destructor
0009 
0010 // Default constructor
0011 TriggerFilter::TriggerFilter() : label_(), type_(), status_(), saveTags_() {
0012   objectKeys_.clear();
0013   triggerObjectTypes_.clear();
0014 }
0015 
0016 // Constructor from std::string for filter label
0017 TriggerFilter::TriggerFilter(const std::string& label, int status, bool saveTags)
0018     : label_(label), type_(), status_(status), saveTags_(saveTags) {
0019   objectKeys_.clear();
0020   triggerObjectTypes_.clear();
0021 }
0022 
0023 // Constructor from edm::InputTag for filter label
0024 TriggerFilter::TriggerFilter(const edm::InputTag& tag, int status, bool saveTags)
0025     : label_(tag.label()), type_(), status_(status), saveTags_(saveTags) {
0026   objectKeys_.clear();
0027   triggerObjectTypes_.clear();
0028 }
0029 
0030 // Methods
0031 
0032 // Set the filter status
0033 bool TriggerFilter::setStatus(int status) {
0034   if (status < -1 || 1 < status)
0035     return false;
0036   status_ = status;
0037   return true;
0038 }
0039 
0040 // Get all trigger object type identifiers
0041 std::vector<int> TriggerFilter::triggerObjectTypes() const {
0042   std::vector<int> triggerObjectTypes;
0043   for (size_t iTo = 0; iTo < triggerObjectTypes_.size(); ++iTo) {
0044     triggerObjectTypes.push_back(triggerObjectTypes_.at(iTo));
0045   }
0046   return triggerObjectTypes;
0047 }
0048 
0049 // Checks, if a certain trigger object collection index is assigned
0050 bool TriggerFilter::hasObjectKey(unsigned objectKey) const {
0051   for (size_t iO = 0; iO < objectKeys().size(); ++iO) {
0052     if (objectKeys().at(iO) == objectKey)
0053       return true;
0054   }
0055   return false;
0056 }
0057 
0058 // Checks, if a certain trigger object type identifier is assigned
0059 bool TriggerFilter::hasTriggerObjectType(trigger::TriggerObjectType triggerObjectType) const {
0060   for (size_t iO = 0; iO < triggerObjectTypes().size(); ++iO) {
0061     if (triggerObjectTypes().at(iO) == triggerObjectType)
0062       return true;
0063   }
0064   return false;
0065 }