REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawDAQMetadata.cxx
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
60#include "TRestRawDAQMetadata.h"
61using namespace std;
62
63ClassImp(TRestRawDAQMetadata);
64
65TRestRawDAQMetadata::TRestRawDAQMetadata() { Initialize(); }
66
67TRestRawDAQMetadata::TRestRawDAQMetadata(const char* configFilename) : TRestMetadata(configFilename) {
68 Initialize();
69
70 LoadConfigFromFile(fConfigFileName);
71
72 SetScriptsBuffer();
73 SetParFromPedBuffer();
74}
75
77 SetSectionName(this->ClassName());
78 SetLibraryVersion(LIBRARY_VERSION);
79}
80
81TRestRawDAQMetadata::~TRestRawDAQMetadata() { cout << "Deleting TRestRawDAQMetadata" << endl; }
82
84 // string daqString;
85
86 fNamePedScript = GetParameter("pedScript");
87 if (fNamePedScript == "") {
88 cout << "Pedestal script " << endl;
89 }
90
91 fNameRunScript = GetParameter("runScript");
92 if (fNameRunScript == "") {
93 cout << "Run script " << endl;
94 }
95
96 fElectronicsType = GetParameter("electronics");
97 if (fElectronicsType == "") {
98 cout << "electronic type not found " << endl;
99 }
100}
101
103 cout << endl;
104 cout << "====================================" << endl;
105 cout << "DAQ : " << GetTitle() << endl;
106 cout << "Pedestal script : " << fNamePedScript.Data() << endl;
107 cout << "Run script : " << fNameRunScript.Data() << endl;
108 cout << "Electronics type : " << fElectronicsType.Data() << endl;
109 cout << "Gain : " << GetGain() << endl;
110 cout << "Shapping time : " << GetShappingTime() << endl;
111 cout << "====================================" << endl;
112
113 cout << endl;
114}
115
116void TRestRawDAQMetadata::SetScriptsBuffer() {
117 TString folder = REST_PATH;
118 folder.Append("data/acquisition/");
119
120 TString fName;
121
122 fName = folder + fNamePedScript;
123
124 ifstream file(fName);
125 if (!file) {
126 cout << __PRETTY_FUNCTION__ << " ERROR:FILE " << fName << " not found " << endl;
127 return;
128 }
129
130 string line;
131 while (getline(file, line)) {
132 fPedBuffer.push_back(line);
133 }
134
135 file.close();
136
137 fName = folder + fNameRunScript;
138
139 ifstream file2(fName);
140 if (!file2) {
141 cout << __PRETTY_FUNCTION__ << " ERROR:FILE " << fName << " not found " << endl;
142 return;
143 }
144
145 while (getline(file2, line)) {
146 fRunBuffer.push_back(line);
147 }
148
149 file2.close();
150}
151
152void TRestRawDAQMetadata::PrintRunScript() {
153 for (unsigned int i = 0; i < fRunBuffer.size(); i++) cout << fRunBuffer[i].Data() << endl;
154}
155
156void TRestRawDAQMetadata::PrintPedScript() {
157 for (unsigned int i = 0; i < fPedBuffer.size(); i++) cout << fPedBuffer[i].Data() << endl;
158}
159
160void TRestRawDAQMetadata::SetParFromPedBuffer() {
161 for (unsigned int i = 0; i < fPedBuffer.size(); i++) {
162 if (fPedBuffer[i].Contains("aget * gain * "))
163 fGain = GetValFromString("aget * gain * ", fPedBuffer[i]);
164
165 if (fPedBuffer[i].Contains("aget * time "))
166 fShappingTime = GetValFromString("aget * time ", fPedBuffer[i]);
167
168 if (fPedBuffer[i].Contains("after * gain * "))
169 fGain = GetValFromString("after * gain * ", fPedBuffer[i]);
170
171 if (fPedBuffer[i].Contains("after * time "))
172 fShappingTime = GetValFromString("after * time ", fPedBuffer[i]);
173 }
174}
175
176UInt_t TRestRawDAQMetadata::GetValFromString(TString var, TString line) {
177 unsigned int val;
178
179 unsigned int varSize = var.Sizeof();
180 unsigned int lineSize = line.Sizeof();
181
182 TString diff(line(varSize - 1, lineSize - 1));
183
184 cout << diff.Data() << endl;
185
186 sscanf(diff.Data(), "0x%x", &val);
187
188 return val;
189}
A base class for any REST metadata class.
Definition: TRestMetadata.h:74
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
void SetSectionName(std::string sName)
set the section name, clear the section content
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.
A metadata class to store DAQ information.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void Initialize() override
Making default settings.