REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawMultiCoBoAsAdToSignalProcess.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_TRestRawMultiCoBoAsAdToSignalProcess
24#define RestCore_TRestRawMultiCoBoAsAdToSignalProcess
25
26#include <map>
27
28#include "TRestRawSignalEvent.h"
29#include "TRestRawToSignalProcess.h"
30
31struct CoBoDataFrame {
32 CoBoDataFrame() {
33 timeStamp = 0;
34 evId = -1;
35 asadId = -1;
36 for (bool& m : chHit) m = kFALSE;
37 for (auto& m : data) {
38 for (int& l : m) {
39 l = 0;
40 }
41 }
42 }
43 TTimeStamp timeStamp;
44 Bool_t chHit[272];
45 Int_t data[272][512];
46 Int_t evId; // if equals -1, this data frame is used but have not been
47 // re-filled
48 Int_t asadId;
49 Bool_t finished;
50};
51
52struct CoBoHeaderFrame {
53 CoBoHeaderFrame() {
54 for (unsigned char& m : frameHeader) {
55 m = 0;
56 }
57 // 4294967295 == -1 --> ends reading
58 // 4294967294 == -2 --> just initialized
59 eventIdx = (unsigned int)4294967294;
60 }
61 UChar_t frameHeader[256]; // 256: size of header of the cobo data frame
62
63 unsigned int frameSize;
64 unsigned int frameType;
65 unsigned int revision;
66 unsigned int headerSize;
67 unsigned int itemSize;
68 unsigned int nItems;
69 unsigned int eventIdx;
70 unsigned int asadIdx;
71 unsigned int readOffset;
72 unsigned int status;
73
74 Long64_t eventTime;
75 // TTimeStamp fEveTimeStamp;
76 // int fEveTimeSec;
77 // int fEveTimeNanoSec;
78
79 void Show() {
80 std::cout << "------ Frame Header ------" << std::endl;
81 std::cout << "frameSize " << frameSize << std::endl;
82
83 std::cout << "frameType " << frameType << std::endl;
84 std::cout << "revision " << revision << std::endl;
85 std::cout << "headerSize " << headerSize << std::endl;
86 std::cout << "itemSize " << itemSize << std::endl;
87 std::cout << "nItems " << nItems << std::endl;
88 std::cout << "eventTime " << eventTime << std::endl;
89 std::cout << "eventIdx " << eventIdx << std::endl;
90
91 std::cout << "asadIdx " << asadIdx << std::endl;
92 std::cout << "readOffset " << readOffset << std::endl;
93 std::cout << "status " << status << std::endl;
94 }
95};
96
98 private:
99#ifndef __CINT__
100 TRestRawSignal signal;
101
102 UChar_t frameDataP[2048];
103 UChar_t frameDataF[278528];
104
105 TTimeStamp fStartTimeStamp;
106
107 std::map<int, CoBoDataFrame> fDataFrame;
108
109 std::vector<CoBoHeaderFrame> fHeaderFrame;
110
111 int fCurrentEvent = -1;
112 int fNextEvent = -1;
113#endif
114
115 public:
116 void InitProcess() override;
117
118 Bool_t AddInputFile(const std::string& file) override;
119
120 void Initialize() override;
121
122 Bool_t InitializeStartTimeStampFromFilename(TString fName);
123
124 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
125
126 void EndProcess() override;
127
128 Bool_t FillBuffer(Int_t n);
129
130 bool FillBuffer();
131
132 bool ReadFrameHeader(CoBoHeaderFrame& Frame);
133
134 bool ReadFrameDataP(FILE* f, CoBoHeaderFrame& hdr);
135 bool ReadFrameDataF(CoBoHeaderFrame& hdr);
136
137 Bool_t EndReading();
138
139 // Constructor
141 TRestRawMultiCoBoAsAdToSignalProcess(const char* configFilename);
142 // Destructor
144
145 const char* GetProcessName() const override { return "RawMultiCoBoAsAdToSignal"; }
146
147 ClassDefOverride(TRestRawMultiCoBoAsAdToSignalProcess, 1);
148};
149#endif
A base class for any REST event.
Definition: TRestEvent.h:38
UChar_t frameDataF[278528]
///for partial readout data frame
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void Initialize() override
Making default settings.
int fCurrentEvent
///reserves a header frame for each file
TTimeStamp fStartTimeStamp
///for full readout data frame
void EndProcess() override
To be executed at the end of the run (outside event loop)
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
std::vector< CoBoHeaderFrame > fHeaderFrame
///asadId, dataframe
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
A base class for any process reading a binary external file as input to REST.