48#include "TRestDataQualityProcess.h"
87 SetName(this->ClassName());
88 SetTitle(
"Default config");
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)))
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);
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)) !=
"") {
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;
238 RESTMetadata <<
"xxxxxxxxxxxxxxxxxxxxxx" <<
RESTendl;
240 RESTMetadata <<
"xxxxxxxxxxxxxxxxxxxxxx" <<
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++)
247 RESTMetadata <<
fRules[n].GetValue(r) <<
" is in range (" <<
fRules[n].GetRange(r).X() <<
", "
251 if (!rulesInRange) RESTMetadata <<
"No rules found in range!" <<
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++)
259 RESTMetadata <<
fRules[n].GetValue(r) <<
" is NOT in range (" <<
fRules[n].GetRange(r).X()
263 if (!rulesOutRange) RESTMetadata <<
"No rules found outside range!" <<
RESTendl;
269Bool_t TRestDataQualityProcess::EvaluateMetadataRule(TString value, TVector2 range) {
272 if (results.size() == 2) {
273 if (
fRunInfo->GetMetadataClass(results[0])) {
278 if (dblVal >= range.X() && dblVal <= range.Y())
return true;
279 }
else if (GetFriend(results[0])) {
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 EnableBit(UInt_t &number, Int_t bitPosition)
It sets to 1 the bit of number at position bitPosition
std::vector< UInt_t > fQualityNumber
A std::vector of custom quality numbers.
std::vector< TString > fQualityTag
A std::vector of tag names for each quality number.
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 DisableBit(UInt_t &number, Int_t bitPosition)
It sets to 0 the bit of number at position bitPosition
std::vector< TRestDataQualityRules > fRules
A std::vector with the rule definitions for each quality number.
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.
void BeginPrintProcess()
[name, cut range]
TRestRun * fRunInfo
< Pointer to TRestRun object where to find metadata.
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.