Project
Loading...
Searching...
No Matches
CalibLaserTracksSpec.h
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#ifndef O2_TPC_CalibLaserTracksSpec_H
13#define O2_TPC_CalibLaserTracksSpec_H
14
17
18#include "TFile.h"
22#include "Framework/Task.h"
26#include "CCDB/CcdbApi.h"
27#include "CCDB/CcdbObjectInfo.h"
30
32
33using namespace o2::framework;
34
35namespace o2::tpc
36{
37
39{
40 public:
42 {
43 mWriteDebug = ic.options().get<bool>("write-debug");
44 mCalib.setWriteDebugTree(mWriteDebug);
45 mMinNumberTFs = ic.options().get<int>("min-tfs");
46 mOnlyPublishOnEOS = ic.options().get<bool>("only-publish-on-eos");
47 mNormalize = !ic.options().get<bool>("ignore-normalization");
48 auto finishFunction = [this]() {
49 if (!mPublished) {
50 const auto nTFs = mCalib.getCalibData().processedTFs;
51 const auto nMatchA = mCalib.getMatchedPairsA();
52 const auto nMatchC = mCalib.getMatchedPairsC();
53 LOGP(error, "Calibration data was not published, laser track calibration might not have enough statistics: {} ({}) matched tracks in {} TFs on the A (C) < {} min TFs * {} min matches per side per TF? Or eos was not called by the framework.", nMatchA, nMatchC, nTFs, mMinNumberTFs, CalibLaserTracks::MinTrackPerSidePerTF);
54 }
55 };
56 ic.services().get<CallbackService>().set<CallbackService::Id::Stop>(finishFunction);
57 }
58
60 {
61 const auto dph = o2::header::get<o2::framework::DataProcessingHeader*>(pc.inputs().get("input").header);
62 if (!dph) {
63 LOGP(warning, "CalibLaserTracksDevice::run: No DataProcessingHeader found for \"input\". Only conditions? Skipping event.");
64 return;
65 }
66 mTPCVDriftHelper.extractCCDBInputs(pc);
67 const auto timestamp = pc.services().get<o2::framework::TimingInfo>().creation;
68
69 // if reference temperature / pressure of VDrift object is zero then it was not corrected
70 const float tp = (mTPCVDriftHelper.getVDriftObject().refTP == 0) ? mTPCVDriftHelper.getPTHelper().getTP(timestamp) : mTPCVDriftHelper.getVDriftObject().refTP;
71 if (mTPCVDriftHelper.isUpdated()) {
72 mTPCVDriftHelper.acknowledgeUpdate();
73 mCalib.setVDriftRef(mTPCVDriftHelper.getVDriftObject().getVDrift());
74 LOGP(info, "Updated reference drift velocity to: {}", mTPCVDriftHelper.getVDriftObject().getVDrift());
75 }
76 const auto startTime = dph->startTime;
77 const auto endTime = dph->startTime + dph->duration;
78 mRunNumber = processing_helpers::getRunNumber(pc);
79
80 auto data = pc.inputs().get<gsl::span<TrackTPC>>("input");
81 mCalib.setTFtimes(startTime, endTime);
82 mCalib.fill(data, tp);
83
84 if (!mOnlyPublishOnEOS && mCalib.hasEnoughData(mMinNumberTFs) && !mPublished) {
85 sendOutput(pc.outputs());
86 }
87 }
88
90 {
91 LOGP(info, "CalibLaserTracksDevice::endOfStream: Finalizing calibration");
92 if (!mCalib.hasEnoughData(mMinNumberTFs)) {
93 const auto nTFs = mCalib.getCalibData().processedTFs;
94 const auto nMatchA = mCalib.getMatchedPairsA();
95 const auto nMatchC = mCalib.getMatchedPairsC();
96 LOGP(warning, "laser track calibration does not have enough statistics: {} ({}) matched tracks in {} TFs on the A (C) < {} min TFs * {} min matches per side per TF ", nMatchA, nMatchC, nTFs, mMinNumberTFs, CalibLaserTracks::MinTrackPerSidePerTF);
97 }
98 sendOutput(ec.outputs());
99 }
100
101 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final
102 {
103 if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
104 return;
105 }
106 }
107
108 private:
109 CalibLaserTracks mCalib;
110 o2::tpc::VDriftHelper mTPCVDriftHelper{};
111 uint64_t mRunNumber{0};
112 int mMinNumberTFs{100};
113 bool mPublished{false};
114 bool mOnlyPublishOnEOS{false};
115 bool mNormalize{true};
116 bool mWriteDebug{false};
117
118 //________________________________________________________________
119 void sendOutput(DataAllocator& output)
120 {
121 mCalib.finalize();
122 mCalib.print();
123
124 std::map<std::string, std::string> md;
125
127 auto ltrCalib = mCalib.getCalibData();
128 if (!ltrCalib.isValid()) {
129 LOGP(error, "Invalid Laser calibration (corrections: A-side={}, C-side={}, NTracks: A-side={} C-side={}), will NOT upload to CCDB", ltrCalib.dvCorrectionA, ltrCalib.dvCorrectionC, ltrCalib.nTracksA, ltrCalib.nTracksC);
130 return;
131 }
132
133 if (mNormalize) {
134 ltrCalib.normalize(0.);
135 LOGP(info, "After normalization: correction factors: {} / {} for A- / C-Side, reference: {}, vdrift correction: {}", ltrCalib.dvCorrectionA, ltrCalib.dvCorrectionC, ltrCalib.refVDrift, ltrCalib.getDriftVCorrection());
136 }
137
139 auto image = o2::ccdb::CcdbApi::createObjectImage(&ltrCalib, &w);
140
141 md = w.getMetaData();
142 md[o2::base::NameConf::CCDBRunTag.data()] = std::to_string(mRunNumber);
143 w.setMetaData(md);
144
145 const auto now = std::chrono::system_clock::now();
146 const long timeStart = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
147 // const auto timeStart = ltrCalib.firstTime; //TODO: use once it is a correct time not TFid
149
150 w.setPath("TPC/Calib/LaserTracks");
151 w.setStartValidityTimestamp(timeStart);
152 w.setEndValidityTimestamp(timeEnd);
153
154 LOGP(info, "Sending object {} / {} of size {} bytes, valid for {} : {} ", w.getPath(), w.getFileName(), image->size(), w.getStartValidityTimestamp(), w.getEndValidityTimestamp());
155 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TPC_CalibLtr", 0}, *image.get());
156 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibLtr", 0}, w);
157
158 mPublished = true;
159
160 if (mWriteDebug) {
161 TFile f("LaserTracks.snapshot.root", "recreate");
162 f.WriteObject(&ltrCalib, "ccdb_object");
163 }
164 }
165};
166
167DataProcessorSpec getCalibLaserTracks(const std::string inputSpec)
168{
170
171 std::vector<OutputSpec> outputs;
172 outputs.emplace_back(ConcreteDataTypeMatcher{"TPC", "LtrCalibData"}, Lifetime::Sporadic);
173 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TPC_CalibLtr"}, Lifetime::Sporadic);
174 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibLtr"}, Lifetime::Sporadic);
175 std::vector<InputSpec> inputs = select(inputSpec.data());
177
178 return DataProcessorSpec{
179 "tpc-calib-laser-tracks",
180 inputs,
181 outputs,
182 AlgorithmSpec{adaptFromTask<device>()},
183 Options{
184 {"write-debug", VariantType::Bool, false, {"write a debug output tree."}},
185 {"min-tfs", VariantType::Int, 100, {"minimum number of TFs with enough laser tracks to finalize the calibration."}},
186 {"only-publish-on-eos", VariantType::Bool, false, {"only publish the calibration on eos, not during running"}},
187 {"ignore-normalization", VariantType::Bool, false, {"ignore normalization of reference to have mean correction factor 1"}},
188 }};
189}
190
191} // namespace o2::tpc
192
193#endif
calibration using laser tracks
Utils and constants for calibration and related workflows.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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 configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder Print launch bounds used for RTC code as debugging for exit after Allow RTC with slave GPUReconstruction instances with optConstexpr and optSpecialcode Maximum number of RTC cache files per backend in the cache the oldest are Prepend RTC compilation commands by this string Load a parameter object containing the launch bounds from a file h configStandalone Processing proc_param TPC Cluster Z Error Parameterization h configStandalone Processing settings for neural network proc_nn std::string Specify inference device(cpu(default), rocm, cuda)") AddOption(nnInferenceDeviceId
char error[CURL_ERROR_SIZE]
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the Names Generator class.
Helper class to extract VDrift from different sources.
static constexpr std::string_view CCDBRunTag
Definition NameConf.h:69
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:109
static constexpr long INFINITE_TIMESTAMP
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finalize()
Finalize full processing.
size_t getMatchedPairsC() const
number of associated laser tracks for all processed TFs on the C-Side
bool hasEnoughData(size_t numTFs=1) const
static constexpr size_t MinTrackPerSidePerTF
void fill(const gsl::span< const TrackTPC > tracks, float tp=0)
void setWriteDebugTree(bool write)
void print() const
print information
size_t getMatchedPairsA() const
number of associated laser tracks for all processed TFs on the A-Side
void setTFtimes(uint64_t tfStart, uint64_t tfEnd=0)
const LtrCalibData & getCalibData()
drift velocity fit information for full data set
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, bool laser=true, bool itstpcTgl=true)
void extractCCDBInputs(o2::framework::ProcessingContext &pc, bool laser=true, bool itstpcTgl=true)
const auto & getPTHelper() const
const VDriftCorrFact & getVDriftObject() const
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
bool isUpdated() const
GLeglImageOES image
Definition glcorearb.h:4021
GLdouble f
Definition glcorearb.h:310
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
uint64_t now() noexcept
Definition Clock.h:69
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< InputSpec > select(char const *matcher="")
uint64_t getRunNumber(o2::framework::ProcessingContext &pc)
Global TPC definitions and constants.
DataProcessorSpec getCalibLaserTracks(const std::string inputSpec)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
size_t processedTFs
number of processed TFs with laser track candidates
float refTP
reference temperature / pressure for which refVDrift was extracted