Project
Loading...
Searching...
No Matches
FITIntegrateClusterSpec.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
12#ifndef O2_FITINTEGRATECLUSTERSPEC_SPEC
13#define O2_FITINTEGRATECLUSTERSPEC_SPEC
14
15#include "Framework/Task.h"
22
23using namespace o2::framework;
24
25namespace o2
26{
27
28namespace fv0
29{
30class RecPoints;
31}
32
33namespace ft0
34{
35class RecPoints;
36}
37
38namespace fdd
39{
40class RecPoint;
41}
42
43namespace fit
44{
45
46template <typename DataT>
48
49template <>
52 std::string static getName() { return "fv0"; }
53 std::string static getCCDBPath() { return "FV0/Calib/IFV0C"; }
58};
59
60template <>
63 std::string static getName() { return "ft0"; }
64 std::string static getCCDBPath() { return "FT0/Calib/IFT0C"; }
69};
70
71template <>
74 std::string static getName() { return "fdd"; }
75 std::string static getCCDBPath() { return "FDD/Calib/IFDDC"; }
80};
81
82template <typename DataT>
84{
85 public:
87 FITIntegrateClusters(std::shared_ptr<o2::base::GRPGeomRequest> req, const bool disableWriter, const int minNChan, const int minAmpl) : mCCDBRequest(req), mDisableWriter(disableWriter), mMinNChan(minNChan), mMinAmpl(minAmpl){};
88
90 {
92 mNSlicesTF = ic.options().get<int>("nSlicesTF");
93 mBufferCurrents.resize(mNSlicesTF);
94 }
95
96 void run(ProcessingContext& pc) final
97 {
99 const int nHBFPerTF = o2::base::GRPGeomHelper::instance().getNHBFPerTF();
100 const int nBunchesPerTF = nHBFPerTF * o2::constants::lhc::LHCMaxBunches;
101 const uint32_t firstTFOrbit = pc.services().get<o2::framework::TimingInfo>().firstTForbit;
102 const float bunchesPerSlice = nBunchesPerTF / float(mNSlicesTF);
103 const float bunchesPerSliceInv = 1.f / bunchesPerSlice;
104
105 // reset buffered currents
106 mBufferCurrents.reset();
107
108 // looping over cluster and integrating the currents
109 const auto clusters = pc.inputs().get<gsl::span<DataT>>("recpoints");
110 for (const auto& cluster : clusters) {
111 const unsigned int orbit = cluster.getInteractionRecord().orbit;
112 const uint32_t relOrbit = orbit - firstTFOrbit; // from 0->128
113 const unsigned int bunchInSlice = relOrbit * o2::constants::lhc::LHCMaxBunches + cluster.getInteractionRecord().bc;
114 const unsigned int sliceInTF = bunchInSlice / bunchesPerSlice;
115 if (sliceInTF < mNSlicesTF) {
116 const float nChanA = static_cast<float>(cluster.getTrigger().getNChanA());
117 const float amplA = static_cast<float>(cluster.getTrigger().getAmplA());
118
119 if ((nChanA > mMinNChan) && (amplA > mMinAmpl)) {
120 mBufferCurrents.mINChanA[sliceInTF] += nChanA;
121 mBufferCurrents.mIAmplA[sliceInTF] += amplA;
122 }
123
124 if constexpr (std::is_same_v<DataT, o2::ft0::RecPoints> || std::is_same_v<DataT, o2::fdd::RecPoint>) {
125 const float nChanC = static_cast<float>(cluster.getTrigger().getNChanC());
126 const float amplC = static_cast<float>(cluster.getTrigger().getAmplC());
127 if ((nChanC > mMinNChan) && (amplC > mMinAmpl)) {
128 mBufferCurrents.mINChanC[sliceInTF] += nChanC;
129 mBufferCurrents.mIAmplC[sliceInTF] += amplC;
130 }
131 }
132 } else {
133 LOGP(info, "slice in TF {} is larger than max expected slice {} with relOrbit {} and {} orbits per slice", sliceInTF, mNSlicesTF, relOrbit, bunchesPerSlice);
134 }
135 }
136
137 // normalize currents to integration time
138 mBufferCurrents.normalize(bunchesPerSliceInv);
139 sendOutput(pc);
140 }
141
142 void endOfStream(EndOfStreamContext& eos) final { eos.services().get<ControlService>().readyToQuit(QuitRequest::Me); }
143
145
146 private:
147 int mNSlicesTF = 11;
148 const int mMinNChan = 2;
149 const int mMinAmpl = 2;
150 const bool mDisableWriter{false};
151 typename DataDescriptionFITCurrents<DataT>::DataTStruct mBufferCurrents;
152 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
153
154 void sendOutput(ProcessingContext& pc)
155 {
156 using FitType = DataDescriptionFITCurrents<DataT>;
157 pc.outputs().snapshot(Output{FitType::getDataOrigin(), FitType::getDataDescriptionFITC()}, mBufferCurrents);
158 // in case of ROOT output also store the TFinfo in the TTree
159 if (!mDisableWriter) {
162 pc.outputs().snapshot(Output{FitType::getDataOrigin(), FitType::getDataDescriptionFITTFId()}, tfinfo);
163 }
164 }
165};
166
167template <typename DataT>
168o2::framework::DataProcessorSpec getFITIntegrateClusterSpec(const bool disableWriter, const int minNChan, const int minAmpl)
169{
170 using FitType = DataDescriptionFITCurrents<DataT>;
171
172 std::vector<InputSpec> inputs;
173 inputs.emplace_back("recpoints", FitType::getDataOrigin(), "RECPOINTS", 0, Lifetime::Timeframe);
174 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
175 true, // GRPECS=true for nHBF per TF
176 false, // GRPLHCIF
177 false, // GRPMagField
178 false, // askMatLUT
180 inputs);
181
182 std::vector<OutputSpec> outputs;
183 outputs.emplace_back(FitType::getDataOrigin(), FitType::getDataDescriptionFITC(), 0, Lifetime::Timeframe);
184 if (!disableWriter) {
185 outputs.emplace_back(FitType::getDataOrigin(), FitType::getDataDescriptionFITTFId(), 0, Lifetime::Timeframe);
186 }
187
188 return DataProcessorSpec{
189 fmt::format("{}-integrate-clusters", FitType::getName()),
190 inputs,
191 outputs,
192 AlgorithmSpec{adaptFromTask<FITIntegrateClusters<DataT>>(ccdbRequest, disableWriter, minNChan, minAmpl)},
193 Options{
194 {"nSlicesTF", VariantType::Int, 11, {"number of slices into which a TF is divided"}}}};
195}
196
197} // namespace fit
198} // end namespace o2
199
200#endif
uint64_t nChanC
uint64_t nChanA
int64_t amplA
uint64_t orbit
Definition RawEventData.h:6
int64_t amplC
Helper for geometry and GRP related CCDB requests.
calibrator class for accumulating integrated clusters
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void endOfStream(EndOfStreamContext &eos) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void init(framework::InitContext &ic) final
FITIntegrateClusters(std::shared_ptr< o2::base::GRPGeomRequest > req, const bool disableWriter, const int minNChan, const int minAmpl)
\constructor
void run(ProcessingContext &pc) final
void snapshot(const Output &spec, T const &object)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
constexpr o2::header::DataOrigin gDataOriginFDD
Definition DataHeader.h:568
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:566
constexpr o2::header::DataOrigin gDataOriginFV0
Definition DataHeader.h:567
constexpr int LHCMaxBunches
o2::framework::DataProcessorSpec getFITIntegrateClusterSpec(const bool disableWriter, const int minNChan, const int minAmpl)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
TFitResultPtr fit(const size_t nBins, const T *arr, const T xMin, const T xMax, TF1 &func, std::string_view option="")
Definition fit.h:59
struct o2::upgrades_utils::@459 fdd
Collision labels.
struct o2::upgrades_utils::@462 ft0
structure to keep V0C information
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr header::DataDescription getDataDescriptionFITTFId()
static constexpr header::DataDescription getDataDescriptionFITC()
static constexpr header::DataDescription getDataDescriptionCCDB()
static constexpr header::DataDescription getDataDescriptionCCDB()
static constexpr header::DataDescription getDataDescriptionFITC()
static constexpr header::DataDescription getDataDescriptionFITTFId()
static constexpr header::DataDescription getDataDescriptionCCDB()
static constexpr header::DataDescription getDataDescriptionFITTFId()
static constexpr header::DataDescription getDataDescriptionFITC()
struct containing the integrated FDD currents
struct containing the integrated FT0 currents
struct containing the integrated FV0 currents
std::vector< Cluster > clusters