GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DDASDataFormat.h
Go to the documentation of this file.
1 #ifndef _DDASDATAFORMAT_H_
2 #define _DDASDATAFORMAT_H_
3 
4 #include <ostream>
5 
6 #include "TObject.h"
7 
8 #include "TSmartBuffer.h"
9 
10 #define CHANNELIDMASK 0xF // Bits 0-3 inclusive
11 #define SLOTIDMASK 0xF0 // Bits 4-7 inclusive
12 #define CRATEIDMASK 0xF00 // Bits 8-11 inclusive
13 #define HEADERLENGTHMASK 0x1F000 // Bits 12-16 inclusive
14 #define CHANNELLENGTHMASK 0x3FFE0000 // Bits 17-29 inclusive
15 #define OVERFLOWMASK 0x40000000 // Bit 30 has overflow information (1 - overflow)
16 #define FINISHCODEMASK 0x80000000 // Bit 31 has pileup information (1 - pileup)
17 #define LOWER16BITMASK 0xFFFF // Lower 16 bits
18 #define UPPER16BITMASK 0xFFFF0000 // Upper 16 bits
19 #define LOWER12BITMASK 0xFFF // Lower 12 bits
20 #define BIT31MASK 0x80000000 // Bit 31
21 #define BIT30MASK 0x40000000 // Bit 30
22 #define BIT30TO29MASK 0x60000000 // Bits 30 through 29
23 #define BIT31TO29MASK 0xE0000000 // Bits 31 through 29
24 #define BIT30TO16MASK 0x7FFF0000 // Bits 30 through 16
25 #define BIT29TO16MASK 0x3FFF0000 // Bits 29 through 16
26 #define BIT28TO16MASK 0x1FFF0000 // Bits 28 through 16
27 
28 
29 class TDDASEvent : public TObject {
30 public:
31 #include "DDASBanks.h"
32 
33  TDDASEvent(const TSmartBuffer& buf);
34 
37  unsigned short* trace;
38 
39  bool HasQDCSum() const;
40  bool HasEnergySum() const;
41 
42  unsigned int GetSize() const { return header->size; }
43  unsigned short GetFrequency() const { return header->frequency; }
44  unsigned char GetADCBits() const { return header->adc_bits; }
45  unsigned char GetRevision() const { return header->revision; }
46 
47  int GetChannelID() const { return (header->status & CHANNELIDMASK) >> 0; }
48  int GetSlotID() const { return (header->status & SLOTIDMASK) >> 4; }
49  int GetCrateID() const { return (header->status & CRATEIDMASK) >> 8; }
50  int GetChannelHeaderLength() const { return (header->status & HEADERLENGTHMASK) >> 12; }
51  int GetChannelLength() const { return (header->status & CHANNELLENGTHMASK) >> 17; }
52  int GetOverflowCode() const { return (header->status & OVERFLOWMASK) >> 30; }
53  int GetFinishCode() const { return (header->status & FINISHCODEMASK) >> 31; }
54 
55  unsigned int GetTimeLow() const { return header->time_low; }
56  unsigned int GetTimeHigh() const { return (header->time_high_cfd & LOWER16BITMASK); }
57  int GetCFDFailBit() const { return (header->time_high_cfd & BIT31MASK) >> 31; }
58  int GetCFDTime() const { return (header->time_high_cfd & BIT30TO16MASK) >> 16; }
59 
60  int GetEnergy() const { return (header->energy_tracelength & LOWER16BITMASK); }
61  int GetTraceLength() const { return (header->energy_tracelength & UPPER16BITMASK) >> 16; }
62 
63 private:
65 
67 
68  ClassDef(TDDASEvent, 0);
69 };
70 
71 std::ostream& operator<<(std::ostream& out, const TDDASEvent& event);
72 
73 #endif /* _DDASDATAFORMAT_H_ */