OpticalRawDigitReformatter_module.cc
Go to the documentation of this file.
1 // Ben Jones, MIT, 2013
2 //
3 // This module finds periods of time-localized activity
4 // from the optical system, called Flashes.
5 
6 // LArSoft includes
12 
13 // Framework includes
18 #include "fhiclcpp/ParameterSet.h"
19 
20 // C++ Includes
21 #include <cstring>
22 
23 namespace opdet {
24 
26  public:
27  // Standard constructor and destructor for an ART module.
29 
30  // The producer routine, called once per event.
31  void produce(art::Event&);
32 
33  private:
34  // The parameters we'll read from the .fcl file.
35  std::string fInputModule; // Input tag for OpDet collection
37 
38  std::vector<std::string> CategoryLabels;
39  };
40 
41 }
42 
43 namespace opdet {
45 }
46 
47 namespace opdet {
48 
49  //-----------------------------------------------------------------------
50  // Constructor
52  : EDProducer{pset}
53  {
54  // Indicate that the Input Module comes from .fcl
55  fInputModule = pset.get<std::string>("InputModule");
56  fGenModule = pset.get<std::string>("GenModule");
57 
58  CategoryLabels.push_back("Undefined");
59  CategoryLabels.push_back("HighGain");
60  CategoryLabels.push_back("LowGain");
61  CategoryLabels.push_back("LogicPulse");
62  CategoryLabels.push_back("FEMCosmicHighGain");
63  CategoryLabels.push_back("FEMCosmicLowGain");
64  CategoryLabels.push_back("FEMCosmicLogicPulse");
65  CategoryLabels.push_back("FEMBeamHighGain");
66  CategoryLabels.push_back("FEMBeamLowGain");
67  CategoryLabels.push_back("FEMBeamLogicPulse");
68  CategoryLabels.push_back("BeamPMTTrigger");
69  CategoryLabels.push_back("CosmicPMTTrigger");
70 
71  // One for each category
72  for (auto label : CategoryLabels)
73  produces<std::vector<raw::OpDetWaveform>>(label);
74  }
75 
76  //-----------------------------------------------------------------------
77  void
79  {
80 
81  // These are the storage pointers we will put in the event, one per category
82  std::vector<std::unique_ptr<std::vector<raw::OpDetWaveform>>> RawOpDetVecs;
83  for (unsigned int i = 0; i < CategoryLabels.size(); i++) {
84  std::unique_ptr<std::vector<raw::OpDetWaveform>> tmp(new std::vector<raw::OpDetWaveform>);
85  RawOpDetVecs.push_back(std::move(tmp));
86  }
87 
88  std::vector<const sim::BeamGateInfo*> beamGateArray;
89  try {
90  evt.getView(fGenModule, beamGateArray);
91  }
92  catch (art::Exception const& err) {
93  if (err.categoryCode() != art::errors::ProductNotFound) throw;
94  }
95 
96  // Read in the OpticalRawDigit collection from the event.
98  evt.getByLabel(fInputModule, ordHandle);
99  std::vector<optdata::OpticalRawDigit> const& ord_vec(*ordHandle);
100 
101  auto const clock_data =
103 
104  for (auto ord : ord_vec) {
105  optdata::Channel_t channel = ord.ChannelNumber();
106  optdata::TimeSlice_t timeSlice = ord.TimeSlice();
107  optdata::Frame_t frame = ord.Frame();
108  optdata::Optical_Category_t category = ord.Category();
109 
110  // Use the optical clock to conver timeSlice and frame
111  // to an absolute time
112  double timeStamp = clock_data.OpticalClock().Time(timeSlice, frame);
113 
114  RawOpDetVecs[category]->push_back(raw::OpDetWaveform(timeStamp, channel, ord));
115  }
116 
117  // Store results into the event
118  for (unsigned int i = 0; i < CategoryLabels.size(); i++) {
119  // Only store collections which contain waveforms, assign the label
120  if (RawOpDetVecs[i]->size() > 0) { evt.put(std::move(RawOpDetVecs[i]), CategoryLabels[i]); }
121  }
122  }
123 
124 } // namespace opdet
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
enum optdata::_optical_category_t Optical_Category_t
uint8_t channel
Definition: CRTFragment.hh:201
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
string tmp
Definition: languages.py:63
void err(const char *fmt,...)
Definition: message.cpp:226
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
unsigned int Frame_t
Definition: OpticalTypes.h:21
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:500
TCEvent evt
Definition: DataStructs.cxx:7
unsigned int Channel_t
Definition: OpticalTypes.h:19
OpticalRawDigitReformatter(const fhicl::ParameterSet &)