RawDigit.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Definition of basic raw digits
3 /// TDC and ADC vectors are no longer unsigned. The DAQ may very well
4 /// write out negative numbers (especially for the ADC values, which
5 /// are actually outputs of an algorithm applied to the digitizations.)
6 /// \author denis@fnal.gov
7 /// \date
8 ////////////////////////////////////////////////////////////////////////
9 #ifndef RAWDIGIT_H
10 #define RAWDIGIT_H
11 
12 #ifndef __GCCXML__
13 #include <iosfwd>
14 #endif
15 
16 #include <vector>
17 #include <stdint.h>
18 
19 namespace rawdata {
20 
21 
22 #ifndef __GCCXML__
23 
24  enum ChanMasks {
25  DETECTOR_MASK = 0XF0000000,
26  PLANE_MASK = 0x0FFFFC00,
27  CELL_MASK = 0X000003FF,
28 
32  };
33 
34 #endif
35 
36  class RawDigit {
37  public:
38  RawDigit(); // Default constructor
39  virtual ~RawDigit() {}; //Destructor
40 
41  // Nanoslice parameters
42  uint8_t fFrameSequenceNumber;
43  uint8_t fFEBStatus;
44  bool fDebugMode;
47  uint16_t fReserved; ///< Should be 0xCAFE
48 
49  std::vector<int16_t> fADC; ///< list of ADC(-like) charge values
50  std::vector<int32_t> fTDC; ///< TDC(-like) time value. Event time is subtracted. Vector structure is a historical artifact.
51 
52  uint8_t fVersion; ///< NanoSlice version
53 
54 
55  private:
56 
57  uint32_t fChannel; ///< channel ID
58  uint32_t fDaqChannel; ///< DAQ readout channel
59 
60  // Structure of the fMCBits field:
61  //
62  // The highest (32nd) bit indicates if this hit originates in data or
63  // Monte Carlo. 1 for MC, 0 for data. We set it and read it by masking
64  // with (1<<31). It's done this way for historical reasons. One day we
65  // should just have a bool, or at least a proper bitfield.
66  //
67  // Initialization: safest to initialize the field to "0", and then set the
68  // MC bit as necessary with the relevant function.
69 
70  uint32_t fMCBits; ///< status bits for MC information
71 
72 #ifndef __GCCXML__
73 
74  public:
75  RawDigit(uint32_t channel,
76  uint32_t daqchannel,
77  std::vector<int16_t> adclist,
78  int32_t tdc);
79 
80  // Getters (although data members are public)
81  uint32_t NADC() const { return fADC.size(); }
82  int16_t ADC(uint32_t i) const;
83 
84  uint32_t Channel() const { return fChannel; }
85  uint32_t DaqChannel() const { return fDaqChannel; }
86 
87  uint8_t Version() const { return fVersion; }
88 
89  /// \brief Best estimator of the hit charge
90  ///
91  /// The DCS value appropriate for this readout version
92  int16_t ADC() const;
93  /// The time of the last baseline sample
94  int32_t TDC() const { return fTDC[0]; }
95 
96  // Setters
97  void SetADC(uint32_t i, int16_t iADC);
98  void SetTDC(int32_t iTDC);
99  void SetChannel(uint32_t iChan) { fChannel = iChan; }
100  void SetDaqChannel(uint32_t iChan) { fDaqChannel = iChan; }
101  void SetVersion(uint8_t v) { fVersion = v; }
102 
103  // Below here is stuff related to MC hits.
104  // Unpack some of the information from fMCBits
105 
106  void SetMC(bool isMC=true) { if(isMC) fMCBits |= (1<<31); else fMCBits = 0; }
107  bool IsRealData() const { return !this->IsMC(); }
108  bool IsMC() const { return fMCBits & (1<<31); }
109 
110  friend std::ostream& operator << (std::ostream& o, const RawDigit& r);
111 #endif // __GCCXML__
112 
113  };
114 
115 }
116 
117 /* #ifndef __GCCXML__ */
118 
119 /* uint32_t rawdata::RawDigit::NADC() const { return fADC.size(); } */
120 /* uint32_t rawdata::RawDigit::NTDC() const { return fTDC.size(); } */
121 /* uint32_t rawdata::RawDigit::Channel() const { return fChannel; } */
122 /* uint32_t rawdata::RawDigit::DaqChannel() const { return fDaqChannel; } */
123 /* bool rawdata::RawDigit::IsRealData() const { return !this->IsMC(); } */
124 /* bool rawdata::RawDigit::IsMC() const { return fMCBits & (1<<31); } */
125 /* void rawdata::RawDigit::SetMC() { fMCBits |= (1<<31); } */
126 /* void rawdata::RawDigit::SetChannel(uint32_t iChan) { fChannel = iChan; } */
127 /* void rawdata::RawDigit::SetDaqChannel(uint32_t iChan) { fDaqChannel = iChan; } */
128 
129 /* #endif */
130 
131 
132 #endif // RAWDIGIT_H
friend std::ostream & operator<<(std::ostream &o, const RawDigit &r)
Definition: RawDigit.cxx:122
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
void SetTDC(int32_t iTDC)
Definition: RawDigit.cxx:116
virtual ~RawDigit()
Definition: RawDigit.h:39
uint16_t fReserved
Should be 0xCAFE.
Definition: RawDigit.h:47
void SetChannel(uint32_t iChan)
Definition: RawDigit.h:99
Definition of connection map class.
Definition: CMap.h:19
uint32_t fDaqChannel
DAQ readout channel.
Definition: RawDigit.h:58
void SetVersion(uint8_t v)
Definition: RawDigit.h:101
void SetADC(uint32_t i, int16_t iADC)
Definition: RawDigit.cxx:108
uint32_t fMCBits
status bits for MC information
Definition: RawDigit.h:70
uint8_t fVersion
NanoSlice version.
Definition: RawDigit.h:52
uint32_t fChannel
channel ID
Definition: RawDigit.h:57
uint32_t DaqChannel() const
Definition: RawDigit.h:85
uint8_t fFrameSequenceNumber
Definition: RawDigit.h:39
ChanMasks
Definition: RawDigit.h:24
int16_t ADC() const
Best estimator of the hit charge.
Definition: RawDigit.cxx:67
bool IsMC() const
Definition: RawDigit.h:108
void SetDaqChannel(uint32_t iChan)
Definition: RawDigit.h:100
std::vector< int32_t > fTDC
TDC(-like) time value. Event time is subtracted. Vector structure is a historical artifact...
Definition: RawDigit.h:50
uint8_t Version() const
Definition: RawDigit.h:87
void SetMC(bool isMC=true)
Definition: RawDigit.h:106
std::vector< int16_t > fADC
list of ADC(-like) charge values
Definition: RawDigit.h:49
uint32_t NADC() const
Definition: RawDigit.h:81
uint32_t Channel() const
Definition: RawDigit.h:84
TRandom3 r(0)
uint8_t fFEBStatus
Definition: RawDigit.h:43
bool IsRealData() const
Definition: RawDigit.h:107