OnlineUnpack.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////
2 // \file OnlineUnpack.h
3 // \author denis@fnal.gov
4 //
5 // \brief This class does the unpack from the flat (binary)
6 // DAQ data to the online format
7 // \version $Id: OnlineUnpack.h,v 1.22 2012-11-09 17:22:59 jpaley Exp $
8 ////////////////////////////////////////////////////////////////
9 #ifndef DAQ2RAW_ONLINEUNPACK_H
10 #define DAQ2RAW_ONLINEUNPACK_H
11 #include "DAQChannelMap/DAQChannelMapConstants.h"
12 #include "DAQQualityCheck/QualityCheck.h"
13 #include "RawData/RawDigit.h"
14 
15 #include <stdint.h> // int64_t
16 
17 /// Do we need to subtract event time from the TDC?
18 #define SUBTRACT_EVENT_TIME_FROM_HIT
19 
20 /// Define this only if you want to use checks of the DAQDataFormat
21 //#define RUNCHECKS
22 
23 // forward dectarations
24 class TH1F;
25 
26 namespace rawfileparser {
27  class RawFileParser;
28 }
29 
30 namespace rawdata{
31  class DAQHeader;
32  class RawTrigger;
33  class RawSumDropMB;
34  class RawSumDCM;
35  class FlatDAQData;
36 }
37 
38 namespace daq2raw {
39 
40  typedef struct {
41  // See DocDB 4390
42  // using unsigned long long rather than uint64_t to ensure consistent behavior on OSX and LINUX
43  uint32_t fTriggerHeader_Source; ///! Trigger source (see DAQDataFormats/TriggerDefines.h)
44  uint32_t fTriggerHeader_SourceID; ///! Identifier of the source system
45  uint32_t fTriggerHeader_SourceSubID; ///! Identifier of the subsystem or channel on source device
46  unsigned long long fTriggerHeader_TriggerNumber; ///! Universal trigger number
48  unsigned long long fTriggerTime_GenTime;
50  unsigned long long fTriggerTimingMarker_TimeStart;
54  uint32_t fTriggerMask_MCBit;
55  uint32_t fTriggerMask_TMod;
60 
61  int fDetectorType; ///! Detector type
62  int fNumberOfDigits; ///! Number of RawDigits
63 
64  } UnpackedEvent;
65 
66 
67  class OnlineUnpack{
68 
69  public:
70  /// Constructor
71  OnlineUnpack (TH1F *pulseHeightVals, TH1F *timeStampVals, TH1F *triggerVals, const std::string* file_name=nullptr);
72  /// Destructor
73  ~OnlineUnpack ();
74 
75  /// Unpack the RawEvent
76  bool ProcessRawEvent (void* rawevent_buffer, std::vector<rawdata::RawDigit>*, rawdata::RawTrigger*,rawdata::RawSumDropMB*, rawdata::RawSumDCM*, rawdata::FlatDAQData*, rawdata::DAQHeader*);
78 
79  uint32_t getRunNumber() const { return fRawEvent.getRunNumber(); }
80  uint32_t getSubrunNumber() const { return fRawEvent.getSubrun(); }
81  unsigned long long getEventNumber() const { return fRawEvent.getEventNumber(); }
82  int getDetId() const { return fDetId; }
83  uint32_t getNumberOfNonemptyMicroblocks() const { return fNumberOfNonemptyMicroblocks; }
84 
85 
86  private:
87  // Common code to unpack the event
88  bool ProcessRawEvent_(std::vector<rawdata::RawDigit>*, rawdata::RawTrigger*, rawdata::RawSumDropMB*, rawdata::RawSumDCM*, rawdata::FlatDAQData*, rawdata::DAQHeader*);
89 
90  /// Try to get Detector ID from the file name
91  bool getDetIDFromFileName(const std::string*);
92 
93 
94 
95  public:
96  bool fFilterCorruptedNanoslices; ///< Do we need to filter out Corrupted NanoSlices?
97 
98  private:
99 
100  int fDetId; ///< Detector ID reading from Microblocks
102 
103  daqdataformats::RawEvent fRawEvent; ///< Flat DAQ RawEvent
104 
105  rawdata::RawDigit fDigit; ///< Instance of RawDigit class
106 
108 
109  // Unpacking Histograms
113  TH1F* fTDC_values;
114  uint32_t fHitNumber;
115 
116  const std::string* fCurrentFileName; ///< Current file name
117 
118 #ifdef RUNCHECKS
119  daqqc::QualityCheck qc; ///< Runs checks on raw event
120 #endif
121  };
122 
123 }// end of namespace rawp
124 
125 #endif /* DAQ2RAW_ONLINEUNPACK_H */
126 
int fNumberOfDigits
! Detector type
Definition: OnlineUnpack.h:62
uint32_t fTriggerMask_TriggerTypesHigh2
Definition: OnlineUnpack.h:58
uint32_t fTriggerHeader_SourceID
! Trigger source (see DAQDataFormats/TriggerDefines.h)
Definition: OnlineUnpack.h:44
uint32_t getNumberOfNonemptyMicroblocks() const
Definition: OnlineUnpack.h:83
uint32_t fNumberOfNonemptyMicroblocks
Definition: OnlineUnpack.h:101
uint32_t getSubrunNumber() const
Definition: OnlineUnpack.h:80
bool fFilterCorruptedNanoslices
Do we need to filter out Corrupted NanoSlices?
Definition: OnlineUnpack.h:96
Definition of connection map class.
Definition: CMap.h:19
int fDetId
Detector ID reading from Microblocks.
Definition: OnlineUnpack.h:100
uint32_t fTriggerMask_TriggerTypesLow
Definition: OnlineUnpack.h:56
const std::string * fCurrentFileName
Current file name.
Definition: OnlineUnpack.h:116
uint32_t fTriggerHeader_Source
Definition: OnlineUnpack.h:43
daqdataformats::RawEvent fRawEvent
Flat DAQ RawEvent.
Definition: OnlineUnpack.h:103
uint32_t fTriggerTime_ClockSource
Definition: OnlineUnpack.h:49
uint32_t fTriggerRange_TriggerLength
Definition: OnlineUnpack.h:53
unsigned long long fTriggerTimingMarker_TimeStart
Definition: OnlineUnpack.h:50
unsigned long long fTriggerTime_GenTime
Definition: OnlineUnpack.h:48
rawdata::RawDigit fDigit
Instance of RawDigit class.
Definition: OnlineUnpack.h:105
uint32_t fTriggerMask_Prescale
Definition: OnlineUnpack.h:59
A module to produce rawdata::RawDigits from NOvADDT DAQHits.
uint32_t fTriggerMask_TriggerTypesHigh
Definition: OnlineUnpack.h:57
unsigned long long fTriggerTimingMarker_ExtractionStart
Definition: OnlineUnpack.h:51
unsigned long long fTriggerHeader_TriggerNumber
! Identifier of the subsystem or channel on source device
Definition: OnlineUnpack.h:46
int getDetId() const
Definition: OnlineUnpack.h:82
uint32_t fTriggerRange_InfBit
Definition: OnlineUnpack.h:52
uint32_t getRunNumber() const
Definition: OnlineUnpack.h:79
UnpackedEvent fUnpackedEventParameters
Definition: OnlineUnpack.h:107
unsigned long long getEventNumber() const
Definition: OnlineUnpack.h:81
unsigned long long fTriggerHeader_MasterTriggerNumber
! Universal trigger number
Definition: OnlineUnpack.h:47
uint32_t fTriggerHeader_SourceSubID
! Identifier of the source system
Definition: OnlineUnpack.h:45
enum BeamMode string