Skip to content

Commit e6ca521

Browse files
authored
FT0Calibration: slewing added + some bugfixes for time offset calib (#12328)
* FT0Calibration: slewing added + some bugfixes for time offset calibration * files added * changing struct to pair<vector,vector> for optimized TGraph init
1 parent aaa1300 commit e6ca521

13 files changed

Lines changed: 145 additions & 48 deletions

File tree

DataFormats/Detectors/FIT/FT0/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ o2_add_library(DataFormatsFT0
1818
src/RawEventData.cxx
1919
src/CTF.cxx
2020
src/LookUpTable.cxx
21+
src/SlewingCoef.cxx
22+
2123
PUBLIC_LINK_LIBRARIES O2::FT0Base
2224
O2::DataFormatsFIT
2325
O2::SimulationDataFormat
@@ -43,4 +45,5 @@ o2_target_root_dictionary(DataFormatsFT0
4345
include/DataFormatsFT0/GlobalOffsetsInfoObject.h
4446
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
4547
include/DataFormatsFT0/SpectraInfoObject.h
48+
include/DataFormatsFT0/SlewingCoef.h
4649
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 ALICEO2_FT0_SLEWINGCOEF_H_
13+
#define ALICEO2_FT0_SLEWINGCOEF_H_
14+
////////////////////////////////////////////////
15+
// Slewing coefficients for FT0
16+
//////////////////////////////////////////////
17+
#include "TGraph.h"
18+
#include "Rtypes.h"
19+
20+
#include <vector>
21+
#include <array>
22+
#include <utility>
23+
24+
namespace o2
25+
{
26+
namespace ft0
27+
{
28+
29+
struct SlewingCoef {
30+
constexpr static int sNCHANNELS = 208;
31+
constexpr static int sNAdc = 2;
32+
using VecPoints_t = std::vector<Double_t>; // Set of points
33+
using VecPlot_t = std::pair<VecPoints_t, VecPoints_t>; // Plot as pair of two set of points
34+
using VecSlewingCoefs_t = std::array<std::array<VecPlot_t, sNCHANNELS>, sNAdc>; // 0 - adc0, 1 - adc1
35+
typedef std::array<std::array<TGraph, sNCHANNELS>, sNAdc> SlewingPlots_t;
36+
VecSlewingCoefs_t mSlewingCoefs{};
37+
SlewingPlots_t makeSlewingPlots() const;
38+
constexpr static const char* getObjectPath()
39+
{
40+
return "FT0/Calib/SlewingCoef";
41+
}
42+
ClassDefNV(SlewingCoef, 1)
43+
};
44+
} // namespace ft0
45+
} // namespace o2
46+
47+
#endif

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@
5353
#pragma link C++ class o2::ft0::GlobalOffsetsCalibrationObject + ;
5454
#pragma link C++ class o2::ft0::RecoCalibInfoObject + ;
5555
#pragma link C++ class o2::ft0::GlobalOffsetsInfoObject + ;
56+
#pragma link C++ class std::pair < std::vector < double>, std::vector < double>> + ;
57+
#pragma link C++ class o2::ft0::SlewingCoef + ;
5658
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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/SlewingCoef.h"
13+
#include <cassert>
14+
using namespace o2::ft0;
15+
16+
SlewingCoef::SlewingPlots_t SlewingCoef::makeSlewingPlots() const
17+
{
18+
typename o2::ft0::SlewingCoef::SlewingPlots_t plots{};
19+
for (int iAdc = 0; iAdc < sNAdc; iAdc++) {
20+
const auto& slewingCoefs = mSlewingCoefs[iAdc];
21+
auto& plotsAdc = plots[iAdc];
22+
for (int iCh = 0; iCh < sNCHANNELS; iCh++) {
23+
const auto& points_x = slewingCoefs[iCh].first;
24+
const auto& points_y = slewingCoefs[iCh].second;
25+
assert(points_x.size() == points_y.size());
26+
const int nPoints = points_x.size();
27+
auto& plot = plotsAdc[iCh];
28+
plot = TGraph(nPoints, points_x.data(), points_y.data());
29+
}
30+
}
31+
return plots;
32+
}

Detectors/FIT/FT0/reconstruction/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ o2_add_library(FT0Reconstruction
2525
O2::DetectorsCalibration)
2626

2727
o2_target_root_dictionary(FT0Reconstruction
28-
HEADERS include/FT0Reconstruction/CollisionTimeRecoTask.h
29-
include/FT0Reconstruction/InteractionTag.h)
28+
HEADERS include/FT0Reconstruction/InteractionTag.h)
3029

3130
o2_add_executable(
3231
test-raw-conversion

Detectors/FIT/FT0/reconstruction/include/FT0Reconstruction/CollisionTimeRecoTask.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "DataFormatsFT0/RecPoints.h"
2121
#include "DataFormatsFT0/FT0ChannelTimeCalibrationObject.h"
2222
#include "DataFormatsFT0/SpectraInfoObject.h"
23+
#include "DataFormatsFT0/SlewingCoef.h"
2324
#include <gsl/span>
2425
#include <array>
2526
#include <vector>
@@ -51,18 +52,16 @@ class CollisionTimeRecoTask
5152
std::vector<o2::ft0::ChannelDataFloat>& outChData);
5253
void FinishTask();
5354
void SetTimeCalibObject(o2::ft0::TimeSpectraInfoObject const* timeCalibObject) { mTimeCalibObject = timeCalibObject; };
54-
void SetSlew(std::array<TGraph, NCHANNELS>* calibslew)
55+
void SetSlewingCalibObject(o2::ft0::SlewingCoef const* calibSlew)
5556
{
56-
LOG(info) << "@@@SetSlew " << calibslew->size();
57-
mCalibSlew = calibslew;
57+
LOG(info) << "Init for slewing calib object";
58+
mCalibSlew = calibSlew->makeSlewingPlots();
5859
};
5960
float getTimeInPS(const o2::ft0::ChannelData& channelData);
6061

6162
private:
6263
o2::ft0::TimeSpectraInfoObject const* mTimeCalibObject = nullptr;
63-
std::array<TGraph, NCHANNELS>* mCalibSlew = nullptr;
64-
65-
ClassDefNV(CollisionTimeRecoTask, 3);
64+
typename o2::ft0::SlewingCoef::SlewingPlots_t mCalibSlew{};
6665
};
6766
} // namespace ft0
6867
} // namespace o2

Detectors/FIT/FT0/reconstruction/src/CollisionTimeRecoTask.cxx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ void CollisionTimeRecoTask::processTF(const gsl::span<const o2::ft0::Digit>& dig
3636
std::vector<o2::ft0::RecPoints>& vecRecPoints,
3737
std::vector<o2::ft0::ChannelDataFloat>& vecChData)
3838
{
39-
// vecRecPoints.reserve(digits.size());
40-
// vecChData.reserve(channels.size());
4139
for (const auto& digit : digits) {
4240
if (!ChannelFilterParam::Instance().checkTCMbits(digit.getTriggers().getTriggersignals())) {
4341
continue;
@@ -58,28 +56,31 @@ RP CollisionTimeRecoTask::processDigit(const o2::ft0::Digit& digit,
5856
float sideCtime = 0;
5957

6058
constexpr int nMCPsA = 4 * Geometry::NCellsA;
61-
const auto parInv = FT0DigParam::Instance().mMV_2_NchannelsInverse;
6259

6360
int nch{0};
6461
for (const auto& channelData : inChData) {
62+
if (channelData.ChId >= NCHANNELS) {
63+
// Reference channels shouldn't participate in reco at all!
64+
continue;
65+
}
6566
const float timeInPS = getTimeInPS(channelData);
6667
if (ChannelFilterParam::Instance().checkAll(channelData)) {
6768
outChData.emplace_back(channelData.ChId, timeInPS, (float)channelData.QTCAmpl, channelData.ChainQTC);
6869
nch++;
6970
}
70-
// only signals with amplitude participate in collision time
71+
// only signals which satisfy conditions may participate in time calculation
7172
if (TimeFilterParam::Instance().checkAll(channelData)) {
7273
if (channelData.ChId < nMCPsA) {
7374
sideAtime += timeInPS;
7475
ndigitsA++;
75-
} else if (channelData.ChId < NCHANNELS) {
76+
} else {
7677
sideCtime += timeInPS;
7778
ndigitsC++;
7879
}
7980
}
8081
}
8182
std::array<short, 4> mCollisionTime = {RP::sDummyCollissionTime, RP::sDummyCollissionTime, RP::sDummyCollissionTime, RP::sDummyCollissionTime};
82-
// !!!! tobe done::should be fix with ITS vertex
83+
8384
mCollisionTime[TimeA] = (ndigitsA > 0) ? sideAtime / ndigitsA : RP::sDummyCollissionTime; // 2 * o2::InteractionRecord::DummyTime;
8485
mCollisionTime[TimeC] = (ndigitsC > 0) ? sideCtime / ndigitsC : RP::sDummyCollissionTime; // 2 * o2::InteractionRecord::DummyTime;
8586

@@ -100,9 +101,9 @@ void CollisionTimeRecoTask::FinishTask()
100101

101102
float CollisionTimeRecoTask::getTimeInPS(const o2::ft0::ChannelData& channelData)
102103
{
104+
// Getting time offset
103105
float offsetChannel{0};
104-
float slewoffset{0};
105-
if (mTimeCalibObject && channelData.ChId < NCHANNELS) {
106+
if (mTimeCalibObject) {
106107
// Temporary, will be changed to status bit checking
107108
// Check statistics
108109
const auto& stat = mTimeCalibObject->mTime[channelData.ChId].mStat;
@@ -122,12 +123,12 @@ float CollisionTimeRecoTask::getTimeInPS(const o2::ft0::ChannelData& channelData
122123
offsetChannel = meanHist;
123124
}
124125
}
125-
/*
126-
if (mCalibSlew && channelData.ChId < NCHANNELS) {
127-
TGraph& gr = mCalibSlew->at(channelData.ChId);
128-
slewoffset = gr.Eval(channelData.QTCAmpl);
129-
}
130-
*/
131-
const float globalOffset = (offsetChannel + slewoffset) * Geometry::ChannelWidth;
132-
return float(channelData.CFDTime) * Geometry::ChannelWidth - globalOffset;
126+
// Getting slewing offset
127+
float slewoffset{0};
128+
const auto& gr = mCalibSlew[static_cast<int>(channelData.getFlag(o2::ft0::ChannelData::EEventDataBit::kNumberADC))][channelData.ChId];
129+
slewoffset = gr.Eval(channelData.QTCAmpl);
130+
131+
// Final calculation
132+
const float globalOffset = offsetChannel + slewoffset;
133+
return (static_cast<float>(channelData.CFDTime) - globalOffset) * Geometry::ChannelWidth;
133134
}

Detectors/FIT/FT0/reconstruction/src/FT0ReconstructionLinkDef.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#pragma link off all classes;
1616
#pragma link off all functions;
1717

18-
#pragma link C++ class o2::ft0::CollisionTimeRecoTask + ;
1918
#pragma link C++ class o2::ft0::InteractionTag + ;
2019

2120
#endif

Detectors/FIT/FT0/workflow/include/FT0Workflow/RecoWorkflow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace o2
2020
{
2121
namespace ft0
2222
{
23-
framework::WorkflowSpec getRecoWorkflow(bool useMC, std::string ccdbpath, bool useTimeOffsetCalib, bool disableRootInp, bool disableRootOut);
23+
framework::WorkflowSpec getRecoWorkflow(bool useMC, std::string ccdbpath, bool useTimeOffsetCalib, bool useSlewingCalib, bool disableRootInp, bool disableRootOut);
2424
} // namespace ft0
2525
} // namespace o2
2626
#endif

Detectors/FIT/FT0/workflow/include/FT0Workflow/ReconstructionSpec.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ReconstructionDPL : public Task
3434
static constexpr int NCHANNELS = o2::ft0::Geometry::Nchannels;
3535

3636
public:
37-
ReconstructionDPL(bool useMC, const std::string& ccdbpath, bool useTimeOffsetCalib) : mUseMC(useMC), mCCDBpath(ccdbpath), mUseTimeOffsetCalib(useTimeOffsetCalib) {}
37+
ReconstructionDPL(bool useMC, const std::string& ccdbpath, bool useTimeOffsetCalib, bool useSlewingCalib) : mUseMC(useMC), mCCDBpath(ccdbpath), mUseTimeOffsetCalib(useTimeOffsetCalib), mUseSlewingCalib(useSlewingCalib) {}
3838
~ReconstructionDPL() override = default;
3939
void init(InitContext& ic) final;
4040
void run(ProcessingContext& pc) final;
@@ -44,7 +44,8 @@ class ReconstructionDPL : public Task
4444
private:
4545
bool mUseMC = false;
4646
bool mUpdateCCDB = true;
47-
const bool mUseTimeOffsetCalib = true;
47+
bool mUseTimeOffsetCalib = true;
48+
bool mUseSlewingCalib = true;
4849
const std::string mCCDBpath = o2::base::NameConf::getCCDBServer();
4950
std::vector<o2::ft0::RecPoints> mRecPoints;
5051
std::vector<o2::ft0::ChannelDataFloat> mRecChData;
@@ -54,7 +55,7 @@ class ReconstructionDPL : public Task
5455
};
5556

5657
/// create a processor spec
57-
framework::DataProcessorSpec getReconstructionSpec(bool useMC = false, const std::string ccdbpath = "http://alice-ccdb.cern.ch", bool useTimeOffsetCalib = true);
58+
framework::DataProcessorSpec getReconstructionSpec(bool useMC = false, const std::string ccdbpath = "http://alice-ccdb.cern.ch", bool useTimeOffsetCalib = true, bool useSlewingCalib = true);
5859

5960
} // namespace ft0
6061
} // namespace o2

0 commit comments

Comments
 (0)