CopyCellHits_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief A module to copy hits from selected clusers into a vector of cell hits
3 /// \author edniner@fnal.gov
4 /// \date
5 ////////////////////////////////////////////////////////////////////////
6 
7 // Framework includes
10 
11 // NOvA includes
12 #include "RecoBase/CellHit.h"
13 #include "RecoBase/Cluster.h"
14 
15 namespace util {
16 
17  /// A module to copy hits from selected clusers into a vector of cell hits
18  class CopyCellHits : public art::EDFilter {
19 
20  public:
21 
22  explicit CopyCellHits(fhicl::ParameterSet const &pset);
23  virtual ~CopyCellHits();
24  void beginJob();
25  bool filter(art::Event& evt);
26  protected:
28 
31  };
32 
33  //___________________________________________________________________________
35  fClusterToken(consumes<std::vector<rb::Cluster>>(pset.get<std::string>("ClusterLabel"))),
36  fOutputRawDigits(pset.get<bool>("OutputRawDigits")),
37  fOutputCellHits(pset.get<bool>("OutputCellHits"))
38  {
39  if(fOutputRawDigits) produces<std::vector<rawdata::RawDigit>>();
40  if(fOutputCellHits) produces<std::vector<rb::CellHit>>();
41  }
42 
43  //___________________________________________________________________________
45  {
46  }
47 
48  //___________________________________________________________________________
50  {
51  }
52 
53  //___________________________________________________________________________
54  template<class T> std::unique_ptr<std::vector<T>> GetHits(const std::vector<rb::Cluster>& clusts)
55  {
56  auto hitcol = std::make_unique<std::vector<T>>();
57 
58  for(const rb::Cluster& clust: clusts)
59  for(unsigned int iCell = 0; iCell < clust.NCell(); ++iCell)
60  hitcol->push_back(*clust.Cell(iCell));
61 
62  return hitcol;
63  }
64 
65  //___________________________________________________________________________
67  {
69  evt.getByToken(fClusterToken, clustcol);
70 
71  if (clustcol->size() == 0) return false;
72 
73  if(fOutputRawDigits) evt.put(GetHits<rawdata::RawDigit>(*clustcol));
74  if(fOutputCellHits) evt.put(GetHits<rb::CellHit>(*clustcol));
75 
76  return true;
77  }
78 
80 
81 } // namespace
Filter events based on their run/event numbers.
A collection of associated CellHits.
Definition: Cluster.h:47
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool filter(art::Event &evt)
std::unique_ptr< std::vector< T > > GetHits(const std::vector< rb::Cluster > &clusts)
Perform a "2 point" Hough transform on a collection of hits.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
CopyCellHits(fhicl::ParameterSet const &pset)
bool getByToken(ProductToken< PROD > const &token, Handle< PROD > &result) const
Definition: DataViewImpl.h:387
A module to copy hits from selected clusers into a vector of cell hits.
ProductToken< T > consumes(InputTag const &)
const art::ProductToken< std::vector< rb::Cluster > > fClusterToken