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 fRawDataLabel(p.get<std::string>("RawDataLabel")),
52 fPassingTriggerList(p.get<std::vector<int>>("PassingTriggerList")),
53 fFilterOnMicroslices(p.get<bool>("FilterOnMicroslices")),
54 fFilterOnTriggerType(p.get<bool>("FilterOnTriggerType"))
55 {
56 }
57 
58 
59 // ............................................................................
61 {
62  /* Get ART data products */
64  e.getByLabel(fRawDataLabel, trigs);
65  const rawdata::RawTrigger trig = trigs->at(0);
66  const int trigType = trig.fTriggerMask_TriggerType;
67 
69  e.getByLabel(fRawDataLabel, daqheader);
70  const int nMicroslices = daqheader->TotalMicroSlices();
71 
72  /* Perform checks */
73  bool fTriggerNotInList = std::find(fPassingTriggerList.begin(), fPassingTriggerList.end(), trigType) == fPassingTriggerList.end();
74  bool fZeroMicroslices = nMicroslices == 0;
75 
76 
77  /* Filter the event (or not) */
78  if (fTriggerNotInList && fFilterOnTriggerType) {
79  std::cout << "Trigger type " << trigType << " is not in the list of passable types. This event will be filtered out." << std::endl;
80  return false;
81  }
82 
83  if (fZeroMicroslices && fFilterOnMicroslices) {
84  std::cout << "Trigger has zero microslices." << std::endl;
85  return false;
86  }
87 
88  return true;
89 }
90 
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 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
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
bool filter(art::Event &e) override
Float_t e
Definition: plot.C:35
enum BeamMode string