Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:44

0001 /**
0002  * \class HLTBeamModeFilter
0003  *
0004  *
0005  * Description: see class header.
0006  *
0007  *
0008  * \author: Vasile Mihai Ghete - HEPHY Vienna
0009  *
0010  *
0011  */
0012 
0013 // this class header
0014 #include "HLTBeamModeFilter.h"
0015 
0016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017 
0018 // system include files
0019 #include <vector>
0020 #include <iostream>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025 
0026 #include "DataFormats/Common/interface/Handle.h"
0027 
0028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0029 
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031 
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0034 
0035 // constructor(s)
0036 HLTBeamModeFilter::HLTBeamModeFilter(const edm::ParameterSet& parSet)
0037     : HLTFilter(parSet),
0038 
0039       m_l1GtEvmReadoutRecordTag(parSet.getParameter<edm::InputTag>("L1GtEvmReadoutRecordTag")),
0040       m_l1GtEvmReadoutRecordToken(consumes<L1GlobalTriggerEvmReadoutRecord>(m_l1GtEvmReadoutRecordTag)),
0041       m_allowedBeamMode(parSet.getParameter<std::vector<unsigned int> >("AllowedBeamMode")),
0042       m_isDebugEnabled(edm::isDebugEnabled()) {
0043   if (m_isDebugEnabled) {
0044     LogDebug("HLTBeamModeFilter") << std::endl;
0045 
0046     LogTrace("HLTBeamModeFilter") << "Input tag for L1 GT EVM record: " << m_l1GtEvmReadoutRecordTag
0047                                   << "\nAllowed beam modes:" << std::endl;
0048 
0049     for (std::vector<unsigned int>::const_iterator itMode = m_allowedBeamMode.begin();
0050          itMode != m_allowedBeamMode.end();
0051          ++itMode) {
0052       LogTrace("HLTBeamModeFilter") << "  " << (*itMode) << std::endl;
0053     }
0054 
0055     LogTrace("HLTBeamModeFilter") << std::endl;
0056   }
0057 }
0058 
0059 // destructor
0060 HLTBeamModeFilter::~HLTBeamModeFilter() {
0061   // empty now
0062 }
0063 
0064 // member functions
0065 void HLTBeamModeFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0066   edm::ParameterSetDescription desc;
0067   makeHLTFilterDescription(desc);
0068   //    #
0069   //    # InputTag for the L1 Global Trigger EVM readout record
0070   //    #   gtDigis        GT Emulator
0071   //    #   l1GtEvmUnpack  GT EVM Unpacker (default module name)
0072   //    #   gtEvmDigis     GT EVM Unpacker in RawToDigi standard sequence
0073   //    #
0074   //    #   cloned GT unpacker in HLT = gtEvmDigis
0075   desc.add<edm::InputTag>("L1GtEvmReadoutRecordTag", edm::InputTag("gtEvmDigis"));
0076   //    #
0077   //    # vector of allowed beam modes
0078   //    # default value: 11 (STABLE)
0079   std::vector<unsigned int> allowedBeamMode(1, 11);
0080   desc.add<std::vector<unsigned int> >("AllowedBeamMode", allowedBeamMode);
0081   descriptions.add("hltBeamModeFilter", desc);
0082 }
0083 
0084 bool HLTBeamModeFilter::hltFilter(edm::Event& iEvent,
0085                                   const edm::EventSetup& evSetup,
0086                                   trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0087   // for MC samples, return always true (not even checking validity of L1GlobalTriggerEvmReadoutRecord)
0088   // eventually, the BST information will be filled also in MC simulation to spare this check
0089 
0090   if (!(iEvent.isRealData())) {
0091     //LogDebug("HLTBeamModeFilter") << "\nRunning on MC sample."
0092     //        << "\nAll events are automatically selected, without testing the beam mode"
0093     //        << "\n" << std::endl;
0094     return true;
0095   }
0096 
0097   // data
0098 
0099   // initialize filter result
0100   bool filterResult = false;
0101 
0102   // get L1GlobalTriggerEvmReadoutRecord and beam mode
0103   edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
0104   iEvent.getByToken(m_l1GtEvmReadoutRecordToken, gtEvmReadoutRecord);
0105 
0106   if (!gtEvmReadoutRecord.isValid()) {
0107     edm::LogWarning("HLTBeamModeFilter") << "\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag "
0108                                          << m_l1GtEvmReadoutRecordTag
0109                                          << "\nrequested in configuration, but not found in the event." << std::endl;
0110 
0111     return false;
0112   }
0113 
0114   const uint16_t beamModeValue = (gtEvmReadoutRecord->gtfeWord()).beamMode();
0115 
0116   edm::LogInfo("HLTBeamModeFilter") << "Beam mode: " << beamModeValue;
0117 
0118   for (unsigned int itMode : m_allowedBeamMode) {
0119     if (beamModeValue == itMode) {
0120       filterResult = true;
0121 
0122       //LogTrace("HLTBeamModeFilter") << "Event selected - beam mode: "
0123       //        << beamModeValue << "\n" << std::endl;
0124 
0125       break;
0126     }
0127   }
0128 
0129   //
0130   return filterResult;
0131 }
0132 
0133 // register as framework plugin
0134 #include "FWCore/Framework/interface/MakerMacros.h"
0135 #include <cstdint>
0136 DEFINE_FWK_MODULE(HLTBeamModeFilter);