Skip to content

Commit 7416128

Browse files
author
afurs
committed
AFIT-98: new update
1 parent f3e25c7 commit 7416128

21 files changed

Lines changed: 650 additions & 246 deletions

DataFormats/Detectors/FIT/FT0/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ o2_add_library(DataFormatsFT0
1919
src/CTF.cxx
2020
src/LookUpTable.cxx
2121
src/SlewingCoef.cxx
22-
src/SlewingCurve.cxx
2322

2423
PUBLIC_LINK_LIBRARIES O2::FT0Base
2524
O2::DataFormatsFIT
@@ -48,5 +47,4 @@ o2_target_root_dictionary(DataFormatsFT0
4847
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
4948
include/DataFormatsFT0/SpectraInfoObject.h
5049
include/DataFormatsFT0/SlewingCoef.h
51-
include/DataFormatsFT0/SlewingCurve.h
5250
)

DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/SlewingCoef.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <array>
2222
#include <utility>
2323

24+
#include "DataFormatsFIT/AmpTimeDistribution.h"
25+
2426
namespace o2
2527
{
2628
namespace ft0
@@ -29,12 +31,18 @@ namespace ft0
2931
struct SlewingCoef {
3032
constexpr static int sNCHANNELS = 208;
3133
constexpr static int sNAdc = 2;
34+
typedef o2::fit::AmpTimeDistributionDetector<sNCHANNELS, sNAdc> AmpTimeDistributionFT0_t;
35+
SlewingCoef() = default;
36+
SlewingCoef(const AmpTimeDistributionFT0_t& ampTimeDistribution);
37+
~SlewingCoef() = default;
38+
3239
using VecPoints_t = std::vector<Double_t>; // Set of points
3340
using VecPlot_t = std::pair<VecPoints_t, VecPoints_t>; // Plot as pair of two set of points
3441
using VecSlewingCoefs_t = std::array<std::array<VecPlot_t, sNCHANNELS>, sNAdc>; // 0 - adc0, 1 - adc1
3542
typedef std::array<std::array<TGraph, sNCHANNELS>, sNAdc> SlewingPlots_t;
3643
VecSlewingCoefs_t mSlewingCoefs{};
3744
SlewingPlots_t makeSlewingPlots() const;
45+
void fromCSV(const std::string& filepathSlewing, const std::string& filepathOffset = "");
3846
constexpr static const char* getObjectPath()
3947
{
4048
return "FT0/Calib/SlewingCoef";

DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/SlewingCurve.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

DataFormats/Detectors/FIT/FT0/src/SlewingCoef.cxx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#include "DataFormatsFT0/SlewingCoef.h"
12+
#include <string>
13+
#include <map>
14+
#include <ROOT/RCsvDS.hxx>
1315
#include <cassert>
16+
17+
#include "DataFormatsFT0/SlewingCoef.h"
18+
1419
using namespace o2::ft0;
1520

1621
SlewingCoef::SlewingPlots_t SlewingCoef::makeSlewingPlots() const
@@ -30,3 +35,28 @@ SlewingCoef::SlewingPlots_t SlewingCoef::makeSlewingPlots() const
3035
}
3136
return plots;
3237
}
38+
39+
void SlewingCoef::fromCSV(const std::string& filepathSlewing, const std::string& filepathOffset)
40+
{
41+
std::map<std::pair<int, int>, double> mapOffsets{}; // std::pair<int, int>{channelID, adc}
42+
if (filepathOffset.size() > 0) {
43+
auto dfOffset = ROOT::RDF::FromCSV(filepathOffset.c_str(), true, ';', -1LL);
44+
dfOffset.Foreach([&mapOffsets](const Long64_t& chID, const Long64_t& adc, const double peak) {
45+
mapOffsets.insert({{chID, adc}, peak});
46+
},
47+
{"channelID", "ADC", "peak"});
48+
}
49+
auto dfSlewing = ROOT::RDF::FromCSV(filepathSlewing.c_str(), true, ';', -1LL);
50+
dfSlewing.Foreach([this, &mapOffsets](const Long64_t& chID, const Long64_t& adc, const double& x_min,
51+
const double& y_min, const double& x_max, const double& y_max) {
52+
const auto& it = mapOffsets.find({chID, adc});
53+
const double offset = 0. ? it == mapOffsets.end() : it->second;
54+
auto& pointsX = mSlewingCoefs[adc][chID].first;
55+
auto& pointsY = mSlewingCoefs[adc][chID].second;
56+
pointsX.emplace_back(x_min);
57+
pointsX.emplace_back(x_max);
58+
pointsY.emplace_back(y_min - offset);
59+
pointsY.emplace_back(y_max - offset);
60+
},
61+
{"channelID", "ADC", "x_min", "y_min", "x_max", "y_max"});
62+
}

DataFormats/Detectors/FIT/FT0/src/SlewingCurve.cxx

Lines changed: 0 additions & 69 deletions
This file was deleted.

DataFormats/Detectors/FIT/common/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ o2_add_library(DataFormatsFIT
1313
SOURCES src/RawEventData.cxx
1414
src/Triggers.cxx
1515
src/RawDataMetric.cxx
16+
src/AmpTimeDistribution.cxx
1617
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat
1718
O2::DetectorsCommonDataFormats
1819
O2::CCDB)
@@ -22,4 +23,6 @@ o2_target_root_dictionary(DataFormatsFIT
2223
include/DataFormatsFIT/LookUpTable.h
2324
include/DataFormatsFIT/Triggers.h
2425
include/DataFormatsFIT/ChannelData.h
25-
include/DataFormatsFIT/Digit.h)
26+
include/DataFormatsFIT/Digit.h
27+
include/DataFormatsFIT/AmpTimeDistribution.h
28+
)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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_FITAMPTIMEDISTRIBUTION_H
13+
#define O2_FITAMPTIMEDISTRIBUTION_H
14+
15+
#include "TH2F.h"
16+
17+
#include <string>
18+
#include <memory>
19+
#include <utility>
20+
#include <vector>
21+
22+
#include <Vc/Vc>
23+
#include <span>
24+
25+
namespace o2::fit
26+
{
27+
28+
struct AmpTimeDistribution {
29+
AmpTimeDistribution() = default;
30+
AmpTimeDistribution(const std::string& name, const std::string& title, int nBins, double minRange, double maxRange, int binsInStep = 50, int binMax = 4095, int axis = 0);
31+
AmpTimeDistribution(const AmpTimeDistribution&);
32+
AmpTimeDistribution(AmpTimeDistribution&&) noexcept;
33+
AmpTimeDistribution& operator=(const AmpTimeDistribution&);
34+
AmpTimeDistribution& operator=(AmpTimeDistribution&&) noexcept;
35+
typedef float Content_t; // to template?
36+
typedef TH2F Hist2F_t;
37+
typedef Vc::float_v VcContent_t;
38+
std::unique_ptr<Hist2F_t> mHist = nullptr;
39+
// TODO: not finished yet, for perspective
40+
struct Header { // for serialization/deserialization
41+
static constexpr std::size_t sNFirstFields = 5;
42+
static constexpr std::size_t sSizeFirstFields = sizeof(Content_t) * sNFirstFields;
43+
// First five double fields
44+
Content_t mNBinConstant;
45+
Content_t mMinBinConstant;
46+
Content_t mMaxBinConstant;
47+
Content_t mNEdgesVariable; // N elements to specialize edges
48+
Content_t mAxisConstant; // Which axis has constant bin width, 0 -> X, 1 -> Y
49+
//
50+
std::vector<Content_t> mVecBinEdge;
51+
52+
std::size_t serialize(std::vector<Content_t>& vecDst, std::size_t startPos) const
53+
{
54+
std::memcpy(&vecDst[startPos], this, sSizeFirstFields);
55+
startPos += sNFirstFields;
56+
std::memcpy(&vecDst[startPos], mVecBinEdge.data(), sizeof(Content_t) * mVecBinEdge.size());
57+
startPos += mVecBinEdge.size();
58+
return startPos;
59+
}
60+
61+
std::size_t deserialize(std::vector<Content_t>& vecSrc, std::size_t startPos)
62+
{
63+
std::memcpy(this, &vecSrc[startPos], sSizeFirstFields);
64+
startPos += sNFirstFields;
65+
const std::size_t nElementsVec = static_cast<std::size_t>(mNEdgesVariable);
66+
std::memcpy(&vecSrc[startPos], mVecBinEdge.data(), sizeof(Content_t) * nElementsVec);
67+
startPos += nElementsVec;
68+
return startPos;
69+
}
70+
std::size_t getTotalN() const
71+
{
72+
return mVecBinEdge.size() + 5;
73+
}
74+
};
75+
76+
void initHists(const std::string& name, const std::string& title, int nBins, double minRange, double maxRange, int binsInStep = 50, int binMax = 4095, int axis = 0);
77+
static std::vector<double> makeVaribleBins(const std::vector<std::pair<int, int>>& vecParams, int binMax = 4095);
78+
static std::vector<double> makeVaribleBins(int binsInStep = 50, int binMax = 4095);
79+
std::size_t serialize(std::vector<Content_t>& vecDst, size_t startPos);
80+
std::size_t deserialize(std::vector<Content_t>& vecDst, size_t startPos);
81+
std::size_t addContent(const std::span<const Content_t>& vecSrc, size_t startPos);
82+
};
83+
84+
template <std::size_t NCHANNELS, std::size_t NADC>
85+
using AmpTimeDistributionDetector = std::array<std::array<AmpTimeDistribution, NCHANNELS>, NADC>;
86+
87+
} // namespace o2::fit
88+
#endif
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
// \file HelperTypes.h
13+
/// \brief Helper with metafunctions for type definitions
14+
/// \author Artur Furs afurs@cern.ch
15+
16+
#ifndef O2_FIT_HELPER_TYPES_H_
17+
#define O2_FIT_HELPER_TYPES_H_
18+
19+
#include <boost/mpl/map.hpp>
20+
#include <boost/mpl/find.hpp>
21+
#include <boost/mpl/placeholders.hpp>
22+
#include <Vc/Vc>
23+
#include "TH1.h"
24+
namespace o2
25+
{
26+
namespace fit
27+
{
28+
namespace helper
29+
{
30+
31+
template <typename T>
32+
struct VcType {
33+
typedef TH2F Hist2F_t;
34+
typedef boost::mpl::map<
35+
boost::mpl::pair<float, Vc::float_v>,
36+
boost::mpl::pair<double, Vc::double_v>,
37+
boost::mpl::pair<int, Vc::int_v>,
38+
boost::mpl::pair<unsigned int, Vc::uint_v>,
39+
boost::mpl::pair<long, Vc::long_v>,
40+
boost::mpl::pair<unsigned long, Vc::ulong_v>,
41+
boost::mpl::pair<short, Vc::short_v>,
42+
boost::mpl::pair<unsigned short, Vc::ushort_v>,
43+
boost::mpl::pair<char, Vc::char_v>,
44+
boost::mpl::pair<unsigned char, Vc::uchar_v>,
45+
boost::mpl::pair<long long, Vc::longlong_v>,
46+
boost::mpl::pair<unsigned long long, Vc::ulonglong_v>>
47+
MapTypeToVc;
48+
typedef typename mpl::at<MapType, T>::type type;
49+
};
50+
51+
template <typename T>
52+
struct HistType {
53+
typedef TH2F Hist2F_t;
54+
typedef boost::mpl::map<
55+
boost::mpl::pair<float, Vc::float_v>,
56+
boost::mpl::pair<double, Vc::double_v>,
57+
boost::mpl::pair<int, Vc::int_v>,
58+
boost::mpl::pair<unsigned int, Vc::uint_v>,
59+
boost::mpl::pair<long, Vc::long_v>,
60+
boost::mpl::pair<unsigned long, Vc::ulong_v>,
61+
boost::mpl::pair<short, Vc::short_v>,
62+
boost::mpl::pair<unsigned short, Vc::ushort_v>,
63+
boost::mpl::pair<char, Vc::char_v>,
64+
boost::mpl::pair<unsigned char, Vc::uchar_v>,
65+
boost::mpl::pair<long long, Vc::longlong_v>,
66+
boost::mpl::pair<unsigned long long, Vc::ulonglong_v>>
67+
MapType;
68+
typedef typename mpl::at<MapType, T>::type type;
69+
};
70+
71+
} // namespace helper
72+
} // namespace fit
73+
} // namespace o2
74+
75+
#endif

0 commit comments

Comments
 (0)