Project
Loading...
Searching...
No Matches
TRDTrackletTransformerSpec.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
12#include <gsl/span>
13#include <cstring>
14
16
23
24using namespace o2::framework;
25using namespace o2::globaltracking;
26
27namespace o2
28{
29namespace trd
30{
31
33{
35 if (ic.options().get<bool>("apply-xor")) {
36 mTransformer.setApplyXOR();
37 }
38 if ((getenv("ALIEN_JDL_LPMPRODUCTIONTYPE") && std::strcmp(getenv("ALIEN_JDL_LPMPRODUCTIONTYPE"), "MC") == 0) || ic.options().get<bool>("disable-shift")) {
39 LOGF(info, "TRD pad shift is not applied");
40 // apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
41 mTransformer.setApplyShift(false);
42 }
43}
44
46{
47 LOG(debug) << "Running tracklet transformer";
48
50 inputData.collectData(pc, *mDataRequest);
51 updateTimeDependentParams(pc); // Make sure this is called after recoData.collectData, which may load some conditions
52
53 auto tracklets = pc.inputs().get<gsl::span<Tracklet64>>("trdtracklets");
54 auto trigRecs = pc.inputs().get<gsl::span<TriggerRecord>>("trdtriggerrec");
55
56 std::vector<CalibratedTracklet> calibratedTracklets(tracklets.size());
57
58 std::vector<char> trigRecBitfield(trigRecs.size()); // flag TRD IR with ITS data (std::vector<bool> platform dependend)
59 int nTrackletsTransformed = 0;
60
61 if (mTrigRecFilterActive) {
62 const auto irFrames = inputData.getIRFramesITS();
63 size_t lastMatchedIdx = 0; // ITS IR are sorted in time and do not overlap
64 for (const auto& irFrame : irFrames) {
65 if (!irFrame.info) { // skip IRFrames where ITS did not find any track
66 continue;
67 }
68 for (auto j = lastMatchedIdx; j < trigRecs.size(); ++j) {
69 const auto& trigRec = trigRecs[j];
70 if (trigRec.getBCData() >= irFrame.getMin()) {
71 if (trigRec.getBCData() <= irFrame.getMax()) {
72 // TRD interaction record inside ITS frame
73 trigRecBitfield[j] = 1;
74 lastMatchedIdx = j;
75 } else {
76 // too late, also the higher trigger records won't match
77 break;
78 }
79 }
80 }
81 LOGF(debug, "ITS IR Frame start: %li, end: %li", irFrame.getMin().toLong(), irFrame.getMax().toLong());
82 }
83 /*
84 // for debugging: print TRD trigger times which are accepted and which are filtered out
85 for (int j = 0; j < trigRecs.size(); ++j) {
86 const auto& trigRec = trigRecs[j];
87 if (!trigRecBitfield[j]) {
88 LOGF(debug, "Could not find ITS info for TRD trigger %i: %li", j, trigRec.getBCData().toLong());
89 } else {
90 LOGF(debug, "Found ITS info for TRD trigger %i: %li", j, trigRec.getBCData().toLong());
91 }
92 }
93 */
94 } else {
95 // fill bitmask with 1
96 std::fill(trigRecBitfield.begin(), trigRecBitfield.end(), 1);
97 }
98
99 if (mTrigRecFilterActive) {
100 // skip tracklets from TRD triggers without ITS data
101 for (size_t iTrig = 0; iTrig < trigRecs.size(); ++iTrig) {
102 if (!trigRecBitfield[iTrig]) {
103 continue;
104 } else {
105 const auto& trigRec = trigRecs[iTrig];
106 for (int iTrklt = trigRec.getFirstTracklet(); iTrklt < trigRec.getFirstTracklet() + trigRec.getNumberOfTracklets(); ++iTrklt) {
107 calibratedTracklets[iTrklt] = mTransformer.transformTracklet(tracklets[iTrklt]);
108 ++nTrackletsTransformed;
109 }
110 }
111 }
112 } else {
113 // transform all tracklets
114 for (size_t iTrklt = 0; iTrklt < tracklets.size(); ++iTrklt) {
115 calibratedTracklets[iTrklt] = mTransformer.transformTracklet(tracklets[iTrklt]);
116 ++nTrackletsTransformed;
117 }
118 }
119
120 LOGF(info, "Found %lu tracklets in %lu trigger records. Applied filter for ITS IR frames: %i. Transformed %i tracklets.", tracklets.size(), trigRecs.size(), mTrigRecFilterActive, nTrackletsTransformed);
121
122 pc.outputs().snapshot(Output{"TRD", "CTRACKLETS", 0}, calibratedTracklets);
123 pc.outputs().snapshot(Output{"TRD", "TRIGRECMASK", 0}, trigRecBitfield);
124}
125
126void TRDTrackletTransformerSpec::updateTimeDependentParams(ProcessingContext& pc)
127{
129 static bool initOnceDone = false;
130 if (!initOnceDone) { // this params need to be queried only once
131 initOnceDone = true;
132 // init-once stuff
133 mTransformer.init();
134 }
135 pc.inputs().get<o2::trd::CalVdriftExB*>("calvdexb"); // just to trigger the finaliseCCDB
136}
137
139{
141 return;
142 }
143 if (matcher == ConcreteDataMatcher("TRD", "CALVDRIFTEXB", 0)) {
144 LOG(info) << "CalVdriftExB object has been updated";
145 mTransformer.setCalVdriftExB((const o2::trd::CalVdriftExB*)obj);
146 return;
147 }
148}
149
151{
152 std::shared_ptr<DataRequest> dataRequest = std::make_shared<DataRequest>();
153 if (trigRecFilterActive) {
154 dataRequest->requestIRFramesITS();
155 }
156 auto& inputs = dataRequest->inputs;
157 inputs.emplace_back("trdtracklets", "TRD", "TRACKLETS", 0, Lifetime::Timeframe);
158 inputs.emplace_back("trdtriggerrec", "TRD", "TRKTRGRD", 0, Lifetime::Timeframe);
159 inputs.emplace_back("calvdexb", "TRD", "CALVDRIFTEXB", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CalVdriftExB"));
160 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
161 false, // GRPECS=true
162 false, // GRPLHCIF
163 true, // GRPMagField
164 false, // askMatLUT
166 inputs,
167 true);
168 std::vector<OutputSpec> outputs;
169 outputs.emplace_back("TRD", "CTRACKLETS", 0, Lifetime::Timeframe);
170 outputs.emplace_back("TRD", "TRIGRECMASK", 0, Lifetime::Timeframe);
171
172 return DataProcessorSpec{
173 "TRDTRACKLETTRANSFORMER",
174 inputs,
175 outputs,
176 AlgorithmSpec{adaptFromTask<TRDTrackletTransformerSpec>(dataRequest, ggRequest, trigRecFilterActive)},
177 Options{
178 {"apply-xor", o2::framework::VariantType::Bool, false, {"flip the 8-th bit of slope and position (for processing CTFs from 2021 pilot beam)"}},
179 {"disable-shift", o2::framework::VariantType::Bool, false, {"whether we apply the one pad shift in data (always disabled in MC)"}}}};
180}
181
182} //end namespace trd
183} //end namespace o2
std::ostringstream debug
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 to delimit start and end IR of certain time period.
uint32_t j
Definition RawData.h:0
std::vector< o2::mid::ColumnData > inputData
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void snapshot(const Output &spec, T const &object)
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 finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj) final
void run(o2::framework::ProcessingContext &pc) override
void init(o2::framework::InitContext &ic) override
CalibratedTracklet transformTracklet(Tracklet64 tracklet, bool trackingFrame=true) const
void setCalVdriftExB(const CalVdriftExB *cal)
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)
o2::framework::DataProcessorSpec getTRDTrackletTransformerSpec(bool trigRecFilterActive)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Tracklet64 > tracklets