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