Skip to content

Commit 675464b

Browse files
wpierozakwpierozak
authored andcommitted
FT0: refined logs in EventsPerBc calibration, fixed setting TF info in run method
1 parent 00be70b commit 675464b

File tree

4 files changed

+63
-13
lines changed

4 files changed

+63
-13
lines changed

Detectors/FIT/FT0/calibration/include/FT0Calibration/EventsPerBcCalibrator.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <bitset>
55
#include <array>
6+
#include <limits>
67
#include <TH1F.h>
78

89
#include "CommonDataFormat/FlatHisto2D.h"
@@ -11,20 +12,24 @@
1112
#include "DataFormatsFT0/Digit.h"
1213
#include "DetectorsCalibration/TimeSlotCalibration.h"
1314
#include "DetectorsCalibration/TimeSlot.h"
15+
#include "CommonDataFormat/TFIDInfo.h"
1416
#include "TH1F.h"
1517
#include "Rtypes.h"
1618

1719
namespace o2::ft0
1820
{
1921
struct EventsPerBc
2022
{
21-
EventsPerBc() = default;
23+
EventsPerBc(int32_t minAmplitudeSideA, int32_t minAmplitudeSideC): mMinAmplitudeSideA(minAmplitudeSideA), mMinAmplitudeSideC(minAmplitudeSideC) {}
2224

2325
size_t getEntries() const { return entries; }
2426
void print() const;
25-
void fill(const gsl::span<const o2::ft0::Digit> data);
27+
void fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const o2::ft0::Digit> data);
2628
void merge(const EventsPerBc* prev);
2729

30+
const int32_t mMinAmplitudeSideA;
31+
const int32_t mMinAmplitudeSideC;
32+
2833
std::array<double, o2::constants::lhc::LHCMaxBunches> mTvx{0.0};
2934
size_t entries{0};
3035
long startTimeStamp{0};
@@ -39,7 +44,7 @@ namespace o2::ft0
3944
using TFType = o2::calibration::TFType;
4045

4146
public:
42-
EventsPerBcCalibrator() = default;
47+
EventsPerBcCalibrator(uint32_t minNumberOfEntries, int32_t minAmplitudeSideA, int32_t minAmplitudeSideC);
4348

4449
bool hasEnoughData(const Slot& slot) const override;
4550
void initOutput() override;
@@ -50,9 +55,12 @@ namespace o2::ft0
5055
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>>& getTvxPerBcCcdbInfo() { return mTvxPerBcInfos; }
5156

5257
private:
58+
const uint32_t mMinNumberOfEntries;
59+
const int32_t mMinAmplitudeSideA;
60+
const int32_t mMinAmplitudeSideC;
61+
5362
std::vector<std::unique_ptr<TH1F>> mTvxPerBcs;
5463
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>> mTvxPerBcInfos;
55-
uint32_t mMinNumberOfEntries{1000};
5664

5765
ClassDefOverride(EventsPerBcCalibrator, 1);
5866
};

Detectors/FIT/FT0/calibration/src/EventsPerBcCalibrator.cxx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ namespace o2::ft0
88
LOG(info) << entries << " entries";
99
}
1010

11-
void EventsPerBc::fill(const gsl::span<const o2::ft0::Digit> data)
11+
void EventsPerBc::fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const o2::ft0::Digit> data)
1212
{
1313
size_t oldEntries = entries;
1414
for(const auto& digit: data) {
1515
double isVertex = digit.mTriggers.getVertex();
16+
if(digit.mTriggers.getAmplA() < mMinAmplitudeSideA || digit.mTriggers.getAmplC() < mMinAmplitudeSideC) {
17+
continue;
18+
}
1619
mTvx[digit.mIntRecord.bc] += isVertex;
1720
entries += isVertex;
1821
}
@@ -33,14 +36,22 @@ namespace o2::ft0
3336
mTvxPerBcInfos.clear();
3437
}
3538

39+
40+
EventsPerBcCalibrator::EventsPerBcCalibrator(uint32_t minNumberOfEntries, int32_t minAmplitudeSideA, int32_t minAmplitudeSideC): mMinNumberOfEntries(minNumberOfEntries), mMinAmplitudeSideA(minAmplitudeSideA), mMinAmplitudeSideC(minAmplitudeSideC)
41+
{
42+
LOG(info) << "Defined threshold for number of entires per slot: " << mMinNumberOfEntries;
43+
LOG(info) << "Defined threshold for side A amplitude for event: " << mMinAmplitudeSideA;
44+
LOG(info) << "Defined threshold for side C amplitude for event: " << mMinAmplitudeSideC;
45+
}
46+
3647
bool EventsPerBcCalibrator::hasEnoughData(const EventsPerBcCalibrator::Slot& slot) const
3748
{
3849
return slot.getContainer()->entries > mMinNumberOfEntries;
3950
}
4051

4152
void EventsPerBcCalibrator::finalizeSlot(EventsPerBcCalibrator::Slot& slot)
4253
{
43-
LOG(info) << "Finializing slot from " << slot.getStartTimeMS() << " to " << slot.getEndTimeMS();
54+
LOG(info) << "Finalizing slot from " << slot.getStartTimeMS() << " to " << slot.getEndTimeMS();
4455
o2::ft0::EventsPerBc* data = slot.getContainer();
4556
mTvxPerBcs.emplace_back(std::make_unique<TH1F>("TvxPerBc", "FT0 TVX per BC", o2::constants::lhc::LHCMaxBunches, 0, o2::constants::lhc::LHCMaxBunches - 1));
4657
for(int bin = 0; bin < o2::constants::lhc::LHCMaxBunches; bin++) {
@@ -57,7 +68,7 @@ namespace o2::ft0
5768
{
5869
auto& cont = getSlots();
5970
auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
60-
slot.setContainer(std::make_unique<EventsPerBc>());
71+
slot.setContainer(std::make_unique<EventsPerBc>(mMinAmplitudeSideA, mMinAmplitudeSideC));
6172
return slot;
6273
}
6374
}

Detectors/FIT/FT0/calibration/workflow/FT0EventsPerBcProcessor-Workflow.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "FT0EventsPerBcSpec.h"
2+
#include <limits>
23
o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc)
34
{
45
using namespace o2::framework;
@@ -14,8 +15,12 @@ o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext co
1415
outputs,
1516
AlgorithmSpec(adaptFromTask<FT0EventsPerBcProcessor>()),
1617
Options{
17-
{"slot-len-sec", VariantType::UInt32, 3600u, {"Time lenght of slot in seconds"}},
18-
{"one-object-per-run", VariantType::Bool, false, {"If true, then one calibration object is created per run"}}
18+
{"slot-len-sec", VariantType::UInt32, 3600u, {"Duration of each slot in seconds"}},
19+
{"slot-len-tf", VariantType::UInt32, 0u, {"Slot length in Time Frames (TFs)"}},
20+
{"one-object-per-run", VariantType::Bool, false, {"If set, workflow creates only one calibration object per run"}},
21+
{"min-entries-number", VariantType::UInt32, 0u, {"Minimum number of entries required for a slot to be valid"}},
22+
{"min-ampl-side-a", VariantType::Int, std::numeric_limits<int32_t>::min(), {"Amplitude threshold for Side A events"}},
23+
{"min-ampl-side-c", VariantType::Int, std::numeric_limits<int32_t>::min(), {"Amplitude threshold for Side C events"}}
1924
}
2025
};
2126

Detectors/FIT/FT0/calibration/workflow/FT0EventsPerBcSpec.h

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,45 @@ namespace o2::calibration
2424

2525
void init(o2::framework::InitContext& ic) final
2626
{
27-
mCalibrator = std::make_unique<o2::ft0::EventsPerBcCalibrator>();
2827
if(ic.options().hasOption("slot-len-sec")) {
2928
mSlotLenSec = ic.options().get<uint32_t>("slot-len-sec");
3029
}
3130
if(ic.options().hasOption("one-object-per-run")) {
3231
mOneObjectPerRun = ic.options().get<bool>("one-object-per-run");
3332
}
33+
if(ic.options().hasOption("slot-len-tf")) {
34+
mSlotLen = ic.options().get<o2::calibration::TFType>("slot-len-tf");
35+
}
36+
if(ic.options().hasOption("min-entries-number")) {
37+
mMinNumberOfEntries = ic.options().get<uint32_t>("min-entries-number");
38+
}
39+
if(ic.options().hasOption("min-ampl-side-a")) {
40+
mMinAmplitudeSideA = ic.options().get<int32_t>("min-ampl-side-a");
41+
}
42+
if(ic.options().hasOption("min-ampl-side-c")) {
43+
mMinAmplitudeSideC = ic.options().get<int32_t>("min-ampl-side-c");
44+
}
45+
46+
mCalibrator = std::make_unique<o2::ft0::EventsPerBcCalibrator>(mMinNumberOfEntries, mMinAmplitudeSideA, mMinAmplitudeSideC);
3447

3548
if(mOneObjectPerRun) {
49+
LOG(info) << "Only one object will be created at the end of run";
3650
mCalibrator->setUpdateAtTheEndOfRunOnly();
37-
} else {
51+
}
52+
if (mOneObjectPerRun == false && mSlotLen == 0){
53+
LOG(info) << "Defined slot interval to " << mSlotLenSec << " seconds";
3854
mCalibrator->setSlotLengthInSeconds(mSlotLenSec);
55+
}
56+
if (mOneObjectPerRun == false && mSlotLen != 0) {
57+
LOG(info) << "Defined slot interval to " << mSlotLen << " TFS";
58+
mCalibrator->setSlotLength(mSlotLen);
3959
}
4060
}
4161

4262
void run(o2::framework::ProcessingContext& pc) final
4363
{
4464
auto digits = pc.inputs().get<gsl::span<o2::ft0::Digit>>("digits");
65+
o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo());
4566
if(digits.size() == 0) {
4667
return;
4768
}
@@ -51,8 +72,9 @@ namespace o2::calibration
5172
}
5273
}
5374

54-
void endOfStream(o2::framework::EndOfStreamContext& ec) final
75+
void endOfStream(o2::framework::EndOfStreamContext& ec) final
5576
{
77+
LOG(info) << "Received end-of-stream, checking for slot to finalize...";
5678
mCalibrator->checkSlotsToFinalize();
5779
sendOutput(ec.outputs());
5880
mCalibrator->initOutput();
@@ -63,7 +85,7 @@ namespace o2::calibration
6385
using o2::framework::Output;
6486
const auto& tvxHists = mCalibrator->getTvxPerBc();
6587
auto& infos = mCalibrator->getTvxPerBcCcdbInfo();
66-
for(int idx = 0; idx < tvxHists.size(); idx++){
88+
for(unsigned int idx = 0; idx < tvxHists.size(); idx++){
6789
auto& info = infos[idx];
6890
const auto& payload = tvxHists[idx];
6991

@@ -83,6 +105,10 @@ namespace o2::calibration
83105
std::unique_ptr<o2::ft0::EventsPerBcCalibrator> mCalibrator;
84106
bool mOneObjectPerRun;
85107
uint32_t mSlotLenSec;
108+
o2::calibration::TFType mSlotLen;
109+
uint32_t mMinNumberOfEntries;
110+
int32_t mMinAmplitudeSideA;
111+
int32_t mMinAmplitudeSideC;
86112
};
87113
}
88114
#endif

0 commit comments

Comments
 (0)