QualityControl  1.5.1
O2 Data Quality Control Framework
ExamplePrinterSpec.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
15 
16 #ifndef QUALITYCONTROL_EXAMPLEPRINTERSPEC_H
17 #define QUALITYCONTROL_EXAMPLEPRINTERSPEC_H
18 
19 #include <string>
20 #include <memory>
21 
22 #include <TH1F.h>
23 #include <TObjArray.h>
24 
25 #include <Framework/Task.h>
26 #include <Framework/DataRefUtils.h>
27 
29 #include "QualityControl/QualityObject.h"
30 
32 {
33 
40 class ExamplePrinterSpec : public framework::Task
41 {
42  public:
43  void run(ProcessingContext& processingContext) final
44  {
45  LOG(INFO) << "Received data";
46  std::shared_ptr<TObjArray> moArray{ DataRefUtils::as<TObjArray>(*processingContext.inputs().begin()) };
47 
48  if (moArray->IsEmpty()) {
49  LOG(INFO) << "Array is empty";
50  return;
51  }
52 
53  // get the object
54  auto* mo = dynamic_cast<MonitorObject*>(moArray->At(0));
55  if (mo == nullptr) {
56  LOG(INFO) << "First element is not a MonitorObject";
57  return;
58  }
59  auto* histo = dynamic_cast<TH1F*>(mo->getObject());
60  if (histo == nullptr) {
61  LOG(INFO) << "MonitorObject does not contain a TH1";
62  return;
63  }
64 
65  std::string bins = "BINS:";
66  for (int i = 0; i < histo->GetNbinsX(); i++) {
67  bins += " " + std::to_string((int)histo->GetBinContent(i));
68  }
69  LOG(INFO) << bins;
70  }
71 };
72 
79 class ExampleQualityPrinterSpec : public framework::Task
80 {
81  public:
82  void run(ProcessingContext& processingContext) final
83  {
84  auto qo = processingContext.inputs().get<QualityObject*>("checked-mo");
85 
86  LOG(INFO) << "Received Quality: " << qo->getQuality();
87  }
88 };
89 
90 } // namespace o2::quality_control::example
91 
92 #endif //QUALITYCONTROL_EXAMPLEPRINTERSPEC_H
Example DPL task to be plugged after a QC check.
Definition: ExamplePrinterSpec.h:79
Encapsulation of a Quality into a TObject that can be streamed and stored.
Definition: QualityObject.h:29
Definition: ExamplePrinterSpec.h:31
Example DPL task to be plugged after a QC task.
Definition: ExamplePrinterSpec.h:40
This class keeps the meta data about one published object.
Definition: MonitorObject.h:41