LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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
36  std::string fGenModule;
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  //-----------------------------------------------------------------------
78  {
79 
80  // These are the storage pointers we will put in the event, one per category
81  std::vector<std::unique_ptr<std::vector<raw::OpDetWaveform>>> RawOpDetVecs;
82  for (unsigned int i = 0; i < CategoryLabels.size(); i++) {
83  std::unique_ptr<std::vector<raw::OpDetWaveform>> tmp(new std::vector<raw::OpDetWaveform>);
84  RawOpDetVecs.push_back(std::move(tmp));
85  }
86 
87  std::vector<const sim::BeamGateInfo*> beamGateArray;
88  try {
89  evt.getView(fGenModule, beamGateArray);
90  }
91  catch (art::Exception const& err) {
92  if (err.categoryCode() != art::errors::ProductNotFound) throw;
93  }
94 
95  // Read in the OpticalRawDigit collection from the event.
97  evt.getByLabel(fInputModule, ordHandle);
98  std::vector<optdata::OpticalRawDigit> const& ord_vec(*ordHandle);
99 
100  auto const clock_data =
102 
103  for (auto ord : ord_vec) {
104  optdata::Channel_t channel = ord.ChannelNumber();
105  optdata::TimeSlice_t timeSlice = ord.TimeSlice();
106  optdata::Frame_t frame = ord.Frame();
107  optdata::Optical_Category_t category = ord.Category();
108 
109  // Use the optical clock to conver timeSlice and frame
110  // to an absolute time
111  double timeStamp = clock_data.OpticalClock().Time(timeSlice, frame);
112 
113  RawOpDetVecs[category]->push_back(raw::OpDetWaveform(timeStamp, channel, ord));
114  }
115 
116  // Store results into the event
117  for (unsigned int i = 0; i < CategoryLabels.size(); i++) {
118  // Only store collections which contain waveforms, assign the label
119  if (RawOpDetVecs[i]->size() > 0) { evt.put(std::move(RawOpDetVecs[i]), CategoryLabels[i]); }
120  }
121  }
122 
123 } // namespace opdet
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
enum optdata::_optical_category_t Optical_Category_t
Float_t tmp
Definition: plot.C:35
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
unsigned int Frame_t
Definition: OpticalTypes.h:21
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int Channel_t
Definition: OpticalTypes.h:19
OpticalRawDigitReformatter(const fhicl::ParameterSet &)