Project
Loading...
Searching...
No Matches
TPCIntegrateIDCSpec.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
16
17#ifndef O2_TPCINTEGRATEIDCSPEC_H
18#define O2_TPCINTEGRATEIDCSPEC_H
19
20#include <vector>
21#include <fmt/format.h>
22#include "Framework/Task.h"
24#include "Framework/Logger.h"
26#include "Headers/DataHeader.h"
30#include "TPCBase/Mapper.h"
31
32using namespace o2::framework;
34using namespace o2::tpc;
35
36namespace o2::tpc
37{
38
40{
41 public:
42 // enum for the output format of the integrated IDCs
43 enum class IDCFormat : int {
44 Sim = 0, // output format of simulation for faster processing
45 Real = 1 // output format of real CRUs
46 };
47
48 TPCIntegrateIDCDevice(const std::vector<unsigned int>& sectors, const int nOrbitsPerIDCIntervall, const IDCFormat outputFormat, const bool debug) : mSectors{sectors}, mIDCFormat{outputFormat}, mDebug{debug}
49 {
50 for (const auto& sector : mSectors) {
51 mIDCs.emplace(sector, IDCSim(sector, nOrbitsPerIDCIntervall));
52 }
53 }
54
56 {
57 LOGP(info, "integrating digits for sectors {} to {}", mSectors.front(), mSectors.back());
58
59 for (int iSec = 0; iSec < mSectors.size(); ++iSec) {
60 const DataRef ref = pc.inputs().getByPos(iSec);
61 const int sector = o2::framework::DataRefUtils::getHeader<o2::tpc::TPCSectorHeader*>(ref)->sector();
62
63 // integrate digits for given sector
64 mIDCs[sector].integrateDigitsForOneTF(pc.inputs().get<gsl::span<o2::tpc::Digit>>(ref));
65
66 if (mDebug) {
67 auto const* tpcHeader = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
68 mIDCs[sector].dumpIDCs(fmt::format("idcs_obj_sec{:02}_tf{:02}.root", sector, tpcHeader->tfCounter).data(), fmt::format("IDCSim_sec{:02}", sector).data());
69 }
70
71 // send the output for one sector for one TF
72 sendOutput(pc.outputs(), sector);
73 }
74 }
75
76 void endOfStream(o2::framework::EndOfStreamContext& ec) final { ec.services().get<ControlService>().readyToQuit(QuitRequest::Me); }
77
80 static constexpr header::DataDescription getDataDescription(const IDCFormat idcFormat) { return (idcFormat == IDCFormat::Sim) ? header::DataDescription{"IDCVECTOR"} : header::DataDescription{"IDC"}; }
81
82 private:
83 const std::vector<unsigned int> mSectors{};
84 const IDCFormat mIDCFormat{IDCFormat::Sim};
85 const bool mDebug{false};
86 std::unordered_map<unsigned int, IDCSim> mIDCs{};
87
88 // send output for one sector
89 void sendOutput(DataAllocator& output, const int sector)
90 {
92 for (const auto& idcs : mIDCs[sector].get()) {
93 const header::DataHeader::SubSpecificationType subSpec{cru << 7};
94 if (mIDCFormat == IDCFormat::Sim) {
95 output.snapshot(Output{gDataOriginTPC, getDataDescription(mIDCFormat), subSpec}, idcs);
96 } else {
97 // TODO
98 // convert to format from thorsten here
99 // send.......
100 // DUMMY FOR NOW
101 // const TPCCRUHeader cruheader{cru, mIntegrationIntervalsPerTF};
102 output.snapshot(Output{gDataOriginTPC, getDataDescription(mIDCFormat), subSpec}, idcs);
103 }
104 ++cru;
105 }
106 }
107};
108
109DataProcessorSpec getTPCIntegrateIDCSpec(const int ilane, const std::vector<unsigned int>& sectors, const int nOrbits = 12, const TPCIntegrateIDCDevice::IDCFormat outputFormat = TPCIntegrateIDCDevice::IDCFormat::Sim, const bool debug = false)
110{
111 std::vector<InputSpec> inputSpecs;
112 inputSpecs.reserve(sectors.size());
113
114 std::vector<OutputSpec> outputSpecs;
115 outputSpecs.reserve(sectors.size() * Mapper::NREGIONS);
116
117 // define input and output specs
118 for (const auto& sector : sectors) {
119 inputSpecs.emplace_back(InputSpec{"digits", gDataOriginTPC, "DIGITS", sector, Lifetime::Timeframe});
120
121 // output spec
122 unsigned int cru = sector * Mapper::NREGIONS;
123 for (int iRegion = 0; iRegion < Mapper::NREGIONS; ++iRegion) {
124 const header::DataHeader::SubSpecificationType subSpec{cru << 7};
125 outputSpecs.emplace_back(ConcreteDataMatcher{gDataOriginTPC, TPCIntegrateIDCDevice::getDataDescription(outputFormat), subSpec});
126 ++cru;
127 }
128 }
129
130 const auto id = fmt::format("tpc-integrate-idc-{:02}", ilane);
131 return DataProcessorSpec{
132 id.data(),
133 inputSpecs,
134 outputSpecs,
135 AlgorithmSpec{adaptFromTask<TPCIntegrateIDCDevice>(sectors, nOrbits, outputFormat, debug)}}; // end DataProcessorSpec
136}
137
138} // namespace o2::tpc
139
140#endif
Definition of the TPC Digit.
std::ostringstream debug
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate sectors
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
class for integration of IDCs
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
static constexpr unsigned int NREGIONS
total number of regions in one sector
Definition Mapper.h:527
void run(o2::framework::ProcessingContext &pc) final
TPCIntegrateIDCDevice(const std::vector< unsigned int > &sectors, const int nOrbitsPerIDCIntervall, const IDCFormat outputFormat, const bool debug)
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
static constexpr header::DataDescription getDataDescription(const IDCFormat idcFormat)
GLint ref
Definition glcorearb.h:291
constexpr o2::header::DataOrigin gDataOriginTPC
Definition DataHeader.h:579
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
auto get(const std::byte *buffer, size_t=0)
Definition DataHeader.h:457
Global TPC definitions and constants.
DataProcessorSpec getTPCIntegrateIDCSpec(const int ilane, const std::vector< unsigned int > &sectors, const int nOrbits=12, const TPCIntegrateIDCDevice::IDCFormat outputFormat=TPCIntegrateIDCDevice::IDCFormat::Sim, const bool debug=false)