IcebergDataInterface.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // IcebergDataInterface.h
3 //
4 // Tool to unpack RCE and FELIX fragments. A restructuring from the IcebergRawDecoder 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 IcebergDataInterface_H
17 #define IcebergDataInterface_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 
95 
96  unsigned int _tick_count_this_event; // for use in comparing tick counts for all channels
100 
101  // some convenience typedefs for porting old code
102 
103  typedef std::vector<raw::RawDigit> RawDigits;
104  typedef std::vector<raw::RDTimeStamp> RDTimeStamps;
105  typedef std::vector<raw::RDStatus> RDStatuses;
106 
107  // private methods
108 
109  void _collectRDStatus(std::vector<raw::RDStatus> &rdstatuses);
110 
111  bool _processRCE(art::Event &evt,
112  std::string inputLabel,
113  RawDigits& raw_digits,
114  RDTimeStamps &timestamps,
115  std::vector<int> &apalist);
116 
118  size_t &n_rce_frags,
119  bool is_container,
120  art::Event &evt,
121  RawDigits& raw_digits,
122  RDTimeStamps &timestamps,
123  std::vector<int> &apalist);
124 
125  bool _process_RCE_AUX(art::Event &evt,
126  const artdaq::Fragment& frag,
127  RawDigits& raw_digits,
128  RDTimeStamps &timestamps,
129  std::vector<int> &apalist);
130 
131  bool _processFELIX(art::Event &evt,
132  std::string inputLabel,
133  RawDigits& raw_digits,
134  RDTimeStamps &timestamps,
135  std::vector<int> &apalist);
136 
138  size_t &n_felix_frags,
139  bool is_container,
140  art::Event &evt,
141  RawDigits& raw_digits,
142  RDTimeStamps &timestamps,
143  std::vector<int> &apalist,
144  std::string inputLabel);
145 
146  bool _process_FELIX_AUX(art::Event &evt,
147  const artdaq::Fragment& frag,
148  RawDigits& raw_digits,
149  RDTimeStamps &timestamps,
150  std::vector<int> &apalist,
151  uint32_t runNumber,
152  std::string inputLabel);
153 
155  float &median,
156  float &sigma);
157 
158 };
159 
160 
161 #endif
std::string string
Definition: nybbler.cc:12
bool _process_RCE_AUX(art::Event &evt, const artdaq::Fragment &frag, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist)
unsigned int _tick_count_this_event
unsigned int _default_crate_if_unexpected
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)
std::vector< raw::RDStatus > RDStatuses
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, std::string inputLabel)
IcebergDataInterface(fhicl::ParameterSet const &ps)
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)
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
static constexpr double ps
Definition: Units.h:99
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)
bool _process_FELIX_AUX(art::Event &evt, const artdaq::Fragment &frag, RawDigits &raw_digits, RDTimeStamps &timestamps, std::vector< int > &apalist, uint32_t runNumber, std::string inputLabel)
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
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)
TCEvent evt
Definition: DataStructs.cxx:7
std::vector< raw::RDTimeStamp > RDTimeStamps
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:26
void _collectRDStatus(std::vector< raw::RDStatus > &rdstatuses)