PDSPTPCDataInterface.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // PDSPTPCDataInterface.h
3 //
4 // Tool to unpack RCE and FELIX fragments. A restructuring from the PDSPTPCRawDecoder module
5 //
6 // These methods take references to vectors of raw::RawDigit, raw::RDTimeStamp, and raw::RDStatus data products as arguments.
7 // These vectors are not cleared on input, and so when data are retrieved, they are appended to any existing data already
8 // in the vectors. The RDStatus vector is an exception, where just one RDStatus instance will be in the vector. Previously
9 // accumulated RDStatus values from previous calls will be logically ORed into the single RDStatus instances contents.
10 //
11 // Methods are provided to retrieve all data from fragments on an input label, or by specified APA list. In cases where
12 // data from a specified APA are requested but no labels are provided by the caller, labels are input via FCL parameters.
13 // This is true because data from an APA may appear with different labels during the course of the ProtoDUNE-SP run.
14 //
15 /////////////////////////////////////////////////////////////////////////
16 #ifndef PDSPTPCDataInterface_H
17 #define PDSPTPCDataInterface_H
18 
19 #include <vector>
20 
22 #include "fhiclcpp/ParameterSet.h"
25 //#include "art/Framework/Principal/Run.h"
26 //#include "art/Framework/Principal/SubRun.h"
32 #include "artdaq-core/Data/Fragment.hh"
33 #include "artdaq-core/Data/ContainerFragment.hh"
35 
37 
38  public:
39 
41 
42  int retrieveData(art::Event &evt, std::string inputlabel, std::vector<raw::RawDigit> &raw_digits, std::vector<raw::RDTimeStamp> &rd_timestamps,
43  std::vector<raw::RDStatus> &rdstatuses );
44 
45  // method to get raw digits, RDTimeStamps, RDStatuses from all input fragments specified by an input label (like "daq:ContainerTPC") but ony for
46  // APA's (== crate numbers) on a list. If the list contains a -1 in it, it returns all APA data found in the input label.
47 
48  int retrieveDataAPAListWithLabels(art::Event &evt, std::string inputlabel, std::vector<raw::RawDigit> &raw_digits, std::vector<raw::RDTimeStamp> &rd_timestamps,
49  std::vector<raw::RDStatus> &rdstatuses,
50  std::vector<int> &apalist);
51 
52  // method to get raw digits, RDTimeStamps, RDStatuses for a specified list of APA's. The list of possible labels on which to find
53  // APA data is proved by fcl configuration.
54 
55  int retrieveDataForSpecifiedAPAs(art::Event &evt, std::vector<raw::RawDigit> &raw_digits, std::vector<raw::RDTimeStamp> &rd_timestamps,
56  std::vector<raw::RDStatus> &rdstatuses,
57  std::vector<int> &apalist);
58 
59  // inputLabel examples: "daq:TPC" or "daq::ContainerTPC" for RCE, "daq:FELIX" or "daq::ContainerFELIX" for FELIX
60  // returns: 0: success, or 1: discarded corrupted data, or 2: kept some corrupted data
61 
62  private:
63 
64  std::map<int,std::vector<std::string>> _input_labels_by_apa;
65 
66  // what to do with unexpected crate numbers
67 
69 
70  long int _min_offline_channel; // min offline channel to decode. <0: no limit
71  long int _max_offline_channel; // max offline channel to decode. <0: no limit. max<min: no limit
72 
76  unsigned int _full_tick_count;
87 
88  // flags for attempting to fix FEMB 110's misaligned data
89 
91  unsigned int _rce_fix110_nticks;
92 
100 
101  unsigned int _tick_count_this_event; // for use in comparing tick counts for all channels
105 
106  // some convenience typedefs for porting old code
107 
108  typedef std::vector<raw::RawDigit> RawDigits;
109  typedef std::vector<raw::RDTimeStamp> RDTimeStamps;
110  typedef std::vector<raw::RDStatus> RDStatuses;
111 
112  // private methods
113 
114  void _collectRDStatus(std::vector<raw::RDStatus> &rdstatuses);
115 
116  bool _processRCE(art::Event &evt,
117  std::string inputLabel,
118  RawDigits& raw_digits,
119  RDTimeStamps &timestamps,
120  std::vector<int> &apalist);
121 
123  size_t &n_rce_frags,
124  bool is_container,
125  art::Event &evt,
126  RawDigits& raw_digits,
127  RDTimeStamps &timestamps,
128  std::vector<int> &apalist);
129 
130  bool _process_RCE_AUX(art::Event &evt,
131  const artdaq::Fragment& frag,
132  RawDigits& raw_digits,
133  RDTimeStamps &timestamps,
134  std::vector<int> &apalist);
135 
136  bool _processFELIX(art::Event &evt,
137  std::string inputLabel,
138  RawDigits& raw_digits,
139  RDTimeStamps &timestamps,
140  std::vector<int> &apalist);
141 
143  size_t &n_felix_frags,
144  bool is_container,
145  art::Event &evt,
146  RawDigits& raw_digits,
147  RDTimeStamps &timestamps,
148  std::vector<int> &apalist);
149 
150  bool _process_FELIX_AUX(art::Event &evt,
151  const artdaq::Fragment& frag,
152  RawDigits& raw_digits,
153  RDTimeStamps &timestamps,
154  std::vector<int> &apalist);
155 
157  float &median,
158  float &sigma);
159 
160 };
161 
162 
163 #endif
bool _processFELIX(art::Event &evt, std::string inputLabel, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
int retrieveData(art::Event &evt, std::string inputlabel, std::vector< raw::RawDigit > &raw_digits, std::vector< raw::RDTimeStamp > &rd_timestamps, std::vector< raw::RDStatus > &rdstatuses)
int retrieveDataForSpecifiedAPAs(art::Event &evt, std::vector< raw::RawDigit > &raw_digits, std::vector< raw::RDTimeStamp > &rd_timestamps, std::vector< raw::RDStatus > &rdstatuses, std::vector< int > &apalist)
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
std::string string
Definition: nybbler.cc:12
unsigned int _default_crate_if_unexpected
unsigned int _tick_count_this_event
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
bool _processRCE(art::Event &evt, std::string inputLabel, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
bool _process_FELIX_AUX(art::Event &evt, const artdaq::Fragment &frag, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
std::vector< raw::RawDigit > RawDigits
bool _felixProcContNCFrags(art::Handle< artdaq::Fragments > frags, size_t &n_felix_frags, bool is_container, art::Event &evt, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
void _collectRDStatus(std::vector< raw::RDStatus > &rdstatuses)
static constexpr double ps
Definition: Units.h:99
std::vector< raw::RDTimeStamp > RDTimeStamps
int retrieveDataAPAListWithLabels(art::Event &evt, std::string inputlabel, std::vector< raw::RawDigit > &raw_digits, std::vector< raw::RDTimeStamp > &rd_timestamps, std::vector< raw::RDStatus > &rdstatuses, std::vector< int > &apalist)
std::vector< raw::RDStatus > RDStatuses
bool _rceProcContNCFrags(art::Handle< artdaq::Fragments > frags, size_t &n_rce_frags, bool is_container, art::Event &evt, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
std::map< int, std::vector< std::string > > _input_labels_by_apa
bool _process_RCE_AUX(art::Event &evt, const artdaq::Fragment &frag, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
TCEvent evt
Definition: DataStructs.cxx:7
PDSPTPCDataInterface(fhicl::ParameterSet const &ps)
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:26