12#ifndef O2_TPC_CalibLaserTracksSpec_H
13#define O2_TPC_CalibLaserTracksSpec_H
43 mWriteDebug = ic.options().get<
bool>(
"write-debug");
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]() {
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);
56 ic.services().get<
CallbackService>().set<CallbackService::Id::Stop>(finishFunction);
61 const auto dph = o2::header::get<o2::framework::DataProcessingHeader*>(pc.inputs().get(
"input").header);
63 LOGP(warning,
"CalibLaserTracksDevice::run: No DataProcessingHeader found for \"input\". Only conditions? Skipping event.");
72 const auto startTime = dph->startTime;
73 const auto endTime = dph->startTime + dph->duration;
76 auto data = pc.inputs().get<gsl::span<TrackTPC>>(
"input");
80 if (!mOnlyPublishOnEOS && mCalib.
hasEnoughData(mMinNumberTFs) && !mPublished) {
81 sendOutput(pc.outputs());
87 LOGP(info,
"CalibLaserTracksDevice::endOfStream: Finalizing calibration");
92 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);
94 sendOutput(ec.outputs());
107 uint64_t mRunNumber{0};
108 int mMinNumberTFs{100};
109 bool mPublished{
false};
110 bool mOnlyPublishOnEOS{
false};
111 bool mNormalize{
true};
112 bool mWriteDebug{
false};
120 std::map<std::string, std::string> md;
124 if (!ltrCalib.isValid()) {
125 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 ltrCalib.normalize(0.);
131 LOGP(info,
"After normalization: correction factors: {} / {} for A- / C-Side, reference: {}, vdrift correction: {}", ltrCalib.dvCorrectionA, ltrCalib.dvCorrectionC, ltrCalib.refVDrift, ltrCalib.getDriftVCorrection());
137 md =
w.getMetaData();
141 const auto now = std::chrono::system_clock::now();
142 const long timeStart = std::chrono::duration_cast<std::chrono::milliseconds>(
now.time_since_epoch()).count();
146 w.setPath(
"TPC/Calib/LaserTracks");
147 w.setStartValidityTimestamp(timeStart);
148 w.setEndValidityTimestamp(timeEnd);
150 LOGP(info,
"Sending object {} / {} of size {} bytes, valid for {} : {} ",
w.getPath(),
w.getFileName(),
image->size(),
w.getStartValidityTimestamp(),
w.getEndValidityTimestamp());
157 TFile
f(
"LaserTracks.snapshot.root",
"recreate");
158 f.WriteObject(<rCalib,
"ccdb_object");
167 std::vector<OutputSpec> outputs;
171 std::vector<InputSpec> inputs =
select(inputSpec.data());
175 "tpc-calib-laser-tracks",
180 {
"write-debug", VariantType::Bool,
false, {
"write a debug output tree."}},
181 {
"min-tfs", VariantType::Int, 100, {
"minimum number of TFs with enough laser tracks to finalize the calibration."}},
182 {
"only-publish-on-eos", VariantType::Bool,
false, {
"only publish the calibration on eos, not during running"}},
183 {
"ignore-normalization", VariantType::Bool,
false, {
"ignore normalization of reference to have mean correction factor 1"}},
calibration using laser tracks
Utils and constants for calibration and related workflows.
Definition of the Names Generator class.
Helper class to extract VDrift from different sources.
static constexpr std::string_view CCDBRunTag
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
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.
void setVDriftRef(float v)
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)
process all tracks of one TF
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 VDriftCorrFact & getVDriftObject() const
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
GLubyte GLubyte GLubyte GLubyte w
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
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)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
size_t processedTFs
number of processed TFs with laser track candidates