REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawBiPoToSignalProcess.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_TRestBiPoToSignalProcess
24#define RestCore_TRestBiPoToSignalProcess
25
26#include "TRestRawSignalEvent.h"
27#include "TRestRawToSignalProcess.h"
28
29constexpr size_t CTAG_SZ = 4;
30
31constexpr int MATACQ_N_CH = 4; // Number of channels
32constexpr int MATACQ_MAX_DATA_SAMP = 10240; // Max number of samples for
33constexpr int MATACQ_BIPO_TIMEOUT = 0; // BiPo mode timeout
34
35constexpr uint32_t MATACQ_UNDERFLOW = 0x0000;
36constexpr uint32_t MATACQ_ZERO = 0x8000;
37constexpr uint32_t MATACQ_OVERFLOW = 0xFFFF;
38
39constexpr char TAG_RUN_START[] = "STA";
40constexpr char TAG_RUN_BIPO[] = "ST2";
41constexpr char TAG_RUN_STOP[] = "STO";
42constexpr char TAG_ACQ[] = "ACQ";
43constexpr char TAG_ACQ_2[] = "AC2";
44
47 public:
49 struct MatacqBoard {
51 int32_t address;
52
53 std::array<int32_t, MATACQ_N_CH> en_ch;
54 std::array<int32_t, MATACQ_N_CH> trg_ch;
55
56 int32_t Trig_Type;
57 int32_t Threshold;
58 int32_t Nb_Acq;
59 int32_t Posttrig;
60 int32_t Time_Tag_On;
61 int32_t Sampling_GHz;
62
63 std::array<int32_t, MATACQ_N_CH> ch_shifts;
64 int32_t nChannels;
65 };
66
68 struct BiPoSettings {
69 int32_t trigger_address;
70
71 int32_t Win1_Posttrig;
72 int32_t Timeout_200KHz;
73
74 std::array<int32_t, MATACQ_N_CH> Trig_Chan;
75 std::array<int32_t, MATACQ_N_CH> Level1_mV;
76 std::array<int32_t, MATACQ_N_CH> Level2_mV;
77
78 int32_t t1_window;
79 int32_t t2_window;
80 int32_t t1_t2_timeout;
81 };
82
83 protected:
85 Int_t fNBoards = 0;
86
88 std::vector<MatacqBoard> fMatacqBoard; //<
89
91 std::vector<BiPoSettings> fBiPoSettings; //<
92
94 Int_t fEventCounter = 0;
95
96 void ReadHeader();
97 void ReadFooter();
98 void ReadBoard();
99 void ReadBiPoSetup();
100 Int_t ReadBiPoEventData(std::vector<uint16_t>& mdata);
101
102 UInt_t GetBoardIndex(Int_t address);
103 Int_t GetBin(Int_t boardIndex, Int_t channel, Int_t bin);
104
105 public:
106 void InitProcess() override;
107 void Initialize() override;
108 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
109
111 const char* GetProcessName() const override { return "BiPoToSignal"; }
112
113 void PrintMetadata() override;
114
116 MatacqBoard GetMatacqBoard(Int_t n) { return n > fNBoards ? (MatacqBoard){} : fMatacqBoard[n]; }
117
120
123
124 ClassDefOverride(TRestRawBiPoToSignalProcess, 1);
125};
126
127#endif
A base class for any REST event.
Definition: TRestEvent.h:38
An process to read binary data from BiPo electronics.
const char * GetProcessName() const override
Returs a given process name.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
MatacqBoard GetMatacqBoard(Int_t n)
It gives access to a Matacq board confituration.
Int_t GetBin(Int_t boardIndex, Int_t channel, Int_t bin)
It returns the ordered channel value from the Matacq memory buffer for a given board,...
std::vector< BiPoSettings > fBiPoSettings
A vector of BiPo settings.
Int_t ReadBiPoEventData(std::vector< uint16_t > &mdata)
This method reads the event data corresponding to one event. The sampled channel data that will be ma...
void ReadBoard()
This method reads the settings of one of the Matacq boards.
void ReadFooter()
This method reads the header data containing the run timestamp, the number of Matacq boards,...
TRestRawBiPoToSignalProcess()
Default constructor.
Int_t fNBoards
The number of Matacq boards present on the setup.
void ReadHeader()
This method reads the header data containing the run timestamp, the number of Matacq boards,...
UInt_t GetBoardIndex(Int_t address)
It returns the std::vector storage index using the hardware address of the Matacq board.
BiPoSettings GetBiPoSettings(Int_t n)
It gives access to confituration of BiPo settings.
~TRestRawBiPoToSignalProcess()
Default destructor.
Int_t fEventCounter
A temporary counter used to define the event id.
std::vector< MatacqBoard > fMatacqBoard
A vector of Matacq boards that contain the information of each card.
void InitProcess() override
Process initialization. Data members that require initialization just before start processing should ...
void PrintMetadata() override
Prints out the Matacq boards configuration and BiPo setup.
void ReadBiPoSetup()
This method reads the header data corresponding to the BiPo settings of one card.
void Initialize() override
Function to initialize input/output event members and define the section name.
A base class for any process reading a binary external file as input to REST.
A structure to store the BiPo settings.
A structure to store the configuration settings of Matacq board.
int32_t address
The base memory address of the Matacq board.