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