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 mTrackQCDCAxy{3.};
243 float mTrackQCPt{0.2};
244 int mTrackQCNCls{80};
245 float mSqrtS{13860.};
246 std::mt19937 mGenerator{};
247 o2::base::Propagator::MatCorrType mMatCorr{o2::base::Propagator::MatCorrType::USEMatCorrLUT};
249 float mMinPropR{o2::constants::geom::XTPCInnerRef + 0.1f};
250
251 std::unordered_set<GIndex> mGIDUsedBySVtx;
252 std::unordered_set<GIndex> mGIDUsedByStr;
253
255 std::shared_ptr<o2::utils::TreeStreamRedirector> mStreamer;
256
257 int mNThreads = 1;
258 bool mUseMC = true;
259 bool mEnableSV = true; // enable secondary vertices
260 bool mEnableFITextra = false;
261 bool mFieldON = false;
262 const float cSpeed = 0.029979246f; // speed of light in TOF units
263
264 GID::mask_t mInputSources;
265 int64_t mTFNumber{-1};
266 int mRunNumber{-1};
267 int mTruncate{1};
268 int mRecoOnly{0};
269 o2::InteractionRecord mStartIR{}; // TF 1st IR
270 TString mLPMProdTag{""};
271 TString mAnchorPass{""};
272 TString mAnchorProd{""};
273 TString mRecoPass{""};
274 TStopwatch mTimer;
275 bool mEMCselectLeading{false};
276 uint64_t mEMCALTrgClassMask = 0;
277
278 // unordered map connects global indices and table indices of barrel tracks
279 std::unordered_map<GIndex, int> mGIDToTableID;
280 int mTableTrID{0};
281 // unordered map connects global indices and table indices of fwd tracks
282 std::unordered_map<GIndex, int> mGIDToTableFwdID;
283 int mTableTrFwdID{0};
284 // unordered map connects global indices and table indices of MFT tracks
285 std::unordered_map<GIndex, int> mGIDToTableMFTID;
286 int mTableTrMFTID{0};
287 // unordered map connects global indices and table indices of vertices
288 std::unordered_map<GIndex, int> mVtxToTableCollID;
289 int mTableCollID{0};
290 // unordered map connects global indices and table indices of V0s (needed for cascades references)
291 std::unordered_map<GIndex, int> mV0ToTableID;
292 int mTableV0ID{0};
293
294 // Strangeness tracking indices lookup tables
295 std::vector<int> mVertexStrLUT;
296 std::vector<std::pair<int, int>> mCollisionStrTrk;
297 std::vector<int> mStrTrkIndices;
298
299 // std::unordered_map<int, int> mIndexTableFwd;
300 std::vector<int> mIndexTableFwd;
301 int mIndexFwdID{0};
302 // std::unordered_map<int, int> mIndexTableMFT;
303 std::vector<int> mIndexTableMFT;
304 int mIndexMFTID{0};
305
306 BunchCrossings mBCLookup;
307
308 // zdc helper maps to avoid a number of "if" statements
309 // when filling ZDC table
310 std::array<float, o2::zdc::NChannels> mZDCEnergyMap; // mapping detector id to a corresponding energy
311 std::array<float, o2::zdc::NTDCChannels> mZDCTDCMap; // mapping TDC channel id to a corresponding TDC value
312
313 std::vector<uint16_t> mITSTPCTRDTriggers; // mapping from TRD tracks ID to corresponding trigger (for tracks time extraction)
314 std::vector<uint16_t> mTPCTRDTriggers; // mapping from TRD tracks ID to corresponding trigger (for tracks time extraction)
315 std::vector<uint16_t> mITSROFs; // mapping from ITS tracks ID to corresponding ROF (for SA ITS tracks time extraction)
316 std::vector<uint16_t> mMFTROFs; // mapping from MFT tracks ID to corresponding ROF (for SA MFT tracks time extraction)
317 std::vector<uint16_t> mMCHROFs; // mapping from MCH tracks ID to corresponding ROF (for SA MCH tracks time extraction)
318 double mITSROFrameHalfLengthNS = -1; // ITS ROF half length
319 double mMFTROFrameHalfLengthNS = -1; // ITS ROF half length
320 double mITSROFBiasNS = 0; // ITS ROF start bias
321 double mMFTROFBiasNS = 0; // ITS ROF start bias
322 double mNSigmaTimeTrack = -1; // number track errors sigmas (for gaussian errors only) used in track-vertex matching
323 double mTimeMarginTrackTime = -1; // safety margin in NS used for track-vertex matching (additive to track uncertainty)
324 double mTPCBinNS = -1; // inverse TPC time-bin in ns
325
326 // Container used to mark MC particles to store/transfer to AOD.
327 // Mapping of eventID, sourceID, trackID to some integer.
328 // The first two indices are not sparse whereas the trackID index is sparse which explains
329 // the combination of vector and map
330 std::vector<std::vector<std::unordered_map<int, int>>> mToStore;
331 o2::steer::MCKinematicsReader* mMCKineReader = nullptr;
332
333 // production metadata
334 std::vector<TString> mMetaDataKeys;
335 std::vector<TString> mMetaDataVals;
336
337 std::shared_ptr<DataRequest> mDataRequest;
338 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
339
341
342 static constexpr int TOFTimePrecPS = 16; // required max error in ps for TOF tracks
343 // truncation is enabled by default
344 uint32_t mCollisionPosition = 0xFFFFFFF0; // 19 bits mantissa
345 uint32_t mCollisionPositionCov = 0xFFFFE000; // 10 bits mantissa
346 uint32_t mTrackX = 0xFFFFFFF0; // 19 bits
347 uint32_t mTrackAlpha = 0xFFFFFFF0; // 19 bits
348 uint32_t mTrackSnp = 0xFFFFFF00; // 15 bits
349 uint32_t mTrackTgl = 0xFFFFFF00; // 15 bits
350 uint32_t mTrack1Pt = 0xFFFFFC00; // 13 bits
351 uint32_t mTrackCovDiag = 0xFFFFFF00; // 15 bits
352 uint32_t mTrackChi2 = 0xFFFF0000; // 7 bits
353 uint32_t mTrackCovOffDiag = 0xFFFF0000; // 7 bits
354 uint32_t mTrackSignal = 0xFFFFFF00; // 15 bits
355 uint32_t mTrackTime = 0xFFFFFFFF; // use full float precision for time
356 uint32_t mTPCTime0 = 0xFFFFFFE0; // 18 bits, providing 14256./(1<<19) = 0.027 TB precision e.g., ~0.13 mm in z
357 uint32_t mTrackTimeError = 0xFFFFFF00; // 15 bits
358 uint32_t mTrackPosEMCAL = 0xFFFFFF00; // 15 bits
359 uint32_t mTracklets = 0xFFFFFF00; // 15 bits
360 uint32_t mMcParticleW = 0xFFFFFFF0; // 19 bits
361 uint32_t mMcParticlePos = 0xFFFFFFF0; // 19 bits
362 uint32_t mMcParticleMom = 0xFFFFFFF0; // 19 bits
363 uint32_t mCaloAmp = 0xFFFFFF00; // 15 bits todo check which truncation should actually be used
364 uint32_t mCaloTime = 0xFFFFFF00; // 15 bits todo check which truncation should actually be used
365 uint32_t mCPVPos = 0xFFFFF800; // 12 bits
366 uint32_t mCPVAmpl = 0xFFFFFF00; // 15 bits
367 uint32_t mMuonTr1P = 0xFFFFFC00; // 13 bits
368 uint32_t mMuonTrThetaX = 0xFFFFFF00; // 15 bits
369 uint32_t mMuonTrThetaY = 0xFFFFFF00; // 15 bits
370 uint32_t mMuonTrZmu = 0xFFFFFFF0; // 19 bits
371 uint32_t mMuonTrBend = 0xFFFFFFF0; // 19 bits
372 uint32_t mMuonTrNonBend = 0xFFFFFFF0; // 19 bits
373 uint32_t mMuonTrCov = 0xFFFF0000; // 7 bits
374 uint32_t mMuonCl = 0xFFFFFF00; // 15 bits
375 uint32_t mMuonClErr = 0xFFFF0000; // 7 bits
376 uint32_t mV0Time = 0xFFFFF000; // 11 bits
377 uint32_t mV0ChannelTime = 0xFFFFFF00; // 15 bits
378 uint32_t mFDDTime = 0xFFFFF000; // 11 bits
379 uint32_t mFDDChannelTime = 0xFFFFFF00; // 15 bits
380 uint32_t mT0Time = 0xFFFFFF00; // 15 bits
381 uint32_t mT0ChannelTime = 0xFFFFFFF0; // 19 bits
382 uint32_t mV0Amplitude = 0xFFFFF000; // 11 bits
383 uint32_t mFDDAmplitude = 0xFFFFF000; // 11 bits
384 uint32_t mT0Amplitude = 0xFFFFF000; // 11 bits
385 int mCTPReadout = 0; // 0 = use CTP readout from CTP; 1 = create CTP readout
386 bool mCTPConfigPerRun = false; // 0 = use common CTPconfig as for MC; 1 = run dependent CTP config
387 // helper struct for extra info in fillTrackTablesPerCollision()
388 struct TrackExtraInfo {
389 float tpcInnerParam = 0.f;
390 uint32_t flags = 0;
391 uint32_t itsClusterSizes = 0u;
392 uint8_t itsClusterMap = 0;
393 uint8_t tpcNClsFindable = 0;
394 int8_t tpcNClsFindableMinusFound = 0;
395 int8_t tpcNClsFindableMinusPID = 0;
396 int8_t tpcNClsFindableMinusCrossedRows = 0;
397 uint8_t tpcNClsShared = 0;
398 uint8_t trdPattern = 0;
399 float itsChi2NCl = -999.f;
400 float tpcChi2NCl = -999.f;
401 float trdChi2 = -999.f;
402 float tofChi2 = -999.f;
403 float tpcSignal = -999.f;
404 float trdSignal = -999.f;
405 float length = -999.f;
406 float tofExpMom = -999.f;
407 float trackEtaEMCAL = -999.f;
408 float trackPhiEMCAL = -999.f;
409 float trackTime = -999.f;
410 float trackTimeRes = -999.f;
411 int diffBCRef = 0; // offset of time reference BC from the start of the orbit
412 int bcSlice[2] = {-1, -1};
413 bool isTPConly = false; // not to be written out
414 };
415
416 struct TrackQA {
417 GID trackID;
418 float tpcTime0{};
419 float tpcdEdxNorm{};
420 int16_t tpcdcaR{};
421 int16_t tpcdcaZ{};
422 uint8_t tpcClusterByteMask{};
423 uint8_t tpcdEdxMax0R{};
424 uint8_t tpcdEdxMax1R{};
425 uint8_t tpcdEdxMax2R{};
426 uint8_t tpcdEdxMax3R{};
427 uint8_t tpcdEdxTot0R{};
428 uint8_t tpcdEdxTot1R{};
429 uint8_t tpcdEdxTot2R{};
430 uint8_t tpcdEdxTot3R{};
431 int8_t dRefContY{std::numeric_limits<int8_t>::min()};
432 int8_t dRefContZ{std::numeric_limits<int8_t>::min()};
433 int8_t dRefContSnp{std::numeric_limits<int8_t>::min()};
434 int8_t dRefContTgl{std::numeric_limits<int8_t>::min()};
435 int8_t dRefContQ2Pt{std::numeric_limits<int8_t>::min()};
436 int8_t dRefGloY{std::numeric_limits<int8_t>::min()};
437 int8_t dRefGloZ{std::numeric_limits<int8_t>::min()};
438 int8_t dRefGloSnp{std::numeric_limits<int8_t>::min()};
439 int8_t dRefGloTgl{std::numeric_limits<int8_t>::min()};
440 int8_t dRefGloQ2Pt{std::numeric_limits<int8_t>::min()};
441 int8_t dTofdX{std::numeric_limits<int8_t>::min()};
442 int8_t dTofdZ{std::numeric_limits<int8_t>::min()};
443 };
444
445 // helper struct for addToFwdTracksTable()
446 struct FwdTrackInfo {
447 uint8_t trackTypeId = 0;
448 float x = 0.f;
449 float y = 0.f;
450 float z = 0.f;
451 float rabs = 0.f;
452 float phi = 0.f;
453 float tanl = 0.f;
454 float invqpt = 0.f;
455 float chi2 = 0.f;
456 float pdca = 0.f;
457 int nClusters = -1;
458 float chi2matchmchmid = -1.0;
459 float chi2matchmchmft = -1.0;
460 float matchscoremchmft = -1.0;
461 int matchmfttrackid = -1;
462 int matchmchtrackid = -1;
463 uint16_t mchBitMap = 0;
464 uint8_t midBitMap = 0;
465 uint32_t midBoards = 0;
466 float trackTime = -999.f;
467 float trackTimeRes = -999.f;
468 };
469
470 // helper struct for addToFwdTracksTable()
471 struct FwdTrackCovInfo {
472 float sigX = 0.f;
473 float sigY = 0.f;
474 float sigPhi = 0.f;
475 float sigTgl = 0.f;
476 float sig1Pt = 0.f;
477 int8_t rhoXY = 0;
478 int8_t rhoPhiX = 0;
479 int8_t rhoPhiY = 0;
480 int8_t rhoTglX = 0;
481 int8_t rhoTglY = 0;
482 int8_t rhoTglPhi = 0;
483 int8_t rho1PtX = 0;
484 int8_t rho1PtY = 0;
485 int8_t rho1PtPhi = 0;
486 int8_t rho1PtTgl = 0;
487 };
488
489 // helper struct for mc track labels
490 // using -1 as dummies for AOD
491 struct MCLabels {
492 uint32_t labelID = -1;
493 uint16_t labelMask = 0;
494 uint8_t fwdLabelMask = 0;
495 };
496
497 // counters for TPC clusters
498 struct TPCCounters {
499 uint8_t shared = 0;
500 uint8_t found = 0;
501 uint8_t crossed = 0;
502 };
503 std::vector<TPCCounters> mTPCCounters;
504
505 void updateTimeDependentParams(ProcessingContext& pc);
506
507 void addRefGlobalBCsForTOF(const o2::dataformats::VtxTrackRef& trackRef, const gsl::span<const GIndex>& GIndices,
508 const o2::globaltracking::RecoContainer& data, std::map<uint64_t, int>& bcsMap);
509 void createCTPReadout(const o2::globaltracking::RecoContainer& recoData, std::vector<o2::ctp::CTPDigit>& ctpDigits, ProcessingContext& pc);
510 void collectBCs(const o2::globaltracking::RecoContainer& data,
511 const std::vector<o2::InteractionTimeRecord>& mcRecords,
512 std::map<uint64_t, int>& bcsMap);
513
514 template <typename TracksCursorType, typename TracksCovCursorType>
515 void addToTracksTable(TracksCursorType& tracksCursor, TracksCovCursorType& tracksCovCursor,
517
518 template <typename TracksExtraCursorType>
519 void addToTracksExtraTable(TracksExtraCursorType& tracksExtraCursor, TrackExtraInfo& extraInfoHolder);
520
521 template <typename TracksQACursorType>
522 void addToTracksQATable(TracksQACursorType& tracksQACursor, TrackQA& trackQAInfoHolder);
523
524 template <typename mftTracksCursorType, typename AmbigMFTTracksCursorType>
525 void addToMFTTracksTable(mftTracksCursorType& mftTracksCursor, AmbigMFTTracksCursorType& ambigMFTTracksCursor,
526 GIndex trackID, const o2::globaltracking::RecoContainer& data, int collisionID,
527 std::uint64_t collisionBC, const std::map<uint64_t, int>& bcsMap);
528
529 template <typename fwdTracksCursorType, typename fwdTracksCovCursorType, typename AmbigFwdTracksCursorType, typename mftTracksCovCursorType>
530 void addToFwdTracksTable(fwdTracksCursorType& fwdTracksCursor, fwdTracksCovCursorType& fwdTracksCovCursor, AmbigFwdTracksCursorType& ambigFwdTracksCursor, mftTracksCovCursorType& mftTracksCovCursor,
531 GIndex trackID, const o2::globaltracking::RecoContainer& data, int collisionID, std::uint64_t collisionBC, const std::map<uint64_t, int>& bcsMap);
532
533 TrackExtraInfo processBarrelTrack(int collisionID, std::uint64_t collisionBC, GIndex trackIndex, const o2::globaltracking::RecoContainer& data, const std::map<uint64_t, int>& bcsMap);
534 TrackQA processBarrelTrackQA(int collisionID, std::uint64_t collisionBC, GIndex trackIndex, const o2::globaltracking::RecoContainer& data, const std::map<uint64_t, int>& bcsMap);
535
536 bool propagateTrackToPV(o2::track::TrackParametrizationWithError<float>& trackPar, const o2::globaltracking::RecoContainer& data, int colID);
537 void extrapolateToCalorimeters(TrackExtraInfo& extraInfoHolder, const o2::track::TrackPar& track);
538 void cacheTriggers(const o2::globaltracking::RecoContainer& recoData);
539
540 // helper for track tables
541 // * fills tables collision by collision
542 // * interaction time is for TOF information
543 template <typename TracksCursorType, typename TracksCovCursorType, typename TracksExtraCursorType, typename TracksQACursorType, typename AmbigTracksCursorType,
544 typename MFTTracksCursorType, typename MFTTracksCovCursorType, typename AmbigMFTTracksCursorType,
545 typename FwdTracksCursorType, typename FwdTracksCovCursorType, typename AmbigFwdTracksCursorType, typename FwdTrkClsCursorType>
546 void fillTrackTablesPerCollision(int collisionID,
547 std::uint64_t collisionBC,
548 const o2::dataformats::VtxTrackRef& trackRef,
549 const gsl::span<const GIndex>& GIndices,
551 TracksCursorType& tracksCursor,
552 TracksCovCursorType& tracksCovCursor,
553 TracksExtraCursorType& tracksExtraCursor,
554 TracksQACursorType& tracksQACursor,
555 AmbigTracksCursorType& ambigTracksCursor,
556 MFTTracksCursorType& mftTracksCursor,
557 MFTTracksCovCursorType& mftTracksCovCursor,
558 AmbigMFTTracksCursorType& ambigMFTTracksCursor,
559 FwdTracksCursorType& fwdTracksCursor,
560 FwdTracksCovCursorType& fwdTracksCovCursor,
561 AmbigFwdTracksCursorType& ambigFwdTracksCursor,
562 FwdTrkClsCursorType& fwdTrkClsCursor,
563 const std::map<uint64_t, int>& bcsMap);
564
565 template <typename FwdTrkClsCursorType>
566 void addClustersToFwdTrkClsTable(const o2::globaltracking::RecoContainer& recoData, FwdTrkClsCursorType& fwdTrkClsCursor, GIndex trackID, int fwdTrackId);
567
568 void fillIndexTablesPerCollision(const o2::dataformats::VtxTrackRef& trackRef, const gsl::span<const GIndex>& GIndices, const o2::globaltracking::RecoContainer& data);
569
570 template <typename V0CursorType, typename CascadeCursorType, typename Decay3bodyCursorType>
571 void fillSecondaryVertices(const o2::globaltracking::RecoContainer& data, V0CursorType& v0Cursor, CascadeCursorType& cascadeCursor, Decay3bodyCursorType& decay3bodyCursor);
572
573 template <typename HMPCursorType>
574 void fillHMPID(const o2::globaltracking::RecoContainer& recoData, HMPCursorType& hmpCursor);
575
576 void prepareStrangenessTracking(const o2::globaltracking::RecoContainer& recoData);
577 template <typename V0C, typename CC, typename D3BC>
578 void fillStrangenessTrackingTables(const o2::globaltracking::RecoContainer& data, V0C& v0Cursor, CC& cascadeCursor, D3BC& decay3bodyCursor);
579
581 using MCCollisionCursor = aodmchelpers::CollisionCursor;
582 using XSectionCursor = aodmchelpers::XSectionCursor;
583 using PdfInfoCursor = aodmchelpers::PdfInfoCursor;
584 using HeavyIonCursor = aodmchelpers::HeavyIonCursor;
585 using MCParticlesCursor = aodmchelpers::ParticleCursor;
586 using HepMCUpdate = aodmchelpers::HepMCUpdate;
587 using MCEventHeader = dataformats::MCEventHeader;
589 HepMCUpdate mXSectionUpdate = HepMCUpdate::anyKey;
590 HepMCUpdate mPdfInfoUpdate = HepMCUpdate::anyKey;
591 HepMCUpdate mHeavyIonUpdate = HepMCUpdate::anyKey;
629 void updateMCHeader(MCCollisionCursor& collisionCursor,
630 XSectionCursor& xSectionCursor,
631 PdfInfoCursor& pdfInfoCursor,
632 HeavyIonCursor& heavyIonCursor,
633 const MCEventHeader& header,
634 int collisionID,
635 int bcID,
636 float time,
637 short generatorID,
638 int sourceID);
639
640 void fillMCParticlesTable(o2::steer::MCKinematicsReader& mcReader,
641 MCParticlesCursor& mcParticlesCursor,
642 const gsl::span<const o2::dataformats::VtxTrackRef>& primVer2TRefs,
643 const gsl::span<const GIndex>& GIndices,
645 const std::vector<std::vector<int>>& mcColToEvSrc);
646
647 template <typename MCTrackLabelCursorType, typename MCMFTTrackLabelCursorType, typename MCFwdTrackLabelCursorType>
648 void fillMCTrackLabelsTable(MCTrackLabelCursorType& mcTrackLabelCursor,
649 MCMFTTrackLabelCursorType& mcMFTTrackLabelCursor,
650 MCFwdTrackLabelCursorType& mcFwdTrackLabelCursor,
651 const o2::dataformats::VtxTrackRef& trackRef,
652 const gsl::span<const GIndex>& primVerGIs,
654 int vertexId = -1);
655
656 std::uint64_t fillBCSlice(int (&slice)[2], double tmin, double tmax, const std::map<uint64_t, int>& bcsMap) const;
657
658 std::vector<uint8_t> fillBCFlags(const o2::globaltracking::RecoContainer& data, std::map<uint64_t, int>& bcsMap) const;
659
660 // helper for tpc clusters
661 void countTPCClusters(const o2::globaltracking::RecoContainer& data);
662
663 // helper for trd pattern
664 uint8_t getTRDPattern(const o2::trd::TrackTRD& track);
665
666 template <typename TCaloHandler, typename TCaloCursor, typename TCaloTRGCursor, typename TMCCaloLabelCursor>
667 void addToCaloTable(TCaloHandler& caloHandler, TCaloCursor& caloCellCursor, TCaloTRGCursor& caloTRGCursor,
668 TMCCaloLabelCursor& mcCaloCellLabelCursor, int eventID, int bcID, int8_t caloType);
669
670 template <typename TCaloCursor, typename TCaloTRGCursor, typename TMCCaloLabelCursor>
671 void fillCaloTable(TCaloCursor& caloCellCursor, TCaloTRGCursor& caloTRGCursor,
672 TMCCaloLabelCursor& mcCaloCellLabelCursor, const std::map<uint64_t, int>& bcsMap,
674
675 std::set<uint64_t> filterEMCALIncomplete(const gsl::span<const o2::emcal::TriggerRecord> triggers);
676};
677
679framework::DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, bool enableST, bool useMC, bool CTPConfigPerRun, bool enableFITextra);
680
681// helper interface for calo cells to "befriend" emcal and phos cells
683{
684 public:
685 static int8_t getTriggerBits(const o2::emcal::Cell& /*cell*/)
686 {
687 return 0; // dummy value
688 }
689
690 static int8_t getTriggerBits(const o2::phos::Cell& cell)
691 {
692 return (cell.getType() == o2::phos::ChannelType_t::TRU2x2) ? 0 : 1;
693 }
694
695 static int16_t getCellNumber(const o2::emcal::Cell& cell)
696 {
697 return cell.getTower();
698 }
699
700 static int16_t getCellNumber(const o2::phos::Cell& cell)
701 {
702 if (cell.getTRU()) {
703 return cell.getTRUId();
704 }
705 return cell.getAbsId();
706 }
707 // If this cell - trigger one?
708 static bool isTRU(const o2::emcal::Cell& cell)
709 {
710 return cell.getTRU();
711 }
712
713 static bool isTRU(const o2::phos::Cell& cell)
714 {
715 return cell.getTRU();
716 }
717
718 static int16_t getFastOrAbsID(const o2::emcal::Cell& /*cell*/)
719 {
720 return 0; // dummy value
721 }
722
723 static int16_t getFastOrAbsID(const o2::phos::Cell& cell)
724 {
725 return cell.getTRUId();
726 }
727
728 static float getAmplitude(const o2::emcal::Cell& cell)
729 {
730 return cell.getAmplitude();
731 }
732
733 static float getAmplitude(const o2::phos::Cell& cell)
734 {
735 return cell.getEnergy();
736 }
737
738 static int16_t getLnAmplitude(const o2::emcal::Cell& /*cell*/)
739 {
740 return 0; // dummy value
741 }
742
743 static int16_t getLnAmplitude(const o2::phos::Cell& cell)
744 {
745 return cell.getEnergy(); // dummy value
746 }
747
748 static float getTimeStamp(const o2::emcal::Cell& cell)
749 {
750 return cell.getTimeStamp();
751 }
752
753 static float getTimeStamp(const o2::phos::Cell& cell)
754 {
755 return cell.getTime();
756 }
757};
758
759} // namespace o2::aodproducer
760
761#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"