|
| 1 | +#include <string> |
| 2 | +#include <TH1.h> |
| 3 | + |
| 4 | +#include "Framework/DataSampling.h" |
| 5 | +#include "Framework/DataSamplingReadoutAdapter.h" |
| 6 | +#include "EMCALWorkflow/PublisherSpec.h" |
| 7 | +#include "QualityControl/InfrastructureGenerator.h" |
| 8 | +#include "QualityControl/Checker.h" |
| 9 | +#include "QualityControl/CheckerFactory.h" |
| 10 | + |
| 11 | +void customize(std::vector<o2::framework::CompletionPolicy>& policies) |
| 12 | +{ |
| 13 | + o2::framework::DataSampling::CustomizeInfrastructure(policies); |
| 14 | + o2::quality_control::customizeInfrastructure(policies); |
| 15 | +} |
| 16 | + |
| 17 | +void customize(std::vector<o2::framework::ChannelConfigurationPolicy>& policies) |
| 18 | +{ |
| 19 | + o2::framework::DataSampling::CustomizeInfrastructure(policies); |
| 20 | +} |
| 21 | + |
| 22 | +void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions) |
| 23 | +{ |
| 24 | + workflowOptions.push_back( |
| 25 | + o2::framework::ConfigParamSpec{ "config-path", o2::framework::VariantType::String, "", { "Path to the config file. Overwrite the default paths. Do not use with no-data-sampling." } }); |
| 26 | + workflowOptions.push_back( |
| 27 | + o2::framework::ConfigParamSpec{ "no-data-sampling", o2::framework::VariantType::Bool, false, { "Skips data sampling, connects directly the task to the producer." } }); |
| 28 | +} |
| 29 | + |
| 30 | +#include "Framework/runDataProcessing.h" |
| 31 | + |
| 32 | +std::string getConfigPath(const o2::framework::ConfigContext& config); |
| 33 | + |
| 34 | +o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& config) |
| 35 | +{ |
| 36 | + o2::framework::WorkflowSpec specs; |
| 37 | + specs.push_back(o2::emcal::getPublisherSpec(o2::emcal::PublisherConf{ |
| 38 | + "emcal-digit-reader", |
| 39 | + "o2sim", |
| 40 | + { "digitbranch", "EMCALDigit", "Digit branch" }, |
| 41 | + { "mcbranch", "EMCALDigitMCTruth", "MC label branch" }, |
| 42 | + o2::framework::OutputSpec{ "EMC", "DIGITS" }, |
| 43 | + o2::framework::OutputSpec{ "EMC", "DIGITSMCTR" } }, |
| 44 | + false)); |
| 45 | + |
| 46 | + // Path to the config file |
| 47 | + std::string qcConfigurationSource = getConfigPath(config); |
| 48 | + |
| 49 | + // Generation of the QC topology |
| 50 | + o2::quality_control::generateRemoteInfrastructure(specs, qcConfigurationSource); |
| 51 | + |
| 52 | + /* |
| 53 | + o2::framework::DataProcessorSpec printer{ |
| 54 | + "printer", |
| 55 | + o2::framework::Inputs{ |
| 56 | + {"checked-mo", "QC", o2::quality_control::checker::Checker::createCheckerDataDescription("DigitsQcTask"), 0} |
| 57 | + }, |
| 58 | + o2::framework::Outputs{}, |
| 59 | + o2::framework::AlgorithmSpec{ |
| 60 | + (o2::framework::AlgorithmSpec::InitCallback) [](o2::framework::InitContext& initContext) { |
| 61 | +
|
| 62 | + return (o2::framework::AlgorithmSpec::ProcessCallback) [](o2::framework::ProcessingContext& processingContext) mutable { |
| 63 | + std::shared_ptr<TObjArray> moArray{ |
| 64 | + std::move(o2::framework::DataRefUtils::as<TObjArray>(*processingContext.inputs().begin())) |
| 65 | + }; |
| 66 | +
|
| 67 | + for (const auto& to : *moArray) { |
| 68 | + MonitorObject* mo = dynamic_cast<MonitorObject*>(to); |
| 69 | +
|
| 70 | + if (mo->getName() == "example") { |
| 71 | + auto* g = dynamic_cast<TH1F*>(mo->getObject()); |
| 72 | + std::string bins = "BINS:"; |
| 73 | + for (int i = 0; i < g->GetNbinsX(); i++) { |
| 74 | + bins += " " + std::to_string((int) g->GetBinContent(i)); |
| 75 | + } |
| 76 | + LOG(INFO) << bins; |
| 77 | + } |
| 78 | + } |
| 79 | + }; |
| 80 | + } |
| 81 | + } |
| 82 | + }; |
| 83 | + specs.push_back(printer); |
| 84 | +*/ |
| 85 | + LOG(INFO) << "Using config file '" << qcConfigurationSource << "'"; |
| 86 | + o2::framework::DataSampling::GenerateInfrastructure(specs, qcConfigurationSource); |
| 87 | + |
| 88 | + return specs; |
| 89 | +} |
| 90 | + |
| 91 | +std::string getConfigPath(const o2::framework::ConfigContext& config) |
| 92 | +{ |
| 93 | + std::string userConfigPath = config.options().get<std::string>("config-path"); |
| 94 | + std::string defaultConfigPath = getenv("QUALITYCONTROL_ROOT") != nullptr ? std::string(getenv("QUALITYCONTROL_ROOT")) + "/Modules/EMCAL/etc/digits.json" : "$QUALITYCONTROL_ROOT undefined"; |
| 95 | + std::string path = userConfigPath == "" ? defaultConfigPath : userConfigPath; |
| 96 | + const std::string qcConfigurationSource = std::string("json:/") + path; |
| 97 | + return qcConfigurationSource; |
| 98 | +} |
0 commit comments