SSPToOffline_module.cc
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 2; -*-
2 ////////////////////////////////////////////////////////////////////////
3 // Class: SSPToOffline
4 // Module Type: producer
5 // File: SSPToOffline_module.cc
6 //
7 // Repackage raw SSP data into OpDetPulse data products
8 //
9 // Alex Himmel ahimme@phy.duke.edu
10 //
11 ////////////////////////////////////////////////////////////////////////
12 
20 #include "fhiclcpp/ParameterSet.h"
22 
23 #include <memory>
24 #include <iostream>
25 #include <map>
26 
27 //lbne-artdaq includes
28 #include "lbne-raw-data/Overlays/SSPFragment.hh"
29 #include "lbne-raw-data/Overlays/anlTypes.hh"
30 #include "artdaq-core/Data/Fragment.hh"
31 
32 //larsoft includes
33 #include "lardataobj/RawData/raw.h"
36 
37 //daqinput35t includes
38 
40 #include "SSPReformatterAlgs.h"
41 
42 namespace DAQToOffline {
43  class SSPToOffline;
44 }
45 
47 public:
48  explicit SSPToOffline(fhicl::ParameterSet const & pset);
49  // The destructor generated by the compiler is fine for classes
50  // without bare pointers or other resource use.
51 
52  // Plugins should not be copied or assigned.
53  SSPToOffline(SSPToOffline const &) = delete;
54  SSPToOffline(SSPToOffline &&) = delete;
55  SSPToOffline & operator = (SSPToOffline const &) = delete;
56  SSPToOffline & operator = (SSPToOffline &&) = delete;
57  void produce(art::Event & evt) override;
58  void reconfigure(fhicl::ParameterSet const& pset);
59  void printParameterSet();
60 
61 private:
62 
66 
68 
69  //long first_FirstSample;
70  //double first_TimeStamp;
71  //long first_InternalSample;
72  //double first_InternalTimeStamp;
73 
74  //bool fDebug;
75  //raw::Compress_t fCompression; ///< compression type to use
76  //unsigned int fZeroThreshold; ///< Zero suppression threshold
77 
78 
79 };
80 
81 
83  : EDProducer{pset}, sspReform(pset.get<fhicl::ParameterSet>("SSPReformatter"))
84 {
85 
86  this->reconfigure(pset);
87 
88  produces< std::vector<raw::OpDetWaveform> > (fOutputDataLabel);
89  produces< std::vector<recob::OpHit> > (fOutputDataLabel);
90 
91  //first_FirstSample = -1;
92  //first_TimeStamp = -1;
93 }
94 
96 
97  fFragType = pset.get<std::string>("FragType");
98  fRawDataLabel = pset.get<std::string>("RawDataLabel");
99  fOutputDataLabel = pset.get<std::string>("OutputDataLabel");
100 
101  //fDebug = pset.get<bool>("Debug");
102  //fZeroThreshold=0;
103  //fCompression=raw::kNone;
104 
106 }
107 
109 
110  mf::LogDebug("SSPToOffline") << "====================================" << "\n"
111  << "Parameter Set" << "\n"
112  << "====================================" << "\n"
113  << "fFragType: " << fFragType << "\n"
114  << "fRawDataLabel: " << fRawDataLabel << "\n"
115  << "fOutputDataLabel: " << fOutputDataLabel << "\n"
116  << "====================================" << "\n";
117 }
118 
119 
121 {
122 
123  art::Handle<artdaq::Fragments> rawFragments;
124  evt.getByLabel(fRawDataLabel, fFragType, rawFragments);
125 
126  // Create the output data structures
127  std::vector<raw::OpDetWaveform> waveforms;
128  std::vector<recob::OpHit> hits;
129 
130 
131  // Check if there is SSP data in this event
132  // Don't crash code if not present, just don't save anything
133  try {
134  rawFragments->size();
135  }
136  catch(std::exception const&) {
137  mf::LogWarning("SSPToOffline") << "WARNING: Raw SSP data not found in event " << evt.event();
138  evt.put(std::make_unique<decltype(waveforms)>(std::move(waveforms)), fOutputDataLabel);
139  evt.put(std::make_unique<decltype(hits)>(std::move(hits)), fOutputDataLabel);
140  return;
141  }
142 
143  // Check that the data is valid
144  if(!rawFragments.isValid()){
145  mf::LogError("SSPToOffline") << "Run: " << evt.run()
146  << ", SubRun: " << evt.subRun()
147  << ", Event: " << evt.event()
148  << " is NOT VALID";
149  throw cet::exception("raw NOT VALID");
150  return;
151  }
152 
153  sspReform.SSPFragmentToWaveformsAndHits(*rawFragments, waveforms, hits);
154 
155  evt.put(std::make_unique<decltype(waveforms)>(std::move(waveforms)), fOutputDataLabel);
156  evt.put(std::make_unique<decltype(hits)>(std::move(hits)), fOutputDataLabel);
157 
158 }
159 
void SSPFragmentToWaveformsAndHits(artdaq::Fragments const &rawFragments, std::vector< raw::OpDetWaveform > &opDetWaveformVector, std::vector< recob::OpHit > &opHitVector)
EventNumber_t event() const
Definition: DataViewImpl.cc:96
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
SSPToOffline(fhicl::ParameterSet const &pset)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isValid() const
Definition: Handle.h:183
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
void produce(art::Event &evt) override
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69
SSPToOffline & operator=(SSPToOffline const &)=delete
def move(depos, offset)
Definition: depos.py:107
Collect all the RawData header files together.
T get(std::string const &key) const
Definition: ParameterSet.h:231
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:89
RunNumber_t run() const
Definition: DataViewImpl.cc:82
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TCEvent evt
Definition: DataStructs.cxx:7
void reconfigure(fhicl::ParameterSet const &pset)
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33