REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawFEUDreamToSignalProcess.h
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef RestCore_TRestFEUDreamToSignalProcess
24#define RestCore_TRestFEUDreamToSignalProcess
25
26#include <TError.h>
27#include <TF1.h>
28#include <TH1D.h>
29#include <TH2D.h>
30#include <TMath.h>
31#include <TROOT.h>
32#include <TSystem.h>
33#include <TTree.h>
34#ifndef WIN32
35#include <arpa/inet.h>
36#else
37#include <Winsock.h>
38#endif
39#include <signal.h>
40#include <stdint.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44#include <time.h>
45
46#include <iostream>
47#include <list>
48#include <map>
49#include <string>
50#include <vector>
51
52#include "TRestRawSignalEvent.h"
53#include "TRestRawToSignalProcess.h"
54#include "math.h"
55
58 protected:
60 public:
61 DataLineDream() { data = 0; }
63 void ntohs_() { data = ntohs(data); };
64 bool is_final_trailer() const { return (((data)&0x7000) >> 12) == 7; } // X111
65 bool is_end_of_event() const { return (((data)&0x7800) >> 11) == 0xF; } // X1111
66 bool is_data_trailer() const { return (((data)&0x6000) >> 13) == 2; } // X10X
67 bool is_first_line() const { return (((data)&0x7000) >> 12) == 3; } // X011
68 bool is_data() const { return (((data)&0x7000) >> 12) == 0; } // X000
69 bool is_data_zs() const { return (((data)&0x6000) >> 13) == 0; } // X00X
70 bool is_channel_ID() const { return (((data)&0x7000) >> 12) == 1; } // X001
71 bool is_Feu_header() const { return (((data)&0x7000) >> 12) == 6; } // X110
72 bool is_data_header() const { return (((data)&0x6000) >> 13) == 1; } // X01X
73 bool get_zs_mode() const { return (((data)&0x400) >> 10); }
74 int get_Feu_ID() const { return (((data)&0xFF)); }
75 long int get_finetstp() const { return (((data)&0x0007)); }
76 // #define GET_FINETSTP(word) (word & 0x0007)
77 int get_sample_ID() const { return (((data)&0xFF8) >> 3); }
78 int get_channel_ID() const { return (((data)&0x3F)); }
79 int get_dream_ID() const { return (((data)&0xE00) >> 9); } // non-zS mode
80 int get_dream_ID_ZS() const { return (((data)&0xE00) >> 6); } // zS mode
81 int get_TimeStamp_Op() const { return (((data)&0x1FF)); }
82 int get_data() const { return (((data)&0xFFF)); }
83 unsigned short int data;
84 };
85
86 class FeuReadOut {
87 public:
88 int Id = -1;
89 int N = -1;
90 DataLineDream current_data;
91 bool data_to_treat = false;
92 bool event_completed = false;
93 bool last_event = false;
94 bool FeuHeaderLoaded;
95 int FeuHeaderLine = 0;
96 int DataHeaderLine = 0;
97 int DataTrailerLine = 0;
98 int asicN = -1;
99 int channelN = 0;
100 int channel_data;
101 int physChannel = 0;
102 int EventID = -1;
103 int EventID_Op = -1;
104 int TriggerID = -1;
105 int TriggerID_ISB = -1;
106 int TriggerID_LSB = -1;
107 int CMN = -1;
108 int CMN_rest = -1;
109 long int Cell_ID = -1;
110 int Cell_ID_ISB = -1;
111 int Cell_ID_LSB = -1;
112 int Cell_ID_MSB = -1;
113 long int TimeStamp = -1;
114 long int TimeStamp_Op1 = -1;
115 long int TimeStamp_Op2 = -1;
116 long int TimeStamp_Op3 = -1;
117 long int FineTimeStamp = -1;
118 int isample = -1;
119 int isample_prev = -2;
120 bool zs_mode = false;
121
122 FeuReadOut() {}
123
124 void NewEvent() {
125 FeuHeaderLoaded = false;
126 EventID = -1;
127 event_completed = false;
128 isample = -1;
129 isample_prev = -2;
130 FeuHeaderLine = 0;
131 DataHeaderLine = 0;
132 FineTimeStamp = -1;
133 TimeStamp = -1;
134 Id = -1;
135 }
136 };
137
138 // unsigned int fLastEventId;
139 // Double_t fLastTimeStamp;
140 const int NstripMax = 64; // number of strips on each chip
141 const int MaxPhysChannel = 512;
142 bool bad_event; // flag to tag bad event
143 int line; // line number
144 int Nevent, Nbadevent; // current event number
145 int IDEvent = 0; // ID of event in Feu header
146 // double MaxThreshold;
147
148 public:
149 bool ReadFeuHeaders(FeuReadOut& feu);
150 bool ReadDreamData(FeuReadOut& feu);
151 bool ReadFeuTrailer(FeuReadOut& feu);
152 bool ReadEvent(FeuReadOut& feu);
153
154 void InitProcess() override;
155 void Initialize() override;
156 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
157 const char* GetProcessName() const override { return "DreamToSignal"; }
158
159 // Constructor
161 TRestRawFEUDreamToSignalProcess(const char* configFilename);
162
163 // Destructor
165
166 ClassDefOverride(TRestRawFEUDreamToSignalProcess, 1);
167};
168
169#endif
A base class for any REST event.
Definition: TRestEvent.h:38
An process to read binary data from FEUDream electronics.
void Initialize() override
Making default settings.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
A base class for any process reading a binary external file as input to REST.