Project
Loading...
Searching...
No Matches
CTPDigitizerSpec.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 "CTPDigitizerSpec.h"
17#include "Framework//Task.h"
21#include "Steer/HitProcessingManager.h" // for DigitizationContext
28
29#include <TStopwatch.h>
30#include <gsl/span>
31
32using namespace o2::framework;
33namespace o2
34{
35namespace ctp
36{
38{
40
41 public:
42 CTPDPLDigitizerTask(const std::vector<o2::detectors::DetID>& detList, float ctpLumiScaler) : o2::base::BaseDPLDigitizer(), mDigitizer(), mDetList(detList), mLumiScaler(ctpLumiScaler) {}
43 ~CTPDPLDigitizerTask() override = default;
45 {
47 }
49 {
50 // read collision context from input
51 // auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
52 // const bool withQED = context->isQEDProvided();
53 // auto& timesview = context->getEventRecords(withQED);
54 // read ctp inputs from input
55
56 std::vector<o2::ctp::CTPInputDigit> finputs;
57 TStopwatch timer;
58 timer.Start();
59 pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
60 LOG(info) << "CALLING CTP DIGITIZATION";
61 // Input order: T0, V0, ... but O need also position of inputs DETInputs
62 // fv0
63 if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::FT0) != mDetList.end()) {
64 auto ft0inputs = pc.inputs().get<gsl::span<o2::ft0::DetTrigInput>>("ft0");
65 for (const auto& inp : ft0inputs) {
66 finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FT0});
67 }
68 }
69 // fv0
70 if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::FV0) != mDetList.end()) {
71 auto fv0inputs = pc.inputs().get<gsl::span<o2::fv0::DetTrigInput>>("fv0");
72 for (const auto& inp : fv0inputs) {
73 finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FV0});
74 }
75 }
76 // emc
77 if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::EMC) != mDetList.end()) {
78 auto emcinputs = pc.inputs().get<gsl::span<o2::ctp::CTPInputDigit>>("emc");
79 for (const auto& inp : emcinputs) {
80 finputs.emplace_back(inp);
81 }
82 }
83 gsl::span<CTPInputDigit> ginputs(finputs);
84 auto digits = mDigitizer.process(ginputs);
85 // send out to next stage
86 LOG(info) << "CTP DIGITS being sent.";
87 pc.outputs().snapshot(Output{"CTP", "DIGITS", 0}, digits);
88 LOG(info) << "CTP PRESENT being sent.";
89 pc.outputs().snapshot(Output{"CTP", "ROMode", 0}, mROMode);
90 if (mLumiScaler >= 0.) {
91 uint32_t nhbf = mLumiScaler > 0.f ? uint32_t(int(mLumiScaler) / mLumiScaler * o2::constants::lhc::LHCRevFreq) : 0;
92 o2::ctp::LumiInfo lminfo{pc.services().get<o2::framework::TimingInfo>().firstTForbit, nhbf, 0, uint64_t(mLumiScaler), 0};
93 LOG(info) << "CTP Lumi scaler " << lminfo.counts << " for integration time of " << lminfo.nHBFCounted << " being sent";
94 pc.outputs().snapshot(Output{"CTP", "LUMI", 0}, lminfo);
95 }
96 timer.Stop();
97 LOG(info) << "CTP Digitization took " << timer.CpuTime() << "s";
98 }
99
101 {
102
103 if (matcher == o2::framework::ConcreteDataMatcher("CTP", "CTPCONFIG", 0)) {
104 LOG(info) << "Loading CTP configuration" << std::endl;
106 }
107 }
108
109 protected:
112 std::vector<o2::detectors::DetID> mDetList;
113 float mLumiScaler = -1.;
114};
115
116o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector<o2::detectors::DetID>& detList, float ctpLumiScaler, bool mctruth)
117{
118 std::vector<InputSpec> inputs;
119 std::vector<OutputSpec> output;
120
121 if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FT0) != detList.end()) {
122 inputs.emplace_back("ft0", "FT0", "TRIGGERINPUT", 0, Lifetime::Timeframe);
123 }
124 if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FV0) != detList.end()) {
125 inputs.emplace_back("fv0", "FV0", "TRIGGERINPUT", 0, Lifetime::Timeframe);
126 }
127 if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::EMC) != detList.end()) {
128 inputs.emplace_back("emc", "EMC", "TRIGGERINPUT", 0, Lifetime::Timeframe);
129 }
130 inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", true));
131 output.emplace_back("CTP", "DIGITS", 0, Lifetime::Timeframe);
132 if (ctpLumiScaler >= 0.f) {
133 output.emplace_back("CTP", "LUMI", 0, Lifetime::Timeframe);
134 }
135 output.emplace_back("CTP", "ROMode", 0, Lifetime::Timeframe);
136 return DataProcessorSpec{
137 "CTPDigitizer",
138 inputs,
139 output,
140 AlgorithmSpec{adaptFromTask<CTPDPLDigitizerTask>(detList, ctpLumiScaler)},
141 Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}},
142 {"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}}};
143}
144} // namespace ctp
145} // namespace o2
Definition of the base digitizer task class.
definition of CTPConfiguration and related CTP structures
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
definition of CTPDigit, CTPInputDigit
Header to collect LHC related constants.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
std::vector< o2::detectors::DetID > mDetList
CTPDPLDigitizerTask(const std::vector< o2::detectors::DetID > &detList, float ctpLumiScaler)
void run(framework::ProcessingContext &pc)
void initDigitizerTask(framework::InitContext &ic) override
~CTPDPLDigitizerTask() override=default
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
o2::parameters::GRPObject::ROMode mROMode
o2::ctp::Digitizer mDigitizer
Digitizer.
std::vector< CTPDigit > process(const gsl::span< o2::ctp::CTPInputDigit > detinputs)
Definition Digitizer.cxx:27
void setCTPConfiguration(o2::ctp::CTPConfiguration *config)
static constexpr ID FV0
Definition DetID.h:76
static constexpr ID FT0
Definition DetID.h:75
static constexpr ID EMC
Definition DetID.h:69
void snapshot(const Output &spec, T const &object)
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.
constexpr double LHCRevFreq
o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector< o2::detectors::DetID > &detList, float ctpLumiScaler, bool mctruth)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
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< Digit > digits