Skip to content

Commit 376860a

Browse files
committed
feat(fiber/test):Add CI test for parameter containers
Minor change More basic changes Update Minor change Last change
1 parent 5bb7992 commit 376860a

7 files changed

Lines changed: 134 additions & 45 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The following systems are tested regularly.
9797

9898
| **OS Name** | **Arch** | **OS Version** | **Compiler** | **CMake** | **C++ Version** |
9999
| ----------- | -------- | -------------- | ------------ | --------------- | --------------- |
100-
| Almalinux | x86\_64 | 9.3 | GCC 11.4.1 | 3.27.9 / 4.0.3 | C++17 / C++20 |
100+
| Almalinux | x86\_64 | 9.3 | GCC 11.4.1 | 3.27.9 / 4.0.3 | C++17 / C++20 / C++23 |
101101
| Almalinux | x86\_64 | 9.4 | GCC 14.2.0 | 3.30.6 | C++17 |
102102
| RHEL | x86\_64 | 9.6 | GCC 14.2.0 | 3.30.6 | C++17 |
103103
| Debian | x86\_64 | 10 | GCC 8.3.0 | 3.27.4 / 4.0.3 | C++17 |

alpide/pars/R3BAlpideMappingPar.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,4 @@ void R3BAlpideMappingPar::printParams()
186186
}
187187
}
188188

189-
ClassImp(R3BAlpideMappingPar);
189+
ClassImp(R3BAlpideMappingPar)

fiber/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,8 @@ add_library_with_dictionary(
7777
DEPENDENCIES
7878
R3BTCal
7979
R3BTracking)
80+
81+
if(BUILD_GEOMETRY)
82+
# add_subdirectory(geobase)
83+
endif()
84+
add_subdirectory(test)

fiber/pars/R3BFiberMappingPar.cxx

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,27 @@
1818

1919
#include "R3BFiberMappingPar.h"
2020

21-
#include "FairParamList.h"
2221
#include "R3BLogger.h"
22+
#include <FairParamList.h>
2323

24-
#include "TMath.h"
25-
#include "TString.h"
24+
#include <TMath.h>
25+
#include <TString.h>
2626

2727
// ---- Standard Constructor ---------------------------------------------------
2828
R3BFiberMappingPar::R3BFiberMappingPar(const TString& name, const TString& title, const TString& context)
2929
: FairParGenericSet(name, title, context)
30-
, fNbSides(2)
31-
, fNbChannels(512)
3230
{
33-
for (Int_t s = 0; s < fNbSides; s++)
31+
fTrigmap.resize(fNbSides);
32+
for (size_t s = 0; s < fNbSides; s++)
3433
{
3534
fTrigmap[s] = new TArrayI(fNbChannels);
36-
for (Int_t c = 0; c < fNbChannels; c++)
35+
for (size_t c = 0; c < fNbChannels; c++)
3736
{
3837
fTrigmap[s]->AddAt(0, c);
3938
}
4039
}
4140
}
4241

43-
// ---- Destructor ------------------------------------------------------------
44-
R3BFiberMappingPar::~R3BFiberMappingPar()
45-
{
46-
clear();
47-
for (Int_t s = 0; s < fNbSides; s++)
48-
if (fTrigmap[s])
49-
delete fTrigmap[s];
50-
}
51-
5242
// ---- Method clear ----------------------------------------------------------
5343
void R3BFiberMappingPar::clear()
5444
{
@@ -71,12 +61,11 @@ void R3BFiberMappingPar::putParams(FairParamList* list)
7161
R3BLOG(info, "Nb of channels: " << fNbChannels);
7262
R3BLOG(info, "Nb of sides: " << fNbSides);
7363

74-
char name[300];
75-
for (Int_t s = 0; s < fNbSides; s++)
64+
for (size_t s = 0; s < fNbSides; s++)
7665
{
7766
fTrigmap[s]->Set(fNbChannels);
78-
sprintf(name, "fiberside%dPar", s + 1);
79-
list->add(name, *fTrigmap[s]);
67+
TString name = Form("fiberside%zuPar", s + 1);
68+
list->add(name.Data(), *fTrigmap[s]);
8069
}
8170
}
8271

@@ -100,13 +89,11 @@ Bool_t R3BFiberMappingPar::getParams(FairParamList* list)
10089
return kFALSE;
10190
}
10291

103-
char name[300];
104-
for (Int_t s = 0; s < fNbSides; s++)
92+
for (size_t s = 0; s < fNbSides; s++)
10593
{
10694
fTrigmap[s]->Set(fNbChannels);
107-
sprintf(name, "fiberside%dPar", s + 1);
108-
109-
if (!(list->fill(name, fTrigmap[s])))
95+
TString name = Form("fiberside%zuPar", s + 1);
96+
if (!(list->fill(name.Data(), fTrigmap[s])))
11097
{
11198
R3BLOG(error, "Could not initialize " << name);
11299
return kFALSE;
@@ -123,11 +110,11 @@ void R3BFiberMappingPar::print() { printParams(); }
123110
void R3BFiberMappingPar::printParams()
124111
{
125112
R3BLOG(info, "Mapping params for Fiber: Num of sides: " << fNbSides << " and channels: " << fNbChannels);
126-
for (Int_t s = 0; s < fNbSides; s++)
127-
for (Int_t c = 0; c < fNbChannels; c++)
113+
for (size_t s = 0; s < fNbSides; s++)
114+
for (size_t c = 0; c < fNbChannels; c++)
128115
{
129116
R3BLOG(info, "Side: " << s + 1 << " , channel:" << c + 1 << ", value: " << fTrigmap[s]->GetAt(c));
130117
}
131118
}
132119

133-
ClassImp(R3BFiberMappingPar);
120+
ClassImp(R3BFiberMappingPar)

fiber/pars/R3BFiberMappingPar.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
#pragma once
2020

21-
#include "FairParGenericSet.h"
21+
#include <FairParGenericSet.h>
2222

2323
#include "TArrayI.h"
24-
#include "TObjArray.h"
2524
#include <Rtypes.h>
25+
#include <TString.h>
2626
#include <stdint.h>
2727
#include <vector>
2828

@@ -37,40 +37,40 @@ class R3BFiberMappingPar : public FairParGenericSet
3737
const TString& context = "fiberMappingContext");
3838

3939
/** Destructor **/
40-
virtual ~R3BFiberMappingPar();
40+
virtual ~R3BFiberMappingPar() = default;
4141

4242
/** Reset all parameters **/
43-
virtual void clear();
43+
void clear() override;
4444

4545
/** Store all parameters using FairRuntimeDB **/
46-
virtual void putParams(FairParamList* list);
46+
void putParams(FairParamList* list) override;
4747

4848
/** Retrieve all parameters using FairRuntimeDB**/
49-
Bool_t getParams(FairParamList* list);
49+
Bool_t getParams(FairParamList* list) override;
5050

5151
/** Print values of parameters to the standard output **/
52-
virtual void print();
53-
void printParams();
52+
void print() override;
53+
void printParams() override;
5454

5555
/** Accessor functions **/
5656
const Int_t GetNbChannels() { return fNbChannels; }
5757
const Int_t GetNbSides() { return fNbSides; }
5858
// GetTrigMap in 1-base for side(1-2) and channel(1-X)
5959
const Int_t GetTrigMap(UInt_t side, UInt_t ch) { return fTrigmap[side - 1]->GetAt(ch - 1); }
6060

61-
void SetNbChannels(Int_t p) { fNbChannels = p; }
62-
void SetNbSides(Int_t p) { fNbSides = p; }
61+
inline void SetNbChannels(Int_t p) { fNbChannels = p; }
62+
inline void SetNbSides(Int_t p) { fNbSides = p; }
6363
// SetTrigMap in 1-base for side(1-2) and channel(1-X)
64-
void SetTrigMap(Int_t value, UInt_t side, UInt_t ch) { fTrigmap[side - 1]->AddAt(value, ch - 1); }
64+
inline void SetTrigMap(Int_t value, UInt_t side, UInt_t ch) { fTrigmap[side - 1]->AddAt(value, ch - 1); }
6565

6666
private:
67-
Int_t fNbChannels;
68-
Int_t fNbSides;
69-
TArrayI* fTrigmap[2]; // Two sides per fiber
67+
Int_t fNbChannels = 512;
68+
Int_t fNbSides = 2; // Two sides per fiber
69+
std::vector<TArrayI*> fTrigmap;
7070

7171
const R3BFiberMappingPar& operator=(const R3BFiberMappingPar&);
7272
R3BFiberMappingPar(const R3BFiberMappingPar&);
7373

7474
public:
75-
ClassDef(R3BFiberMappingPar, 1);
75+
ClassDefOverride(R3BFiberMappingPar, 1);
7676
};

fiber/test/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
##############################################################################
2+
# Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH #
3+
# Copyright (C) 2022-2025 Members of R3B Collaboration #
4+
# #
5+
# This software is distributed under the terms of the #
6+
# GNU General Public Licence (GPL) version 3, #
7+
# copied verbatim in the file "LICENSE". #
8+
# #
9+
# In applying this license GSI does not waive the privileges and immunities #
10+
# granted to it by virtue of its status as an Intergovernmental Organization #
11+
# or submit itself to any jurisdiction. #
12+
##############################################################################
13+
14+
if(GTEST_FOUND)
15+
add_executable(
16+
FiberUnitTests
17+
testFiberContainerPar.cxx)
18+
target_link_libraries(FiberUnitTests PRIVATE GTest::gtest_main GTest::gmock_main
19+
R3BBunchedFiber)
20+
gtest_discover_tests(FiberUnitTests DISCOVERY_TIMEOUT 600)
21+
endif(GTEST_FOUND)
22+
23+
#generate_root_test_script(${R3BROOT_SOURCE_DIR}/fiber/test/testFiberSimulation.C)
24+
#add_test(NAME FiberSimulation COMMAND ${R3BROOT_BINARY_DIR}/fiber/test/testFiberSimulation.sh)
25+
#set_tests_properties(FiberSimulation PROPERTIES TIMEOUT "2000")
26+
#set_tests_properties(FiberSimulation PROPERTIES PASS_REGULAR_EXPRESSION
27+
# "Macro finished successfully.")
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
/******************************************************************************
3+
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
4+
* Copyright (C) 2022-2025 Members of R3B Collaboration *
5+
* *
6+
* This software is distributed under the terms of the *
7+
* GNU General Public Licence (GPL) version 3, *
8+
* copied verbatim in the file "LICENSE". *
9+
* *
10+
* In applying this license GSI does not waive the privileges and immunities *
11+
* granted to it by virtue of its status as an Intergovernmental Organization *
12+
* or submit itself to any jurisdiction. *
13+
******************************************************************************/
14+
15+
#include "R3BBunchedFiberHitModulePar.h"
16+
#include "R3BFiberMAPMTHitModulePar.h"
17+
#include "R3BFiberMappingPar.h"
18+
#include "gtest/gtest.h"
19+
#include <map>
20+
21+
namespace
22+
{
23+
TEST(testFiberMappingPar, GetNbChannels)
24+
{
25+
R3BFiberMappingPar par;
26+
par.SetNbChannels(20);
27+
28+
EXPECT_EQ(par.GetNbChannels(), 20);
29+
}
30+
31+
TEST(testFiberMappingPar, GetNbSides)
32+
{
33+
R3BFiberMappingPar par;
34+
par.SetNbSides(10);
35+
36+
EXPECT_EQ(par.GetNbSides(), 10);
37+
}
38+
39+
TEST(testFiberMAPMTHitModulePar, GetFiber)
40+
{
41+
R3BFiberMAPMTHitModulePar par;
42+
par.SetFiber(100);
43+
44+
EXPECT_EQ(par.GetFiber(), 100);
45+
}
46+
47+
TEST(testFiberMAPMTHitModulePar, GetGainUp)
48+
{
49+
R3BFiberMAPMTHitModulePar par;
50+
par.SetGainUp(12.24);
51+
52+
EXPECT_EQ(par.GetGainUp(), 12.24);
53+
}
54+
55+
TEST(testBunchedFiberHitModulePar, GetFiber)
56+
{
57+
R3BBunchedFiberHitModulePar par;
58+
par.SetFiber(100);
59+
60+
EXPECT_EQ(par.GetFiber(), 100);
61+
}
62+
63+
TEST(testBunchedFiberHitModulePar, GetVeff)
64+
{
65+
R3BBunchedFiberHitModulePar par;
66+
par.SetVeff(12.2);
67+
68+
EXPECT_EQ(par.GetVeff(), 12.2);
69+
}
70+
} // namespace

0 commit comments

Comments
 (0)