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