48 #include "TRestDataQualityProcess.h"
75 LoadConfig(configFilename);
87 SetName(this->ClassName());
88 SetTitle(
"Default config");
104 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
138 for (
unsigned int n = 0; n < fQualityNumber.size(); n++) {
140 for (
int r = 0; r < fRules[n].GetNumberOfRules(); r++) {
142 if (fRules[n].GetType(r) ==
"metadata") {
143 if (EvaluateMetadataRule(fRules[n].GetValue(r), fRules[n].GetRange(r)))
144 EnableBit(fQualityNumber[n], fRules[n].GetBit(r));
146 DisableBit(fQualityNumber[n], fRules[n].GetBit(r));
149 if (fRules[n].GetType(r) ==
"obsAverage") {
153 if (fRules[n].GetType(r) ==
"obsMax") {
177 string QNumberString;
180 while ((QNumberString = GetKEYStructure(
"qualityNumber", position)) !=
"NotFound") {
181 string qualityDefinition = GetKEYDefinition(
"qualityNumber", QNumberString);
183 TString name = GetFieldValue(
"name", qualityDefinition);
184 fQualityTag.push_back(name);
186 fQualityNumber.push_back(0);
190 RESTDebug <<
"Quality number tag : " << name << RESTendl;
191 RESTDebug <<
"------------------" << RESTendl;
193 size_t position_2 = 0;
194 string ruleDefinition;
195 while ((ruleDefinition = GetKEYDefinition(
"rule", position_2, QNumberString)) !=
"") {
197 TString type = GetFieldValue(
"type", ruleDefinition);
198 TString value = GetFieldValue(
"value", ruleDefinition);
214 rules.AddRule(type, value, range, bit);
216 RESTDebug <<
"Rule " << rules.GetNumberOfRules() << RESTendl;
217 RESTDebug <<
"+++++++++++" << RESTendl;
218 RESTDebug <<
"Type : " << type << RESTendl;
219 RESTDebug <<
"Value : " << value << RESTendl;
220 RESTDebug <<
"Bit : " << bit << RESTendl;
221 RESTDebug <<
"Range : (" << range.X() <<
", " << range.Y() <<
")" << RESTendl;
223 fRules.push_back(rules);
236 for (
unsigned int n = 0; n < fQualityNumber.size(); n++) {
237 RESTMetadata <<
" " << RESTendl;
238 RESTMetadata <<
"xxxxxxxxxxxxxxxxxxxxxx" << RESTendl;
239 RESTMetadata <<
" tag : " << fQualityTag[n] <<
". Quality number : " << fQualityNumber[n] << RESTendl;
240 RESTMetadata <<
"xxxxxxxxxxxxxxxxxxxxxx" << RESTendl;
241 RESTMetadata <<
" " << RESTendl;
242 RESTMetadata <<
"Rules that have been found in range:" << RESTendl;
243 RESTMetadata <<
" ----------------- " << RESTendl;
244 Int_t rulesInRange = 0;
245 for (
int r = 0; r < fRules[n].GetNumberOfRules(); r++)
246 if (isBitEnabled(fQualityNumber[n], fRules[n].GetBit(r))) {
247 RESTMetadata << fRules[n].GetValue(r) <<
" is in range (" << fRules[n].GetRange(r).X() <<
", "
248 << fRules[n].GetRange(r).Y() <<
")" << RESTendl;
251 if (!rulesInRange) RESTMetadata <<
"No rules found in range!" << RESTendl;
252 RESTMetadata <<
" " << RESTendl;
254 RESTMetadata <<
"Rules that have NOT been found in range:" << RESTendl;
255 RESTMetadata <<
" ----------------- " << RESTendl;
256 Int_t rulesOutRange = 0;
257 for (
int r = 0; r < fRules[n].GetNumberOfRules(); r++)
258 if (!isBitEnabled(fQualityNumber[n], fRules[n].GetBit(r))) {
259 RESTMetadata << fRules[n].GetValue(r) <<
" is NOT in range (" << fRules[n].GetRange(r).X()
260 <<
", " << fRules[n].GetRange(r).Y() <<
")" << RESTendl;
263 if (!rulesOutRange) RESTMetadata <<
"No rules found outside range!" << RESTendl;
269 Bool_t TRestDataQualityProcess::EvaluateMetadataRule(TString value, TVector2 range) {
272 if (results.size() == 2) {
273 if (fRunInfo->GetMetadataClass(results[0])) {
274 string val = fRunInfo->GetMetadataClass(results[0])->GetDataMemberValue(results[1]);
278 if (dblVal >= range.X() && dblVal <= range.Y())
return true;
279 }
else if (GetFriend(results[0])) {
280 string val = GetFriend(results[0])->GetDataMemberValue(results[1]);
284 if (dblVal >= range.X() && dblVal <= range.Y())
return true;
286 RESTError <<
"TRestDataQualityProcess::EvaluateMetadataRule." << RESTendl;
287 RESTError <<
"Metadata class " << results[0] <<
" is not available inside TRestRun" << RESTendl;
290 RESTError <<
"TRestDataQualityProcess::EvaluateMetadataRule. Wrong number of elements found"
A process to define and store quality numbers.
~TRestDataQualityProcess()
Default destructor.
void EndProcess() override
Function to use when all events have been processed.
void InitFromConfigFile() override
Function reading input parameters from the RML TRestDataQualityProcess section.
void PrintMetadata() override
It prints out the process parameters stored in the metadata structure.
TRestDataQualityProcess()
Default constructor.
void InitProcess() override
Function to use in initialization of process members before starting to process the event.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void Initialize() override
Function to initialize input/output event members and define the section name and library version.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
A class to define the properties of a rule inside TRestDataQualityRules.
A base class for any REST event.
@ REST_Extreme
show everything
@ REST_Info
+show most of the information for each steps
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
std::vector< std::string > Split(std::string in, std::string separator, bool allowBlankString=false, bool removeWhiteSpaces=false, int startPos=-1)
Split the input string according to the given separator. Returning a vector of fragments.
Double_t StringToDouble(std::string in)
Gets a double from a string.
Int_t StringToInteger(std::string in)
Gets an integer from a string.
TVector2 StringTo2DVector(std::string in)
Gets a 2D-vector from a string.