Public Types | Public Member Functions | Private Attributes | List of all members
DuneEventFilter Class Reference
Inheritance diagram for DuneEventFilter:
art::EDFilter art::detail::Filter art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using IndexSet = std::set< Index >
 
using Name = std::string
 
- Public Types inherited from art::EDFilter
using ModuleType = EDFilter
 
using WorkerType = WorkerT< EDFilter >
 
- Public Types inherited from art::detail::Filter
template<typename UserConfig >
using Table = Modifier::Table< UserConfig >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 DuneEventFilter (fhicl::ParameterSet const &pset)
 
virtual ~DuneEventFilter ()
 
virtual bool filter (art::Event &e)
 
- Public Member Functions inherited from art::EDFilter
 EDFilter (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDFilter (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Filter
virtual ~Filter () noexcept
 
 Filter (fhicl::ParameterSet const &)
 
 Filter (Filter const &)=delete
 
 Filter (Filter &&)=delete
 
Filteroperator= (Filter const &)=delete
 
Filteroperator= (Filter &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

Index m_LogLevel
 
IndexVector m_SelectEventVector
 
IndexVector m_RejectEventVector
 
Index m_EventBegin
 
Index m_EventEnd
 
Index m_EventModFreq
 
Index m_EventModVal
 
Name m_JobIndexRangeTool
 
Name m_SkipEventTool
 
Index m_beginEvent
 
Index m_endEvent
 
IndexSet m_SelectEvents
 
IndexSet m_RejectEvents
 
const IndexVectorMapToolm_pSkipEventTool
 
Index m_nproc
 
Index m_nsel
 

Additional Inherited Members

- Static Public Attributes inherited from art::detail::Filter
static constexpr bool Pass {true}
 
static constexpr bool Fail {false}
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 34 of file DuneEventFilter_module.cc.

Member Typedef Documentation

using DuneEventFilter::Index = unsigned int

Definition at line 38 of file DuneEventFilter_module.cc.

using DuneEventFilter::IndexSet = std::set<Index>

Definition at line 40 of file DuneEventFilter_module.cc.

Definition at line 39 of file DuneEventFilter_module.cc.

Definition at line 41 of file DuneEventFilter_module.cc.

Constructor & Destructor Documentation

DuneEventFilter::DuneEventFilter ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 75 of file DuneEventFilter_module.cc.

76 : EDFilter(pset),
77  m_LogLevel(pset.get<Index>("LogLevel")),
78  m_SelectEventVector(pset.get<IndexVector>("SelectEvents")),
79  m_RejectEventVector(pset.get<IndexVector>("RejectEvents")),
80  m_EventBegin(pset.get<Index>("EventBegin")),
81  m_EventEnd(pset.get<Index>("EventEnd")),
82  m_EventModFreq(pset.get<Index>("EventModFreq")),
83  m_EventModVal(pset.get<Index>("EventModVal")),
84  m_JobIndexRangeTool(pset.get<Name>("JobIndexRangeTool")),
85  m_SkipEventTool(pset.get<Name>("SkipEventTool")),
86  m_beginEvent(0), m_endEvent(0),
87  m_pSkipEventTool(nullptr),
88  m_nproc(0), m_nsel(0) {
89  using std::cout;
90  using std::endl;
91  using std::string;
92  const string myname = "DuneEventFilter::ctor: ";
93  for ( Index ievt : m_SelectEventVector ) m_SelectEvents.insert(ievt);
94  for ( Index ievt : m_RejectEventVector ) m_RejectEvents.insert(ievt);
95  if ( m_LogLevel >= 1 ) {
96  cout << myname << " LogLevel: " << m_LogLevel << endl;
97  cout << myname << " SelectEvents: [";
98  bool first = true;
99  for ( unsigned int ievt : m_SelectEvents ) {
100  if ( first ) first = false;
101  else cout << ", ";
102  cout << ievt;
103  }
104  cout << "]" << endl;
105  cout << myname << " RejectEvents: [";
106  first = true;
107  for ( unsigned int ievt : m_RejectEvents ) {
108  if ( first ) first = false;
109  else cout << ", ";
110  cout << ievt;
111  }
112  cout << "]" << endl;
113  cout << myname << " EventBegin: " << m_EventBegin << endl;
114  cout << myname << " EventEnd: " << m_EventEnd << endl;
115  cout << myname << " EventModVal: " << m_EventModVal << endl;
116  cout << myname << " EventModFreq: " << m_EventModFreq << endl;
117  cout << myname << " JobIndexRangeTool: " << m_JobIndexRangeTool << endl;
118  cout << myname << " SkipEventTool: " << m_SkipEventTool << endl;
119  }
120  if ( m_EventEnd > m_EventBegin ) {
123  } else if ( m_JobIndexRangeTool.size() ) {
126  if ( pjrt == nullptr ) {
127  cout << myname << "ERROR: Job index range tool not found: " << m_JobIndexRangeTool << endl;
128  } else {
129  IndexRange ran = pjrt->get("events");
130  if ( ! ran.isValid() ) {
131  cout << myname << "Event range is unrestricted." << endl;
132  } else {
133  m_beginEvent = ran.begin;
134  m_endEvent = ran.end;
135  }
136  }
137  }
138  if ( m_endEvent > m_beginEvent ) {
139  cout << myname << "Event selection range is [" << m_beginEvent << ", "
140  << m_endEvent << ")." << endl;
141  } else {
142  cout << myname << "No event selection range." << endl;
143  }
144  if ( m_SkipEventTool.size() ) {
147  if ( m_pSkipEventTool == nullptr ) {
148  cout << "WARNING: Unable to find SkipEventTool " << m_SkipEventTool << endl;
149  } else {
150  cout << myname << "Using SkipEventTool @" << m_pSkipEventTool << endl;
151  }
152  }
153 }
std::vector< Index > IndexVector
std::string string
Definition: nybbler.cc:12
Index begin
Definition: IndexRange.h:34
ChannelGroupService::Name Name
const IndexVectorMapTool * m_pSkipEventTool
unsigned int Index
bool isValid() const
Definition: IndexRange.h:94
Index end
Definition: IndexRange.h:35
IndexVector m_RejectEventVector
IndexVector m_SelectEventVector
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:21
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)
virtual IndexRange get(Name nam) const =0
DuneEventFilter::~DuneEventFilter ( )
virtual

Definition at line 187 of file DuneEventFilter_module.cc.

187  {
188  using std::cout;
189  using std::endl;
190  using std::string;
191  const string myname = "DuneEventFilter::dtor: ";
192  if ( m_LogLevel >= 1 ) {
193  float fsel = double(m_nsel)/double(m_nproc);
194  cout << myname << " Events processed: " << m_nproc << endl;
195  cout << myname << " Events selected: " << m_nsel << " (" << fsel << ")" << endl;
196  }
197 }
std::string string
Definition: nybbler.cc:12
QTextStream & endl(QTextStream &s)

Member Function Documentation

bool DuneEventFilter::filter ( art::Event e)
virtual

Implements art::EDFilter.

Definition at line 157 of file DuneEventFilter_module.cc.

157  {
158  using std::cout;
159  using std::endl;
160  using std::string;
161  const string myname = "DuneEventFilter::filter: ";
162  Index ievt = evt.event();
163  ++m_nproc;
164  bool keep = true;
165  if ( keep && m_SelectEvents.size() ) keep = m_SelectEvents.count(ievt);
166  if ( keep ) keep = m_RejectEvents.count(ievt) == 0;
167  if ( keep && m_endEvent > m_beginEvent ) keep = ievt >= m_beginEvent && ievt < m_endEvent;
168  if ( keep && m_EventModFreq ) keep = (ievt % m_EventModFreq) == m_EventModVal;
169  if ( keep && m_pSkipEventTool != nullptr ) {
170  const IndexVector& skipEvents = m_pSkipEventTool->get(evt.run());
171  if ( find(skipEvents.begin(), skipEvents.end(), ievt) != skipEvents.end() ) {
172  keep = false;
173  if ( m_LogLevel >= 3 ) {
174  cout << myname << " Event " << ievt << " rejected by SkipEventTool" << endl;
175  }
176  }
177  }
178  if ( m_LogLevel >= 2 ) {
179  cout << myname << (keep ? "Sel" : "Rej") << "ecting event " << ievt << endl;
180  }
181  if ( keep ) ++m_nsel;
182  return keep;
183 }
std::vector< Index > IndexVector
unsigned int event
Definition: DataStructs.h:636
unsigned int run
Definition: DataStructs.h:637
std::string string
Definition: nybbler.cc:12
virtual IndexVector get(Index idx) const =0
const IndexVectorMapTool * m_pSkipEventTool
unsigned int Index
TCEvent evt
Definition: DataStructs.cxx:7
QTextStream & endl(QTextStream &s)

Member Data Documentation

Index DuneEventFilter::m_beginEvent
private

Definition at line 61 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_endEvent
private

Definition at line 62 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_EventBegin
private

Definition at line 53 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_EventEnd
private

Definition at line 54 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_EventModFreq
private

Definition at line 55 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_EventModVal
private

Definition at line 56 of file DuneEventFilter_module.cc.

Name DuneEventFilter::m_JobIndexRangeTool
private

Definition at line 57 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_LogLevel
private

Definition at line 50 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_nproc
private

Definition at line 68 of file DuneEventFilter_module.cc.

Index DuneEventFilter::m_nsel
private

Definition at line 69 of file DuneEventFilter_module.cc.

const IndexVectorMapTool* DuneEventFilter::m_pSkipEventTool
private

Definition at line 65 of file DuneEventFilter_module.cc.

IndexSet DuneEventFilter::m_RejectEvents
private

Definition at line 64 of file DuneEventFilter_module.cc.

IndexVector DuneEventFilter::m_RejectEventVector
private

Definition at line 52 of file DuneEventFilter_module.cc.

IndexSet DuneEventFilter::m_SelectEvents
private

Definition at line 63 of file DuneEventFilter_module.cc.

IndexVector DuneEventFilter::m_SelectEventVector
private

Definition at line 51 of file DuneEventFilter_module.cc.

Name DuneEventFilter::m_SkipEventTool
private

Definition at line 58 of file DuneEventFilter_module.cc.


The documentation for this class was generated from the following file: