Skip to content

Commit 970ed8e

Browse files
authored
EventsPerBC calibration task for FT0 (O2-6563) (#14986)
Implements the EventsPerBC calibration task for FT0, which generates a histogram of VTX events above a defined amplitude threshold plotted against the BC. * FT0: created first sketch of implementation of generation of TVX per Event calibration object * FT0: Updated CMakeLists for calibration * FT0: Added missing entry in FT0CalibrationLinkDef.h * FT0 calibration: fixed ROOT directory compilation, fixed CCDB output * FT0: refined logs in EventsPerBc calibration, fixed setting TF info in run method * FT0: Added readme to calibrations * FT0: Changed calibration object name, implemented missing OrbitReset fetching * FT0 EventsPerBc calibration: storing histograms in float format, updated readme * Changed type of EventsPerBc calibration object to std::array * FT0: corrected macro FT0readEventsPerBc, corrected typo in calibration README * Created CCDB object class for EvetnsPerBC calibration * FT0: formatted EvensPerBc.h * FT0: removed amplitudes thresholds from EventsPerBc * FT0: Removed from EventsPerBc calibarion option to define slot lenght in TFs; Small code cleaning * Changed default value of min number of entries in EventsPerBcProcessor from 5000 to 5000u
1 parent 331f2cc commit 970ed8e

File tree

12 files changed

+538
-30
lines changed

12 files changed

+538
-30
lines changed

DataFormats/Detectors/FIT/FT0/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ o2_target_root_dictionary(DataFormatsFT0
4747
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
4848
include/DataFormatsFT0/SpectraInfoObject.h
4949
include/DataFormatsFT0/SlewingCoef.h
50+
include/DataFormatsFT0/EventsPerBc.h
5051
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
12+
#ifndef _FT0_EVENTS_PER_BC_CALIB_OBJECT
13+
#define _FT0_EVENTS_PER_BC_CALIB_OBJECT
14+
15+
#include "CommonConstants/LHCConstants.h"
16+
#include <Rtypes.h>
17+
18+
namespace o2::ft0
19+
{
20+
struct EventsPerBc {
21+
std::array<double, o2::constants::lhc::LHCMaxBunches> histogram;
22+
ClassDefNV(EventsPerBc, 1);
23+
};
24+
} // namespace o2::ft0
25+
#endif

DataFormats/Detectors/FIT/FT0/src/DataFormatsFT0LinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@
5656
#pragma link C++ class std::pair < std::vector < double>, std::vector < double>> + ;
5757
#pragma link C++ class o2::ft0::SlewingCoef + ;
5858

59+
#pragma link C++ class o2::ft0::EventsPerBc + ;
60+
5961
#endif

Detectors/FIT/FT0/calibration/CMakeLists.txt

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,50 @@
1010
# or submit itself to any jurisdiction.
1111

1212
o2_add_library(FT0Calibration
13-
SOURCES
14-
src/FT0TimeOffsetSlotContainer.cxx
15-
PUBLIC_LINK_LIBRARIES
16-
O2::DataFormatsFT0
17-
O2::CommonDataFormat
18-
O2::DetectorsCalibration
19-
)
20-
o2_target_root_dictionary(FT0Calibration
21-
HEADERS
22-
include/FT0Calibration/FT0TimeOffsetSlotContainer.h
23-
)
24-
o2_add_executable(ft0-time-offset-calib
25-
COMPONENT_NAME calibration
26-
SOURCES workflow/FT0TimeOffsetCalibration-Workflow.cxx
27-
PUBLIC_LINK_LIBRARIES
28-
O2::FT0Calibration O2::FITCalibration
29-
)
30-
o2_add_executable(ft0-time-spectra-processor
31-
COMPONENT_NAME calibration
32-
SOURCES workflow/FT0TimeSpectraProcessor-Workflow.cxx
33-
PUBLIC_LINK_LIBRARIES
34-
O2::FT0Calibration
35-
)
13+
SOURCES
14+
src/FT0TimeOffsetSlotContainer.cxx
15+
src/EventsPerBcCalibrator.cxx
16+
PUBLIC_LINK_LIBRARIES
17+
O2::DetectorsCalibration
18+
O2::Framework
19+
O2::CommonUtils
20+
Microsoft.GSL::GSL
21+
O2::DataFormatsFT0
22+
O2::CommonDataFormat
23+
O2::Steer
24+
O2::CCDB
25+
ROOT::Minuit
26+
ROOT::Hist
27+
)
28+
29+
o2_target_root_dictionary(FT0Calibration
30+
HEADERS
31+
include/FT0Calibration/FT0TimeOffsetSlotContainer.h
32+
include/FT0Calibration/EventsPerBcCalibrator.h
33+
)
34+
35+
o2_add_executable(ft0-time-offset-calib
36+
COMPONENT_NAME calibration
37+
SOURCES
38+
workflow/FT0TimeOffsetCalibration-Workflow.cxx
39+
PUBLIC_LINK_LIBRARIES
40+
O2::FT0Calibration O2::FITCalibration
41+
)
42+
43+
o2_add_executable(ft0-time-spectra-processor
44+
COMPONENT_NAME calibration
45+
SOURCES
46+
workflow/FT0TimeSpectraProcessor-Workflow.cxx
47+
PUBLIC_LINK_LIBRARIES
48+
O2::FT0Calibration
49+
)
50+
51+
o2_add_executable(ft0-events-per-bc-processor
52+
COMPONENT_NAME calibration
53+
SOURCES
54+
workflow/FT0EventsPerBcProcessor-Workflow.cxx
55+
PUBLIC_LINK_LIBRARIES
56+
O2::FT0Calibration
57+
O2::Framework
58+
O2::CCDB
59+
)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Calibrations
2+
3+
## Events per BC Calibration
4+
### Description
5+
Generates histograms of **Events per Bunch Crossing (BC)**. Events can be filtered by applying amplitude thresholds to the **A-side** and **C-side**.
6+
7+
### Command-Line Options
8+
| Option | Default | Description |
9+
| :--- | :--- | :--- |
10+
| `--slot-len-sec` | `3600` | Duration of each slot in seconds. |
11+
| `--slot-len-tf` | `0` | Slot length in Time Frames (TFs). |
12+
| `--one-object-per-run` || If set, the workflow creates only one calibration object per run. |
13+
| `--min-entries-number` | `0` | Minimum number of entries required for a slot to be valid. |
14+
| `--min-ampl-side-a` | `-2147483648` | Amplitude threshold for Side A events. |
15+
| `--min-ampl-side-c` | `-2147483648` | Amplitude threshold for Side C events. |
16+
17+
---
18+
19+
## How to Run
20+
21+
### Simulation Data
22+
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.
23+
```
24+
o2-sim-digitizer-workflow \
25+
--onlyDet FT0 \
26+
--configKeyValues="HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=128;HBFUtils.orbitFirstSampled=256;HBFUtils.runNumber=560560;HBFUtils.startTime=1768464099000"
27+
```
28+
29+
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.
30+
31+
Once converted, you can run the calibration either as a single integrated workflow or by spawning as the sender and receiver components separately.
32+
33+
#### Single Workflow Example
34+
Execute the following command within the simulation directory:
35+
```
36+
o2-raw-file-reader-workflow --input-conf FT0raw.cfg --loop -1 \
37+
| o2-ft0-flp-dpl-workflow --condition-backend=http://localhost:8080 \
38+
| o2-calibration-ft0-events-per-bc-processor --FT0EventsPerBcProcessor "--slot-len-sec=10" \
39+
| o2-calibration-ccdb-populator-workflow --ccdb-path=http://localhost:8080
40+
```
41+
42+
Sender example (in simulation directory):
43+
```
44+
o2-raw-file-reader-workflow --input-conf FT0raw.cfg --loop -1 \
45+
| o2-ft0-flp-dpl-workflow --condition-backend=http://localhost:8080 \
46+
| o2-dpl-output-proxy --channel-config "name=downstream,method=connect,address=tcp://localhost:30453,type=push,transport=zeromq" --dataspec "downstream:FT0/DIGITSBC"
47+
```
48+
49+
Receiver example:
50+
```
51+
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" \
52+
| o2-calibration-ft0-events-per-bc-processor --FT0EventsPerBcProcessor "--slot-len-sec=10 --min-ampl-side-a=0" \
53+
| o2-calibration-ccdb-populator-workflow --ccdb-path=http://localhost:8080/
54+
```
55+
56+
### CTF Data
57+
Example:
58+
```
59+
o2-ctf-reader-workflow --ctf-input ctf.root --onlyDet FT0 \
60+
| o2-calibration-ft0-events-per-bc-processor --FT0EventsPerBcProcessor "--slot-len-sec=10" \
61+
| o2-calibration-ccdb-populator-workflow --ccdb-path=http://localhost:8080/
62+
```
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
12+
#ifndef O2_FT0TVXPERBCID
13+
#define O2_FT0TVXPERBCID
14+
15+
#include <bitset>
16+
#include <array>
17+
#include <limits>
18+
#include <TH1F.h>
19+
20+
#include "CommonDataFormat/FlatHisto2D.h"
21+
#include "CommonConstants/LHCConstants.h"
22+
#include "DataFormatsFT0/SpectraInfoObject.h"
23+
#include "DataFormatsFT0/Digit.h"
24+
#include "DataFormatsFT0/EventsPerBc.h"
25+
#include "DetectorsCalibration/TimeSlotCalibration.h"
26+
#include "DetectorsCalibration/TimeSlot.h"
27+
#include "CommonDataFormat/TFIDInfo.h"
28+
#include "TH1F.h"
29+
#include "Rtypes.h"
30+
31+
namespace o2::ft0
32+
{
33+
struct EventsPerBcContainer {
34+
EventsPerBcContainer(int32_t minAmplitudeSideA, int32_t minAmplitudeSideC) : mMinAmplitudeSideA(minAmplitudeSideA), mMinAmplitudeSideC(minAmplitudeSideC) {}
35+
36+
size_t getEntries() const { return entries; }
37+
void print() const;
38+
void fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const o2::ft0::Digit> data);
39+
void merge(const EventsPerBcContainer* prev);
40+
41+
const int32_t mMinAmplitudeSideA;
42+
const int32_t mMinAmplitudeSideC;
43+
44+
std::array<double, o2::constants::lhc::LHCMaxBunches> mTvx{0.0};
45+
size_t entries{0};
46+
long startTimeStamp{0};
47+
long stopTimeStamp{0};
48+
49+
ClassDefNV(EventsPerBcContainer, 1);
50+
};
51+
52+
class EventsPerBcCalibrator final : public o2::calibration::TimeSlotCalibration<o2::ft0::EventsPerBcContainer>
53+
{
54+
using Slot = o2::calibration::TimeSlot<o2::ft0::EventsPerBcContainer>;
55+
using TFType = o2::calibration::TFType;
56+
using EventsHistogram = std::array<double, o2::constants::lhc::LHCMaxBunches>;
57+
58+
public:
59+
EventsPerBcCalibrator(uint32_t minNumberOfEntries, int32_t minAmplitudeSideA, int32_t minAmplitudeSideC);
60+
61+
bool hasEnoughData(const Slot& slot) const override;
62+
void initOutput() override;
63+
void finalizeSlot(Slot& slot) override;
64+
Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) override;
65+
66+
const std::vector<EventsPerBc>& getTvxPerBc() { return mTvxPerBcs; }
67+
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>>& getTvxPerBcCcdbInfo() { return mTvxPerBcInfos; }
68+
69+
private:
70+
const uint32_t mMinNumberOfEntries;
71+
const int32_t mMinAmplitudeSideA;
72+
const int32_t mMinAmplitudeSideC;
73+
74+
std::vector<EventsPerBc> mTvxPerBcs;
75+
std::vector<std::unique_ptr<o2::ccdb::CcdbObjectInfo>> mTvxPerBcInfos;
76+
77+
ClassDefOverride(EventsPerBcCalibrator, 1);
78+
};
79+
} // namespace o2::ft0
80+
81+
#endif
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
12+
#include "FT0Calibration/EventsPerBcCalibrator.h"
13+
#include "CommonUtils/MemFileHelper.h"
14+
15+
namespace o2::ft0
16+
{
17+
void EventsPerBcContainer::print() const
18+
{
19+
LOG(info) << entries << " entries";
20+
}
21+
22+
void EventsPerBcContainer::fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const o2::ft0::Digit> data)
23+
{
24+
size_t oldEntries = entries;
25+
for (const auto& digit : data) {
26+
if (digit.mTriggers.getVertex() && digit.mTriggers.getAmplA() >= mMinAmplitudeSideA && digit.mTriggers.getAmplC() >= mMinAmplitudeSideC) {
27+
mTvx[digit.mIntRecord.bc]++;
28+
entries++;
29+
}
30+
}
31+
LOG(debug) << "Container is filled with " << entries - oldEntries << " new events";
32+
}
33+
34+
void EventsPerBcContainer::merge(const EventsPerBcContainer* prev)
35+
{
36+
for (int bc = 0; bc < o2::constants::lhc::LHCMaxBunches; bc++) {
37+
mTvx[bc] += prev->mTvx[bc];
38+
}
39+
entries += prev->entries;
40+
}
41+
42+
void EventsPerBcCalibrator::initOutput()
43+
{
44+
mTvxPerBcs.clear();
45+
mTvxPerBcInfos.clear();
46+
}
47+
48+
EventsPerBcCalibrator::EventsPerBcCalibrator(uint32_t minNumberOfEntries, int32_t minAmplitudeSideA, int32_t minAmplitudeSideC) : mMinNumberOfEntries(minNumberOfEntries), mMinAmplitudeSideA(minAmplitudeSideA), mMinAmplitudeSideC(minAmplitudeSideC)
49+
{
50+
LOG(info) << "Defined threshold for number of entires per slot: " << mMinNumberOfEntries;
51+
LOG(info) << "Defined threshold for side A amplitude for event: " << mMinAmplitudeSideA;
52+
LOG(info) << "Defined threshold for side C amplitude for event: " << mMinAmplitudeSideC;
53+
}
54+
55+
bool EventsPerBcCalibrator::hasEnoughData(const EventsPerBcCalibrator::Slot& slot) const
56+
{
57+
return slot.getContainer()->entries > mMinNumberOfEntries;
58+
}
59+
60+
void EventsPerBcCalibrator::finalizeSlot(EventsPerBcCalibrator::Slot& slot)
61+
{
62+
LOG(info) << "Finalizing slot from " << slot.getStartTimeMS() << " to " << slot.getEndTimeMS();
63+
o2::ft0::EventsPerBcContainer* data = slot.getContainer();
64+
mTvxPerBcs.emplace_back(data->mTvx);
65+
66+
auto clName = o2::utils::MemFileHelper::getClassName(mTvxPerBcs.back());
67+
auto flName = o2::ccdb::CcdbApi::generateFileName(clName);
68+
69+
std::map<std::string, std::string> metaData;
70+
mTvxPerBcInfos.emplace_back(std::make_unique<o2::ccdb::CcdbObjectInfo>("FT0/Calib/EventsPerBc", clName, flName, metaData, slot.getStartTimeMS(), slot.getEndTimeMS()));
71+
LOG(info) << "Created object valid from " << mTvxPerBcInfos.back()->getStartValidityTimestamp() << " to " << mTvxPerBcInfos.back()->getEndValidityTimestamp();
72+
}
73+
74+
EventsPerBcCalibrator::Slot& EventsPerBcCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType tend)
75+
{
76+
auto& cont = getSlots();
77+
auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
78+
slot.setContainer(std::make_unique<EventsPerBcContainer>(mMinAmplitudeSideA, mMinAmplitudeSideC));
79+
return slot;
80+
}
81+
} // namespace o2::ft0

Detectors/FIT/FT0/calibration/src/FT0CalibrationLinkDef.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#pragma link off all functions;
1717

1818
#pragma link C++ class o2::ft0::FT0TimeOffsetSlotContainer + ;
19+
#pragma link C++ class o2::ft0::EventsPerBcCalibrator + ;
1920
#pragma link C++ class o2::calibration::TimeSlot < o2::ft0::FT0TimeOffsetSlotContainer>;
2021
#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::ft0::FT0TimeOffsetSlotContainer>;
21-
22+
#pragma link C++ class o2::calibration::TimeSlot < o2::ft0::EventsPerBcContainer> + ;
23+
#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::ft0::EventsPerBcContainer> + ;
2224
#endif

0 commit comments

Comments
 (0)