LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 
7 #ifndef OpticalRawDigitReformatter_H
8 #define OpticalRawDigitReformatter_H 1
9 
10 // LArSoft includes
17 
18 // Framework includes
22 #include "fhiclcpp/ParameterSet.h"
28 
29 // ROOT includes
30 
31 // C++ Includes
32 #include <vector>
33 #include <iostream>
34 #include <cstring>
35 #include <climits>
36 
37 namespace opdet {
38 
40  public:
41 
42  // Standard constructor and destructor for an ART module.
45 
46  void beginJob();
47  void endJob();
48  void reconfigure(fhicl::ParameterSet const& pset);
49 
50  // The producer routine, called once per event.
51  void produce (art::Event&);
52 
53 
54  private:
55 
56  // The parameters we'll read from the .fcl file.
57  std::string fInputModule; // Input tag for OpDet collection
58  std::string fGenModule ;
59 
60  std::vector<std::string> CategoryLabels;
61 
62  };
63 
64 
65 }
66 
67 namespace opdet {
69 }
70 
71 #endif
72 
73 
74 namespace opdet {
75 
76  //-----------------------------------------------------------------------
77  // Constructor
79  {
80 
81  reconfigure(pset);
82 
83  CategoryLabels.push_back("Undefined");
84  CategoryLabels.push_back("HighGain");
85  CategoryLabels.push_back("LowGain");
86  CategoryLabels.push_back("LogicPulse");
87  CategoryLabels.push_back("FEMCosmicHighGain");
88  CategoryLabels.push_back("FEMCosmicLowGain");
89  CategoryLabels.push_back("FEMCosmicLogicPulse");
90  CategoryLabels.push_back("FEMBeamHighGain");
91  CategoryLabels.push_back("FEMBeamLowGain");
92  CategoryLabels.push_back("FEMBeamLogicPulse");
93  CategoryLabels.push_back("BeamPMTTrigger");
94  CategoryLabels.push_back("CosmicPMTTrigger");
95 
96 
97  // One for each category
98  for (auto label : CategoryLabels)
99  produces<std::vector< raw::OpDetWaveform > >(label);
100 
101  }
102 
103  //---------------------------------------------
104 
106  {
107  // Indicate that the Input Module comes from .fcl
108  fInputModule = pset.get<std::string>("InputModule");
109  fGenModule = pset.get<std::string>("GenModule");
110 
111  }
112 
113  //-----------------------------------------------------------------------
114  // Destructor
116  {}
117 
118  //-----------------------------------------------------------------------
120  {
121  }
122 
123  //-----------------------------------------------------------------------
125  {
126 
127  }
128 
129 
130 
131  //-----------------------------------------------------------------------
133  {
134 
135 
136  // These are the storage pointers we will put in the event, one per category
137  std::vector<std::unique_ptr<std::vector< raw::OpDetWaveform > > > RawOpDetVecs;
138  for (unsigned int i = 0; i < CategoryLabels.size(); i++) {
139  std::unique_ptr<std::vector< raw::OpDetWaveform > > tmp(new std::vector< raw::OpDetWaveform >);
140  RawOpDetVecs.push_back(std::move(tmp));
141  }
142 
143 
144  std::vector<const sim::BeamGateInfo*> beamGateArray;
145  try { evt.getView(fGenModule, beamGateArray); }
146  catch ( art::Exception const& err ){
147  if ( err.categoryCode() != art::errors::ProductNotFound ) throw;
148  }
149 
150  // Read in the OpticalRawDigit collection from the event.
152  evt.getByLabel(fInputModule, ordHandle);
153  std::vector<optdata::OpticalRawDigit> const& ord_vec(*ordHandle);
154 
155  auto const* ts = lar::providerFrom<detinfo::DetectorClocksService>();
156 
157  for (auto ord: ord_vec) {
158  optdata::Channel_t channel = ord.ChannelNumber();
159  optdata::TimeSlice_t timeSlice = ord.TimeSlice();
160  optdata::Frame_t frame = ord.Frame();
161  optdata::Optical_Category_t category = ord.Category();
162 
163  // Use the optical clock to conver timeSlice and frame
164  // to an absolute time
165  double timeStamp = ts->OpticalClock().Time(timeSlice, frame);
166 
167  RawOpDetVecs[category]->push_back(raw::OpDetWaveform(timeStamp, channel, ord));
168  }
169 
170 
171 
172  // Store results into the event
173  for (unsigned int i = 0; i < CategoryLabels.size(); i++) {
174  // Only store collections which contain waveforms, assign the label
175  if (RawOpDetVecs[i]->size() > 0) {
176  evt.put(std::move(RawOpDetVecs[i]), CategoryLabels[i]);
177  }
178  }
179 
180  }
181 
182 
183 } // namespace opdet
184 
const std::string label
enum optdata::_optical_category_t Optical_Category_t
Float_t tmp
Definition: plot.C:37
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:474
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
T get(std::string const &key) const
Definition: ParameterSet.h:231
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
unsigned int Frame_t
Definition: OpticalTypes.h:21
unsigned int Channel_t
Definition: OpticalTypes.h:19
void reconfigure(fhicl::ParameterSet const &pset)
OpticalRawDigitReformatter(const fhicl::ParameterSet &)