Skip to content
Draft

O2 6563 #14986

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13e19c5
FT0: created first sketch of implementation of generation of TVX per …
Dec 18, 2025
24919bb
Fixed typos and scope issues
Dec 30, 2025
eb60797
Fixing bugs
Dec 30, 2025
aec692a
FT0: Updated CMakeLists for calibration
Jan 5, 2026
f49611c
FT0: Added missing entry in FT0CalibrationLinkDef.h
Jan 5, 2026
00be70b
FT0 calibration: fixed ROOT directory compilation, fixed CCDB output
Jan 5, 2026
675464b
FT0: refined logs in EventsPerBc calibration, fixed setting TF info i…
Jan 7, 2026
986a12b
FT0: executed clang-format
Jan 12, 2026
05cc06e
FT0: Added readme to calibrations
Jan 15, 2026
864d008
FT0: Changed calibration object name, implemented missing OrbitReset …
Jan 15, 2026
56e38b6
FT0 EventsPerBc calibration: storing histograms in float format, upda…
Jan 15, 2026
797d924
Changed type of EventsPerBc calibration object to std::array
Jan 21, 2026
61f71e9
FT0: corrected macro FT0readEventsPerBc, corrected typo in calibratio…
Jan 21, 2026
3c5b138
Please consider the following formatting changes
alibuild Jan 22, 2026
b4aead4
Merge pull request #5 from alibuild/alibot-cleanup-14986
wpierozak Jan 22, 2026
3fc6d24
Created CCDB object class for EvetnsPerBC calibration
Jan 29, 2026
21746d8
FT0: formatted EvensPerBc.h
Jan 29, 2026
e3f58ca
FT0: removed amplitudes thresholds from EventsPerBc
Jan 29, 2026
35d6fec
FT0: fixed bugs after rebase
Jan 29, 2026
8c28976
Please consider the following formatting changes
alibuild Jan 29, 2026
7ae0fa7
Merge pull request #7 from alibuild/alibot-cleanup-14986
wpierozak Jan 29, 2026
c10563b
Fixed formatting isues
Jan 29, 2026
dbb62e1
Fixed formatting isues
Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DataFormats/Detectors/FIT/FT0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ o2_target_root_dictionary(DataFormatsFT0
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
include/DataFormatsFT0/SpectraInfoObject.h
include/DataFormatsFT0/SlewingCoef.h
include/DataFormatsFT0/EventsPerBc.h
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef _FT0_EVENTS_PER_BC_CALIB_OBJECT
#define _FT0_EVENTS_PER_BC_CALIB_OBJECT

#include "CommonConstants/LHCConstants.h"
#include <Rtypes.h>

namespace o2::ft0
{
struct EventsPerBc {
std::array<double, o2::constants::lhc::LHCMaxBunches> histogram;
ClassDefNV(EventsPerBc, 1);
};
} // namespace o2::ft0
#endif
2 changes: 2 additions & 0 deletions DataFormats/Detectors/FIT/FT0/src/DataFormatsFT0LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@
#pragma link C++ class std::pair < std::vector < double>, std::vector < double>> + ;
#pragma link C++ class o2::ft0::SlewingCoef + ;

#pragma link C++ class o2::ft0::EventsPerBc + ;

#endif
70 changes: 47 additions & 23 deletions Detectors/FIT/FT0/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,50 @@
# or submit itself to any jurisdiction.

o2_add_library(FT0Calibration
SOURCES
src/FT0TimeOffsetSlotContainer.cxx
PUBLIC_LINK_LIBRARIES
O2::DataFormatsFT0
O2::CommonDataFormat
O2::DetectorsCalibration
)
o2_target_root_dictionary(FT0Calibration
HEADERS
include/FT0Calibration/FT0TimeOffsetSlotContainer.h
)
o2_add_executable(ft0-time-offset-calib
COMPONENT_NAME calibration
SOURCES workflow/FT0TimeOffsetCalibration-Workflow.cxx
PUBLIC_LINK_LIBRARIES
O2::FT0Calibration O2::FITCalibration
)
o2_add_executable(ft0-time-spectra-processor
COMPONENT_NAME calibration
SOURCES workflow/FT0TimeSpectraProcessor-Workflow.cxx
PUBLIC_LINK_LIBRARIES
O2::FT0Calibration
)
SOURCES
src/FT0TimeOffsetSlotContainer.cxx
src/EventsPerBcCalibrator.cxx
PUBLIC_LINK_LIBRARIES
O2::DetectorsCalibration
O2::Framework
O2::CommonUtils
Microsoft.GSL::GSL
O2::DataFormatsFT0
O2::CommonDataFormat
O2::Steer
O2::CCDB
ROOT::Minuit
ROOT::Hist
)

o2_target_root_dictionary(FT0Calibration
HEADERS
include/FT0Calibration/FT0TimeOffsetSlotContainer.h
include/FT0Calibration/EventsPerBcCalibrator.h
)

o2_add_executable(ft0-time-offset-calib
COMPONENT_NAME calibration
SOURCES
workflow/FT0TimeOffsetCalibration-Workflow.cxx
PUBLIC_LINK_LIBRARIES
O2::FT0Calibration O2::FITCalibration
)

o2_add_executable(ft0-time-spectra-processor
COMPONENT_NAME calibration
SOURCES
workflow/FT0TimeSpectraProcessor-Workflow.cxx
PUBLIC_LINK_LIBRARIES
O2::FT0Calibration
)

o2_add_executable(ft0-events-per-bc-processor
COMPONENT_NAME calibration
SOURCES
workflow/FT0EventsPerBcProcessor-Workflow.cxx
PUBLIC_LINK_LIBRARIES
O2::FT0Calibration
O2::Framework
O2::CCDB
)
62 changes: 62 additions & 0 deletions Detectors/FIT/FT0/calibration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Calibrations

## Events per BC Calibration
### Description
Generates histograms of **Events per Bunch Crossing (BC)**. Events can be filtered by applying amplitude thresholds to the **A-side** and **C-side**.

### Command-Line Options
| Option | Default | Description |
| :--- | :--- | :--- |
| `--slot-len-sec` | `3600` | Duration of each slot in seconds. |
| `--slot-len-tf` | `0` | Slot length in Time Frames (TFs). |
| `--one-object-per-run` | — | If set, the workflow creates only one calibration object per run. |
| `--min-entries-number` | `0` | Minimum number of entries required for a slot to be valid. |
| `--min-ampl-side-a` | `-2147483648` | Amplitude threshold for Side A events. |
| `--min-ampl-side-c` | `-2147483648` | Amplitude threshold for Side C events. |

---

## How to Run

### Simulation Data
First, it is important to digitize data with a non-zero run number, orbit, and timestamp. To set these parameters, one can use the `--configKeyValues` option, as shown in the example below.
```
o2-sim-digitizer-workflow \
--onlyDet FT0 \
--configKeyValues="HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=128;HBFUtils.orbitFirstSampled=256;HBFUtils.runNumber=560560;HBFUtils.startTime=1768464099000"
```

To process simulation data, digits must first be converted to RAW format. The `o2-ft0-digi2raw` tool performs this conversion and generates the required configuration file.

Once converted, you can run the calibration either as a single integrated workflow or by spawning as the sender and receiver components separately.

#### Single Workflow Example
Execute the following command within the simulation directory:
```
o2-raw-file-reader-workflow --input-conf FT0raw.cfg --loop -1 \
| o2-ft0-flp-dpl-workflow --condition-backend=http://localhost:8080 \
| o2-calibration-ft0-events-per-bc-processor --FT0EventsPerBcProcessor "--slot-len-sec=10" \
| o2-calibration-ccdb-populator-workflow --ccdb-path=http://localhost:8080
```

Sender example (in simulation directory):
```
o2-raw-file-reader-workflow --input-conf FT0raw.cfg --loop -1 \
| o2-ft0-flp-dpl-workflow --condition-backend=http://localhost:8080 \
| o2-dpl-output-proxy --channel-config "name=downstream,method=connect,address=tcp://localhost:30453,type=push,transport=zeromq" --dataspec "downstream:FT0/DIGITSBC"
```

Receiver example:
```
o2-dpl-raw-proxy --channel-config "name=readout-proxy,type=pull,method=bind,address=tcp://localhost:30453,rateLogging=1,transport=zeromq" --dataspec "A:FT0/DIGITSBC/0" \
| o2-calibration-ft0-events-per-bc-processor --FT0EventsPerBcProcessor "--slot-len-sec=10 --min-ampl-side-a=0" \
| o2-calibration-ccdb-populator-workflow --ccdb-path=http://localhost:8080/
```

### CTF Data
Example:
```
o2-ctf-reader-workflow --ctf-input ctf.root --onlyDet FT0 \
| o2-calibration-ft0-events-per-bc-processor --FT0EventsPerBcProcessor "--slot-len-sec=10" \
| o2-calibration-ccdb-populator-workflow --ccdb-path=http://localhost:8080/
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef O2_FT0TVXPERBCID
#define O2_FT0TVXPERBCID

#include <bitset>
#include <array>
#include <limits>
#include <TH1F.h>

#include "CommonDataFormat/FlatHisto2D.h"
#include "CommonConstants/LHCConstants.h"
#include "DataFormatsFT0/SpectraInfoObject.h"
#include "DataFormatsFT0/Digit.h"
#include "DataFormatsFT0/EventsPerBc.h"
#include "DetectorsCalibration/TimeSlotCalibration.h"
#include "DetectorsCalibration/TimeSlot.h"
#include "CommonDataFormat/TFIDInfo.h"
#include "TH1F.h"
#include "Rtypes.h"

namespace o2::ft0
{
struct EventsPerBcContainer {
EventsPerBcContainer(int32_t minAmplitudeSideA, int32_t minAmplitudeSideC) : mMinAmplitudeSideA(minAmplitudeSideA), mMinAmplitudeSideC(minAmplitudeSideC) {}

size_t getEntries() const { return entries; }
void print() const;
void fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const o2::ft0::Digit> data);
void merge(const EventsPerBcContainer* prev);

const int32_t mMinAmplitudeSideA;
const int32_t mMinAmplitudeSideC;

std::array<double, o2::constants::lhc::LHCMaxBunches> mTvx{0.0};
size_t entries{0};
long startTimeStamp{0};
long stopTimeStamp{0};

ClassDefNV(EventsPerBcContainer, 1);
};

class EventsPerBcCalibrator final : public o2::calibration::TimeSlotCalibration<o2::ft0::EventsPerBcContainer>
{
using Slot = o2::calibration::TimeSlot<o2::ft0::EventsPerBcContainer>;
using TFType = o2::calibration::TFType;
using EventsHistogram = std::array<double, o2::constants::lhc::LHCMaxBunches>;

public:
EventsPerBcCalibrator(uint32_t minNumberOfEntries, int32_t minAmplitudeSideA, int32_t minAmplitudeSideC);

bool hasEnoughData(const Slot& slot) const override;
void initOutput() override;
void finalizeSlot(Slot& slot) override;
Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) override;

const std::vector<EventsPerBc>& getTvxPerBc() { return mTvxPerBcs; }
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>>& getTvxPerBcCcdbInfo() { return mTvxPerBcInfos; }

private:
const uint32_t mMinNumberOfEntries;
const int32_t mMinAmplitudeSideA;
const int32_t mMinAmplitudeSideC;

std::vector<EventsPerBc> mTvxPerBcs;
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>> mTvxPerBcInfos;

ClassDefOverride(EventsPerBcCalibrator, 1);
};
} // namespace o2::ft0

#endif
83 changes: 83 additions & 0 deletions Detectors/FIT/FT0/calibration/src/EventsPerBcCalibrator.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include "FT0Calibration/EventsPerBcCalibrator.h"
#include "CommonUtils/MemFileHelper.h"

namespace o2::ft0
{
void EventsPerBcContainer::print() const
{
LOG(info) << entries << " entries";
}

void EventsPerBcContainer::fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const o2::ft0::Digit> data)
{
size_t oldEntries = entries;
for (const auto& digit : data) {
double isVertex = digit.mTriggers.getVertex();
if (digit.mTriggers.getAmplA() < mMinAmplitudeSideA || digit.mTriggers.getAmplC() < mMinAmplitudeSideC) {
continue;
}
mTvx[digit.mIntRecord.bc] += isVertex;
entries += isVertex;
}
LOG(debug) << "Container is filled with " << entries - oldEntries << " new events";
}

void EventsPerBcContainer::merge(const EventsPerBcContainer* prev)
{
for (int bc = 0; bc < o2::constants::lhc::LHCMaxBunches; bc++) {
mTvx[bc] += prev->mTvx[bc];
}
entries += prev->entries;
}

void EventsPerBcCalibrator::initOutput()
{
mTvxPerBcs.clear();
mTvxPerBcInfos.clear();
}

EventsPerBcCalibrator::EventsPerBcCalibrator(uint32_t minNumberOfEntries, int32_t minAmplitudeSideA, int32_t minAmplitudeSideC) : mMinNumberOfEntries(minNumberOfEntries), mMinAmplitudeSideA(minAmplitudeSideA), mMinAmplitudeSideC(minAmplitudeSideC)
{
LOG(info) << "Defined threshold for number of entires per slot: " << mMinNumberOfEntries;
LOG(info) << "Defined threshold for side A amplitude for event: " << mMinAmplitudeSideA;
LOG(info) << "Defined threshold for side C amplitude for event: " << mMinAmplitudeSideC;
}

bool EventsPerBcCalibrator::hasEnoughData(const EventsPerBcCalibrator::Slot& slot) const
{
return slot.getContainer()->entries > mMinNumberOfEntries;
}

void EventsPerBcCalibrator::finalizeSlot(EventsPerBcCalibrator::Slot& slot)
{
LOG(info) << "Finalizing slot from " << slot.getStartTimeMS() << " to " << slot.getEndTimeMS();
o2::ft0::EventsPerBcContainer* data = slot.getContainer();
mTvxPerBcs.emplace_back(data->mTvx);

auto clName = o2::utils::MemFileHelper::getClassName(mTvxPerBcs.back());
auto flName = o2::ccdb::CcdbApi::generateFileName(clName);

std::map<std::string, std::string> metaData;
mTvxPerBcInfos.emplace_back(std::make_unique<o2::ccdb::CcdbObjectInfo>("FT0/Calib/EventsPerBcContainer", clName, flName, metaData, slot.getStartTimeMS(), slot.getEndTimeMS()));
LOG(info) << "Created object valid from " << mTvxPerBcInfos.back()->getStartValidityTimestamp() << " to " << mTvxPerBcInfos.back()->getEndValidityTimestamp();
}

EventsPerBcCalibrator::Slot& EventsPerBcCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType tend)
{
auto& cont = getSlots();
auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
slot.setContainer(std::make_unique<EventsPerBcContainer>(mMinAmplitudeSideA, mMinAmplitudeSideC));
return slot;
}
} // namespace o2::ft0
4 changes: 3 additions & 1 deletion Detectors/FIT/FT0/calibration/src/FT0CalibrationLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#pragma link off all functions;

#pragma link C++ class o2::ft0::FT0TimeOffsetSlotContainer + ;
#pragma link C++ class o2::ft0::EventsPerBcCalibrator + ;
#pragma link C++ class o2::calibration::TimeSlot < o2::ft0::FT0TimeOffsetSlotContainer>;
#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::ft0::FT0TimeOffsetSlotContainer>;

#pragma link C++ class o2::calibration::TimeSlot < o2::ft0::EventsPerBcContainer> + ;
#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::ft0::EventsPerBcContainer> + ;
#endif
Loading