Project
Loading...
Searching...
No Matches
DumpDigitsSpec.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
19#include <random>
20#include <iostream>
21#include <fstream>
22#include <stdexcept>
23#include <array>
24#include <functional>
25#include <vector>
26
31#include "Framework/Lifetime.h"
32#include "Framework/Output.h"
33#include "Framework/Task.h"
35#include "Framework/Logger.h"
38
42
45#include "HMPIDBase/Geo.h"
47
48namespace o2
49{
50namespace hmpid
51{
52
53using namespace o2;
54using namespace o2::header;
55using namespace o2::framework;
57
58//=======================
59// Data decoder
61{
62 LOG(info) << "[HMPID Dump Digits - init() ] ";
63 mPrintDigits = ic.options().get<bool>("print");
64
65 mIsOutputOnFile = false;
66 mOutputFileName = ic.options().get<std::string>("out-file");
67 if (mOutputFileName != "") {
68 mOsFile.open(mOutputFileName, std::ios::out);
69 if (mOsFile.is_open()) {
70 mIsOutputOnFile = true;
71 }
72 }
73 if (mPrintDigits) {
74 std::cout << "--- HMP Digits : [Chamb,PhoCat,x,y]=Charge ---" << std::endl;
75 }
76 if (mIsOutputOnFile) {
77 mOsFile << "--- HMP Digits : [Chamb,PhoCat,x,y]=Charge ---" << std::endl;
78 }
79 mOrbit = -1;
80 mBc = -1;
81 mDigitsReceived = 0;
82
83 mExTimer.start();
84 return;
85}
86
88{
89 LOG(info) << "[HMPID Dump Digits - run() ] Enter Dump ...";
90 std::vector<o2::hmpid::Trigger> triggers;
91 std::vector<o2::hmpid::Digit> digits;
92
93 for (auto const& ref : InputRecordWalker(pc.inputs())) {
94 if (DataRefUtils::match(ref, {"check", ConcreteDataTypeMatcher{gDataOriginHMP, "INTRECORDS"}})) {
95 triggers = pc.inputs().get<std::vector<o2::hmpid::Trigger>>(ref);
96 LOG(info) << "We receive triggers =" << triggers.size();
97 }
99 digits = pc.inputs().get<std::vector<o2::hmpid::Digit>>(ref);
100 LOG(info) << "The size of the vector =" << digits.size();
101 mDigitsReceived += digits.size();
102 }
103 for (int i = 0; i < triggers.size(); i++) {
104 if (mPrintDigits) {
105 std::cout << "Trigger Event Orbit = " << triggers[i].getOrbit() << " BC = " << triggers[i].getBc() << std::endl;
106 for (int j = triggers[i].getFirstEntry(); j <= triggers[i].getLastEntry(); j++) {
107 std::cout << digits[j] << std::endl;
108 }
109 }
110 if (mIsOutputOnFile) {
111 mOsFile << "Trigger Event Orbit = " << triggers[i].getOrbit() << " BC = " << triggers[i].getBc() << std::endl;
112 for (int j = triggers[i].getFirstEntry(); j <= triggers[i].getLastEntry(); j++) {
113 mOsFile << digits[j] << std::endl;
114 }
115 }
116 }
117 }
118 std::cout << ">>----->>>" << triggers.size() << " " << digits.size() << std::endl;
119 mExTimer.elapseMes("Dumping Digits received = " + std::to_string(mDigitsReceived));
120 return;
121}
122
124{
125 mOsFile.close();
126
127 mExTimer.stop();
128 mExTimer.logMes("End Digits Dump ! Dumped digits = " + std::to_string(mDigitsReceived));
129 return;
130}
131
132//_________________________________________________________________________________________________
134{
135 std::vector<o2::framework::InputSpec> inputs;
136 inputs.emplace_back("digits", o2::header::gDataOriginHMP, "DIGITS", 0, Lifetime::Timeframe);
137 inputs.emplace_back("intrecord", o2::header::gDataOriginHMP, "INTRECORDS", 0, Lifetime::Timeframe);
138
139 std::vector<o2::framework::OutputSpec> outputs;
140
141 return DataProcessorSpec{
142 "HMP-DigitsDump",
143 inputs,
144 outputs,
145 AlgorithmSpec{adaptFromTask<DumpDigitsTask>()},
146 Options{{"out-file", VariantType::String, "", {"name of the output file"}},
147 {"print", VariantType::Bool, false, {"print digits (default false )"}}}};
148}
149
150} // namespace hmpid
151} // end namespace o2
A raw page parser for DPL input.
int32_t i
A helper class to iteratate over all parts of all input routes.
Definition of the RAW Data Header.
uint32_t j
Definition RawData.h:0
ConfigParamRegistry const & options()
Definition InitContext.h:33
A helper class to iteratate over all parts of all input routes.
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
void init(framework::InitContext &ic) final
void run(framework::ProcessingContext &pc) final
void endOfStream(framework::EndOfStreamContext &ec) override
This is invoked whenever we have an EndOfStream event.
void stop()
stop : stops the timer
Definition Common.h:73
void elapseMes(std::string const message)
Definition Common.h:91
void start()
start : starts the timer
Definition Common.h:64
void logMes(std::string const message)
Definition Common.h:81
GLint ref
Definition glcorearb.h:291
constexpr o2::header::DataOrigin gDataOriginHMP
Definition DataHeader.h:569
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
O2 data header classes and API, v0.1.
Definition DetID.h:49
o2::framework::DataProcessorSpec getDumpDigitsSpec(std::string inputSpec="HMP/DIGITS")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static bool match(DataRef const &ref, const char *binding)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits