Project
Loading...
Searching...
No Matches
DigitsPrinterSpec.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
12#include <iostream>
13#include <vector>
14#include <type_traits>
15#include <gsl/span>
16
17#include <fairlogger/Logger.h>
18
25
26using namespace o2::emcal::reco_workflow;
27
28template <class InputType>
32
33template <class InputType>
35{
36 // Get the EMCAL block header and check whether it contains digits
37 LOG(debug) << "[EMCALDigitsPrinter - process] called";
38 std::string objectbranch;
39 if constexpr (std::is_same<InputType, o2::emcal::Digit>::value) {
40 objectbranch = "digits";
41 } else if constexpr (std::is_same<InputType, o2::emcal::Cell>::value) {
42 objectbranch = "cells";
43 } else {
44 LOG(error) << "Unsupported input type ... ";
45 return;
46 }
47
48 auto objects = pc.inputs().get<gsl::span<InputType>>(objectbranch);
49 auto triggerrecords = pc.inputs().get<gsl::span<o2::emcal::TriggerRecord>>("triggerrecord");
50 std::cout << "[EMCALDigitsPrinter - process] receiveed " << objects.size() << " digits from " << triggerrecords.size() << " triggers ..." << std::endl;
51 if (triggerrecords.size()) {
52 for (const auto& trg : triggerrecords) {
53 if (!trg.getNumberOfObjects()) {
54 std::cout << "[EMCALDigitsPrinter - process] Trigger does not contain " << objectbranch << ", skipping ..." << std::endl;
55 continue;
56 }
57 std::cout << "[EMCALDigitsPrinter - process] Trigger has " << trg.getNumberOfObjects() << " " << objectbranch << " ..." << std::endl;
58 gsl::span<const InputType> objectsTrigger(objects.data() + trg.getFirstEntry(), trg.getNumberOfObjects());
59 for (const auto& d : objectsTrigger) {
60 std::cout << "[EMCALDigitsPrinter - process] Channel: " << d.getTower() << std::endl;
61 std::cout << "[EMCALDigitsPrinter - process] Energy: " << d.getEnergy() << std::endl;
62 //std::cout << d << std::endl;
63 }
64 }
65 }
66}
67
69{
70 if (inputtype == "digits") {
71 return o2::framework::DataProcessorSpec{"EMCALDigitsPrinter",
72 {{"digits", o2::header::gDataOriginEMC, "DIGITS", 0, o2::framework::Lifetime::Timeframe},
73 {"triggerrecord", o2::header::gDataOriginEMC, "DIGITSTRGR", 0, o2::framework::Lifetime::Timeframe}},
74 {},
75 o2::framework::adaptFromTask<o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Digit>>()};
76 } else if (inputtype == "cells") {
77 return o2::framework::DataProcessorSpec{"EMCALDigitsPrinter",
78 {{"cells", o2::header::gDataOriginEMC, "CELLS", 0, o2::framework::Lifetime::Timeframe},
79 {"triggerrecord", o2::header::gDataOriginEMC, "CELLSTRGR", 0, o2::framework::Lifetime::Timeframe}},
80 {},
81 o2::framework::adaptFromTask<o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Cell>>()};
82 }
83 throw std::runtime_error("Input type not supported");
84}
85
86//template class o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Digit>;
87//template class o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Cell>;
std::vector< std::string > objects
std::ostringstream debug
void run(framework::ProcessingContext &ctx) final
Printing digit-related information.
void init(framework::InitContext &ctx) final
Initializing the digits printer task.
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
o2::framework::DataProcessorSpec getEmcalDigitsPrinterSpec(std::string inputtype)
Creating digits printer spec.
constexpr o2::header::DataOrigin gDataOriginEMC
Definition DataHeader.h:565
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"