LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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
19 
20 // Framework includes
28 #include "fhiclcpp/ParameterSet.h"
29 
30 // ROOT includes
31 
32 // C++ Includes
33 #include <memory>
34 #include <string>
35 
36 namespace opdet {
37 
38  class OpFlashFinder : public art::EDProducer {
39  public:
40  // Standard constructor and destructor for an ART module.
41  explicit OpFlashFinder(const fhicl::ParameterSet&);
42 
43  // The producer routine, called once per event.
44  void produce(art::Event&);
45 
46  private:
47  // The parameters we'll read from the .fcl file.
48  std::string fInputModule; // Input tag for OpHit collection
49 
50  Int_t fBinWidth;
51  Float_t fFlashThreshold;
52  Float_t fWidthTolerance;
53  Double_t fTrigCoinc;
54  };
55 
56 }
57 
58 namespace opdet {
60 }
61 
62 namespace opdet {
63 
64  //----------------------------------------------------------------------------
65  // Constructor
67  {
68 
69  // Indicate that the Input Module comes from .fcl
70  fInputModule = pset.get<std::string>("InputModule");
71 
72  fBinWidth = pset.get<int>("BinWidth");
73  fFlashThreshold = pset.get<float>("FlashThreshold");
74  fWidthTolerance = pset.get<float>("WidthTolerance");
75  fTrigCoinc = pset.get<double>("TrigCoinc");
76 
77  produces<std::vector<recob::OpFlash>>();
78  produces<art::Assns<recob::OpFlash, recob::OpHit>>();
79  }
80 
81  //----------------------------------------------------------------------------
83  {
84  // These are the storage pointers we will put in the event
85  auto flashPtr = std::make_unique<std::vector<recob::OpFlash>>();
86  auto assnPtr = std::make_unique<art::Assns<recob::OpFlash, recob::OpHit>>();
87 
88  // This will keep track of what flashes will assoc to what ophits
89  // at the end of processing
90  std::vector<std::vector<int>> assocList;
91 
92  auto const& geometry(*lar::providerFrom<geo::Geometry>());
93 
94  auto const clock_data =
96 
97  // Get OpHits from the event
98  auto const opHitHandle = evt.getValidHandle<std::vector<recob::OpHit>>(fInputModule);
99 
100  RunFlashFinder(*opHitHandle,
101  *flashPtr,
102  assocList,
103  fBinWidth,
104  geometry,
107  clock_data,
108  fTrigCoinc);
109 
110  // Make the associations which we noted we need
111  for (size_t i = 0; i != assocList.size(); ++i) {
112  art::PtrVector<recob::OpHit> opHitPtrVector;
113  for (size_t const hitIndex : assocList.at(i)) {
114  opHitPtrVector.emplace_back(opHitHandle, hitIndex);
115  }
116 
117  util::CreateAssn(evt, *flashPtr, opHitPtrVector, *(assnPtr.get()), i);
118  }
119 
120  evt.put(std::move(flashPtr));
121  evt.put(std::move(assnPtr));
122  }
123 
124 } // namespace opdet
Utilities related to art service access.
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:60
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
void emplace_back(Args &&...args)
Definition: PtrVector.h:448
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Utility object to perform functions of association.
void produce(art::Event &)
TCEvent evt
Definition: DataStructs.cxx:8
OpFlashFinder(const fhicl::ParameterSet &)
art framework interface to geometry description