TimeDCMSlice_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TimeDCMSlice
3 // Module Type: producer
4 // File: TimeDCMSlice_module.cc
5 //
6 // Generated at Mon Dec 31 13:28:06 2012 by Zukai Wang using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
14 
15 
21 
22 
23 namespace novaddt {
24  class TimeDCMSlice;
25 }
26 
28 public:
29  explicit TimeDCMSlice(fhicl::ParameterSet const & p);
30  virtual ~TimeDCMSlice();
31 
32  virtual bool filter(art::Event & e);
33 
34 
35 private:
36 
37  // Declare member data here.
40  unsigned int fMinHits;
41 };
42 
43 
45  :_ghlabel (p.get<std::string>("gh_label")),
46  _instance (p.get<std::string>("instance")),
47  fMinHits (p.get<int >("MinHits"))
48 // Initialize member data here.
49 {
50  // Call appropriate Produces<>() functions here.
51  produces< std::vector<HitList> >("TimeDCMSlice");
52 }
53 
55 {
56  // Clean up dynamic memory and other resources here.
57 }
58 
60 {
62  e.getByLabel(_ghlabel, _instance, ghits);
63 
64  //make a grouped hitlist out of hits after time slicing
65  std::unique_ptr< std::vector<HitList> >product(new std::vector<HitList>);
66 
67  // std::cout<<"number of corps: "<<ghl.n_groups()<<"\n";
68 
69  for (unsigned int i=0; i<ghits->n_groups(); ++i){
70 
71  HitList temp = ghits->get(i);
72  sort(temp.begin(),temp.end(),CompareDAQHit<DCM>());
73 
74 
75  auto itStart = temp.begin();
76  auto itEnd = temp.begin();
77 
78  while (itEnd!=temp.end()){
79  while (itStart->getDCM().val==itEnd->getDCM().val){
80  ++itEnd;
81  if (itEnd==temp.end()) break;
82  }
83  // std::cout<<"DCM: "<<itStart->getDCM().val<<std::endl;
84 
85  HitList frag(itStart,itEnd);
86  itStart = itEnd;
87 
88  if (frag.size() >= fMinHits) product->push_back(frag);
89 
90  }
91 
92  }
93 
94  //put the hits into the event
95  e.put(std::move(product),"TimeDCMSlice");
96 
97  return true;
98 }
99 
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
TimeDCMSlice(fhicl::ParameterSet const &p)
::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
virtual bool filter(art::Event &e)
Float_t e
Definition: plot.C:35