CbmRoot
Loading...
Searching...
No Matches
_GTestEventBuilder.cxx
Go to the documentation of this file.
1/* Copyright (C) 2021-2023 Facility for Anti-Proton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer] */
4
5#include "EventBuilder.h"
6#include "gtest/gtest-spi.h"
7#include "gtest/gtest.h"
8
9#include <yaml-cpp/yaml.h>
10
11using namespace cbm::algo;
12
13TEST(_GTestEventBuilder, CheckEventBuilderAlgorithmSimple)
14{
15 SCOPED_TRACE("CheckEventBuilderAlgorithSimple");
16
17 //Initialize event builder
18 YAML::Node configNode;
19 configNode[ToString(ECbmModuleId::kMuch)] = std::pair<double, double>{-45., 45.};
20 configNode[ToString(ECbmModuleId::kSts)] = std::pair<double, double>{-45., 45.};
21 configNode[ToString(ECbmModuleId::kTof)] = std::pair<double, double>{-45., 45.};
22 configNode[ToString(ECbmModuleId::kTrd)] = std::pair<double, double>{-45., 45.};
23 configNode[ToString(ECbmModuleId::kRich)] = std::pair<double, double>{-45., 45.};
24 configNode[ToString(ECbmModuleId::kPsd)] = std::pair<double, double>{-45., 45.};
25 configNode[ToString(ECbmModuleId::kFsd)] = std::pair<double, double>{-45., 45.};
26 configNode[ToString(ECbmModuleId::kBmon)] = std::pair<double, double>{-45., 45.};
29
30 DigiData tsIn;
31 const uint nInput = 1000;
32 const double inputSpacing = 10.0;
33
34 //Produce digis with some arbitrary but valid addresses
35 for (uint i = 0; i < nInput; i++) {
36 tsIn.fMuch.push_back(CbmMuchDigi(1111, 1, i * inputSpacing));
37 tsIn.fSts.push_back(CbmStsDigi(268502050, 1, i * inputSpacing, 1.0));
38 tsIn.fTof.push_back(CbmTofDigi(1111, i * inputSpacing, 1.0));
39 tsIn.fTrd.push_back(CbmTrdDigi(475, 37, 150, i * inputSpacing, CbmTrdDigi::eTriggerType::kBeginTriggerTypes, 0));
40 tsIn.fRich.push_back(CbmRichDigi(1111, i * inputSpacing, 1.0));
41 tsIn.fPsd.push_back(CbmPsdDigi(1111, i * inputSpacing, 1.0));
42 tsIn.fFsd.push_back(CbmFsdDigi(1111, i * inputSpacing, 1.0));
43 tsIn.fBmon.push_back(CbmBmonDigi(1111, i * inputSpacing, 1.0));
44 }
45
46 std::vector<double> triggerIn;
47 const uint nTrigger = 99;
48 const double triggerSpacing = 100.0;
49
50 for (uint i = 1; i <= nTrigger; i++) {
51 triggerIn.push_back(i * triggerSpacing);
52 }
53
54 cbm::algo::evbuild::EventBuilder::resultType result = evbuild(tsIn, triggerIn, std::nullopt);
55 std::vector<DigiEvent>& eventsOut = result.first;
56 cbm::algo::evbuild::EventBuilderMonitorData& monitor = result.second;
57
58 EXPECT_EQ(eventsOut.size(), nTrigger);
59
60 for (uint i = 0; i < eventsOut.size(); i++) {
61 EXPECT_EQ(eventsOut[i].fMuch.size(), 9);
62 EXPECT_EQ(eventsOut[i].fSts.size(), 9);
63 EXPECT_EQ(eventsOut[i].fTof.size(), 9);
64 EXPECT_EQ(eventsOut[i].fTrd.size(), 9);
65 EXPECT_EQ(eventsOut[i].fRich.size(), 9);
66 EXPECT_EQ(eventsOut[i].fPsd.size(), 9);
67 EXPECT_EQ(eventsOut[i].fFsd.size(), 9);
68 EXPECT_EQ(eventsOut[i].fBmon.size(), 9);
69 EXPECT_EQ(eventsOut[i].fTime, triggerIn[i]);
70 }
71
72 EXPECT_EQ(monitor.much.nDigisInEvents, 9 * nTrigger);
73 EXPECT_EQ(monitor.sts.nDigisInEvents, 9 * nTrigger);
74 EXPECT_EQ(monitor.tof.nDigisInEvents, 9 * nTrigger);
75 EXPECT_EQ(monitor.trd.nDigisInEvents, 9 * nTrigger);
76 EXPECT_EQ(monitor.rich.nDigisInEvents, 9 * nTrigger);
77 EXPECT_EQ(monitor.psd.nDigisInEvents, 9 * nTrigger);
78 EXPECT_EQ(monitor.fsd.nDigisInEvents, 9 * nTrigger);
79 EXPECT_EQ(monitor.bmon.nDigisInEvents, 9 * nTrigger);
80
81 EXPECT_EQ(monitor.much.nDigis, nInput);
82 EXPECT_EQ(monitor.sts.nDigis, nInput);
83 EXPECT_EQ(monitor.tof.nDigis, nInput);
84 EXPECT_EQ(monitor.trd.nDigis, nInput);
85 EXPECT_EQ(monitor.rich.nDigis, nInput);
86 EXPECT_EQ(monitor.psd.nDigis, nInput);
87 EXPECT_EQ(monitor.fsd.nDigis, nInput);
88 EXPECT_EQ(monitor.bmon.nDigis, nInput);
89}
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kFsd
Forward spectator detector.
@ kRich
Ring-Imaging Cherenkov Detector.
TEST(_GTestEventBuilder, CheckEventBuilderAlgorithmSimple)
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:30
Data class for FSD digital information.
Definition CbmFsdDigi.h:36
Data class for PSD digital information.
Definition CbmPsdDigi.h:36
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47
Configuration of the EventBuilder class.
Constructs CbmDigiEvents out of CbmDigiTimeslices.
std::pair< std::vector< DigiEvent >, EventBuilderMonitorData > resultType
std::string_view ToString(T t)
Definition EnumDict.h:64
Collection of digis from all detector systems.
Definition DigiData.h:31
PODVector< CbmRichDigi > fRich
Unpacked RICH digis.
Definition DigiData.h:38
PODVector< CbmTrdDigi > fTrd
Unpacked TRD digis.
Definition DigiData.h:36
PODVector< CbmStsDigi > fSts
Unpacked STS digis.
Definition DigiData.h:32
PODVector< CbmFsdDigi > fFsd
Unpacked FSD digis.
Definition DigiData.h:40
PODVector< CbmTofDigi > fTof
Unpacked TOF digis.
Definition DigiData.h:34
PODVector< CbmPsdDigi > fPsd
Unpacked PSD digis.
Definition DigiData.h:39
PODVector< CbmMuchDigi > fMuch
Unpacked MUCH digis.
Definition DigiData.h:33
PODVector< CbmBmonDigi > fBmon
Unpacked Bmon digis.
Definition DigiData.h:35
size_t nDigisInEvents
Number of digis collected into events.
size_t nDigis
Full number of digis in input source.
Monitoring data for event building.
EventBuilderDetectorMonitorData much
Monitoring data for MUCH.
EventBuilderDetectorMonitorData rich
Monitoring data for RICH.
EventBuilderDetectorMonitorData sts
Monitoring data for STS.
EventBuilderDetectorMonitorData tof
Monitoring data for TOF.
EventBuilderDetectorMonitorData bmon
Monitoring data for Bmon.
EventBuilderDetectorMonitorData fsd
Monitoring data for FSD.
EventBuilderDetectorMonitorData trd
Monitoring data for TRD.
EventBuilderDetectorMonitorData psd
Monitoring data for PSD.