// -*- C++ -*-
//
// Package:    TriggerUtils
// Class:      GenericTriggerEventFlagTest
//
// $Id: GenericTriggerEventFlagTest.cc,v 1.2 2012/01/19 20:17:34 vadler Exp $
//
/**
  \class    GenericTriggerEventFlagTest
  \brief    Tests functionality of GenericTriggerEventFlag

   This unit test ...

  \author   Volker Adler
  \version  $Id: GenericTriggerEventFlagTest.cc,v 1.2 2012/01/19 20:17:34 vadler Exp $
*/

#include "FWCore/Framework/interface/stream/EDFilter.h"
#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"

class GenericTriggerEventFlagTest : public edm::stream::EDFilter<> {
  GenericTriggerEventFlag genericTriggerEventFlag_;

public:
  explicit GenericTriggerEventFlagTest(const edm::ParameterSet& iConfig);
  virtual ~GenericTriggerEventFlagTest() override = default;

private:
  virtual void beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) override;
  virtual bool filter(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
};

GenericTriggerEventFlagTest::GenericTriggerEventFlagTest(const edm::ParameterSet& iConfig)
    : genericTriggerEventFlag_(GenericTriggerEventFlag(iConfig, consumesCollector(), *this)) {}

void GenericTriggerEventFlagTest::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
  if (genericTriggerEventFlag_.on())
    genericTriggerEventFlag_.initRun(iRun, iSetup);
}

bool GenericTriggerEventFlagTest::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
  if (genericTriggerEventFlag_.on() && !genericTriggerEventFlag_.accept(iEvent, iSetup))
    return false;

  return true;
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GenericTriggerEventFlagTest);
