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"
23#include "MathUtils/Utils.h"
24
25using namespace o2::framework;
26
27namespace o2
28{
29namespace phos
30{
31
33{
34 mTimer.Stop();
35 mTimer.Reset();
36}
37
39{
40 mCaloAmp = 0xFFFFFFFF;
41 mCaloTime = 0xFFFFFFFF;
42
43 mTFNumber = ic.options().get<int64_t>("aod-timeframe-id");
44 mRunNumber = ic.options().get<int>("run-number");
45}
46
48{
49 // auto cput = mTimer.CpuTime();
50 // mTimer.Start(false);
51 const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
52 uint64_t tfNumber;
53 if (mTFNumber == -1L) {
54 // TODO has to be made globally unique (by using absolute time of TF). For now is unique within the run
55 tfNumber = uint64_t(tinfo.firstTForbit) + (uint64_t(tinfo.runNumber) << 32); // getTFNumber(mStartIR, runNumber);
56 } else {
57 tfNumber = mTFNumber;
58 }
59 const int runNumber = (mRunNumber == -1) ? int(tinfo.runNumber) : mRunNumber;
60
61 auto cells = pc.inputs().get<gsl::span<o2::phos::Cell>>("cells");
62 auto ctr = pc.inputs().get<gsl::span<o2::phos::TriggerRecord>>("cellTriggerRecords");
63
64 LOG(debug) << "FOUND " << cells.size() << " PHOS cells in CTF";
65 LOG(debug) << "FOUND " << ctr.size() << " PHOS tiggers in CTF";
66
67 auto bcBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "BC"});
68 auto collisionsBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "COLLISION"});
69 auto caloCellsBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "CALO"});
70 auto caloCellsTRGTableBuilder = pc.outputs().make<TableBuilder>(Output{"AOD", "CALOTRIGGER"});
71
72 auto bcCursor = bcBuilder->cursor<o2::aod::BCs>();
73 auto collisionsCursor = collisionsBuilder->cursor<o2::aod::Collisions>();
74 auto caloCellsCursor = caloCellsBuilder->cursor<o2::aod::Calos>();
75 auto caloCellsTRGTableCursor = caloCellsTRGTableBuilder->cursor<o2::aod::CaloTriggers>();
76
77 uint64_t triggerMask = 1, inputMask = 1;
78 // loop over events
79 int indexBC = -1;
80 for (const auto& tr : ctr) {
81 indexBC++;
82 int firstCellInEvent = tr.getFirstEntry();
83 int lastCellInEvent = firstCellInEvent + tr.getNumberOfObjects();
84 for (int i = firstCellInEvent; i < lastCellInEvent; i++) {
85 const Cell c = cells[i];
86 if (c.getTRU()) {
87 // TODO!!! test time?
88 caloCellsTRGTableCursor(0,
89 indexBC,
90 c.getTRUId(), // fastOrAbsId
91 c.getEnergy(), // lnAmplitude (dummy value)
92 (c.getType() == TRU2x2) ? 0 : 1, // triggerBits 0:L0 2x2, 1: L1 4x4
93 0); // caloType 0: PHOS
94 }
95
96 // TODO: should bad map be applied here? Unrecoverable loss of channels: special loose map?
97 // short absId = c.getAbsId();
98 // if (isBadChannel(absId)) {
99 // continue;
100 // }
101 // fill table
102 caloCellsCursor(0,
103 indexBC,
104 c.getAbsId(),
105 o2::math_utils::detail::truncateFloatFraction(c.getEnergy(), mCaloAmp),
106 o2::math_utils::detail::truncateFloatFraction(c.getTime(), mCaloTime),
107 c.getType(), // HG/LG
108 0); // hard coded for phos (-1 would be undefined, 0 phos)
109 } // end of cell loop
110
111 auto bcID = tr.getBCData().toLong();
112 bcCursor(0,
113 runNumber,
114 bcID,
115 triggerMask,
116 inputMask);
117
118 // fill collision cursor
119 collisionsCursor(0,
120 indexBC,
121 0., // X-Pos dummy value
122 0., // Y Pos
123 0., // Z Pos
124 0, // cov 0
125 0, // cov 1
126 0, // cov 2
127 0, // cov 3
128 0, // cov 4
129 0, // cov 5
130 0, // vertex bit field for flags
131 0, // chi2
132 0, // ncontributors
133 0, // rel interaction time
134 0); // vertex time stamp
135
136 } // end of event loop
137 // std::cout << "Finished cell loop" << std::endl;
138
139 pc.outputs().snapshot(Output{"TFN", "TFNumber", 0}, tfNumber);
140 pc.outputs().snapshot(Output{"TFF", "TFFilename", 0}, "");
141
142 mTimer.Stop();
143}
144
146{
147 LOGF(info, "PHOS Standalone AOD Producer total timing: Cpu: %.3e Real: %.3e s in %d slots",
148 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
149}
150
152{
153 std::vector<o2::framework::InputSpec> inputs;
154 inputs.emplace_back("cells", o2::header::gDataOriginPHS, "CELLS", 0, Lifetime::Timeframe);
155 inputs.emplace_back("cellTriggerRecords", o2::header::gDataOriginPHS, "CELLTRIGREC", 0, Lifetime::Timeframe);
156
157 std::vector<OutputSpec> outputs;
158 outputs.emplace_back(OutputLabel{"O2bc"}, "AOD", "BC", 0, Lifetime::Timeframe);
159 outputs.emplace_back(OutputLabel{"O2collision"}, "AOD", "COLLISION", 0, Lifetime::Timeframe);
160 outputs.emplace_back(OutputLabel{"O2caloCell"}, "AOD", "CALO", 0, Lifetime::Timeframe);
161 outputs.emplace_back(OutputLabel{"O2caloCellTRGR"}, "AOD", "CALOTRIGGER", 0, Lifetime::Timeframe);
162 outputs.emplace_back(OutputSpec{"TFN", "TFNumber"});
163 outputs.emplace_back(OutputSpec{"TFF", "TFFilename"});
164
165 return DataProcessorSpec{
166 "phos-standalone-aod-producer-workflow",
167 inputs,
168 outputs,
169 AlgorithmSpec{adaptFromTask<StandaloneAODProducerSpec>()},
170 Options{
171 ConfigParamSpec{"run-number", VariantType::Int64, -1L, {"The run-number. If left default we try to get it from DPL header."}},
172 ConfigParamSpec{"aod-timeframe-id", VariantType::Int64, -1L, {"Set timeframe number"}}}};
173}
174
175} // namespace phos
176} // namespace o2
General auxilliary methods.
int32_t i
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
std::ostringstream debug
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:574
Collisions_001 Collisions
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
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