Project
Loading...
Searching...
No Matches
test_ctf_io_fdd.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
12#define BOOST_TEST_MODULE Test FDDCTFIO
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#undef NDEBUG
17#include <cassert>
18
19#include <boost/test/unit_test.hpp>
20#include <boost/test/data/test_case.hpp>
21#include <boost/test/data/dataset.hpp>
24#include "FDDBase/Constants.h"
25#include "Framework/Logger.h"
26#include <TFile.h>
27#include <TRandom.h>
28#include <TStopwatch.h>
29#include <cstring>
30
31using namespace o2::fdd;
32namespace boost_data = boost::unit_test::data;
33
34inline std::vector<o2::ctf::ANSHeader> ANSVersions{o2::ctf::ANSVersionCompat, o2::ctf::ANSVersion1};
35
36BOOST_DATA_TEST_CASE(CTFTest, boost_data::make(ANSVersions), ansVersion)
37{
38 std::vector<Digit> digits;
39 std::vector<ChannelData> channels;
40 TStopwatch sw;
41 sw.Start();
43
44 for (int idig = 0; idig < 1000; idig++) {
45 ir += 1 + gRandom->Integer(200);
46 uint8_t ich = gRandom->Poisson(4);
47 auto start = channels.size();
48 int16_t tMeanA = 0, tMeanC = 0;
49 int32_t ampTotA = 0, ampTotC = 0;
50 int8_t nChanA = 0, nChanC = 0;
51 while (ich < Nchannels) {
52 int16_t t = -2048 + gRandom->Integer(2048 * 2);
53 uint16_t q = gRandom->Integer(4096);
54 uint8_t feb = gRandom->Rndm() > 0.5 ? 0 : 1;
55 channels.emplace_back(ich, t, q, feb);
56 if (ich > 7) {
57 nChanA++;
58 ampTotA += q;
59 tMeanA += t;
60 } else {
61 nChanC++;
62 ampTotC += q;
63 tMeanC += t;
64 }
65 ich += 1 + gRandom->Poisson(4);
66 }
67 if (nChanA) {
68 tMeanA /= nChanA;
69 ampTotA *= 0.125;
70 } else {
73 }
74 if (nChanC) {
75 tMeanC /= nChanC;
76 ampTotC *= 0.125; // sum/8
77 } else {
80 }
81 Triggers trig;
82 trig.setTriggers(gRandom->Integer(128), nChanA, nChanC, ampTotA, ampTotC, tMeanA, tMeanC);
83 auto end = channels.size();
84 digits.emplace_back(start, end - start, ir, trig);
85 }
86
87 LOG(info) << "Generated " << channels.size() << " channels in " << digits.size() << " digits " << sw.CpuTime() << " s";
88
89 sw.Start();
90 std::vector<o2::ctf::BufferType> vec;
91 {
93 coder.setANSVersion(ansVersion);
94 coder.encode(vec, digits, channels); // compress
95 }
96 sw.Stop();
97 LOG(info) << "Compressed in " << sw.CpuTime() << " s";
98
99 // writing
100 {
101 sw.Start();
102 TFile flOut("test_ctf_fdd.root", "recreate");
103 TTree ctfTree(std::string(o2::base::NameConf::CTFTREENAME).c_str(), "O2 CTF tree");
105 ctfImage->print();
106 ctfImage->appendToTree(ctfTree, "FDD");
107 ctfTree.Write();
108 sw.Stop();
109 LOG(info) << "Wrote to tree in " << sw.CpuTime() << " s";
110 }
111
112 // reading
113 vec.clear();
114 {
115 sw.Start();
116 TFile flIn("test_ctf_fdd.root");
117 std::unique_ptr<TTree> tree((TTree*)flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()));
119 o2::fdd::CTF::readFromTree(vec, *(tree.get()), "FDD");
120 sw.Stop();
121 LOG(info) << "Read back from tree in " << sw.CpuTime() << " s";
122 }
123
124 std::vector<Digit> digitsD;
125 std::vector<ChannelData> channelsD;
126
127 sw.Start();
128 const auto ctfImage = o2::fdd::CTF::getImage(vec.data());
129 {
131 coder.decode(ctfImage, digitsD, channelsD); // decompress
132 }
133 sw.Stop();
134 LOG(info) << "Decompressed in " << sw.CpuTime() << " s";
135
136 BOOST_CHECK(digitsD.size() == digits.size());
137 BOOST_CHECK(channelsD.size() == channels.size());
138 LOG(info) << " BOOST_CHECK digitsD.size() " << digitsD.size() << " digits.size() " << digits.size() << " BOOST_CHECK(channelsD.size() " << channelsD.size() << " channels.size()) " << channels.size();
139
140 for (int i = digits.size(); i--;) {
141 const auto& dor = digits[i];
142 const auto& ddc = digitsD[i];
143 LOG(debug) << " dor " << dor.mTriggers.print();
144 LOG(debug) << " ddc " << ddc.mTriggers.print();
145
146 BOOST_CHECK(dor.mIntRecord == ddc.mIntRecord);
147 BOOST_CHECK(dor.ref == ddc.ref);
148 BOOST_CHECK(dor.mTriggers.getNChanA() == ddc.mTriggers.getNChanA());
149 BOOST_CHECK(dor.mTriggers.getNChanC() == ddc.mTriggers.getNChanC());
150 BOOST_CHECK(dor.mTriggers.getAmplA() == ddc.mTriggers.getAmplA());
151 BOOST_CHECK(dor.mTriggers.getAmplC() == ddc.mTriggers.getAmplC());
152 BOOST_CHECK(dor.mTriggers.getTimeA() == ddc.mTriggers.getTimeA());
153 BOOST_CHECK(dor.mTriggers.getTimeC() == ddc.mTriggers.getTimeC());
154 BOOST_CHECK(dor.mTriggers.getTriggersignals() == ddc.mTriggers.getTriggersignals());
155 }
156 for (int i = channels.size(); i--;) {
157 const auto& cor = channels[i];
158 const auto& cdc = channelsD[i];
159 BOOST_CHECK(cor.mPMNumber == cdc.mPMNumber);
160 BOOST_CHECK(cor.mTime == cdc.mTime);
161 BOOST_CHECK(cor.mChargeADC == cdc.mChargeADC);
162 BOOST_CHECK(cor.mFEEBits == cdc.mFEEBits);
163 }
164}
std::ostringstream debug
class for entropy encoding/decoding of FDD digits data
uint64_t nChanC
uint64_t nChanA
unsigned short int uint16_t
int32_t i
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
BOOST_DATA_TEST_CASE(DefaultConstructorNofSamplesIsInvariant, boost::unit_test::data::make(nsamples), nofSamples)
Definition testDigit.cxx:50
Definition of the Names Generator class.
static constexpr std::string_view CTFTREENAME
Definition NameConf.h:95
void setANSVersion(const ctf::ANSHeader &ansVersion) noexcept
void readFromTree(TTree &tree, const std::string &name, int ev=0)
read from tree to non-flat object
static auto get(void *head)
cast arbitrary buffer head to container class. Head is supposed to respect the alignment
static auto getImage(const void *newHead)
get const image of the container wrapper, with pointers in the image relocated to new head
o2::ctf::CTFIOSize decode(const CTF::base &ec, VDIG &digitVec, VCHAN &channelVec)
entropy decode clusters from buffer with CTF
Definition CTFCoder.h:127
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const Digit > &digitVec, const gsl::span< const ChannelData > &channelVec)
entropy-encode digits to buffer with CTF
Definition CTFCoder.h:69
static const int16_t DEFAULT_AMP
Definition Triggers.h:51
static const int16_t DEFAULT_TIME
Definition Triggers.h:50
void setTriggers(uint8_t trgsig, uint8_t chanA, uint8_t chanC, int32_t aamplA, int32_t aamplC, int16_t atimeA, int16_t atimeC)
Definition Triggers.h:103
GLuint GLuint end
Definition glcorearb.h:469
constexpr ANSHeader ANSVersionCompat
Definition ANSHeader.h:54
constexpr ANSHeader ANSVersion1
Definition ANSHeader.h:55
constexpr short Nchannels
Definition Constants.h:25
std::vector< o2::ctf::BufferType > vec
std::vector< ChannelData > channelsD
std::vector< ChannelData > channels
BOOST_CHECK(tree)
std::vector< o2::ctf::ANSHeader > ANSVersions
TFile flOut("test_ctf_fdd.root", "recreate")
o2::InteractionRecord ir(0, 0)
TStopwatch sw
TTree ctfTree(std::string(o2::base::NameConf::CTFTREENAME).c_str(), "O2 CTF tree")
auto * ctfImage
TFile flIn("test_ctf_fdd.root")
std::vector< Digit > digitsD
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
LOG(info)<< "Generated "<< channels.size()<< " channels in "<< digits.size()<< " digits "<< sw.CpuTime()<< " s"
std::vector< Digit > digits