Project
Loading...
Searching...
No Matches
AODProducerWorkflowSpec.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
13
14#ifndef O2_AODPRODUCER_WORKFLOW_SPEC
15#define O2_AODPRODUCER_WORKFLOW_SPEC
16
25#include "Framework/Task.h"
29#include "TStopwatch.h"
30#include "ZDCBase/Constants.h"
34
35#include <cstdint>
36#include <limits>
37#include <set>
38#include <vector>
39#include <random>
40using namespace o2::framework;
44
46{
50{
51 public:
53 BunchCrossings() = default;
54
56 void init(std::map<uint64_t, int> const& bcs)
57 {
58 clear();
59 // init the structures
60 for (auto& key : bcs) {
61 mBCTimeVector.emplace_back(key.first);
62 }
63 initTimeWindows();
64 }
65
67 std::vector<uint64_t> const& getBCTimeVector() const { return mBCTimeVector; }
68
82 std::pair<size_t, uint64_t> lower_bound(uint64_t timestamp) const
83 {
84 // a) determine the timewindow
85 const auto NofWindows = static_cast<int>(mTimeWindows.size());
86 const auto smallestBC = mBCTimeVector[0];
87 const auto largestBC = mBCTimeVector.back();
88 auto timeindex = std::max((int)0, (int)((timestamp - smallestBC) / mWindowSize));
89
90 if (timeindex >= NofWindows) {
91 // do extra check avoid valse positive due to machine precision
92 if (timestamp > largestBC) { // there is no next greater; so the bc index is at the end of the vector
93 return std::make_pair<int, uint64_t>(mBCTimeVector.size(), 0);
94 }
95 timeindex = int(mBCTimeVector.size() - 1);
96 }
97
98 const auto* timewindow = &mTimeWindows[timeindex];
99 while (timeindex < NofWindows && (!timewindow->isOccupied() || mBCTimeVector[timewindow->to] < timestamp)) {
100 timeindex = timewindow->nextOccupiedRight;
101 if (timeindex < NofWindows) {
102 timewindow = &mTimeWindows[timeindex];
103 }
104 }
105 if (timeindex >= NofWindows) {
106 // there is no next greater; so the bc index is at the end of the vector
107 return std::make_pair<int, uint64_t>(mBCTimeVector.size(), 0);
108 }
109 // otherwise we actually do a search now
110 std::pair<int, uint64_t> p;
111 auto iter = std::lower_bound(mBCTimeVector.begin() + timewindow->from, mBCTimeVector.begin() + timewindow->to + 1, timestamp);
112 int k = std::distance(mBCTimeVector.begin(), iter);
113 p.first = k;
114 p.second = mBCTimeVector[k];
115 return p;
116 }
117
119 void clear()
120 {
121 mBCs.clear();
122 mBCTimeVector.clear();
123 mTimeWindows.clear();
124 }
125
127 void print()
128 {
129 LOG(info) << "Have " << mBCTimeVector.size() << " BCs";
130 for (auto t : mBCTimeVector) {
131 LOG(info) << t;
132 }
133 int twcount = 0;
134 auto wsize = mWindowSize;
135 for (auto& tw : mTimeWindows) {
136 LOG(info) << "TimeWindow " << twcount << " [ " << wsize * twcount << ":" << wsize * (twcount + 1) << " ] : from " << tw.from << " to " << tw.to << " nextLeft " << tw.nextOccupiedLeft << " nextRight " << tw.nextOccupiedRight;
137 twcount++;
138 }
139 }
140
141 private:
142 std::map<uint64_t, int> mBCs;
143 std::vector<uint64_t> mBCTimeVector; // simple sorted vector of BC times
144
146 void initTimeWindows()
147 {
148 // on average we want say M bunch crossings per time window
149 const int M = 5;
150 int window_number = mBCTimeVector.size() / M;
151 if (mBCTimeVector.size() % M != 0) {
152 window_number += 1;
153 }
154 auto bcrange = (mBCTimeVector.back() + 1 - mBCTimeVector[0]);
155 if (bcrange > (uint64_t(3564 * 258))) {
156 LOGP(warn, "Attention: BC range {}:{} covers more than 258 orbits", mBCTimeVector[0], mBCTimeVector.back());
157 }
158 mWindowSize = bcrange / (1. * window_number);
159 // now we go through the list of times and bucket them into the correct windows
160 mTimeWindows.resize(window_number);
161 for (auto bcindex = 0U; bcindex < mBCTimeVector.size(); ++bcindex) {
162 auto windowindex = (int)((mBCTimeVector[bcindex] - mBCTimeVector[0]) / mWindowSize);
163 // we add "bcindex" to the TimeWindow windowindex
164 auto& tw = mTimeWindows[windowindex];
165 if (tw.from == -1) {
166 tw.from = bcindex;
167 } else {
168 tw.from = std::min(tw.from, static_cast<int>(bcindex));
169 }
170 if (tw.to == -1) {
171 tw.to = bcindex;
172 } else {
173 tw.to = std::max(tw.to, static_cast<int>(bcindex));
174 }
175 }
176
177 // now we do the neighbourhood linking of time windows
178 int lastoccupied = -1;
179 for (int windowindex = 0; windowindex < window_number; ++windowindex) {
180 mTimeWindows[windowindex].nextOccupiedLeft = lastoccupied;
181 if (mTimeWindows[windowindex].isOccupied()) {
182 lastoccupied = windowindex;
183 }
184 }
185 lastoccupied = window_number;
186 for (int windowindex = window_number - 1; windowindex >= 0; --windowindex) {
187 mTimeWindows[windowindex].nextOccupiedRight = lastoccupied;
188 if (mTimeWindows[windowindex].isOccupied()) {
189 lastoccupied = windowindex;
190 }
191 }
192 }
193
197 struct TimeWindow {
198 int from = -1;
199 int to = -1;
200 int nextOccupiedRight = -1; // next time window occupied to the right
201 int nextOccupiedLeft = -1; // next time window which is occupied to the left
202 inline bool size() const { return to - from; }
203 inline bool isOccupied() const { return size() > 0; }
204 }; // end struct
205
206 std::vector<TimeWindow> mTimeWindows; // the time window structure covering the complete duration of mBCTimeVector
207 double mWindowSize; // the size of a single time window
208}; // end internal class
209
210// Steering bits for additional output during AOD production
211enum struct AODProducerStreamerFlags : uint8_t {
212 TrackQA,
213};
214
216{
217 public:
218 AODProducerWorkflowDPL(GID::mask_t src, std::shared_ptr<DataRequest> dataRequest, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool enableSV, bool useMC = true, bool enableFITextra = false) : mUseMC(useMC), mEnableSV(enableSV), mEnableFITextra(enableFITextra), mInputSources(src), mDataRequest(dataRequest), mGGCCDBRequest(gr) {}
219 ~AODProducerWorkflowDPL() override = default;
220 void init(InitContext& ic) final;
221 void run(ProcessingContext& pc) final;
222 void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
224
225 private:
226 // takes a local vertex timing in NS and converts to a lobal BC information relative to start of timeframe
227 uint64_t relativeTime_to_LocalBC(double relativeTimeStampInNS) const
228 {
229 return relativeTimeStampInNS > 0. ? std::round(relativeTimeStampInNS / o2::constants::lhc::LHCBunchSpacingNS) : 0;
230 }
231 // takes a local vertex timing in NS and converts to a global BC information
232 uint64_t relativeTime_to_GlobalBC(double relativeTimeStampInNS) const
233 {
234 return std::uint64_t(mStartIR.toLong()) + relativeTime_to_LocalBC(relativeTimeStampInNS);
235 }
236
237 bool mThinTracks{false};
238 bool mPropTracks{false};
239 bool mPropMuons{false};
240 float mTrackQCFraction{0.00};
241 int64_t mTrackQCNTrCut{4};
242 float mSqrtS{13860.};
243 std::mt19937 mGenerator{};
244 o2::base::Propagator::MatCorrType mMatCorr{o2::base::Propagator::MatCorrType::USEMatCorrLUT};
246 float mMinPropR{o2::constants::geom::XTPCInnerRef + 0.1f};
247
248 std::unordered_set<GIndex> mGIDUsedBySVtx;
249 std::unordered_set<GIndex> mGIDUsedByStr;
250
252 std::shared_ptr<o2::utils::TreeStreamRedirector> mStreamer;
253
254 int mNThreads = 1;
255 bool mUseMC = true;
256 bool mEnableSV = true; // enable secondary vertices
257 bool mEnableFITextra = false;
258 bool mFieldON = false;
259 const float cSpeed = 0.029979246f; // speed of light in TOF units
260
261 GID::mask_t mInputSources;
262 int64_t mTFNumber{-1};
263 int mRunNumber{-1};
264 int mTruncate{1};
265 int mRecoOnly{0};
266 o2::InteractionRecord mStartIR{}; // TF 1st IR
267 TString mLPMProdTag{""};
268 TString mAnchorPass{""};
269 TString mAnchorProd{""};
270 TString mRecoPass{""};
271 TStopwatch mTimer;
272 bool mEMCselectLeading{false};
273 uint64_t mEMCALTrgClassMask = 0;
274
275 // unordered map connects global indices and table indices of barrel tracks
276 std::unordered_map<GIndex, int> mGIDToTableID;
277 int mTableTrID{0};
278 // unordered map connects global indices and table indices of fwd tracks
279 std::unordered_map<GIndex, int> mGIDToTableFwdID;
280 int mTableTrFwdID{0};
281 // unordered map connects global indices and table indices of MFT tracks
282 std::unordered_map<GIndex, int> mGIDToTableMFTID;
283 int mTableTrMFTID{0};
284 // unordered map connects global indices and table indices of vertices
285 std::unordered_map<GIndex, int> mVtxToTableCollID;
286 int mTableCollID{0};
287 // unordered map connects global indices and table indices of V0s (needed for cascades references)
288 std::unordered_map<GIndex, int> mV0ToTableID;
289 int mTableV0ID{0};
290
291 // Strangeness tracking indices lookup tables
292 std::vector<int> mVertexStrLUT;
293 std::vector<std::pair<int, int>> mCollisionStrTrk;
294 std::vector<int> mStrTrkIndices;
295
296 // std::unordered_map<int, int> mIndexTableFwd;
297 std::vector<int> mIndexTableFwd;
298 int mIndexFwdID{0};
299 // std::unordered_map<int, int> mIndexTableMFT;
300 std::vector<int> mIndexTableMFT;
301 int mIndexMFTID{0};
302
303 BunchCrossings mBCLookup;
304
305 // zdc helper maps to avoid a number of "if" statements
306 // when filling ZDC table
307 std::array<float, o2::zdc::NChannels> mZDCEnergyMap; // mapping detector id to a corresponding energy
308 std::array<float, o2::zdc::NTDCChannels> mZDCTDCMap; // mapping TDC channel id to a corresponding TDC value
309
310 std::vector<uint16_t> mITSTPCTRDTriggers; // mapping from TRD tracks ID to corresponding trigger (for tracks time extraction)
311 std::vector<uint16_t> mTPCTRDTriggers; // mapping from TRD tracks ID to corresponding trigger (for tracks time extraction)
312 std::vector<uint16_t> mITSROFs; // mapping from ITS tracks ID to corresponding ROF (for SA ITS tracks time extraction)
313 std::vector<uint16_t> mMFTROFs; // mapping from MFT tracks ID to corresponding ROF (for SA MFT tracks time extraction)
314 std::vector<uint16_t> mMCHROFs; // mapping from MCH tracks ID to corresponding ROF (for SA MCH tracks time extraction)
315 double mITSROFrameHalfLengthNS = -1; // ITS ROF half length
316 double mMFTROFrameHalfLengthNS = -1; // ITS ROF half length
317 double mITSROFBiasNS = 0; // ITS ROF start bias
318 double mMFTROFBiasNS = 0; // ITS ROF start bias
319 double mNSigmaTimeTrack = -1; // number track errors sigmas (for gaussian errors only) used in track-vertex matching
320 double mTimeMarginTrackTime = -1; // safety margin in NS used for track-vertex matching (additive to track uncertainty)
321 double mTPCBinNS = -1; // inverse TPC time-bin in ns
322
323 // Container used to mark MC particles to store/transfer to AOD.
324 // Mapping of eventID, sourceID, trackID to some integer.
325 // The first two indices are not sparse whereas the trackID index is sparse which explains
326 // the combination of vector and map
327 std::vector<std::vector<std::unordered_map<int, int>>> mToStore;
328 o2::steer::MCKinematicsReader* mMCKineReader = nullptr;
329
330 // production metadata
331 std::vector<TString> mMetaDataKeys;
332 std::vector<TString> mMetaDataVals;
333
334 std::shared_ptr<DataRequest> mDataRequest;
335 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
336
338
339 static constexpr int TOFTimePrecPS = 16; // required max error in ps for TOF tracks
340 // truncation is enabled by default
341 uint32_t mCollisionPosition = 0xFFFFFFF0; // 19 bits mantissa
342 uint32_t mCollisionPositionCov = 0xFFFFE000; // 10 bits mantissa
343 uint32_t mTrackX = 0xFFFFFFF0; // 19 bits
344 uint32_t mTrackAlpha = 0xFFFFFFF0; // 19 bits
345 uint32_t mTrackSnp = 0xFFFFFF00; // 15 bits
346 uint32_t mTrackTgl = 0xFFFFFF00; // 15 bits
347 uint32_t mTrack1Pt = 0xFFFFFC00; // 13 bits
348 uint32_t mTrackCovDiag = 0xFFFFFF00; // 15 bits
349 uint32_t mTrackChi2 = 0xFFFF0000; // 7 bits
350 uint32_t mTrackCovOffDiag = 0xFFFF0000; // 7 bits
351 uint32_t mTrackSignal = 0xFFFFFF00; // 15 bits
352 uint32_t mTrackTime = 0xFFFFFFFF; // use full float precision for time
353 uint32_t mTPCTime0 = 0xFFFFFFE0; // 18 bits, providing 14256./(1<<19) = 0.027 TB precision e.g., ~0.13 mm in z
354 uint32_t mTrackTimeError = 0xFFFFFF00; // 15 bits
355 uint32_t mTrackPosEMCAL = 0xFFFFFF00; // 15 bits
356 uint32_t mTracklets = 0xFFFFFF00; // 15 bits
357 uint32_t mMcParticleW = 0xFFFFFFF0; // 19 bits
358 uint32_t mMcParticlePos = 0xFFFFFFF0; // 19 bits
359 uint32_t mMcParticleMom = 0xFFFFFFF0; // 19 bits
360 uint32_t mCaloAmp = 0xFFFFFF00; // 15 bits todo check which truncation should actually be used
361 uint32_t mCaloTime = 0xFFFFFF00; // 15 bits todo check which truncation should actually be used
362 uint32_t mCPVPos = 0xFFFFF800; // 12 bits
363 uint32_t mCPVAmpl = 0xFFFFFF00; // 15 bits
364 uint32_t mMuonTr1P = 0xFFFFFC00; // 13 bits
365 uint32_t mMuonTrThetaX = 0xFFFFFF00; // 15 bits
366 uint32_t mMuonTrThetaY = 0xFFFFFF00; // 15 bits
367 uint32_t mMuonTrZmu = 0xFFFFFFF0; // 19 bits
368 uint32_t mMuonTrBend = 0xFFFFFFF0; // 19 bits
369 uint32_t mMuonTrNonBend = 0xFFFFFFF0; // 19 bits
370 uint32_t mMuonTrCov = 0xFFFF0000; // 7 bits
371 uint32_t mMuonCl = 0xFFFFFF00; // 15 bits
372 uint32_t mMuonClErr = 0xFFFF0000; // 7 bits
373 uint32_t mV0Time = 0xFFFFF000; // 11 bits
374 uint32_t mV0ChannelTime = 0xFFFFFF00; // 15 bits
375 uint32_t mFDDTime = 0xFFFFF000; // 11 bits
376 uint32_t mFDDChannelTime = 0xFFFFFF00; // 15 bits
377 uint32_t mT0Time = 0xFFFFFF00; // 15 bits
378 uint32_t mT0ChannelTime = 0xFFFFFFF0; // 19 bits
379 uint32_t mV0Amplitude = 0xFFFFF000; // 11 bits
380 uint32_t mFDDAmplitude = 0xFFFFF000; // 11 bits
381 uint32_t mT0Amplitude = 0xFFFFF000; // 11 bits
382 int mCTPReadout = 0; // 0 = use CTP readout from CTP; 1 = create CTP readout
383 bool mCTPConfigPerRun = false; // 0 = use common CTPconfig as for MC; 1 = run dependent CTP config
384 // helper struct for extra info in fillTrackTablesPerCollision()
385 struct TrackExtraInfo {
386 float tpcInnerParam = 0.f;
387 uint32_t flags = 0;
388 uint32_t itsClusterSizes = 0u;
389 uint8_t itsClusterMap = 0;
390 uint8_t tpcNClsFindable = 0;
391 int8_t tpcNClsFindableMinusFound = 0;
392 int8_t tpcNClsFindableMinusPID = 0;
393 int8_t tpcNClsFindableMinusCrossedRows = 0;
394 uint8_t tpcNClsShared = 0;
395 uint8_t trdPattern = 0;
396 float itsChi2NCl = -999.f;
397 float tpcChi2NCl = -999.f;
398 float trdChi2 = -999.f;
399 float tofChi2 = -999.f;
400 float tpcSignal = -999.f;
401 float trdSignal = -999.f;
402 float length = -999.f;
403 float tofExpMom = -999.f;
404 float trackEtaEMCAL = -999.f;
405 float trackPhiEMCAL = -999.f;
406 float trackTime = -999.f;
407 float trackTimeRes = -999.f;
408 int diffBCRef = 0; // offset of time reference BC from the start of the orbit
409 int bcSlice[2] = {-1, -1};
410 bool isTPConly = false; // not to be written out
411 };
412
413 struct TrackQA {
414 GID trackID;
415 float tpcTime0{};
416 int16_t tpcdcaR{};
417 int16_t tpcdcaZ{};
418 uint8_t tpcClusterByteMask{};
419 uint8_t tpcdEdxMax0R{};
420 uint8_t tpcdEdxMax1R{};
421 uint8_t tpcdEdxMax2R{};
422 uint8_t tpcdEdxMax3R{};
423 uint8_t tpcdEdxTot0R{};
424 uint8_t tpcdEdxTot1R{};
425 uint8_t tpcdEdxTot2R{};
426 uint8_t tpcdEdxTot3R{};
427 int8_t dRefContY{std::numeric_limits<int8_t>::min()};
428 int8_t dRefContZ{std::numeric_limits<int8_t>::min()};
429 int8_t dRefContSnp{std::numeric_limits<int8_t>::min()};
430 int8_t dRefContTgl{std::numeric_limits<int8_t>::min()};
431 int8_t dRefContQ2Pt{std::numeric_limits<int8_t>::min()};
432 int8_t dRefGloY{std::numeric_limits<int8_t>::min()};
433 int8_t dRefGloZ{std::numeric_limits<int8_t>::min()};
434 int8_t dRefGloSnp{std::numeric_limits<int8_t>::min()};
435 int8_t dRefGloTgl{std::numeric_limits<int8_t>::min()};
436 int8_t dRefGloQ2Pt{std::numeric_limits<int8_t>::min()};
437 int8_t dTofdX{std::numeric_limits<int8_t>::min()};
438 int8_t dTofdZ{std::numeric_limits<int8_t>::min()};
439 };
440
441 // helper struct for addToFwdTracksTable()
442 struct FwdTrackInfo {
443 uint8_t trackTypeId = 0;
444 float x = 0.f;
445 float y = 0.f;
446 float z = 0.f;
447 float rabs = 0.f;
448 float phi = 0.f;
449 float tanl = 0.f;
450 float invqpt = 0.f;
451 float chi2 = 0.f;
452 float pdca = 0.f;
453 int nClusters = -1;
454 float chi2matchmchmid = -1.0;
455 float chi2matchmchmft = -1.0;
456 float matchscoremchmft = -1.0;
457 int matchmfttrackid = -1;
458 int matchmchtrackid = -1;
459 uint16_t mchBitMap = 0;
460 uint8_t midBitMap = 0;
461 uint32_t midBoards = 0;
462 float trackTime = -999.f;
463 float trackTimeRes = -999.f;
464 };
465
466 // helper struct for addToFwdTracksTable()
467 struct FwdTrackCovInfo {
468 float sigX = 0.f;
469 float sigY = 0.f;
470 float sigPhi = 0.f;
471 float sigTgl = 0.f;
472 float sig1Pt = 0.f;
473 int8_t rhoXY = 0;
474 int8_t rhoPhiX = 0;
475 int8_t rhoPhiY = 0;
476 int8_t rhoTglX = 0;
477 int8_t rhoTglY = 0;
478 int8_t rhoTglPhi = 0;
479 int8_t rho1PtX = 0;
480 int8_t rho1PtY = 0;
481 int8_t rho1PtPhi = 0;
482 int8_t rho1PtTgl = 0;
483 };
484
485 // helper struct for mc track labels
486 // using -1 as dummies for AOD
487 struct MCLabels {
488 uint32_t labelID = -1;
489 uint16_t labelMask = 0;
490 uint8_t fwdLabelMask = 0;
491 };
492
493 // counters for TPC clusters
494 struct TPCCounters {
495 uint8_t shared = 0;
496 uint8_t found = 0;
497 uint8_t crossed = 0;
498 };
499 std::vector<TPCCounters> mTPCCounters;
500
501 void updateTimeDependentParams(ProcessingContext& pc);
502
503 void addRefGlobalBCsForTOF(const o2::dataformats::VtxTrackRef& trackRef, const gsl::span<const GIndex>& GIndices,
504 const o2::globaltracking::RecoContainer& data, std::map<uint64_t, int>& bcsMap);
505 void createCTPReadout(const o2::globaltracking::RecoContainer& recoData, std::vector<o2::ctp::CTPDigit>& ctpDigits, ProcessingContext& pc);
506 void collectBCs(const o2::globaltracking::RecoContainer& data,
507 const std::vector<o2::InteractionTimeRecord>& mcRecords,
508 std::map<uint64_t, int>& bcsMap);
509
510 template <typename TracksCursorType, typename TracksCovCursorType>
511 void addToTracksTable(TracksCursorType& tracksCursor, TracksCovCursorType& tracksCovCursor,
513
514 template <typename TracksExtraCursorType>
515 void addToTracksExtraTable(TracksExtraCursorType& tracksExtraCursor, TrackExtraInfo& extraInfoHolder);
516
517 template <typename TracksQACursorType>
518 void addToTracksQATable(TracksQACursorType& tracksQACursor, TrackQA& trackQAInfoHolder);
519
520 template <typename mftTracksCursorType, typename AmbigMFTTracksCursorType>
521 void addToMFTTracksTable(mftTracksCursorType& mftTracksCursor, AmbigMFTTracksCursorType& ambigMFTTracksCursor,
522 GIndex trackID, const o2::globaltracking::RecoContainer& data, int collisionID,
523 std::uint64_t collisionBC, const std::map<uint64_t, int>& bcsMap);
524
525 template <typename fwdTracksCursorType, typename fwdTracksCovCursorType, typename AmbigFwdTracksCursorType, typename mftTracksCovCursorType>
526 void addToFwdTracksTable(fwdTracksCursorType& fwdTracksCursor, fwdTracksCovCursorType& fwdTracksCovCursor, AmbigFwdTracksCursorType& ambigFwdTracksCursor, mftTracksCovCursorType& mftTracksCovCursor,
527 GIndex trackID, const o2::globaltracking::RecoContainer& data, int collisionID, std::uint64_t collisionBC, const std::map<uint64_t, int>& bcsMap);
528
529 TrackExtraInfo processBarrelTrack(int collisionID, std::uint64_t collisionBC, GIndex trackIndex, const o2::globaltracking::RecoContainer& data, const std::map<uint64_t, int>& bcsMap);
530 TrackQA processBarrelTrackQA(int collisionID, std::uint64_t collisionBC, GIndex trackIndex, const o2::globaltracking::RecoContainer& data, const std::map<uint64_t, int>& bcsMap);
531
532 bool propagateTrackToPV(o2::track::TrackParametrizationWithError<float>& trackPar, const o2::globaltracking::RecoContainer& data, int colID);
533 void extrapolateToCalorimeters(TrackExtraInfo& extraInfoHolder, const o2::track::TrackPar& track);
534 void cacheTriggers(const o2::globaltracking::RecoContainer& recoData);
535
536 // helper for track tables
537 // * fills tables collision by collision
538 // * interaction time is for TOF information
539 template <typename TracksCursorType, typename TracksCovCursorType, typename TracksExtraCursorType, typename TracksQACursorType, typename AmbigTracksCursorType,
540 typename MFTTracksCursorType, typename MFTTracksCovCursorType, typename AmbigMFTTracksCursorType,
541 typename FwdTracksCursorType, typename FwdTracksCovCursorType, typename AmbigFwdTracksCursorType, typename FwdTrkClsCursorType>
542 void fillTrackTablesPerCollision(int collisionID,
543 std::uint64_t collisionBC,
544 const o2::dataformats::VtxTrackRef& trackRef,
545 const gsl::span<const GIndex>& GIndices,
547 TracksCursorType& tracksCursor,
548 TracksCovCursorType& tracksCovCursor,
549 TracksExtraCursorType& tracksExtraCursor,
550 TracksQACursorType& tracksQACursor,
551 AmbigTracksCursorType& ambigTracksCursor,
552 MFTTracksCursorType& mftTracksCursor,
553 MFTTracksCovCursorType& mftTracksCovCursor,
554 AmbigMFTTracksCursorType& ambigMFTTracksCursor,
555 FwdTracksCursorType& fwdTracksCursor,
556 FwdTracksCovCursorType& fwdTracksCovCursor,
557 AmbigFwdTracksCursorType& ambigFwdTracksCursor,
558 FwdTrkClsCursorType& fwdTrkClsCursor,
559 const std::map<uint64_t, int>& bcsMap);
560
561 template <typename FwdTrkClsCursorType>
562 void addClustersToFwdTrkClsTable(const o2::globaltracking::RecoContainer& recoData, FwdTrkClsCursorType& fwdTrkClsCursor, GIndex trackID, int fwdTrackId);
563
564 void fillIndexTablesPerCollision(const o2::dataformats::VtxTrackRef& trackRef, const gsl::span<const GIndex>& GIndices, const o2::globaltracking::RecoContainer& data);
565
566 template <typename V0CursorType, typename CascadeCursorType, typename Decay3bodyCursorType>
567 void fillSecondaryVertices(const o2::globaltracking::RecoContainer& data, V0CursorType& v0Cursor, CascadeCursorType& cascadeCursor, Decay3bodyCursorType& decay3bodyCursor);
568
569 template <typename HMPCursorType>
570 void fillHMPID(const o2::globaltracking::RecoContainer& recoData, HMPCursorType& hmpCursor);
571
572 void prepareStrangenessTracking(const o2::globaltracking::RecoContainer& recoData);
573 template <typename V0C, typename CC, typename D3BC>
574 void fillStrangenessTrackingTables(const o2::globaltracking::RecoContainer& data, V0C& v0Cursor, CC& cascadeCursor, D3BC& decay3bodyCursor);
575
577 using MCCollisionCursor = aodmchelpers::CollisionCursor;
578 using XSectionCursor = aodmchelpers::XSectionCursor;
579 using PdfInfoCursor = aodmchelpers::PdfInfoCursor;
580 using HeavyIonCursor = aodmchelpers::HeavyIonCursor;
581 using MCParticlesCursor = aodmchelpers::ParticleCursor;
582 using HepMCUpdate = aodmchelpers::HepMCUpdate;
583 using MCEventHeader = dataformats::MCEventHeader;
585 HepMCUpdate mXSectionUpdate = HepMCUpdate::anyKey;
586 HepMCUpdate mPdfInfoUpdate = HepMCUpdate::anyKey;
587 HepMCUpdate mHeavyIonUpdate = HepMCUpdate::anyKey;
625 void updateMCHeader(MCCollisionCursor& collisionCursor,
626 XSectionCursor& xSectionCursor,
627 PdfInfoCursor& pdfInfoCursor,
628 HeavyIonCursor& heavyIonCursor,
629 const MCEventHeader& header,
630 int collisionID,
631 int bcID,
632 float time,
633 short generatorID,
634 int sourceID);
635
636 void fillMCParticlesTable(o2::steer::MCKinematicsReader& mcReader,
637 MCParticlesCursor& mcParticlesCursor,
638 const gsl::span<const o2::dataformats::VtxTrackRef>& primVer2TRefs,
639 const gsl::span<const GIndex>& GIndices,
641 const std::vector<std::vector<int>>& mcColToEvSrc);
642
643 template <typename MCTrackLabelCursorType, typename MCMFTTrackLabelCursorType, typename MCFwdTrackLabelCursorType>
644 void fillMCTrackLabelsTable(MCTrackLabelCursorType& mcTrackLabelCursor,
645 MCMFTTrackLabelCursorType& mcMFTTrackLabelCursor,
646 MCFwdTrackLabelCursorType& mcFwdTrackLabelCursor,
647 const o2::dataformats::VtxTrackRef& trackRef,
648 const gsl::span<const GIndex>& primVerGIs,
650 int vertexId = -1);
651
652 std::uint64_t fillBCSlice(int (&slice)[2], double tmin, double tmax, const std::map<uint64_t, int>& bcsMap) const;
653
654 std::vector<uint8_t> fillBCFlags(const o2::globaltracking::RecoContainer& data, std::map<uint64_t, int>& bcsMap) const;
655
656 // helper for tpc clusters
657 void countTPCClusters(const o2::globaltracking::RecoContainer& data);
658
659 // helper for trd pattern
660 uint8_t getTRDPattern(const o2::trd::TrackTRD& track);
661
662 template <typename TCaloHandler, typename TCaloCursor, typename TCaloTRGCursor, typename TMCCaloLabelCursor>
663 void addToCaloTable(TCaloHandler& caloHandler, TCaloCursor& caloCellCursor, TCaloTRGCursor& caloTRGCursor,
664 TMCCaloLabelCursor& mcCaloCellLabelCursor, int eventID, int bcID, int8_t caloType);
665
666 template <typename TCaloCursor, typename TCaloTRGCursor, typename TMCCaloLabelCursor>
667 void fillCaloTable(TCaloCursor& caloCellCursor, TCaloTRGCursor& caloTRGCursor,
668 TMCCaloLabelCursor& mcCaloCellLabelCursor, const std::map<uint64_t, int>& bcsMap,
670
671 std::set<uint64_t> filterEMCALIncomplete(const gsl::span<const o2::emcal::TriggerRecord> triggers);
672};
673
675framework::DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableST, bool useMC, bool CTPConfigPerRun, bool enableFITextra);
676
677// helper interface for calo cells to "befriend" emcal and phos cells
679{
680 public:
681 static int8_t getTriggerBits(const o2::emcal::Cell& /*cell*/)
682 {
683 return 0; // dummy value
684 }
685
686 static int8_t getTriggerBits(const o2::phos::Cell& cell)
687 {
688 return (cell.getType() == o2::phos::ChannelType_t::TRU2x2) ? 0 : 1;
689 }
690
691 static int16_t getCellNumber(const o2::emcal::Cell& cell)
692 {
693 return cell.getTower();
694 }
695
696 static int16_t getCellNumber(const o2::phos::Cell& cell)
697 {
698 if (cell.getTRU()) {
699 return cell.getTRUId();
700 }
701 return cell.getAbsId();
702 }
703 // If this cell - trigger one?
704 static bool isTRU(const o2::emcal::Cell& cell)
705 {
706 return cell.getTRU();
707 }
708
709 static bool isTRU(const o2::phos::Cell& cell)
710 {
711 return cell.getTRU();
712 }
713
714 static int16_t getFastOrAbsID(const o2::emcal::Cell& /*cell*/)
715 {
716 return 0; // dummy value
717 }
718
719 static int16_t getFastOrAbsID(const o2::phos::Cell& cell)
720 {
721 return cell.getTRUId();
722 }
723
724 static float getAmplitude(const o2::emcal::Cell& cell)
725 {
726 return cell.getAmplitude();
727 }
728
729 static float getAmplitude(const o2::phos::Cell& cell)
730 {
731 return cell.getEnergy();
732 }
733
734 static int16_t getLnAmplitude(const o2::emcal::Cell& /*cell*/)
735 {
736 return 0; // dummy value
737 }
738
739 static int16_t getLnAmplitude(const o2::phos::Cell& cell)
740 {
741 return cell.getEnergy(); // dummy value
742 }
743
744 static float getTimeStamp(const o2::emcal::Cell& cell)
745 {
746 return cell.getTimeStamp();
747 }
748
749 static float getTimeStamp(const o2::phos::Cell& cell)
750 {
751 return cell.getTime();
752 }
753};
754
755} // namespace o2::aodproducer
756
757#endif /* O2_AODPRODUCER_WORKFLOW_SPEC */
Wrapper container for different reconstructed object types.
int16_t time
Definition RawEventData.h:4
Helper for geometry and GRP related CCDB requests.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Class to perform MFT MCH (and MID) matching.
Extention of GlobalTrackID by flags relevant for verter-track association.
int nClusters
StringRef key
void endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
AODProducerWorkflowDPL(GID::mask_t src, std::shared_ptr< DataRequest > dataRequest, std::shared_ptr< o2::base::GRPGeomRequest > gr, bool enableSV, bool useMC=true, bool enableFITextra=false)
BunchCrossings()=default
Constructor initializes the acceleration structure.
std::pair< size_t, uint64_t > lower_bound(uint64_t timestamp) const
void init(std::map< uint64_t, int > const &bcs)
initialize this container (to be ready for lookup/search queries)
void clear()
clear/reset this container
std::vector< uint64_t > const & getBCTimeVector() const
return the sorted vector of increaing BC times
void print()
print information about this container
static int8_t getTriggerBits(const o2::phos::Cell &cell)
static float getAmplitude(const o2::phos::Cell &cell)
static float getAmplitude(const o2::emcal::Cell &cell)
static int16_t getLnAmplitude(const o2::phos::Cell &cell)
static int16_t getLnAmplitude(const o2::emcal::Cell &)
static int8_t getTriggerBits(const o2::emcal::Cell &)
static float getTimeStamp(const o2::phos::Cell &cell)
static int16_t getCellNumber(const o2::emcal::Cell &cell)
static int16_t getFastOrAbsID(const o2::phos::Cell &cell)
static int16_t getFastOrAbsID(const o2::emcal::Cell &)
static bool isTRU(const o2::emcal::Cell &cell)
static bool isTRU(const o2::phos::Cell &cell)
static float getTimeStamp(const o2::emcal::Cell &cell)
static int16_t getCellNumber(const o2::phos::Cell &cell)
EMCAL compressed cell information.
Definition Cell.h:59
Bool_t getTRU() const
Check whether the cell is a TRU cell.
Definition Cell.h:158
float getTimeStamp() const
Get the time stamp.
Definition Cell.h:101
float getAmplitude() const
Get cell amplitude.
Definition Cell.h:117
short getTower() const
Get the tower ID.
Definition Cell.h:93
short getTRUId() const
Definition Cell.cxx:55
ChannelType_t getType() const
Definition Cell.cxx:174
short getAbsId() const
Definition Cell.cxx:44
float getTime() const
Definition Cell.cxx:103
bool getTRU() const
Definition Cell.cxx:221
float getEnergy() const
Definition Cell.cxx:147
Classs to aggregate and manage enum-based on-off flags.
Definition EnumFlags.h:347
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLsizeiptr size
Definition glcorearb.h:659
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLboolean * data
Definition glcorearb.h:298
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLbitfield flags
Definition glcorearb.h:1570
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
uint8_t itsSharedClusterMap uint8_t
TableCursor< aod::HepMCPdfInfos >::type PdfInfoCursor
TableCursor< aod::StoredMcParticles_001 >::type ParticleCursor
TableCursor< aod::HepMCHeavyIons >::type HeavyIonCursor
TableCursor< aod::HepMCXSections >::type XSectionCursor
TableCursor< aod::McCollisions >::type CollisionCursor
framework::DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableST, bool useMC, bool CTPConfigPerRun, bool enableFITextra)
create a processor spec
constexpr float XTPCInnerRef
reference radius at which TPC provides the tracks
constexpr double LHCBunchSpacingNS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
@ TRU2x2
TRU channel, 2x2 trigger.
Definition Cell.h:54
TrackParCovF TrackParCov
Definition Track.h:33
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"