|
| 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 | + |
| 11 | +/// |
| 12 | +/// \file runTPCQCPID.cxx |
| 13 | +/// \author Jens Wiechula |
| 14 | +/// |
| 15 | +/// \brief run TPC PID QC task, reading tracks from file for the moment |
| 16 | +/// |
| 17 | + |
| 18 | +// IMPORTANT: |
| 19 | +// for some reason, if the 'customize' functions are below the other includes, |
| 20 | +// the options are not added to the workflow. |
| 21 | +// So the structure should be kept as it is |
| 22 | +#include "Framework/DataSampling.h" |
| 23 | +#include "QualityControl/InfrastructureGenerator.h" |
| 24 | + |
| 25 | +using namespace o2::framework; |
| 26 | + |
| 27 | +void customize(std::vector<CompletionPolicy>& policies) |
| 28 | +{ |
| 29 | + DataSampling::CustomizeInfrastructure(policies); |
| 30 | +} |
| 31 | + |
| 32 | +void customize(std::vector<ChannelConfigurationPolicy>& policies) |
| 33 | +{ |
| 34 | + DataSampling::CustomizeInfrastructure(policies); |
| 35 | +} |
| 36 | + |
| 37 | +void customize(std::vector<ConfigParamSpec>& workflowOptions) |
| 38 | +{ |
| 39 | + workflowOptions.push_back(ConfigParamSpec{ "input-file", VariantType::String, "tpctracks.root", { "Input file name for TPC tracks" } }); |
| 40 | + workflowOptions.push_back(ConfigParamSpec{ "tree-name", VariantType::String, "tpcrec", { "Name of the tree containing the TPC tracks vector" } }); |
| 41 | + workflowOptions.push_back(ConfigParamSpec{ "branch-name", VariantType::String, "TPCTracks", { "Name of the branch of the TPC tracks vector" } }); |
| 42 | +} |
| 43 | + |
| 44 | +// c++ includes |
| 45 | +#include <memory> |
| 46 | +#include <random> |
| 47 | + |
| 48 | +// ROOT includes |
| 49 | +#include <TH1F.h> |
| 50 | + |
| 51 | +// o2 included |
| 52 | +#include "Framework/runDataProcessing.h" |
| 53 | +#include "DPLUtils/RootTreeReader.h" |
| 54 | + |
| 55 | +// qc includes |
| 56 | +#include "QualityControl/Checker.h" |
| 57 | +#include "QualityControl/runnerUtils.h" |
| 58 | + |
| 59 | +WorkflowSpec defineDataProcessing(const ConfigContext& config) |
| 60 | +{ |
| 61 | + WorkflowSpec specs; |
| 62 | + |
| 63 | + // ===| workflow options |==================================================== |
| 64 | + // |
| 65 | + auto inputFile = config.options().get<std::string>("input-file"); |
| 66 | + auto treeName = config.options().get<std::string>("tree-name"); |
| 67 | + auto branchName = config.options().get<std::string>("branch-name"); |
| 68 | + |
| 69 | + // ===| tree reader |========================================================= |
| 70 | + // |
| 71 | + // The tree reader will read tpc tracks from file crated via the o2 sim/rec |
| 72 | + // workflow |
| 73 | + DataProcessorSpec producer{ |
| 74 | + "tpc-track-reader", |
| 75 | + Inputs{}, |
| 76 | + Outputs{ |
| 77 | + { "TPC", "TRACKS", 0, Lifetime::Timeframe } }, |
| 78 | + AlgorithmSpec{ |
| 79 | + (AlgorithmSpec::InitCallback)[inputFile, treeName, branchName](InitContext&){ |
| 80 | + |
| 81 | + // root tree reader |
| 82 | + //constexpr auto persistency = Lifetime::Transient; |
| 83 | + constexpr auto persistency = Lifetime::Timeframe; |
| 84 | + |
| 85 | + auto reader = std::make_shared<RootTreeReader>(treeName.data(), // tree name |
| 86 | + inputFile.data(), // input file name |
| 87 | + RootTreeReader::PublishingMode::Loop, // loop over |
| 88 | + Output{ "TPC", "TRACKS", 0, persistency }, |
| 89 | + branchName.data() // name of the branch |
| 90 | + ); |
| 91 | + |
| 92 | + return (AlgorithmSpec::ProcessCallback)[reader](ProcessingContext & processingContext) mutable |
| 93 | + { |
| 94 | + //(++(*reader))(processingContext); |
| 95 | + if (reader->next()) { |
| 96 | + (*reader)(processingContext); |
| 97 | + //LOG(INFO) << "Call producer AlgorithmSpec::ProcessCallback: has data " << reader->getCount(); |
| 98 | + } else { |
| 99 | + //LOG(INFO) << "Call producer AlgorithmSpec::ProcessCallback: no next data" << reader->getCount(); |
| 100 | + } |
| 101 | + }; |
| 102 | +} |
| 103 | +} |
| 104 | +} |
| 105 | +; |
| 106 | + |
| 107 | +specs.push_back(producer); |
| 108 | + |
| 109 | +// ===| QC task |============================================================= |
| 110 | +// |
| 111 | +std::string filename = "tpcQCPID.json"; |
| 112 | +const std::string qcConfigurationSource = std::string("json://") + getenv("QUALITYCONTROL_ROOT") + "/etc/" + filename; |
| 113 | +LOG(INFO) << "Using config file '" << qcConfigurationSource << "'"; |
| 114 | + |
| 115 | +// Generation of Data Sampling infrastructure |
| 116 | +DataSampling::GenerateInfrastructure(specs, qcConfigurationSource); |
| 117 | + |
| 118 | +// Generation of the QC topology (one task, one checker in this case) |
| 119 | +o2::quality_control::generateRemoteInfrastructure(specs, qcConfigurationSource); |
| 120 | + |
| 121 | +return specs; |
| 122 | +} |
0 commit comments