er  dev
ERDRS4Source.h
1 /********************************************************************************
2  * Copyright (C) Joint Institute for Nuclear Research *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef ERDRS4Source_H
10 #define ERDRS4Source_H
11 
12 #include <stdio.h>
13 
14 #include "TString.h"
15 
16 #include "FairSource.h"
17 #include "FairRootManager.h"
18 
19 #include "ERNeuRadRawEvent.h"
20 
21 class TString;
22 
23 class FairSource;
24 class FairRootManager;
25 
26 class ERNeuRadRawEvent;
27 
34 typedef struct {
35  char tag[3];
36  char version;
37 } FHEADER;
38 
39 typedef struct {
40  char time_header[4];
41 } THEADER;
42 
43 typedef struct {
44  char bn[2];
45  unsigned short board_serial_number;
46 } BHEADER;
47 
48 typedef struct {
49  char event_header[4];
50  unsigned int event_serial_number;
51  unsigned short year;
52  unsigned short month;
53  unsigned short day;
54  unsigned short hour;
55  unsigned short minute;
56  unsigned short second;
57  unsigned short millisecond;
58  unsigned short range; // range center in mV
59 } EHEADER;
60 
61 typedef struct {
62  char tc[2];
63  unsigned short trigger_cell;
64 } TCHEADER;
65 
66 typedef struct {
67  char c[1];
68  char cn[3];
69 } CHEADER;
70 
71 class ERDRS4Source : public FairSource
72 {
73  public:
74  ERDRS4Source();
75  ERDRS4Source(const ERDRS4Source& source);
76  virtual ~ERDRS4Source();
77 
78  virtual Bool_t Init();
79 
80  virtual Int_t ReadEvent(UInt_t=0);
81 
82  virtual void Close();
83 
84  virtual void Reset();
85 
86  virtual Source_Type GetSourceType(){return kFILE;}
87 
88  virtual void SetParUnpackers(){}
89 
90  virtual Bool_t InitUnpackers(){return kTRUE;}
91 
92  virtual Bool_t ReInitUnpackers(){return kTRUE;}
93 
94  void SetFile(TString path){fPath = path;}
95  void SetNChanels(Int_t chanels){fNChanels = chanels;}
96  void SetNPoints(Int_t points){fNPoints = points;}
97  private:
98  FILE* f;
99  TString fPath;
100  FHEADER fh;
101  THEADER th;
102  BHEADER bh;
103  EHEADER eh;
104  TCHEADER tch;
105  CHEADER ch;
106 
107  unsigned int scaler;
108  unsigned short voltage[1024];
109  double waveform[16][4][1024], time[16][4][1024];
110  float bin_width[16][4][1024];
111  int i, j, b, chn, n, chn_index, n_boards;
112  double t1, t2, t3, t4, dt, dt34;
113  char filename[256]; //for input binary file
114  char outroot[256]; //for output root file
115 
116  int ndt;
117  double threshold, sumdt, sumdt2;
118 
119  ERNeuRadRawEvent** fRawEvents;
120  Int_t fNChanels;
121  Int_t fNPoints;
122 
123  protected:
124  Int_t ReadHeader();
125  public:
126  ClassDef(ERDRS4Source, 1)
127 };
128 
129 
130 #endif
class for raw data obtained from measurements or simulations
task for reading raw data from binary files
Definition: ERDRS4Source.h:71