Project
Loading...
Searching...
No Matches
EntropyDecoderSpec.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
13
14#include <vector>
15
22#include <TStopwatch.h>
23
24using namespace o2::framework;
25
26namespace o2
27{
28namespace trd
29{
31{
32 public:
33 EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt = "none");
34 ~EntropyDecoderSpec() override = default;
36 void init(o2::framework::InitContext& ic) final;
38 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
39
40 private:
41 o2::trd::CTFCoder mCTFCoder;
42 bool mCorrectLML0 = false;
43 TStopwatch mTimer;
44};
45
46EntropyDecoderSpec::EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder, ctfdictOpt)
47{
48 mTimer.Stop();
49 mTimer.Reset();
50 mCTFCoder.setVerbosity(verbosity);
51 mCTFCoder.setSupportBCShifts(true);
52 mCTFCoder.setDictBinding("ctfdict_TRD");
53}
54
56{
57 static int bcshift = 0;
58
59 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj) && mCorrectLML0) {
60 // check if the LM_L0 shift was updated
61 const auto& trigOffsParam = o2::ctp::TriggerOffsetsParam::Instance();
62 if (bcshift != trigOffsParam.LM_L0) {
63 bcshift = trigOffsParam.LM_L0;
64 auto customShift = trigOffsParam.customOffset[o2::detectors::DetID::TRD];
65 LOGP(info, "Decoded IRs will be corrected by {} BCs (LM_L0 {} + custom {}), discarded if become prior to 1st orbit", -(bcshift - customShift), -bcshift, customShift);
66 mCTFCoder.setBCShift(bcshift - customShift);
67 }
68 return;
69 }
70}
71
73{
74 mCTFCoder.init<CTF>(ic);
75 mCorrectLML0 = ic.options().get<bool>("correct-trd-trigger-offset");
76
77 int checkBogus = ic.options().get<int>("bogus-trigger-rejection");
78 mCTFCoder.setCheckBogusTrig(checkBogus);
79 LOGP(info, "Bogus triggers rejection flag: {}", checkBogus);
80}
81
83{
84 auto cput = mTimer.CpuTime();
85 mTimer.Start(false);
86 o2::ctf::CTFIOSize iosize;
87
88 mCTFCoder.updateTimeDependentParams(pc, true);
89 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_TRD");
90
91 auto& triggers = pc.outputs().make<std::vector<TriggerRecord>>(OutputRef{"triggers"});
92 auto& tracklets = pc.outputs().make<std::vector<Tracklet64>>(OutputRef{"tracklets"});
93 auto& digits = pc.outputs().make<std::vector<Digit>>(OutputRef{"digits"});
94
95 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
96 if (buff.size()) {
97 const auto ctfImage = o2::trd::CTF::getImage(buff.data());
98 iosize = mCTFCoder.decode(ctfImage, triggers, tracklets, digits);
99 }
100 pc.outputs().snapshot({"ctfrep", 0}, iosize);
101 mTimer.Stop();
102 LOG(info) << "Decoded " << tracklets.size() << " TRD tracklets and " << digits.size() << " digits in " << triggers.size() << " triggers, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
103}
104
106{
107 LOGF(info, "TRD Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
108 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
109}
110
111DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string& ctfdictOpt)
112{
113 std::vector<OutputSpec> outputs{
114 OutputSpec{{"triggers"}, "TRD", "TRKTRGRD", 0, Lifetime::Timeframe},
115 OutputSpec{{"tracklets"}, "TRD", "TRACKLETS", 0, Lifetime::Timeframe},
116 OutputSpec{{"digits"}, "TRD", "DIGITS", 0, Lifetime::Timeframe},
117 OutputSpec{{"ctfrep"}, "TRD", "CTFDECREP", 0, Lifetime::Timeframe}};
118
119 std::vector<InputSpec> inputs;
120 inputs.emplace_back("ctf_TRD", "TRD", "CTFDATA", sspec, Lifetime::Timeframe);
121
122 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
123 inputs.emplace_back("ctfdict_TRD", "TRD", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CTFDictionaryTree"));
124 }
125 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
126
127 return DataProcessorSpec{
128 "trd-entropy-decoder",
129 inputs,
130 outputs,
131 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, ctfdictOpt)},
132 Options{{"correct-trd-trigger-offset", VariantType::Bool, false, {"Correct decoded IR by TriggerOffsetsParam::LM_L0"}},
133 {"bogus-trigger-rejection", VariantType::Int, 10, {">0 : discard, warn N times, <0 : warn only, =0: no check for triggers with no tracklets or bogus IR"}},
134 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
135}
136} // namespace trd
137} // namespace o2
#define verbosity
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
class for entropy encoding/decoding of TRD data
Convert CTF (EncodedBlocks) to TRD digit/tracklets stream.
void setSupportBCShifts(bool v=true)
void updateTimeDependentParams(o2::framework::ProcessingContext &pc, bool askTree=false)
void setDictBinding(const std::string &s)
void init(o2::framework::InitContext &ic)
void setBCShift(int64_t n)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static auto getImage(const void *newHead)
get const image of the container wrapper, with pointers in the image relocated to new head
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
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.
void setCheckBogusTrig(int v)
Definition CTFCoder.h:52
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &trigVec, VTRK &trkVec, VDIG &digVec)
entropy decode data from buffer with CTF
Definition CTFCoder.h:179
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void init(o2::framework::InitContext &ic) final
~EntropyDecoderSpec() override=default
EntropyDecoderSpec(int verbosity, const std::string &ctfdictOpt="none")
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
framework::DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string &ctfdictOpt="none")
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string asString() const
Definition CTFIOSize.cxx:19
wrapper for the Entropy-encoded triggers and cells of the TF
Definition CTF.h:41
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage
std::vector< Digit > digits
std::vector< Tracklet64 > tracklets