RestrictHitsByPlane_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: RestrictHitsByPlane
3 // Module Type: filter
4 // File: RestrictHitsByPlane_module.cc
5 //
6 // Generated at Wed June 5 by Matthew Tamsett based on SpaceSlice
7 //
8 ////////////////////////////////////////////////////////////////////////
9 
14 
18 
19 #include "DAQChannelMap/DAQChannelMap.h"
20 //---------------------------------------------------------------------
21 namespace novaddt {
22  class RestrictHitsByPlane;
23 }
24 //---------------------------------------------------------------------
26  public:
27  explicit RestrictHitsByPlane(fhicl::ParameterSet const & p);
28  virtual ~RestrictHitsByPlane();
29  virtual bool filter(art::Event & event);
30  void endJob() override;
31  private:
32  // Declare member data here.
36  // Counters
37  int _nEvents = 0;
38  int _nInputHits = 0;
39  int _nOutputHits = 0;
40 };
41 //---------------------------------------------------------------------
43 :
44  fInputLabel (p.get< std::string >("InputLabel" )),
45  fInputInstance (p.get< std::string >("InputInstance")),
46  fMaxPlane (p.get< uint > ("MaxPlane"))
47 
48  // Initialize member data here.
49 {
50  std::cout << "=== novaddt::RestrictHitsByPlane instantiate" << std::endl;
51  std::cout << "\t input hits label: " << fInputLabel << std::endl;
52  std::cout << "\t input hits instance: " << fInputInstance << std::endl;
53  std::cout << "\t max plane: " << fMaxPlane << std::endl;
54  // Call appropriate Produces<>() functions here.
55  produces<HitList>();
56 }
57 //---------------------------------------------------------------------
59 {
60  // Clean up dynamic memory and other resources here.
61 }
62 //---------------------------------------------------------------------
64 {
65  //LOG_DEBUG("RestrictHitsByPlane") << "=== novaddt::RestrictHitsByPlane filter. Event: "
66  //<< event.id().event()
67  //<< std::endl;
68  _nEvents++;
69  art::Handle<HitList> hit_list;
70  event.getByLabel(fInputLabel, fInputInstance, hit_list);
71  //LOG_DEBUG("RestrictHitsByPlane") << "\t got " << hit_list->size() << " hits" << std::endl;
72 
73  //make a hit lists out of hits/hit lists that pass the spatial noise removal
74  std::unique_ptr< HitList >final_product(new HitList);
75 
76  for(unsigned int i=0; i<hit_list->size(); ++i){
77  _nInputHits++;
78  DAQHit product = hit_list->at(i);
79  if(product.Plane().val > fMaxPlane){
80  continue;
81  }
82  final_product->push_back(product);
83  } // end of loop on hits lists
84  //put the hits into the event for later use
85  //LOG_DEBUG("RestrictHitsByPlane") << "\t produced " << final_product->size() << " hits" << std::endl;
86  _nOutputHits+=final_product->size();
87  event.put(std::move(final_product));
88 
89  return true;
90 }
91 //---------------------------------------------------------------------
93 {
94  std::cout << "=== novaddt::RestrictHitsByPlane endJob" << std::endl;
95  std::cout << "\tNumber of events: " << _nEvents << std::endl;
96  std::cout << "\tNumber of hits: " << _nInputHits << std::endl;
97  std::cout << "\tNumber of hits filtered: " << _nOutputHits << std::endl;
98 }
99 //---------------------------------------------------------------------
novaddt::Plane const & Plane() const
Definition: DAQHit.h:70
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
virtual bool filter(art::Event &event)
value_type val
Definition: BaseProducts.h:84
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T product(std::vector< T > dims)
RestrictHitsByPlane(fhicl::ParameterSet const &p)
unsigned int uint