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