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