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