Skip to content

Commit f3e25c7

Browse files
author
afurs
committed
AFIT-98: new amp-time calibration for slewing
1 parent f4f8f43 commit f3e25c7

File tree

8 files changed

+559
-0
lines changed

8 files changed

+559
-0
lines changed

DataFormats/Detectors/FIT/FT0/CMakeLists.txt

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

2324
PUBLIC_LINK_LIBRARIES O2::FT0Base
2425
O2::DataFormatsFIT
@@ -47,4 +48,5 @@ o2_target_root_dictionary(DataFormatsFT0
4748
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
4849
include/DataFormatsFT0/SpectraInfoObject.h
4950
include/DataFormatsFT0/SlewingCoef.h
51+
include/DataFormatsFT0/SlewingCurve.h
5052
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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_FT0SLEWINGCURVE_H
13+
#define O2_FT0SLEWINGCURVE_H
14+
15+
#include "TH2F.h"
16+
17+
#include <string>
18+
#include <memory>
19+
#include <utility>
20+
#include <vector>
21+
22+
namespace o2::ft0
23+
{
24+
25+
struct SlewingCurve {
26+
typedef TH2F Hist2D_t;
27+
std::unique_ptr<Hist2D_t> mHist=nullptr;
28+
SlewingCurve() = default;
29+
SlewingCurve(const std::string &name, const std::string &title, int nBins, double minRange, double maxRange, int binsInStep=50, int binMax = 4095, int axis=0);
30+
31+
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);
32+
static std::vector<double> makeVaribleBins(const std::vector<std::pair<int, int> > &vecParams, int binMax=4095);
33+
static std::vector<double> makeVaribleBins(int binsInStep=50, int binMax = 4095);
34+
size_t fillContent(std::vector<Double_t> &vecDst, size_t startPos);
35+
};
36+
} // namespace o2::ft0
37+
#endif
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 "DataFormatsFT0/SlewingCurve.h"
13+
#include <cstring>
14+
using namespace o2::ft0;
15+
16+
SlewingCurve::SlewingCurve(const std::string &name, const std::string &title, int nBins, double minRange, double maxRange, int binsInStep, int binMax, int axis) {
17+
initHists(name, title, nBins, minRange, maxRange, binsInStep, binMax, axis);
18+
}
19+
20+
void SlewingCurve::initHists(const std::string &name, const std::string &title, int nBins, double minRange, double maxRange, int binsInStep, int binMax, int axis) {
21+
const auto &varBins = makeVaribleBins(binsInStep, binMax);
22+
const int varNbins = varBins.size()-1;
23+
if(axis==0) {
24+
mHist = std::make_unique<Hist2D_t>(name.c_str(), title.c_str(), varNbins, varBins.data(), nBins, minRange, maxRange);
25+
}
26+
else if(axis==1) {
27+
mHist = std::make_unique<Hist2D_t>(name.c_str(), title.c_str(), nBins, minRange, maxRange, varNbins, varBins.data());
28+
}
29+
}
30+
31+
std::vector<double> SlewingCurve::makeVaribleBins(const std::vector<std::pair<int, int> > &vecParams, int binMax) {
32+
std::vector<double> vecLowEdgeBins{};
33+
int startBin{0};
34+
auto makeBinRange = [&vec = vecLowEdgeBins, binMax](int startBin, int binWidth, int nBins) {
35+
const int endBin = startBin + binWidth * nBins;
36+
for(int iBin=startBin;iBin<endBin;iBin+=binWidth) {
37+
vec.emplace_back(static_cast<double>(iBin));
38+
if(iBin>binMax) {
39+
break;
40+
}
41+
}
42+
return endBin;
43+
};
44+
for(const auto &entry: vecParams) {
45+
startBin = makeBinRange(startBin , entry.first, entry.second);
46+
}
47+
return vecLowEdgeBins;
48+
}
49+
50+
std::vector<double> SlewingCurve::makeVaribleBins(int binsInStep, int binMax) {
51+
auto generateParams = [](int binsInStep, int binMax) {
52+
std::vector<std::pair<int, int> > vecParams{};
53+
int endBin{0};
54+
int binWidth=1;
55+
while(endBin<binMax) {
56+
vecParams.push_back({binWidth, binsInStep});
57+
endBin+=(binWidth*binsInStep);
58+
binWidth*=2;
59+
}
60+
return vecParams;
61+
};
62+
return makeVaribleBins(generateParams(binsInStep, binMax), binMax);
63+
}
64+
65+
size_t SlewingCurve::fillContent(std::vector<Double_t> &vecDst, size_t startPos) {
66+
const size_t cnt = sizeof(Double_t) * mHist->GetNcells();
67+
std::memcpy(&vecDst[startPos], mHist->fArray, cnt);
68+
return startPos + mHist->GetNcells();
69+
}

Detectors/FIT/FT0/base/include/FT0Base/Constants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ struct Constants {
3333
constexpr static std::size_t sNCHANNELS_PM = sNPM * sNCHANNELS_PER_PM; //Number of PM(not LCS) channels
3434
constexpr static std::size_t sNCHANNELS_PM_LCS = sNPM_LCS * sNCHANNELS_PER_PM; //Number of PM_LCS channels
3535
constexpr static std::size_t sNTOTAL_CHANNELS_PM = sNCHANNELS_PM + sNCHANNELS_PM_LCS; //Total number of PM(+LCS) channels
36+
constexpr static std::size_t sNCHANNELS = 208; //Total channel number
37+
constexpr static std::size_t sNADC = 2; //Total ADCs number
38+
3639
};
3740

3841
} // namespace ft0

Detectors/FIT/FT0/calibration/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ o2_add_library(FT0Calibration
3333
PUBLIC_LINK_LIBRARIES
3434
O2::FT0Calibration
3535
)
36+
o2_add_executable(ft0-amp-time-spectra-processor
37+
COMPONENT_NAME calibration
38+
SOURCES workflow/FT0AmpTimeSpectraProcessor-Workflow.cxx
39+
PUBLIC_LINK_LIBRARIES
40+
O2::FT0Calibration
41+
)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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_FT0SLEWINGSLOTCONTAINER_H
13+
#define O2_FT0SLEWINGSLOTCONTAINER_H
14+
15+
#include <bitset>
16+
#include <array>
17+
18+
#include "CommonDataFormat/FlatHisto2D.h"
19+
#include "DataFormatsFT0/SpectraInfoObject.h"
20+
#include "DetectorsCalibration/TimeSlotCalibration.h"
21+
#include "DetectorsCalibration/TimeSlot.h"
22+
23+
#include "TList.h"
24+
25+
#include "Rtypes.h"
26+
namespace o2::ft0
27+
{
28+
29+
class FT0SlewingSlotContainer final
30+
{
31+
static constexpr int sNCHANNELS = o2::ft0::Geometry::Nchannels;
32+
using TimeSlot = o2::calibration::TimeSlot<FT0TimeOffsetSlotContainer>;
33+
using TimeSlotCalibration = o2::calibration::TimeSlotCalibration<FT0TimeOffsetSlotContainer>;
34+
35+
public:
36+
FT0SlewingSlotContainer(std::size_t minEntries); // constructor is needed due to current version of FITCalibration library, should be removed
37+
FT0SlewingSlotContainer(FT0SlewingSlotContainer const&) = default;
38+
FT0SlewingSlotContainer(FT0SlewingSlotContainer&&) = default;
39+
FT0SlewingSlotContainer& operator=(FT0SlewingSlotContainer&) = default;
40+
FT0SlewingSlotContainer& operator=(FT0SlewingSlotContainer&&) = default;
41+
bool hasEnoughEntries() const;
42+
void fill(const gsl::span<const float>& data);
43+
SpectraInfoObject getSpectraInfoObject(std::size_t channelID, TList* listHists) const;
44+
void merge(FT0TimeOffsetSlotContainer* prev);
45+
void print() const;
46+
TimeSpectraInfoObject generateCalibrationObject(long tsStartMS, long tsEndMS, const std::string& pathToHists) const;
47+
typedef float FlatHistoValue_t;
48+
typedef o2::dataformats::FlatHisto2D<FlatHistoValue_t> FlatHisto2D_t;
49+
auto getHistogram() const { return mHistogram; }
50+
auto isFirstTF() const { return mIsFirstTF; }
51+
52+
private:
53+
// Slot number
54+
uint8_t mCurrentSlot = 0;
55+
// Status of channels, pending channels = !(good | bad)
56+
std::bitset<sNCHANNELS> mBitsetBadChIDs;
57+
std::bitset<sNCHANNELS> mBitsetGoodChIDs;
58+
// For hist init, for making hist ranges dynamic
59+
bool mIsFirstTF{true};
60+
// For slot finalizing
61+
bool mIsReady{false};
62+
// Once it is upper than max entry threshold it stops increasing
63+
std::array<std::size_t, sNCHANNELS> mArrEntries{};
64+
// Total number of events
65+
uint64_t mTotalNevents{0};
66+
// Contains all information about time spectra
67+
FlatHisto2D_t mHistogram;
68+
ClassDefNV(FT0SlewingSlotContainer, 1);
69+
};
70+
} // namespace o2::ft0
71+
72+
#endif // O2_FT0SLEWINGSLOTCONTAINER_H

0 commit comments

Comments
 (0)