SpaceSlice_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SpaceSlice
3 // Module Type: producer
4 // File: SpaceSlice_module.cc
5 //
6 // Generated at Wed Oct 24 09:51:33 2012 by Evan Niner using artmod
7 // from art v1_01_01.
8 ////////////////////////////////////////////////////////////////////////
9 
14 
20 
21 namespace novaddt {
22  class SpaceSlice;
23 }
24 
26 public:
27  explicit SpaceSlice(fhicl::ParameterSet const & p);
28  virtual ~SpaceSlice();
29 
30  virtual bool filter(art::Event & e);
31 
32 private:
33 
34  // Declare member data here.
37  int fMaxZGap;
38  unsigned int fMinHits;
39 
40 };
41 
42 
44 :
45 _ghlabel (p.get< std::string >("gh_label")),
46 _instance (p.get< std::string >("instance")),
47 fMaxZGap (p.get< int >("MaxZGap" )),
48 fMinHits (p.get< int >("MinHits" ))
49 // Initialize member data here.
50 {
51  // Call appropriate Produces<>() functions here.
52  produces<std::vector<HitList>>("TimeSpaceSlice");
53 }
54 
56 {
57  // Clean up dynamic memory and other resources here.
58 }
59 
61 {
62 
64  e.getByLabel(_ghlabel, _instance, ghits);
65 
66  //make a grouped hitlist out of hits after time slicing
67  std::unique_ptr< std::vector<HitList> >product(new std::vector<HitList>);
68 
69  for(unsigned int i=0; i<ghits->n_groups(); ++i){
70  HitList temp = ghits->get(i);
71  if (temp.size()<1) continue;
72  std::sort(temp.begin(), temp.end(), CompareDAQHit<Plane>());
73 
74  auto itStart = temp.begin();
75  auto itEnd = temp.begin();
76  /*
77  int xhits = 0;
78  int yhits = 0;
79  */
80  while (itEnd != temp.end()-1) {
81  const int endPlane = (*itEnd).Plane().val;
82  ++itEnd;
83  const int nextPlane = (*itEnd).Plane().val;
84 
85  if (nextPlane - endPlane > fMaxZGap) {
86  if (itEnd - itStart > fMinHits) {
87  HitList frag(itStart, itEnd);
88  product->emplace_back(frag);
89  }
90  itStart = itEnd;
91  }
92  }
93 
94  if (itEnd-itStart > fMinHits) {
95  HitList frag(itStart, itEnd);
96  product->emplace_back(frag);
97 
98  }
99  /*
100  std::cout<<"xhits: "<<xhits<<std::endl;
101  std::cout<<"yhits: "<<yhits<<std::endl;
102  */
103  }
104 
105  //put the hits into the event for later use
106  e.put(std::move(product),"TimeSpaceSlice");
107 
108  return true;
109 }
110 
111 
SpaceSlice(fhicl::ParameterSet const &p)
virtual bool filter(art::Event &e)
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T product(std::vector< T > dims)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Float_t e
Definition: plot.C:35