LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
12 #ifndef OpFlashFinder_H
13 #define OpFlashFinder_H 1
14 
15 // LArSoft includes
22 
23 // Framework includes
27 #include "fhiclcpp/ParameterSet.h"
32 
33 // ROOT includes
34 
35 // C++ Includes
36 #include <vector>
37 #include <string>
38 #include <memory>
39 
40 namespace opdet {
41 
43  public:
44 
45  // Standard constructor and destructor for an ART module.
46  explicit OpFlashFinder(const fhicl::ParameterSet&);
47  virtual ~OpFlashFinder();
48 
49  void beginJob();
50  void endJob();
51  void reconfigure(fhicl::ParameterSet const& pset);
52 
53  // The producer routine, called once per event.
54  void produce(art::Event&);
55 
56  private:
57 
58  // The parameters we'll read from the .fcl file.
59  std::string fInputModule; // Input tag for OpHit collection
60 
61  Int_t fBinWidth;
62  Float_t fFlashThreshold;
63  Float_t fWidthTolerance;
64  Double_t fTrigCoinc;
65 
66  };
67 
68 }
69 
70 namespace opdet {
72 }
73 
74 #endif
75 
76 namespace opdet {
77 
78  //----------------------------------------------------------------------------
79  // Constructor
81  {
82 
83  reconfigure(pset);
84 
85  produces< std::vector< recob::OpFlash > >();
86  produces< art::Assns< recob::OpFlash, recob::OpHit > >();
87 
88  }
89 
90  //----------------------------------------------------------------------------
92  {
93 
94  // Indicate that the Input Module comes from .fcl
95  fInputModule = pset.get< std::string >("InputModule");
96 
97  fBinWidth = pset.get< int > ("BinWidth");
98  fFlashThreshold = pset.get< float > ("FlashThreshold");
99  fWidthTolerance = pset.get< float > ("WidthTolerance");
100  fTrigCoinc = pset.get< double >("TrigCoinc");
101 
102  }
103 
104  //----------------------------------------------------------------------------
105  // Destructor
107  {
108  }
109 
110  //----------------------------------------------------------------------------
112  {
113  }
114 
115  //----------------------------------------------------------------------------
117  {
118  }
119 
120  //----------------------------------------------------------------------------
122  {
123 
124  // These are the storage pointers we will put in the event
125  std::unique_ptr< std::vector< recob::OpFlash > >
126  flashPtr(new std::vector< recob::OpFlash >);
127  std::unique_ptr< art::Assns< recob::OpFlash, recob::OpHit > >
129 
130  // This will keep track of what flashes will assoc to what ophits
131  // at the end of processing
132  std::vector< std::vector< int > > assocList;
133 
134  auto const& geometry(*lar::providerFrom< geo::Geometry >());
135 
136  auto const& detectorClocks
137  (*lar::providerFrom< detinfo::DetectorClocksService >());
138 
139  // Get OpHits from the event
141  evt.getByLabel(fInputModule, opHitHandle);
142 
143  RunFlashFinder(*opHitHandle,
144  *flashPtr,
145  assocList,
146  fBinWidth,
147  geometry,
150  detectorClocks,
151  fTrigCoinc);
152 
153  // Make the associations which we noted we need
154  for (size_t i = 0; i != assocList.size(); ++i)
155  {
156  art::PtrVector< recob::OpHit > opHitPtrVector;
157  for (int const& hitIndex : assocList.at(i))
158  {
159  art::Ptr< recob::OpHit > opHitPtr(opHitHandle, hitIndex);
160  opHitPtrVector.push_back(opHitPtr);
161  }
162 
163  util::CreateAssn(*this, evt, *flashPtr, opHitPtrVector,
164  *(assnPtr.get()), i);
165  }
166 
167  // Store results into the event
168  evt.put(std::move(flashPtr));
169  evt.put(std::move(assnPtr));
170 
171  }
172 
173 } // 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::DetectorClocks const &ts, float const &TrigCoinc)
Definition: OpFlashAlg.cxx:46
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
T get(std::string const &key) const
Definition: ParameterSet.h:231
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.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void produce(art::Event &)
TCEvent evt
Definition: DataStructs.cxx:5
OpFlashFinder(const fhicl::ParameterSet &)
art framework interface to geometry description
void reconfigure(fhicl::ParameterSet const &pset)