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