39 TOFIntegrateClusters(std::shared_ptr<o2::base::GRPGeomRequest> req,
const bool disableWriter) : mCCDBRequest(req), mDisableWriter(disableWriter){};
44 mNSlicesTF = ic.options().get<
int>(
"nSlicesTF");
45 mTimeCutNoisePS = ic.options().get<
int>(
"time-cut-noise-PS");
46 mMinClustersNeighbours = ic.options().get<
int>(
"min-clusters-neighbours");
47 mTagNoise = !(ic.options().get<
bool>(
"do-not-tag-noise"));
55 const double maxTimeTF = orbitLength * nHBFPerTF;
56 const double sliceWidthPS = maxTimeTF / mNSlicesTF;
57 const double sliceWidthMS = sliceWidthPS * 1.E-9;
58 const int nSlices = maxTimeTF / sliceWidthPS;
59 const double sliceWidthPSinv = 1. / sliceWidthPS;
60 const float sliceWidthMSinv = 1. / float(sliceWidthMS);
66 const auto clusters = pc.inputs().get<gsl::span<o2::tof::Cluster>>(
"tofcluster");
71 for (
size_t iCl = 0; iCl <
clusters.size(); ++iCl) {
72 if (mTagNoise && (mCounterNeighbours[iCl] < mMinClustersNeighbours)) {
76 const double timePS =
clusters[iCl].getTime();
77 const unsigned int sliceInTF = timePS * sliceWidthPSinv;
78 if (sliceInTF < mNSlicesTF) {
79 ++iTOFCNCl[sliceInTF];
80 iTOFCqTot[sliceInTF] +=
clusters[iCl].getTot();
82 LOGP(info,
"slice in TF of ICC {} is larger than max slice {} with nTSPerSlice {}", sliceInTF, mNSlicesTF, nSlices);
87 std::transform(iTOFCNCl.begin(), iTOFCNCl.end(), iTOFCNCl.begin(), [sliceWidthMSinv](
float&
val) { return val * sliceWidthMSinv; });
88 std::transform(iTOFCqTot.begin(), iTOFCqTot.end(), iTOFCqTot.begin(), [sliceWidthMSinv](
float&
val) { return val * sliceWidthMSinv; });
90 sendOutput(pc, std::move(iTOFCNCl), std::move(iTOFCqTot));
95 LOGP(info,
"Finalizing calibration");
102 const bool mDisableWriter{
false};
103 int mTimeCutNoisePS = 4000;
104 int mMinClustersNeighbours = 2;
105 bool mTagNoise{
true};
106 std::vector<int> mCounterNeighbours;
107 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
114 if (!mDisableWriter) {
126 void tagNoiseCluster(
const gsl::span<const o2::tof::Cluster>& tofArray)
128 const size_t nCl = tofArray.size();
130 std::fill(mCounterNeighbours.begin(), mCounterNeighbours.end(), 0);
131 mCounterNeighbours.resize(nCl);
133 std::vector<size_t> tofTimeIndex(nCl);
134 std::iota(tofTimeIndex.begin(), tofTimeIndex.end(), 0);
137 std::stable_sort(tofTimeIndex.begin(), tofTimeIndex.end(), [&tofArray](
size_t i1,
size_t i2) { return tofArray[i1].getTime() < tofArray[i2].getTime(); });
141 for (
int i0 = 0; i0 < nCl; i0++) {
142 const double t0 = tofArray[tofTimeIndex[i0]].getTime();
144 for (
int idP = i0 + 1; idP < nCl; ++idP) {
145 if (std::abs(
t0 - tofArray[tofTimeIndex[idP]].getTime()) > mTimeCutNoisePS) {
149 ++mCounterNeighbours[tofTimeIndex[i0]];
152 for (
int idM = i0 - 1; idM >= 0; --idM) {
153 if (std::abs(
t0 - tofArray[tofTimeIndex[idM]].getTime()) > mTimeCutNoisePS) {
157 ++mCounterNeighbours[tofTimeIndex[i0]];
165 std::vector<InputSpec> inputs;
168 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
176 std::vector<OutputSpec> outputs;
179 if (!disableWriter) {
184 "TOFIntegrateClusters",
187 AlgorithmSpec{adaptFromTask<TOFIntegrateClusters>(ccdbRequest, disableWriter)},
188 Options{{
"nSlicesTF", VariantType::Int, 11, {
"number of slices into which a TF is divided"}},
189 {
"time-cut-noise-PS", VariantType::Int, 4000, {
"time in ps for which neighbouring clusters are checked during the noise filtering"}},
190 {
"min-clusters-neighbours", VariantType::Int, 2, {
"minimum neighbouring clusters for the noise filtering"}},
191 {
"do-not-tag-noise", VariantType::Bool,
false, {
"Do not reject noise"}}}};
Helper for geometry and GRP related CCDB requests.
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static int getNHBFPerTF()
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void snapshot(const Output &spec, T const &object)
CacheId adoptContainer(const Output &, ContainerT &, CacheStrategy, o2::header::SerializationMethod)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
static constexpr Double_t BC_TIME_INPS
void endOfStream(EndOfStreamContext &eos) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
TOFIntegrateClusters(std::shared_ptr< o2::base::GRPGeomRequest > req, const bool disableWriter)
\constructor
void init(framework::InitContext &ic) final
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
constexpr o2::header::DataOrigin gDataOriginTOF
constexpr int LHCMaxBunches
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< T, o2::pmr::polymorphic_allocator< T > > vector
o2::framework::DataProcessorSpec getTOFIntegrateClusterSpec(const bool disableWriter)
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)
std::vector< Cluster > clusters