Project
Loading...
Searching...
No Matches
CollisionTimeRecoTask.cxx
Go to the documentation of this file.
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
14
16#include <fairlogger/Logger.h> // for LOG
18#include "FT0Base/Geometry.h"
19#include "FT0Base/FT0DigParam.h"
24#include <cmath>
25#include <bitset>
26#include <cassert>
27#include <iostream>
29#include <Framework/Logger.h>
30
31using namespace o2::ft0;
33
34void CollisionTimeRecoTask::processTF(const gsl::span<const o2::ft0::Digit>& digits,
35 const gsl::span<const o2::ft0::ChannelData>& channels,
36 std::vector<o2::ft0::RecPoints>& vecRecPoints,
37 std::vector<o2::ft0::ChannelDataFloat>& vecChData)
38{
39 for (const auto& digit : digits) {
40 if (!ChannelFilterParam::Instance().checkTCMbits(digit.getTriggers().getTriggersignals())) {
41 continue;
42 }
43 const auto channelsPerDigit = digit.getBunchChannelData(channels);
44 vecRecPoints.emplace_back(processDigit(digit, channelsPerDigit, vecChData));
45 }
46}
48 const gsl::span<const o2::ft0::ChannelData> inChData,
49 std::vector<o2::ft0::ChannelDataFloat>& outChData)
50{
51 LOG(debug) << "Running reconstruction on new event";
52 const int firstEntry = outChData.size();
53 unsigned int ndigitsA = 0;
54 unsigned int ndigitsC = 0;
55 float sideAtime = 0;
56 float sideCtime = 0;
57
58 constexpr int nMCPsA = 4 * Geometry::NCellsA;
59
60 int nch{0};
61 bool isActiveA = false;
62 bool isActiveC = false;
63 bool isFlangeEvent = false;
64
65 for (const auto& channelData : inChData) {
66 if (channelData.ChId >= NCHANNELS) {
67 // Reference channels shouldn't participate in reco at all!
68 continue;
69 }
70 const float timeInPS = getTimeInPS(channelData);
71 if (ChannelFilterParam::Instance().checkAll(channelData)) {
72 outChData.emplace_back(channelData.ChId, timeInPS, (float)channelData.QTCAmpl, channelData.ChainQTC);
73 nch++;
74 }
75 const bool isOkForTimeCalc = TimeFilterParam::Instance().checkAll(channelData);
76 // only signals which satisfy conditions may participate in time calculation
77 if (channelData.ChId < nMCPsA) {
78 // A-side
79 if (isOkForTimeCalc) {
80 sideAtime += timeInPS;
81 ndigitsA++;
82 }
83 isActiveA = true;
84 } else {
85 // C-side
86 if (isOkForTimeCalc) {
87 sideCtime += timeInPS;
88 ndigitsC++;
89 }
90 isActiveC = true;
91 isFlangeEvent |= channelData.CFDTime < -350 && channelData.CFDTime > -450;
92 }
93 }
95
96 mCollisionTime[TimeA] = (ndigitsA > 0) ? std::round(sideAtime / ndigitsA) : RP::sDummyCollissionTime; // 2 * o2::InteractionRecord::DummyTime;
97 mCollisionTime[TimeC] = (ndigitsC > 0) ? std::round(sideCtime / ndigitsC) : RP::sDummyCollissionTime; // 2 * o2::InteractionRecord::DummyTime;
98
99 if (ndigitsA > 0 && ndigitsC > 0) {
100 mCollisionTime[Vertex] = (mCollisionTime[TimeA] - mCollisionTime[TimeC]) / 2.;
101 mCollisionTime[TimeMean] = (mCollisionTime[TimeA] + mCollisionTime[TimeC]) / 2.;
102 } else {
103 mCollisionTime[TimeMean] = std::min(mCollisionTime[TimeA], mCollisionTime[TimeC]);
104 }
105 const uint8_t extraTrgWord = RecPoints::makeExtraTrgWord(isActiveA, isActiveC, isFlangeEvent);
106 return RecPoints(firstEntry, nch, digit.mIntRecord, mCollisionTime, digit.mTriggers, extraTrgWord);
107}
108//______________________________________________________
110{
111 // finalize digitization, if needed, flash remaining digits
112 // if (!mContinuous) return;
113}
114
116{
117 // Getting time offset
118 float offsetChannel{0};
119 if (mTimeCalibObject) {
120 // Temporary, will be changed to status bit checking
121 // Check statistics
122 const auto& stat = mTimeCalibObject->mTime[channelData.ChId].mStat;
123 const bool isEnoughStat = stat > CalibParam::Instance().mMaxEntriesThreshold;
124 const bool isNotGoogStat = stat > CalibParam::Instance().mMinEntriesThreshold && !isEnoughStat;
125 // Check fit quality
126 const auto& meanGaus = mTimeCalibObject->mTime[channelData.ChId].mGausMean;
127 const auto& meanHist = mTimeCalibObject->mTime[channelData.ChId].mStatMean;
128 const auto& sigmaGaus = mTimeCalibObject->mTime[channelData.ChId].mGausRMS;
129 const auto& rmsHist = mTimeCalibObject->mTime[channelData.ChId].mStatRMS;
130 const bool isGoodFitResult = (mTimeCalibObject->mTime[channelData.ChId].mStatusBits & 1) > 0;
131 const bool isBadFit = std::abs(meanGaus - meanHist) > CalibParam::Instance().mMaxDiffMean || rmsHist < CalibParam::Instance().mMinRMS || sigmaGaus > CalibParam::Instance().mMaxSigma;
132
133 if (isEnoughStat && isGoodFitResult && !isBadFit) {
134 offsetChannel = meanGaus;
135 } else if ((isNotGoogStat || isEnoughStat) && isBadFit) {
136 offsetChannel = meanHist;
137 }
138 }
139 // Getting slewing offset
140 float slewoffset{0};
141 const auto& gr = mCalibSlew[static_cast<int>(channelData.getFlag(o2::ft0::ChannelData::EEventDataBit::kNumberADC))][channelData.ChId];
142 slewoffset = gr.Eval(channelData.QTCAmpl);
143
144 // Final calculation
145 const float globalOffset = offsetChannel + slewoffset;
146 return (static_cast<float>(channelData.CFDTime) - globalOffset) * Geometry::ChannelWidth;
147}
Definition of the FDD reconstruction.
Configurable digit filtering.
Class to describe fired and stored channels for the BC and to refer to channel data.
Configurable digitization parameters.
Definition of the FIT RecPoints class.
std::ostringstream debug
float getTimeInPS(const o2::ft0::ChannelData &channelData)
o2::ft0::RecPoints processDigit(const o2::ft0::Digit &digit, const gsl::span< const o2::ft0::ChannelData > inChData, std::vector< o2::ft0::ChannelDataFloat > &outChData)
void processTF(const gsl::span< const o2::ft0::Digit > &digits, const gsl::span< const o2::ft0::ChannelData > &channels, std::vector< o2::ft0::RecPoints > &vecRecPoints, std::vector< o2::ft0::ChannelDataFloat > &vecChData)
static constexpr int NCellsA
Definition Geometry.h:52
static constexpr float ChannelWidth
Definition Geometry.h:56
static constexpr uint8_t makeExtraTrgWord(bool isActiveA=true, bool isActiveC=true, bool isFlangeEvent=true)
Definition RecPoints.h:134
static short constexpr sDummyCollissionTime
Definition RecPoints.h:143
gsl::span< const ChannelDataFloat > getBunchChannelData(const gsl::span< const ChannelDataFloat > tfdata) const
Definition RecPoints.cxx:29
std::size_t mMaxEntriesThreshold
Definition CalibParam.h:29
std::size_t mMinEntriesThreshold
Definition CalibParam.h:28
bool getFlag(EEventDataBit bitFlag) const
Definition ChannelData.h:65
bool checkTCMbits(uint8_t tcmBits) const
o2::InteractionRecord mIntRecord
Definition Digit.h:64
Triggers mTriggers
Definition Digit.h:62
bool checkAll(const o2::ft0::ChannelData &channelData) const
std::array< SpectraInfoObject, o2::ft0::Geometry::Nchannels > mTime
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< ChannelData > channels
std::vector< Digit > digits