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
16#include "Framework/DataTypes.h"
18#include "Framework/Logger.h"
21#include "MathUtils/Utils.h"
22
23using namespace o2::framework;
24
25namespace o2
26{
27namespace emcal
28{
29
31{
32 mTimer.Stop();
33 mTimer.Reset();
34}
35
37{
38 mCaloEventHandler = new o2::emcal::EventHandler<o2::emcal::Cell>();
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
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 cellsIn = pc.inputs().get<gsl::span<o2::emcal::Cell>>(getCellBinding());
62 auto triggersIn = pc.inputs().get<gsl::span<o2::emcal::TriggerRecord>>(getCellTriggerRecordBinding());
63
64 LOG(info) << "FOUND " << cellsIn.size() << " EMC cells in CTF";
65 LOG(info) << "FOUND " << triggersIn.size() << " EMC 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 // build event for easier handling
78 mCaloEventHandler->reset();
79 mCaloEventHandler->setCellData(cellsIn, triggersIn);
80
81 uint64_t triggerMask = 1, inputMask = 1;
82 // loop over events
83 for (int iev = 0; iev < mCaloEventHandler->getNumberOfEvents(); iev++) {
84 o2::emcal::EventData inputEvent = mCaloEventHandler->buildEvent(iev);
85 auto cellsInEvent = inputEvent.mCells; // get cells belonging to current event
86 auto interactionRecord = inputEvent.mInteractionRecord; // get interaction records belonging to current event
87
88 LOG(info) << "Found " << cellsInEvent.size() << " cells in event";
89
90 auto bcID = interactionRecord.toLong();
91 bcCursor(0,
92 runNumber,
93 bcID,
94 triggerMask,
95 inputMask);
96 auto indexBC = iev;
97
98 for (auto& cell : cellsInEvent) {
99
100 // fill table
101 caloCellsCursor(0,
102 indexBC,
103 cell.getTower(),
104 o2::math_utils::detail::truncateFloatFraction(cell.getAmplitude(), mCaloAmp),
105 o2::math_utils::detail::truncateFloatFraction(cell.getTimeStamp(), mCaloTime),
106 cell.getType(),
107 1); // hard coded for emcal (-1 would be undefined, 0 phos)
108 } // end of cell loop
109
110 // filled only with BCID, rest dummy for no2
111 caloCellsTRGTableCursor(0,
112 indexBC,
113 0, // fastOrAbsId (dummy value)
114 0., // lnAmplitude (dummy value)
115 0, // triggerBits (dummy value)
116 1); // caloType (dummy value)
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, "EMCAL 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<OutputSpec> outputs;
154 outputs.emplace_back(OutputLabel{"O2bc"}, "AOD", "BC", 0, Lifetime::Timeframe);
155 outputs.emplace_back(OutputLabel{"O2collision"}, "AOD", "COLLISION", 0, Lifetime::Timeframe);
156 outputs.emplace_back(OutputLabel{"O2caloCell"}, "AOD", "CALO", 0, Lifetime::Timeframe);
157 outputs.emplace_back(OutputLabel{"O2caloCellTRGR"}, "AOD", "CALOTRIGGER", 0, Lifetime::Timeframe);
158 outputs.emplace_back(OutputSpec{"TFN", "TFNumber"});
159 outputs.emplace_back(OutputSpec{"TFF", "TFFilename"});
160
161 return DataProcessorSpec{
162 "standalone-aod-producer-workflow",
163 Inputs{
164 InputSpec{StandaloneAODProducerSpec::getCellTriggerRecordBinding(), "EMC", "CELLSTRGR", 0, Lifetime::Timeframe},
165 InputSpec{StandaloneAODProducerSpec::getCellBinding(), "EMC", "CELLS", 0, Lifetime::Timeframe}},
166 outputs,
167 AlgorithmSpec{adaptFromTask<StandaloneAODProducerSpec>()},
168 Options{
169 ConfigParamSpec{"run-number", VariantType::Int64, -1L, {"The run-number. If left default we try to get it from DPL header."}},
170 ConfigParamSpec{"aod-timeframe-id", VariantType::Int64, -1L, {"Set timeframe number"}}}};
171}
172
173} // namespace emcal
174} // namespace o2
General auxilliary methods.
Convert CTF (EncodedBlocks) to AO2D EMCal standalone.
A helper class to iteratate over all parts of all input routes.
Handler for EMCAL event data.
EventData< CellInputType > buildEvent(int eventID) const
Build event information for a given event number within the timeframe.
void reset()
Reset containers with empty ranges.
void setCellData(CellRange cells, TriggerRange triggers)
Setting the data at cell level.
int getNumberOfEvents() const
Get the number of events handled by the event handler.
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
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.
Collisions_001 Collisions
framework::DataProcessorSpec getStandaloneAODProducerSpec()
create a processor spec
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
EMCAL event information (per trigger)
Definition EventData.h:38
gsl::span< const InputType > mCells
EMCAL cells / digits.
Definition EventData.h:41
InteractionRecord mInteractionRecord
Interaction record for the trigger corresponding to this event.
Definition EventData.h:39
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"