DDSNEWSfilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DDSNEWSfilter
3 // Module Type: filter
4 // File: DDSNEWSfilter_module.cc
5 //
6 // Generated at Thu May 5 15:39:09 2016 by Justin Vasel using artmod
7 // from cetpkgsupport v1_08_07.
8 ////////////////////////////////////////////////////////////////////////
9 
10 // C++ includes
11 #include <memory>
12 
13 // Framework includes
18 #include "fhiclcpp/ParameterSet.h"
19 
20 // NOvASoft includes
21 #include "RawData/DAQHeader.h"
22 #include "RawData/RawDigit.h"
23 #include "RawData/RawTrigger.h"
24 
25 namespace snutil {
26  class DDSNEWSfilter;
27 }
28 
30 public:
31  explicit DDSNEWSfilter(fhicl::ParameterSet const & p);
32 
33  DDSNEWSfilter(DDSNEWSfilter const &) = delete;
34  DDSNEWSfilter(DDSNEWSfilter &&) = delete;
35  DDSNEWSfilter & operator = (DDSNEWSfilter const &) = delete;
37 
38  // Required functions.
39  bool filter(art::Event & e) override;
40 
41 private:
42  std::string fRawDataLabel; ///< ART product label for rawdata
43  std::vector<int> fPassingTriggerList; ///< List of triggers to keep
44  bool fFilterOnMicroslices; ///< Filter out event if no microslices present?
45  bool fFilterOnTriggerType; ///< Filter out event if trigger type not in PassingTriggerList?
46 };
47 
48 
49 // ............................................................................
51  EDFilter(p),
52  fRawDataLabel(p.get<std::string>("RawDataLabel")),
53  fPassingTriggerList(p.get<std::vector<int>>("PassingTriggerList")),
54  fFilterOnMicroslices(p.get<bool>("FilterOnMicroslices")),
55  fFilterOnTriggerType(p.get<bool>("FilterOnTriggerType"))
56 {
57 }
58 
59 
60 // ............................................................................
62 {
63  /* Get ART data products */
65  e.getByLabel(fRawDataLabel, trigs);
66  const rawdata::RawTrigger trig = trigs->at(0);
67  const int trigType = trig.fTriggerMask_TriggerType;
68 
70  e.getByLabel(fRawDataLabel, daqheader);
71  const int nMicroslices = daqheader->TotalMicroSlices();
72 
73  /* Perform checks */
74  bool fTriggerNotInList = std::find(fPassingTriggerList.begin(), fPassingTriggerList.end(), trigType) == fPassingTriggerList.end();
75  bool fZeroMicroslices = nMicroslices == 0;
76 
77 
78  /* Filter the event (or not) */
79  if (fTriggerNotInList && fFilterOnTriggerType) {
80  std::cout << "Trigger type " << trigType << " is not in the list of passable types. This event will be filtered out." << std::endl;
81  return false;
82  }
83 
84  if (fZeroMicroslices && fFilterOnMicroslices) {
85  std::cout << "Trigger has zero microslices." << std::endl;
86  return false;
87  }
88 
89  return true;
90 }
91 
DDSNEWSfilter(fhicl::ParameterSet const &p)
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
bool fFilterOnMicroslices
Filter out event if no microslices present?
int TotalMicroSlices() const
Definition: DAQHeader.h:27
uint8_t fTriggerMask_TriggerType
Definition: RawTrigger.h:43
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
bool fFilterOnTriggerType
Filter out event if trigger type not in PassingTriggerList?
std::vector< int > fPassingTriggerList
List of triggers to keep.
std::string fRawDataLabel
ART product label for rawdata.
DDSNEWSfilter & operator=(DDSNEWSfilter const &)=delete
OStream cout
Definition: OStream.cxx:6
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:22
bool filter(art::Event &e) override
Float_t e
Definition: plot.C:35
enum BeamMode string