Skip to content

Commit d552e5d

Browse files
committed
FT0 mc->raw->digits test added to full_system_test_ci_extra_tests
1 parent 62e9d2b commit d552e5d

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

Detectors/FIT/FT0/reconstruction/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ o2_target_root_dictionary(
3030
include/FT0Reconstruction/CTFCoder.h
3131
include/FT0Reconstruction/InteractionTag.h
3232
)
33+
34+
o2_add_executable(
35+
test-raw-conversion
36+
COMPONENT_NAME ft0
37+
SOURCES src/test-raw-conversion.cxx
38+
PUBLIC_LINK_LIBRARIES O2::FT0Reconstruction)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#include <TSystem.h>
12+
#include <TTree.h>
13+
#include "Framework/Logger.h"
14+
#include "DataFormatsFT0/Digit.h"
15+
#include <TFile.h>
16+
#include <cstring>
17+
18+
using namespace o2::ft0;
19+
20+
int main(int argc, char* argv[])
21+
{
22+
const std::string genDigDile{"ft0digits.root"};
23+
const std::string decDigDile{"o2digit_ft0.root"};
24+
const std::string branchBC{"FT0DIGITSBC"};
25+
const std::string branchCH{"FT0DIGITSCH"};
26+
27+
if (gSystem->AccessPathName(genDigDile.c_str())) {
28+
LOG(FATAL) << "Generated digits file " << genDigDile << " is absent";
29+
}
30+
TFile flIn(genDigDile.c_str());
31+
std::unique_ptr<TTree> tree((TTree*)flIn.Get("o2sim"));
32+
if (!flIn.IsOpen() || flIn.IsZombie() || !tree) {
33+
LOG(FATAL) << "Failed to get tree from generated digits file " << genDigDile;
34+
}
35+
std::vector<o2::ft0::Digit> digitsBC, *ft0BCDataPtr = &digitsBC;
36+
std::vector<o2::ft0::ChannelData> digitsCh, *ft0ChDataPtr = &digitsCh;
37+
tree->SetBranchAddress("FT0DIGITSBC", &ft0BCDataPtr);
38+
tree->SetBranchAddress("FT0DIGITSCH", &ft0ChDataPtr);
39+
40+
if (gSystem->AccessPathName(decDigDile.c_str())) {
41+
LOG(FATAL) << "Decoded digits file " << genDigDile << " is absent";
42+
}
43+
44+
TFile flIn2(decDigDile.c_str());
45+
std::unique_ptr<TTree> tree2((TTree*)flIn2.Get("o2sim"));
46+
if (!flIn2.IsOpen() || flIn2.IsZombie() || !tree2) {
47+
LOG(FATAL) << "Failed to get tree from decoded digits file " << genDigDile;
48+
}
49+
std::vector<o2::ft0::Digit> digitsBC2, *ft0BCDataPtr2 = &digitsBC2;
50+
std::vector<o2::ft0::ChannelData> digitsCh2, *ft0ChDataPtr2 = &digitsCh2;
51+
tree2->SetBranchAddress("FT0DIGITSBC", &ft0BCDataPtr2);
52+
tree2->SetBranchAddress("FT0DIGITSCH", &ft0ChDataPtr2);
53+
54+
int nbc = 0, nbc2 = 0, nch = 0, nch2 = 0;
55+
for (int ient = 0; ient < tree->GetEntries(); ient++) {
56+
tree->GetEntry(ient);
57+
int nbcEntry = digitsBC.size();
58+
nbc += nbcEntry;
59+
for (int ibc = 0; ibc < nbcEntry; ibc++) {
60+
auto& bcd = digitsBC[ibc];
61+
int bc = bcd.getBC();
62+
auto channels = bcd.getBunchChannelData(digitsCh);
63+
nch += channels.size();
64+
}
65+
}
66+
67+
for (int ient = 0; ient < tree2->GetEntries(); ient++) {
68+
tree2->GetEntry(ient);
69+
int nbc2Entry = digitsBC2.size();
70+
nbc2 += nbc2Entry;
71+
for (int ibc = 0; ibc < nbc2Entry; ibc++) {
72+
auto& bcd2 = digitsBC2[ibc];
73+
int bc2 = bcd2.getBC();
74+
auto channels2 = bcd2.getBunchChannelData(digitsCh2);
75+
nch2 += channels2.size();
76+
}
77+
}
78+
LOG(INFO) << "FT0 simulated: " << nbc << " triggers with " << nch << " channels";
79+
LOG(INFO) << "FT0 decoded : " << nbc2 << " triggers with " << nch2 << " channels";
80+
if (nbc != nbc2 || nch != nch2) {
81+
LOG(FATAL) << "Mismatch between the number of encoded and decoded objects";
82+
}
83+
84+
return 0;
85+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
11
#!/bin/bash
2+
#
3+
# Set of extra tests which may run after the full_system_test.sh
4+
# Particularly, they use the files generated by the full_system_test.sh
5+
#
6+
. ${O2_ROOT}/share/scripts/jobutils.sh
27

8+
if [ "0$O2_ROOT" == "0" ]; then
9+
eval "`alienv shell-helper`"
10+
alienv --no-refresh load O2/latest
11+
fi
312

13+
NHBPERTF=${NHBPERTF:-128} # number of HBFs per orbit to expect in pregenerated files
14+
15+
# Set general arguments
16+
ARGS_ALL="--session default --shm-segment-size $SHMSIZE"
17+
18+
# below we add individual tests
19+
execname=""
20+
logfile=""
21+
22+
# FT0
23+
# run raw->digits conversion from the raw data create elsewhere
24+
execname=o2-raw-file-reader-workflow
25+
taskwrapper ${execname}.log $execname "$ARGS_ALL --configKeyValues \"HBFUtils.nHBFPerTF=${NHBPERTF}\" --detect-tf0 --input-conf raw/FT0/FT0raw.cfg | o2-ft0-flp-dpl-workflow $ARGS_ALL -b"
26+
# and check its correctness
27+
execname=o2-ft0-test-raw-conversion
28+
taskwrapper ${execname}.log $execname
29+
# don't proceed to other tests if error was found
30+
[ ! -f "${execname}.log_done" ] || [ "$?" != 0 ] && exit
31+
32+
# other tests to add

0 commit comments

Comments
 (0)