NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
CMyEventSegment.h
1 #ifndef __CMYEVENTSEGMENT_H
2 #define __CMYEVENTSEGMENT_H
3 
4 #include <Configuration.h>
5 #include <SystemBooter.h>
6 
7 #include <CExperiment.h>
8 #include <CEventSegment.h>
9 #include <CRingItem.h>
10 #include <CRingBuffer.h>
11 #include <vector>
12 #include <deque>
13 #include <fstream>
14 // event segment for the control
15 // and readout of pixie16 modules
16 // 1 crate only readout, standard firmware
17 // snl - 1/20/10
18 using namespace std;
19 
20 #define MAXMOD 14
21 #define MAX_NUM_PIXIE16_MODULES 24
22 
23 class CMyTrigger;
24 
25 namespace DAQ {
26 namespace DDAS {
27 class Configuration;
28 }
29 }
30 
31 class channel
32 {
33 
34  public:
35  double time;
36  int chanid;
37  int channellength;
38  vector<uint32_t> data;
39 
40  channel();
41  ~channel();
42  double GetTime() const {return time;};
43  int SetTime();
44  double GetChannelLength() const {return channellength;};
45  int SetChannelLength();
46  int SetChannel();
47  int GetChannel() const {return chanid;};
48  int Validate(int);
49 };
50 
51 class CMyEventSegment : public CEventSegment
52 {
53 
54 private:
55  //any private variables
56  //CRingBuffer *ring;
57  std::ofstream ofile;
58 
59  int fragcount;
60  double globaltime;
61  double time_buffer;
62 
63  unsigned short NumModules;
64  double *ModEventLen;
65  double StopTime;
66 
67  unsigned int ModuleRevBitMSPSWord[MAX_NUM_PIXIE16_MODULES]; //word to store rev, bit depth, and MSPS of module for insertion into the data stream.
68  unsigned int ModClockCal[MAX_NUM_PIXIE16_MODULES]; //word to calibration between clock ticks and nanoseconds.
69 
70  int retval;
71  unsigned int nFIFOWords;
72 
73  unsigned long totwords;
74 
75  deque<channel *> ModuleDeque[MAXMOD];
76  vector<uint32_t> ModuleData[MAXMOD];
77 
78  vector<uint32_t> nFIFOWordsinModuleCurrentRead;
79  vector<uint64_t> nFIFOWordsinModuleTotal;
80 
81  vector<double> CurrentTimeinModuleRead;
82  vector<double> FirstTimeinModuleRead;
83 
84  bool m_processing;
85  bool processdata;
86 
87  CMyTrigger *mytrigger;
88 
89  double m_tstampScaleFactor;
90 
91  DAQ::DDAS::Configuration m_config;
92  bool m_systemInitialized;
93  bool m_firmwareLoadedRecently;
94 
95 public:
97  ~CMyEventSegment();
98 
99  virtual void initialize();
100  //virtual DAQWordBufferPtr& Read(DAQWordBufferPtr& rBuffer);
101  virtual size_t read(void* rBuffer, size_t maxwords);
102  virtual void disable();
103  virtual void clear();
104 
105  virtual void onEnd(CExperiment* pExperiment);
106  int GetNumberOfModules() {return (int)NumModules;}
107  int GetCrateID() const;
108 
109  bool IsUniqueEvent(const channel* event);
110 
111  void boot(DAQ::DDAS::SystemBooter::BootType type = DAQ::DDAS::SystemBooter::FullBoot);
112  void synchronize();
113 
114  void setTimestampScaleFactor(double value);
115  double getTimestampScaleFactor() const;
116 
117 private:
118  size_t SelectivelyOutputData(void* rBuffer, size_t maxwords);
119  bool DataToRead();
120  void PushDataOntoQueue(std::deque<channel*>& deque, std::deque<channel*>& buffer);
121  uint64_t extractExternalTimestamp(const std::vector<uint32_t>& data);
122  bool isHeterogeneousSystem(const std::vector<int>& hdwrMap);
123 
124 };
125 #endif
Definition: ddaschannelDictionary.cpp:37
Definition: CMyEventSegment.h:47
The Configuration class.
Definition: Configuration.h:50
Definition: CMyTrigger.h:4
Definition: CMyEventSegment.h:26
Definition: SystemBooter.cpp:16