Project
Loading...
Searching...
No Matches
StandaloneAODProducerSpec.cxx
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
18#include "Framework/DataTypes.h"
20#include "Framework/Logger.h"
22#include "MathUtils/Utils.h"
23
24using namespace o2::framework;
25
26namespace o2
27{
28namespace phos
29{
30
32{
33 mTimer.Stop();
34 mTimer.Reset();
35}
36
38{
39 mCaloAmp = 0xFFFFFFFF;
40 mCaloTime = 0xFFFFFFFF;
41
42 mTFNumber = ic.options().get<int64_t>("aod-timeframe-id");
43 mRunNumber = ic.options().get<int>("run-number");
44}
45
47{
48 // auto cput = mTimer.CpuTime();
49 // mTimer.Start(false);
50 const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
51 uint64_t tfNumber;
52 if (mTFNumber == -1L) {
53 // TODO has to be made globally unique (by using absolute time of TF). For now is unique within the run
54 tfNumber = uint64_t(tinfo.firstTForbit) + (uint64_t(tinfo.runNumber) << 32); // getTFNumber(mStartIR, runNumber);
55 } else {
56 tfNumber = mTFNumber;
57 }
58 const int runNumber = (mRunNumber == -1) ? int(tinfo.runNumber) : mRunNumber;
59
60 auto cells = pc.inputs().get<gsl::span<o2::phos::Cell>>("cells");
61 auto ctr = pc.inputs().get<gsl::span<o2::phos::TriggerRecord>>("cellTriggerRecords");
62
63 LOG(debug) << "FOUND " << cells.size() << " PHOS cells in CTF";
64 LOG(debug) << "FOUND " << ctr.size() << " PHOS tiggers in CTF";
65
66 auto bcBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "BC"});
67 auto collisionsBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "COLLISION"});
68 auto caloCellsBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "CALO"});
69 auto caloCellsTRGTableBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "CALOTRIGGER"});
70
71 auto bcCursor = bcBuilder->cursor<o2::aod::BCs>();
72 auto collisionsCursor = collisionsBuilder->cursor<o2::aod::Collisions>();
73 auto caloCellsCursor = caloCellsBuilder->cursor<o2::aod::Calos>();
74 auto caloCellsTRGTableCursor = caloCellsTRGTableBuilder->cursor<o2::aod::CaloTriggers>();
75
76 uint64_t triggerMask = 1, inputMask = 1;
77 // loop over events
78 int indexBC = -1;
79 for (const auto& tr : ctr) {
80 indexBC++;
81 int firstCellInEvent = tr.getFirstEntry();
82 int lastCellInEvent = firstCellInEvent + tr.getNumberOfObjects();
83 for (int i = firstCellInEvent; i < lastCellInEvent; i++) {
84 const Cell c = cells[i];
85 if (c.getTRU()) {
86 // TODO!!! test time?
87 caloCellsTRGTableCursor(0,
88 indexBC,
89 c.getTRUId(), // fastOrAbsId
90 c.getEnergy(), // lnAmplitude (dummy value)
91 (c.getType() == TRU2x2) ? 0 : 1, // triggerBits 0:L0 2x2, 1: L1 4x4
92 0); // caloType 0: PHOS
93 }
94
95 // TODO: should bad map be applied here? Unrecoverable loss of channels: special loose map?
96 // short absId = c.getAbsId();
97 // if (isBadChannel(absId)) {
98 // continue;
99 // }
100 // fill table
101 caloCellsCursor(0,
102 indexBC,
103 c.getAbsId(),
104 o2::math_utils::detail::truncateFloatFraction(c.getEnergy(), mCaloAmp),
105 o2::math_utils::detail::truncateFloatFraction(c.getTime(), mCaloTime),
106 c.getType(), // HG/LG
107 0); // hard coded for phos (-1 would be undefined, 0 phos)
108 } // end of cell loop
109
110 auto bcID = tr.getBCData().toLong();
111 bcCursor(0,
112 runNumber,
113 bcID,
114 triggerMask,
115 inputMask);
116
117 // fill collision cursor
118 collisionsCursor(0,
119 indexBC,
120 0., // X-Pos dummy value
121 0., // Y Pos
122 0., // Z Pos
123 0, // cov 0
124 0, // cov 1
125 0, // cov 2
126 0, // cov 3
127 0, // cov 4
128 0, // cov 5
129 0, // vertex bit field for flags
130 0, // chi2
131 0, // ncontributors
132 0, // rel interaction time
133 0); // vertex time stamp
134
135 } // end of event loop
136 // std::cout << "Finished cell loop" << std::endl;
137
138 pc.outputs().snapshot(Output{"TFN", "TFNumber", 0}, tfNumber);
139 pc.outputs().snapshot(Output{"TFF", "TFFilename", 0}, "");
140
141 mTimer.Stop();
142}
143
145{
146 LOGF(info, "PHOS Standalone AOD Producer total timing: Cpu: %.3e Real: %.3e s in %d slots",
147 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
148}
149
151{
152 std::vector<o2::framework::InputSpec> inputs;
153 inputs.emplace_back("cells", o2::header::gDataOriginPHS, "CELLS", 0, Lifetime::Timeframe);
154 inputs.emplace_back("cellTriggerRecords", o2::header::gDataOriginPHS, "CELLTRIGREC", 0, Lifetime::Timeframe);
155
156 std::vector<OutputSpec> outputs;
157 outputs.emplace_back(OutputLabel{"O2bc"}, "AOD", "BC", 0, Lifetime::Timeframe);
158 outputs.emplace_back(OutputLabel{"O2collision"}, "AOD", "COLLISION", 0, Lifetime::Timeframe);
159 outputs.emplace_back(OutputLabel{"O2caloCell"}, "AOD", "CALO", 0, Lifetime::Timeframe);
160 outputs.emplace_back(OutputLabel{"O2caloCellTRGR"}, "AOD", "CALOTRIGGER", 0, Lifetime::Timeframe);
161 outputs.emplace_back(OutputSpec{"TFN", "TFNumber"});
162 outputs.emplace_back(OutputSpec{"TFF", "TFFilename"});
163
164 return DataProcessorSpec{
165 "phos-standalone-aod-producer-workflow",
166 inputs,
167 outputs,
168 AlgorithmSpec{adaptFromTask<StandaloneAODProducerSpec>()},
169 Options{
170 ConfigParamSpec{"run-number", VariantType::Int64, -1L, {"The run-number. If left default we try to get it from DPL header."}},
171 ConfigParamSpec{"aod-timeframe-id", VariantType::Int64, -1L, {"Set timeframe number"}}}};
172}
173
174} // namespace phos
175} // namespace o2
General auxilliary methods.
std::ostringstream debug
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
A helper class to iteratate over all parts of all input routes.
Convert CTF (EncodedBlocks) to AO2D PHOS standalone.
uint32_t c
Definition RawData.h:2
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
constexpr o2::header::DataOrigin gDataOriginPHS
Definition DataHeader.h:577
Collisions_001 Collisions
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
framework::DataProcessorSpec getPHOSStandaloneAODProducerSpec()
create a processor spec
@ TRU2x2
TRU channel, 2x2 trigger.
Definition Cell.h:54
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cell > cells