Skip to content

Commit 24919bb

Browse files
wpierozakwpierozak
authored andcommitted
Fixed typos and scope issues
1 parent 13e19c5 commit 24919bb

File tree

3 files changed

+63
-33
lines changed

3 files changed

+63
-33
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "DataFormatsFT0/SpectraInfoObject.h"
1010
#include "DetectorsCalibration/TimeSlotCalibration.h"
1111
#include "DetectorsCalibration/TimeSlot.h"
12-
#include "DataFormatsFT0/BcEvents.h"
1312

1413
namespace o2::ft0
1514
{
@@ -34,22 +33,19 @@ namespace o2::ft0
3433
using TFType = o2::calibration::TFType;
3534

3635
public:
37-
EventsPerBcCalibrator()
38-
{
39-
setUpdateAtTheEndOfRunOnly();
40-
}
36+
EventsPerBcCalibrator() = default;
4137

4238
bool hasEnoughData(const Slot& slot) const final { return true; }
4339
void initOutput() final;
4440
void finalizeSlot(Slot& slot) final;
4541
Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
4642

47-
const TH1F* getTvxPerBc() { return mTvxPerBc.get(); }
48-
const CcdbObjectInfo* getTvxPerBcCcdbInfo() { return mTvxPerBcInfo.get(); }
43+
const std::vector<std::unique_ptr<TH1F>>& getTvxPerBc() { return mTvxPerBcs; }
44+
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>>& getTvxPerBcCcdbInfo() { return mTvxPerBcInfos; }
4945

5046
private:
51-
std::unique_ptr<TH1F> mTvxPerBc;
52-
std::unique_ptr<CcdbObjectInfo> mTvxPerBcInfo;
47+
std::vector<std::unique_ptr<TH1F>> mTvxPerBcs;
48+
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>> mTvxPerBcInfos;
5349
};
5450
}
5551

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace o2::ft0
44
{
55
void EventsPerBc::print() const
66
{
7-
7+
LOG(info) << entries << " entries";
88
}
99

1010
void EventsPerBc::fill(const gsl::span<const o2::ft0::Digit> data)
@@ -26,21 +26,21 @@ namespace o2::ft0
2626

2727
void EventsPerBcCalibrator::initOutput() final
2828
{
29-
mTvxPerBc.reset();
30-
mTvxPerBcInfo.reset();
29+
mTvxPerBc.clear();
30+
mTvxPerBcInfo.clear();
3131
}
3232

3333
void EventsPerBcCalibrator::finalizeSlot(EventsPerBcCalibrator::Slot& slot) final
3434
{
3535
o2::ft0::EventsPerBc* data = slot.getContainer();
36-
mTvxPerBc = std::make_unique<TH1F>("TvxPerBc", "FT0 TVX per BC", o2::constants::lhc::LHCMaxBunches, 0, o2::constants::lhc::LHCMaxBunches - 1);
36+
mTvxPerBcs.emplace_back(std::make_unique<TH1F>("TvxPerBc", "FT0 TVX per BC", o2::constants::lhc::LHCMaxBunches, 0, o2::constants::lhc::LHCMaxBunches - 1));
3737
for(int bin = 0; bin < o2::constants::lhc::LHCMaxBunches; bin++) {
38-
tvxsHist->fill(bin, data->mTvx[bin]);
38+
mTvxPerBcs.back()->fill(bin, data->mTvx[bin]);
3939
}
40-
auto clName = o2::utils::MemFileHelper::getClassName(*tvxsHist);
40+
auto clName = o2::utils::MemFileHelper::getClassName(*mTvxPerBcs.back());
4141
auto flName = o2::ccdb::CcdbApi::generateFileName(clName);
4242
std::map<std::string, std::string> metaData;
43-
mTvxPerBcInfo = std::make_unique<CcdbObjectInfo>("FT0/Calib/TvxPerBc", clName, flName, metaData, slot.getStarTimeMs(), slot.getEndTimeStampMS());
43+
mTvxPerBcInfos.emplace_back(std::make_unique<CcdbObjectInfo>("FT0/Calib/TvxPerBc", clName, flName, metaData, slot.getStarTimeMs(), slot.getEndTimeStampMS()));
4444
}
4545

4646
EventsPerBcCalibrator::Slot& EventsPerBcCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType tend) final

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

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,98 @@
55
#include "Framework/DeviceSpec.h"
66
#include "Framework/WorkflowSpec.h"
77
#include "Framework/Task.h"
8+
#include "DetectorsCalibration/Utils.h"
89

910
#include "DataFormatsFT0/Digit.h"
10-
#include "DataFormatsFT0/BcEvents.h"
1111
#include "FT0Calibration/EventsPerBcCalibrator.h"
1212

13-
namespace o2::ft0
13+
14+
namespace o2::calibration
1415
{
1516
class FT0EventsPerBcProcessor final : public o2::framework::Task
1617
{
18+
public:
1719
void init(o2::framework::InitContext& ic) final
1820
{
19-
mCalibrator = std::make_unique<EventsPerBcCalibrator>();
21+
mCalibrator = std::make_unique<o2::ft0::EventsPerBcCalibrator>();
22+
if(ic.options().hasOption("slot-len-sec")) {
23+
mSlotLenSec = ic.options().get<uint32_t>("slot-len-sec");
24+
}
25+
if(ic.options().hasOption("one-object-per-run")) {
26+
mOneObjectPerRun = ic.options().get<bool>("one-object-per-run");
27+
}
28+
29+
if(mOneObjectPerRun) {
30+
mCalibrator->setUpdateAtTheEndOfRunOnly();
31+
} else {
32+
mCalibrator->setSlotLengthInSeconds(mSlotLenSec);
33+
}
2034
}
2135

22-
void run(o2::framework::ProcessContext& pc) final
36+
void run(o2::framework::ProcessingContext& pc) final
2337
{
2438
auto digits = pc.inputs().get<gsl::span<o2::ft0::Digit>>("digits");
2539
mCalibrator->process(digits);
40+
if(mOneObjectPerRun == false) {
41+
sendOutput(pc.outputs());
42+
}
2643
}
2744

2845
void endOfStream(o2::framework::EndOfStreamContext& ec) final
2946
{
30-
mCalibrator->chekSlotToFinalize();
47+
mCalibrator->checkSlotsToFinalize();
3148
sendOutput(ec.outputs());
3249
mCalibrator->initOutput();
3350
}
3451

35-
void sendOutput(DataAllocator& output)
52+
void sendOutput(o2::framework::DataAllocator& output)
3653
{
37-
TH1F* tvxHist = mCalibrator->getTvxPerBc();
38-
CcdbObjectInfo* info = mCalibrator->getTvxPerBcCcdbInfo();
39-
auto image = o2::ccdb::CcdbApi::createObjectImage(tvxHist, info);
40-
LOG(info) << "Sending object to CCDB";
41-
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "EVENTS_PER_BC_INFO", 0}, *image.get());
42-
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "EVENTS_PER_BC_INFO", 0}, info);
54+
using o2::framework::Output;
55+
56+
const auto& tvxHists = mCalibrator->getTvxPerBc();
57+
auto& infos = mCalibrator->getTvxPerBcCcdbInfo();
58+
for(int idx = 0; idx < tvxHists.size(); idx++){
59+
auto& info = infos[idx];
60+
const auto& payload = tvxHists[idx];
61+
62+
auto image = o2::ccdb::CcdbApi::createObjectImage(payload.get(), info.get());
63+
LOG(info) << "Sending object " << info->getPath() << "/" << info->getFileName() << " of size " << image->size()
64+
<< " bytes, valid for " << info->getStartValidityTimestamp() << " : " << info->getEndValidityTimestamp();
65+
output.snapshot(Output(o2::calibration::Utils::gDataOriginCDBPayload, "EVENTS_PER_BC_INFO", 0), *image.get());
66+
output.snapshot(Output(o2::calibration::Utils::gDataOriginCDBWrapper, "EVENTS_PER_BC_INFO", 0), *info.get());
67+
}
4368
}
4469

4570
private:
46-
std::unique_ptr<EventsPerBcCalibrator> mCalibrator;
71+
std::unique_ptr<o2::ft0::EventsPerBcCalibrator> mCalibrator;
72+
bool mOneObjectPerRun;
73+
uint32_t mSlotLenSec;
4774
};
4875
}
4976

50-
WorkflowSpec defineDataProcessing(ConfigContext& const & cfgc)
77+
namespace o2::framework
78+
{
79+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
5180
{
5281
using namespace o2::framework;
82+
using o2::calibration::FT0EventsPerBcProcessor;
5383
std::vector<InputSpec> inputs;
5484
inputs.emplace_back("digits", "FT0", "DIGITSBC");
5585
std::vector<OutputSpec> outputs;
56-
outputs.emplace_back("eventsPerBcInfo", "FT0", "EVENTS_PER_BC_INFO")
86+
outputs.emplace_back("eventsPerBcInfo", "FT0", "EVENTS_PER_BC_INFO");
5787
DataProcessorSpec dataProcessorSpec{
5888
"FT0EventsPerBcProcessor",
5989
inputs,
6090
outputs,
61-
AlgorithmSpec(adaptFromTask<o2::ft0::FT0EventsPerBcProcessor>()),
62-
Options{}
91+
AlgorithmSpec(adaptFromTask<FT0EventsPerBcProcessor>()),
92+
Options{
93+
{"slot-len-sec", VariantType::UInt32, 3600u, "Time lenght of slot in seconds"},
94+
{"one-object-per-run", VariantType::Bool, false, "If true, then one calibration object is created per run"}
95+
}
6396
};
6497

6598
WorkflowSpec workflow;
6699
workflow.emplace_back(dataProcessorSpec);
67100
return workflow;
101+
}
68102
}

0 commit comments

Comments
 (0)