OpFlashFinder_module.cc
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 2; -*-
2 // Ben Jones, MIT, 2013
3 //
4 // This module finds periods of time-localized activity
5 // from the optical system, called Flashes, using OpHits as an input.
6 //
7 // Modified to make it more detector agnostic
8 // by Gleb Sinev, Duke, 2015
9 //
10 
11 // LArSoft includes
18 
19 // Framework includes
26 #include "fhiclcpp/ParameterSet.h"
27 
28 // ROOT includes
29 
30 // C++ Includes
31 #include <memory>
32 #include <string>
33 
34 namespace opdet {
35 
36  class OpFlashFinder : public art::EDProducer {
37  public:
38  // Standard constructor and destructor for an ART module.
39  explicit OpFlashFinder(const fhicl::ParameterSet&);
40 
41  // The producer routine, called once per event.
42  void produce(art::Event&);
43 
44  private:
45  // The parameters we'll read from the .fcl file.
46  std::string fInputModule; // Input tag for OpHit collection
47 
48  Int_t fBinWidth;
49  Float_t fFlashThreshold;
50  Float_t fWidthTolerance;
51  Double_t fTrigCoinc;
52  };
53 
54 }
55 
56 namespace opdet {
58 }
59 
60 namespace opdet {
61 
62  //----------------------------------------------------------------------------
63  // Constructor
65  {
66 
67  // Indicate that the Input Module comes from .fcl
68  fInputModule = pset.get<std::string>("InputModule");
69 
70  fBinWidth = pset.get<int>("BinWidth");
71  fFlashThreshold = pset.get<float>("FlashThreshold");
72  fWidthTolerance = pset.get<float>("WidthTolerance");
73  fTrigCoinc = pset.get<double>("TrigCoinc");
74 
75  produces<std::vector<recob::OpFlash>>();
76  produces<art::Assns<recob::OpFlash, recob::OpHit>>();
77  }
78 
79  //----------------------------------------------------------------------------
80  void
82  {
83  // These are the storage pointers we will put in the event
84  auto flashPtr = std::make_unique<std::vector<recob::OpFlash>>();
85  auto assnPtr = std::make_unique<art::Assns<recob::OpFlash, recob::OpHit>>();
86 
87  // This will keep track of what flashes will assoc to what ophits
88  // at the end of processing
89  std::vector<std::vector<int>> assocList;
90 
91  auto const& geometry(*lar::providerFrom<geo::Geometry>());
92 
93  auto const clock_data =
95 
96  // Get OpHits from the event
97  auto const opHitHandle = evt.getValidHandle<std::vector<recob::OpHit>>(fInputModule);
98 
99  RunFlashFinder(*opHitHandle,
100  *flashPtr,
101  assocList,
102  fBinWidth,
103  geometry,
106  clock_data,
107  fTrigCoinc);
108 
109  // Make the associations which we noted we need
110  for (size_t i = 0; i != assocList.size(); ++i) {
111  art::PtrVector<recob::OpHit> opHitPtrVector;
112  for (size_t const hitIndex : assocList.at(i)) {
113  opHitPtrVector.emplace_back(opHitHandle, hitIndex);
114  }
115 
116  util::CreateAssn(*this, evt, *flashPtr, opHitPtrVector, *(assnPtr.get()), i);
117  }
118 
119  evt.put(std::move(flashPtr));
120  evt.put(std::move(assnPtr));
121  }
122 
123 } // namespace opdet
void RunFlashFinder(std::vector< recob::OpHit > const &HitVector, std::vector< recob::OpFlash > &FlashVector, std::vector< std::vector< int >> &AssocList, double const BinWidth, geo::GeometryCore const &geom, float const FlashThreshold, float const WidthTolerance, detinfo::DetectorClocksData const &ClocksData, float const TrigCoinc)
Definition: OpFlashAlg.cxx:62
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void emplace_back(Args &&...args)
Definition: PtrVector.h:448
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
void produce(art::Event &)
TCEvent evt
Definition: DataStructs.cxx:7
OpFlashFinder(const fhicl::ParameterSet &)