Project
Loading...
Searching...
No Matches
FT0TimeSpectraProcessor-Workflow.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
17#include "Framework/Task.h"
18#include "FT0Base/Geometry.h"
23
24using namespace o2::framework;
25
26namespace o2::ft0
27{
28
30{
31
32 public:
33 static constexpr int sNCHANNELS = Geometry::Nchannels;
34 static constexpr int sNCHANNELS_A = 4 * Geometry::NCellsA;
35
36 int mNbinsY{400};
37 float mMinY{-200.};
38 float mMaxY{200.};
40 int mTimeWindow{153};
42 uint8_t mPMbitsGood{0b01001000};
46 {
47 mNbinsY = ic.options().get<int>("number-bins");
48 mMinY = ic.options().get<float>("low-edge");
49 mMaxY = ic.options().get<float>("upper-edge");
50 LOG(info) << "Histogram parameters: " << mNbinsY << " " << mMinY << " " << mMaxY;
52 param.printKeyValues();
53 mAmpThreshold = param.mAmpThreshold;
54 mTimeWindow = param.mTimeWindow;
55 mPMbitsGood = param.mPMbitsGood;
56 mPMbitsToCheck = param.mPMbitsToCheck;
57 mTrgBitsGood = param.mTrgBitsGood;
58 mTrgBitsToCheck = param.mTrgBitsToCheck;
59 }
61 {
62 enum { kTimeA = sNCHANNELS,
63 kTimeC = sNCHANNELS + 1,
64 kSumTimeAC = sNCHANNELS + 2,
65 kDiffTimeCA = sNCHANNELS + 3
66 };
67 const int nExtraSpectraSlots = 4; // For timeA/C sum and diff
68 auto digits = pc.inputs().get<gsl::span<o2::ft0::Digit>>("digits");
69 auto channels = pc.inputs().get<gsl::span<o2::ft0::ChannelData>>("channels");
70 o2::dataformats::FlatHisto2D<float> timeSpectraInfoObject(sNCHANNELS + nExtraSpectraSlots, 0, sNCHANNELS + nExtraSpectraSlots, mNbinsY, mMinY, mMaxY);
71 for (const auto& digit : digits) {
72 const uint64_t trgWordExt = digit.mTriggers.getExtendedTrgWordFT0();
73 if ((trgWordExt & mTrgBitsToCheck) != mTrgBitsGood) {
74 continue;
75 }
76 const auto& chan = digit.getBunchChannelData(channels);
77 float timeA{0}, timeC{0};
78 int NchanA{0}, NchanC{0};
79 for (const auto& channel : chan) {
80 if (channel.QTCAmpl > mAmpThreshold && std::abs(channel.CFDTime) < mTimeWindow && ((channel.ChainQTC & mPMbitsToCheck) == mPMbitsGood && channel.ChId < sNCHANNELS)) {
81 const auto result = timeSpectraInfoObject.fill(channel.ChId, channel.CFDTime);
82 if (channel.ChId < sNCHANNELS_A) {
83 NchanA++;
84 timeA += channel.CFDTime;
85 } else {
86 NchanC++;
87 timeC += channel.CFDTime;
88 }
89 }
90 }
91 if (NchanA > 0) {
92 timeA = timeA / NchanA;
93 const auto result = timeSpectraInfoObject.fill(kTimeA, timeA);
94 }
95 if (NchanC > 0) {
96 timeC = timeC / NchanC;
97 const auto result = timeSpectraInfoObject.fill(kTimeC, timeC);
98 if (NchanA > 0) {
99 const auto resultSum = timeSpectraInfoObject.fill(kSumTimeAC, (timeA + timeC) / 2);
100 const auto resultDiff = timeSpectraInfoObject.fill(kDiffTimeCA, (timeC - timeA) / 2.);
101 }
102 }
103 }
104
105 pc.outputs().snapshot(o2::framework::Output{o2::header::gDataOriginFT0, "TIME_SPECTRA", 0}, timeSpectraInfoObject.getBase());
106 }
107};
108
109} // namespace o2::ft0
110
111void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
112{
113 std::vector<ConfigParamSpec> options;
114 options.push_back(ConfigParamSpec{"dispatcher-mode", VariantType::Bool, false, {"Dispatcher mode (FT0/SUB_DIGITSCH and FT0/SUB_DIGITSBC DPL channels should be applied as dispatcher output)."}});
115 options.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}});
116 std::swap(workflowOptions, options);
117}
118
120
122{
123 Inputs inputs{};
124 if (cfgc.options().get<bool>("dispatcher-mode")) {
125 inputs.push_back(InputSpec{{"channels"}, "FT0", "SUB_DIGITSCH"});
126 inputs.push_back(InputSpec{{"digits"}, "FT0", "SUB_DIGITSBC"});
127 } else {
128 inputs.push_back(InputSpec{{"channels"}, "FT0", "DIGITSCH"});
129 inputs.push_back(InputSpec{{"digits"}, "FT0", "DIGITSBC"});
130 }
131 o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
132 DataProcessorSpec dataProcessorSpec{
133 "FT0TimeSpectraProcessor",
134 inputs,
135 Outputs{
136 {{"timeSpectra"}, "FT0", "TIME_SPECTRA"}},
137 AlgorithmSpec{adaptFromTask<o2::ft0::FT0TimeSpectraProcessor>()},
138 Options{{"number-bins", VariantType::Int, 400, {"Number of bins along Y-axis"}},
139 {"low-edge", VariantType::Float, -200.0f, {"Lower edge of first bin along Y-axis"}},
140 {"upper-edge", VariantType::Float, 200.0f, {"Upper edge of last bin along Y-axis"}}}};
141
142 WorkflowSpec workflow;
143 workflow.emplace_back(dataProcessorSpec);
144
145 return workflow;
146}
Configurable digit filtering.
Class to describe fired and stored channels for the BC and to refer to channel data.
int64_t timeC
int64_t timeA
void customize(std::vector< o2::framework::ConfigParamSpec > &workflowOptions)
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
unsigned char uint8_t
2D messeageable histo class
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
static constexpr int NCellsA
Definition Geometry.h:52
static constexpr int Nchannels
Definition Geometry.h:50
GLuint64EXT * result
Definition glcorearb.h:5662
GLenum GLfloat param
Definition glcorearb.h:271
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:569
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< ChannelData > channels
std::vector< Digit > digits