DCMSlice_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DCMSlice
3 // Module Type: producer
4 // File: DCMSlice_module.cc
5 //
6 // Generated at Thu Dec 20 13:35:26 2012 by Zukai Wang using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
14 
20 
21 
22 namespace novaddt {
23  class DCMSlice;
24 }
25 
27 public:
28  explicit DCMSlice(fhicl::ParameterSet const & p);
29  virtual ~DCMSlice();
31  bool filter(art::Event & e) override;
32 
33 
34 private:
35 
36  // Declare member data here.
39 
40 };
41 
42 
44 :
45  _hitslabel (p.get< std::string>("hits_label")),
46  _instance (p.get< std::string>("instance" ))
47 // Initialize member data here.
48 {
49  // Call appropriate Produces<>() functions here.
50  produces<GroupedHitList<DCM>>("DCMSlice");
51 }
52 
54 {
55  // Clean up dynamic memory and other resources here.
56 }
57 
59 {
60 
63 
64  //make a grouped hitlist out of hits after time slicing
65  std::unique_ptr< GroupedHitList<DCM> >product(new GroupedHitList<DCM>);
66  *product = MakeSlice(hits);
67  //put the hits into the event for later use
68 
69  e.put(std::move(product),"DCMSlice");
70 
71  return true;
72 }
73 
74 
76 {
77  std::vector<size_t> boundaries;
78 
79  auto itStart = hits->begin();
80  auto itEnd = hits->begin();
81 
82  while (itEnd!=hits->end()){
83 
84  while (itStart->getDCM().val==itEnd->getDCM().val) {
85  ++itEnd;
86  if (itEnd==hits->end()) break;
87  }
88 
89  //now add boundary
90  boundaries.push_back(std::distance(itStart,itEnd));
91  itStart = itEnd;
92 
93  }
94 
95 
96 
97  return GroupedHitList<DCM>(hits->begin(),hits->end(),boundaries);
98 }
99 
const char * p
Definition: xmltok.h:285
bool filter(art::Event &e) override
DEFINE_ART_MODULE(TestTMapFile)
unsigned distance(const T &t1, const T &t2)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
std::string _hitslabel
void hits()
Definition: readHits.C:15
std::string _instance
DCMSlice(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
GroupedHitList< DCM > MakeSlice(art::Handle< novaddt::HitList > &hits)
Float_t e
Definition: plot.C:35