Project
Loading...
Searching...
No Matches
ClusterizerSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#include <fairlogger/Logger.h>
12
20
21using namespace o2::cpv::reco_workflow;
22
24{
25 LOG(debug) << "[CPVClusterizer - init] Initialize clusterizer ...";
26
27 // Initialize clusterizer and link geometry
28 mClusterizer.initialize();
29 mClusterizer.propagateMC(mPropagateMC);
30}
31
33{
34 LOG(info) << "Starting ClusterizerSpec::run() ";
35 LOG(debug) << "CPVClusterizer - run on digits called";
36
37 // update config
38 static bool isConfigFetched = false;
39 if (!isConfigFetched) {
40 LOG(info) << "ClusterizerSpec::run() : fetching o2::cpv::CPVSimParams from CCDB";
41 ctx.inputs().get<o2::cpv::CPVSimParams*>("simparams");
42 LOG(info) << "ClusterizerSpec::run() : o2::cpv::CPVSimParams::Instance() now is following:";
44 isConfigFetched = true;
45 }
46
47 auto digits = ctx.inputs().get<std::vector<Digit>>("digits");
48
49 if (!digits.size()) { // nothing to process
50 LOG(info) << "ClusterizerSpec::run() : no digits; moving on";
51 mOutputClusters.clear();
52 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CLUSTERS", 0}, mOutputClusters);
53 mOutputClusterTrigRecs.clear();
54 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CLUSTERTRIGRECS", 0}, mOutputClusterTrigRecs);
55 mCalibDigits.clear();
56 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CALIBDIGITS", 0}, mCalibDigits);
57 if (mPropagateMC) {
58 mOutputTruthCont.clear();
59 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CLUSTERTRUEMC", 0}, mOutputTruthCont);
60 }
61 return;
62 }
63 auto digitsTR = ctx.inputs().get<std::vector<o2::cpv::TriggerRecord>>("digitTriggerRecords");
64
65 // const o2::dataformats::MCTruthContainer<MCCompLabel>* truthcont = nullptr;
66 // DO NOT TRY TO USE const pointer for MCTruthContainer, it is somehow spoiling whole array
67 if (mPropagateMC) {
68 auto truthcont = ctx.inputs().get<o2::dataformats::MCTruthContainer<o2::MCCompLabel>*>("digitsmctr");
69 mClusterizer.process(digits, digitsTR, truthcont.get(), &mOutputClusters, &mOutputClusterTrigRecs, &mOutputTruthCont, &mCalibDigits); // Find clusters with MC Truth
70 } else {
71 mClusterizer.process(digits, digitsTR, nullptr, &mOutputClusters, &mOutputClusterTrigRecs, &mOutputTruthCont, &mCalibDigits); // Find clusters without MC Truth
72 }
73
74 LOG(debug) << "CPVClusterizer::run() : Received " << digitsTR.size() << " TR, calling clusterizer ...";
75
76 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CLUSTERS", 0}, mOutputClusters);
77 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CLUSTERTRIGRECS", 0}, mOutputClusterTrigRecs);
78 if (mPropagateMC) {
79 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CLUSTERTRUEMC", 0}, mOutputTruthCont);
80 }
81 ctx.outputs().snapshot(o2::framework::Output{"CPV", "CALIBDIGITS", 0}, mCalibDigits);
82 LOG(info) << "Finished, wrote " << mOutputClusters.size() << " clusters, " << mOutputClusterTrigRecs.size() << "TR and " << mOutputTruthCont.getIndexedSize() << " Labels";
83}
85{
86 std::vector<o2::framework::InputSpec> inputs;
87 std::vector<o2::framework::OutputSpec> outputs;
88 inputs.emplace_back("simparams", "CPV", "CPV_SimPars", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("CPV/Config/CPVSimParams"));
89 inputs.emplace_back("digits", o2::header::gDataOriginCPV, "DIGITS", 0, o2::framework::Lifetime::Timeframe);
90 inputs.emplace_back("digitTriggerRecords", o2::header::gDataOriginCPV, "DIGITTRIGREC", 0, o2::framework::Lifetime::Timeframe);
91 if (propagateMC) {
92 inputs.emplace_back("digitsmctr", "CPV", "DIGITSMCTR", 0, o2::framework::Lifetime::Timeframe);
93 }
94 outputs.emplace_back("CPV", "CLUSTERS", 0, o2::framework::Lifetime::Timeframe);
95 outputs.emplace_back("CPV", "CLUSTERTRIGRECS", 0, o2::framework::Lifetime::Timeframe);
96 if (propagateMC) {
97 outputs.emplace_back("CPV", "CLUSTERTRUEMC", 0, o2::framework::Lifetime::Timeframe);
98 }
99 outputs.emplace_back("CPV", "CALIBDIGITS", 0, o2::framework::Lifetime::Timeframe);
100
101 return o2::framework::DataProcessorSpec{"CPVClusterizerSpec",
102 inputs,
103 outputs,
104 o2::framework::adaptFromTask<o2::cpv::reco_workflow::ClusterizerSpec>(propagateMC)};
105}
std::ostringstream debug
void printKeyValues(bool showProv=true, bool useLogger=false) const final
void process(gsl::span< const Digit > digits, gsl::span< const TriggerRecord > dtr, const o2::dataformats::MCTruthContainer< o2::MCCompLabel > *dmc, std::vector< Cluster > *clusters, std::vector< TriggerRecord > *trigRec, o2::dataformats::MCTruthContainer< o2::MCCompLabel > *cluMC, std::vector< Digit > *calibDigits)
Definition Clusterer.cxx:39
void propagateMC(bool toRun=true)
Definition Clusterer.h:46
void run(framework::ProcessingContext &ctx) final
Clusterizes digits into clusters.
void init(framework::InitContext &ctx) final
Initializing the ClusterizerSpec.
A container to hold and manage MC truth information/labels.
void snapshot(const Output &spec, T const &object)
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
constexpr o2::header::DataOrigin gDataOriginCPV
Definition DataHeader.h:563
framework::DataProcessorSpec getClusterizerSpec(bool propagateMC)
Creating DataProcessorSpec for the CPV Clusterizer Spec.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits