forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCTPDigitizerSpec.cxx
More file actions
145 lines (135 loc) · 6.09 KB
/
CTPDigitizerSpec.cxx
File metadata and controls
145 lines (135 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "CTPDigitizerSpec.h"
#include "Framework/CCDBParamSpec.h"
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework//Task.h"
#include "DetectorsBase/BaseDPLDigitizer.h"
#include "DataFormatsCTP/Digits.h"
#include "DataFormatsCTP/LumiInfo.h"
#include "Steer/HitProcessingManager.h" // for DigitizationContext
#include "DetectorsCommonDataFormats/DetID.h"
#include "CTPSimulation/Digitizer.h"
#include "DataFormatsCTP/Configuration.h"
#include "DataFormatsFT0/Digit.h"
#include "DataFormatsFV0/Digit.h"
#include "CommonConstants/LHCConstants.h"
#include <TStopwatch.h>
#include <gsl/span>
using namespace o2::framework;
namespace o2
{
namespace ctp
{
class CTPDPLDigitizerTask : public o2::base::BaseDPLDigitizer
{
using GRP = o2::parameters::GRPObject;
public:
CTPDPLDigitizerTask(const std::vector<o2::detectors::DetID>& detList, float ctpLumiScaler) : o2::base::BaseDPLDigitizer(), mDigitizer(), mDetList(detList), mLumiScaler(ctpLumiScaler) {}
~CTPDPLDigitizerTask() override = default;
void initDigitizerTask(framework::InitContext& ic) override
{
mDigitizer.init();
}
void run(framework::ProcessingContext& pc)
{
// read collision context from input
// auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
// const bool withQED = context->isQEDProvided();
// auto& timesview = context->getEventRecords(withQED);
// read ctp inputs from input
std::vector<o2::ctp::CTPInputDigit> finputs;
TStopwatch timer;
timer.Start();
pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
LOG(info) << "CALLING CTP DIGITIZATION";
// Input order: T0, V0, ... but O need also position of inputs DETInputs
// fv0
if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::FT0) != mDetList.end()) {
auto ft0inputs = pc.inputs().get<gsl::span<o2::ft0::DetTrigInput>>("ft0");
for (const auto& inp : ft0inputs) {
finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FT0});
}
}
// fv0
if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::FV0) != mDetList.end()) {
auto fv0inputs = pc.inputs().get<gsl::span<o2::fv0::DetTrigInput>>("fv0");
for (const auto& inp : fv0inputs) {
finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FV0});
}
}
// emc
if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::EMC) != mDetList.end()) {
auto emcinputs = pc.inputs().get<gsl::span<o2::ctp::CTPInputDigit>>("emc");
for (const auto& inp : emcinputs) {
finputs.emplace_back(inp);
}
}
gsl::span<CTPInputDigit> ginputs(finputs);
auto digits = mDigitizer.process(ginputs);
// send out to next stage
LOG(info) << "CTP DIGITS being sent.";
pc.outputs().snapshot(Output{"CTP", "DIGITS", 0}, digits);
LOG(info) << "CTP PRESENT being sent.";
pc.outputs().snapshot(Output{"CTP", "ROMode", 0}, mROMode);
if (mLumiScaler >= 0.) {
uint32_t nhbf = mLumiScaler > 0.f ? uint32_t(int(mLumiScaler) / mLumiScaler * o2::constants::lhc::LHCRevFreq) : 0;
o2::ctp::LumiInfo lminfo{pc.services().get<o2::framework::TimingInfo>().firstTForbit, nhbf, 0, uint64_t(mLumiScaler), 0};
LOG(info) << "CTP Lumi scaler " << lminfo.counts << " for integration time of " << lminfo.nHBFCounted << " being sent";
pc.outputs().snapshot(Output{"CTP", "LUMI", 0}, lminfo);
}
timer.Stop();
LOG(info) << "CTP Digitization took " << timer.CpuTime() << "s";
}
void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj)
{
if (matcher == o2::framework::ConcreteDataMatcher("CTP", "CTPCONFIG", 0)) {
LOG(info) << "Loading CTP configuration" << std::endl;
mDigitizer.setCTPConfiguration(reinterpret_cast<o2::ctp::CTPConfiguration*>(obj));
}
}
protected:
o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::PRESENT;
o2::ctp::Digitizer mDigitizer; ///< Digitizer
std::vector<o2::detectors::DetID> mDetList;
float mLumiScaler = -1.;
};
o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector<o2::detectors::DetID>& detList, float ctpLumiScaler, bool mctruth)
{
std::vector<InputSpec> inputs;
std::vector<OutputSpec> output;
if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FT0) != detList.end()) {
inputs.emplace_back("ft0", "FT0", "TRIGGERINPUT", 0, Lifetime::Timeframe);
}
if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FV0) != detList.end()) {
inputs.emplace_back("fv0", "FV0", "TRIGGERINPUT", 0, Lifetime::Timeframe);
}
if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::EMC) != detList.end()) {
inputs.emplace_back("emc", "EMC", "TRIGGERINPUT", 0, Lifetime::Timeframe);
}
inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", true));
output.emplace_back("CTP", "DIGITS", 0, Lifetime::Timeframe);
if (ctpLumiScaler >= 0.f) {
output.emplace_back("CTP", "LUMI", 0, Lifetime::Timeframe);
}
output.emplace_back("CTP", "ROMode", 0, Lifetime::Timeframe);
return DataProcessorSpec{
"CTPDigitizer",
inputs,
output,
AlgorithmSpec{adaptFromTask<CTPDPLDigitizerTask>(detList, ctpLumiScaler)},
Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}},
{"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}}};
}
} // namespace ctp
} // namespace o2