All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
filter::EventTimeFilter Class Reference
Inheritance diagram for filter::EventTimeFilter:

Public Member Functions

 EventTimeFilter (fhicl::ParameterSet const &)
 
bool filter (art::Event &evt)
 

Private Attributes

UInt_t fDateRangeLow
 
UInt_t fTimeRangeLow
 
UInt_t fDateRangeHigh
 
UInt_t fTimeRangeHigh
 

Detailed Description

Definition at line 32 of file EventTimeFilter_module.cc.

Constructor & Destructor Documentation

filter::EventTimeFilter::EventTimeFilter ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 51 of file EventTimeFilter_module.cc.

52  : EDFilter{pset}
53 {
54  fDateRangeLow = pset.get<UInt_t>("DateRangeLow", 0); // YYYYMMDD
55  fTimeRangeLow = pset.get<UInt_t>("TimeRangeLow", 0); // HHMMSS
56  fDateRangeHigh = pset.get<UInt_t>("DateRangeHigh", 0); // YYYYMMDD
57  fTimeRangeHigh = pset.get<UInt_t>("TimeRangeHigh", 0); // HHMMSS
58 }

Member Function Documentation

bool filter::EventTimeFilter::filter ( art::Event &  evt)

Definition at line 60 of file EventTimeFilter_module.cc.

60  {
61 
62  // Check that input date is in correct format
63  if (fDateRangeHigh > 99999999 || fDateRangeLow > 99999999) {
64  std::cout << "Warning: please provide date in format YYYYMMDD, event time "
65  << "filter returning false." << std::endl;
66  return false;
67  }
68  if (fDateRangeHigh > 0 && fDateRangeHigh < 10000000) {
69  std::cout << "Warning: please provide date in format YYYYMMDD, event time "
70  << "filter returning false." << std::endl;
71  return false;
72  }
73  if (fDateRangeLow > 0 && fDateRangeLow < 10000000) {
74  std::cout << "Warning: please provide date in format YYYYMMDD, event time "
75  << "filter returning false." << std::endl;
76  return false;
77  }
78 
79  // Check that input times are in correct format
80  if (fTimeRangeHigh > 999999 || fTimeRangeLow > 999999) {
81  std::cout << "Warning: please provide time in format HHMMSS, event time "
82  << "filter returning false." << std::endl;
83  return false;
84  }
85  if (fTimeRangeHigh > 0 && fTimeRangeHigh < 100000) {
86  std::cout << "Warning: please provide time in format HHMMSS, event time "
87  << "filter returning false." << std::endl;
88  return false;
89  }
90  if (fTimeRangeLow > 0 && fTimeRangeLow < 100000) {
91  std::cout << "Warning: please provide time in format HHMMSS, event time "
92  << "filter returning false." << std::endl;
93  return false;
94  }
95 
96  // Event time
97  art::Timestamp evtTime = evt.time();
98  TTimeStamp * evtTTS;
99  if (evtTime.timeHigh() == 0) { evtTTS = new TTimeStamp(evtTime.timeLow()); }
100  else { evtTTS = new TTimeStamp(evtTime.timeHigh(), evtTime.timeLow()); }
101 
102  std::cout << "Event time: " << evtTTS -> AsString() << std::endl;
103 
104  // Requested time range lower end
105  TTimeStamp * ttsLow(nullptr);
106  if (fDateRangeLow != 0) {
107  if (fTimeRangeLow != 0) {
108  ttsLow = new TTimeStamp(fDateRangeLow, fTimeRangeLow, 0u);
109  }
110  else {
111  ttsLow = new TTimeStamp(fDateRangeLow, 0u, 0u);
112  std::cout << "Warning: No start time given for event time filter, "
113  << "assuming 00:00:00" << std::endl;
114  }
115  }
116 
117  // Requested time range higher end
118  TTimeStamp * ttsHigh(nullptr);
119  if (fDateRangeHigh != 0) {
120  if (fTimeRangeHigh != 0) {
121  ttsHigh = new TTimeStamp(fDateRangeHigh, fTimeRangeHigh, 0u);
122  }
123  else {
124  std::cout << "Warning: No end time given for event time filter, assuming "
125  << "23:59:59" << std::endl;
126  ttsHigh = new TTimeStamp(fDateRangeHigh, 235959u, 0u);
127  }
128  }
129 
130  // Filter decision
131  if (ttsLow == nullptr && ttsHigh == nullptr) {
132  std::cout << "Warning: No date range requested for event time filter, "
133  << "returning false." << std::endl;
134  return false;
135  }
136  else if (ttsLow == nullptr) {
137  std::cout << "Warning: No lower limit requested for event time filter, "
138  << "taking all events before " << ttsHigh -> AsString()
139  << std::endl;
140  if (evtTTS -> GetSec() < ttsHigh -> GetSec()) { return true; }
141  else { return false;}
142  }
143  else if (ttsHigh == nullptr) {
144  std::cout << "Warning: No lower limit requested for event time filter, "
145  << "taking all events after " << ttsLow -> AsString()
146  << std::endl;
147  if (evtTTS -> GetSec() > ttsLow -> GetSec()) { return true; }
148  else { return false;}
149  }
150  else {
151  if (evtTTS -> GetSec() > ttsLow -> GetSec() &&
152  evtTTS -> GetSec() < ttsHigh -> GetSec()) { return true; }
153  else { return false; }
154  }
155 
156 }
TCEvent evt
Definition: DataStructs.cxx:8
BEGIN_PROLOG could also be cout

Member Data Documentation

UInt_t filter::EventTimeFilter::fDateRangeHigh
private

Definition at line 44 of file EventTimeFilter_module.cc.

UInt_t filter::EventTimeFilter::fDateRangeLow
private

Definition at line 42 of file EventTimeFilter_module.cc.

UInt_t filter::EventTimeFilter::fTimeRangeHigh
private

Definition at line 45 of file EventTimeFilter_module.cc.

UInt_t filter::EventTimeFilter::fTimeRangeLow
private

Definition at line 43 of file EventTimeFilter_module.cc.


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