All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SBNDOpDeconvolution_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SBNDOpDeconvolution
3 // Plugin Type: producer (art v3_06_03)
4 // File: SBNDOpDeconvolution_module.cc
5 //
6 // Generated at Tue Jul 13 06:29:02 2021 by Francisco Nicolas-Arnaldos using cetskelgen
7 // from cetlib version v3_11_01.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
19 #include "art/Utilities/make_tool.h"
20 
21 #include <memory>
22 
24 
27 
28 namespace opdet {
29  class SBNDOpDeconvolution;
30 }
31 
32 
33 class opdet::SBNDOpDeconvolution : public art::EDProducer {
34 public:
35  explicit SBNDOpDeconvolution(fhicl::ParameterSet const& p);
36  // The compiler-generated destructor is fine for non-base
37  // classes without bare pointers or other resource use.
38 
39  // Plugins should not be copied or assigned.
44 
45  // Required functions.
46  void produce(art::Event& e) override;
47 
48 
49 private:
50 
51  // Declare member data here.
52  std::string fInputLabel;
53  std::vector<std::string> fPDTypes;
54  std::vector<std::string> fElectronics;
55  //OpDecoAlg tool
56  std::unique_ptr<opdet::OpDeconvolutionAlg> fOpDecoAlgPtr;
57  //PDS map
59 };
60 
61 
63  : EDProducer{p} // ,
64  // More initializers here.
65 {
66  // Call appropriate produces<>() functions here.
67  // Call appropriate consumes<>() for any products to be retrieved by this module.
68  fInputLabel = p.get< std::string >("InputLabel");
69  fPDTypes = p.get< std::vector<std::string> >("PDTypes");
70  fElectronics = p.get< std::vector<std::string> >("Electronics");
71  fOpDecoAlgPtr = art::make_tool<opdet::OpDeconvolutionAlg>( p.get< fhicl::ParameterSet >("OpDecoAlg") );
72 
73  produces< std::vector< raw::OpDetWaveform > >();
74 }
75 
77 {
78  //Load the waveforms
79  art::Handle< std::vector< raw::OpDetWaveform > > wfHandle;
80  e.getByLabel(fInputLabel, wfHandle);
81  if (!wfHandle.isValid()) {
82  mf::LogError("SBNDOpDeconvolution")<<"Input waveforms with input label "<<fInputLabel<<" couldn't be loaded..."<<std::endl;
83  throw cet::exception("SBNDOpDeconvolution") << "Input waveforms with input label " << fInputLabel << " not found\n";
84  }
85 
86  std::vector< raw::OpDetWaveform > RawWfVector;
87  RawWfVector.reserve(wfHandle->size());
88 
89  for(auto const& wf : *wfHandle){
90  if((std::find(fPDTypes.begin(), fPDTypes.end(), pdsmap.pdType(wf.ChannelNumber()) ) != fPDTypes.end() ) &&
91  (std::find(fElectronics.begin(), fElectronics.end(), pdsmap.electronicsType(wf.ChannelNumber()) ) != fElectronics.end()) ){
92  RawWfVector.push_back(wf);
93  }
94  }
95 
96  std::unique_ptr< std::vector< raw::OpDetWaveform > > DecoWf_VecPtr(std::make_unique< std::vector< raw::OpDetWaveform > > ());
97  auto & DecoWf_Vec(*DecoWf_VecPtr);
98  DecoWf_Vec = fOpDecoAlgPtr->RunDeconvolution(RawWfVector);
99 
100  e.put( std::move(DecoWf_VecPtr) );
101 
102 }
103 
104 DEFINE_ART_MODULE(opdet::SBNDOpDeconvolution)
SBNDOpDeconvolution & operator=(SBNDOpDeconvolution const &)=delete
SBNDOpDeconvolution(fhicl::ParameterSet const &p)
pdgs p
Definition: selectors.fcl:22
std::vector< std::string > fPDTypes
BEGIN_PROLOG SBNDOpDeconvolution
std::unique_ptr< opdet::OpDeconvolutionAlg > fOpDecoAlgPtr
std::vector< std::string > fElectronics
do i e
void produce(art::Event &e) override