LArSoft  v10_04_05
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
20 
21 // Framework includes
29 #include "fhiclcpp/ParameterSet.h"
30 
31 // ROOT includes
32 
33 // C++ Includes
34 #include <memory>
35 #include <string>
36 
37 namespace opdet {
38 
39  class OpFlashFinder : public art::EDProducer {
40  public:
41  // Standard constructor and destructor for an ART module.
42  explicit OpFlashFinder(const fhicl::ParameterSet&);
43 
44  // The producer routine, called once per event.
45  void produce(art::Event&);
46 
47  private:
48  // The parameters we'll read from the .fcl file.
49  std::string fInputModule; // Input tag for OpHit collection
50 
51  Int_t fBinWidth;
52  Float_t fFlashThreshold;
53  Float_t fWidthTolerance;
54  Double_t fTrigCoinc;
55  };
56 
57 }
58 
59 namespace opdet {
61 }
62 
63 namespace opdet {
64 
65  //----------------------------------------------------------------------------
66  // Constructor
68  {
69 
70  // Indicate that the Input Module comes from .fcl
71  fInputModule = pset.get<std::string>("InputModule");
72 
73  fBinWidth = pset.get<int>("BinWidth");
74  fFlashThreshold = pset.get<float>("FlashThreshold");
75  fWidthTolerance = pset.get<float>("WidthTolerance");
76  fTrigCoinc = pset.get<double>("TrigCoinc");
77 
78  produces<std::vector<recob::OpFlash>>();
79  produces<art::Assns<recob::OpFlash, recob::OpHit>>();
80  }
81 
82  //----------------------------------------------------------------------------
84  {
85  // These are the storage pointers we will put in the event
86  auto flashPtr = std::make_unique<std::vector<recob::OpFlash>>();
87  auto assnPtr = std::make_unique<art::Assns<recob::OpFlash, recob::OpHit>>();
88 
89  // This will keep track of what flashes will assoc to what ophits
90  // at the end of processing
91  std::vector<std::vector<int>> assocList;
92 
93  auto const& geometry(*lar::providerFrom<geo::Geometry>());
94  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
95 
96  auto const clock_data =
98 
99  // Get OpHits from the event
100  auto const opHitHandle = evt.getValidHandle<std::vector<recob::OpHit>>(fInputModule);
101 
102  RunFlashFinder(*opHitHandle,
103  *flashPtr,
104  assocList,
105  fBinWidth,
106  geometry,
107  wireReadoutGeom,
110  clock_data,
111  fTrigCoinc);
112 
113  // Make the associations which we noted we need
114  for (size_t i = 0; i != assocList.size(); ++i) {
115  art::PtrVector<recob::OpHit> opHitPtrVector;
116  for (size_t const hitIndex : assocList.at(i)) {
117  opHitPtrVector.emplace_back(opHitHandle, hitIndex);
118  }
119 
120  util::CreateAssn(evt, *flashPtr, opHitPtrVector, *(assnPtr.get()), i);
121  }
122 
123  evt.put(std::move(flashPtr));
124  evt.put(std::move(assnPtr));
125  }
126 
127 } // namespace opdet
Utilities related to art service access.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
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, geo::WireReadoutGeom const &wireReadoutGeom, float const FlashThreshold, float const WidthTolerance, detinfo::DetectorClocksData const &ClocksData, float const TrigCoinc)
Definition: OpFlashAlg.cxx:61
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
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