Skip to content

Commit 1bd2c6e

Browse files
committed
feat(evtvis):Added CI test to check the event display for simulations
1 parent bb98f9f commit 1bd2c6e

9 files changed

Lines changed: 158 additions & 29 deletions

evtvis/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ add_library_with_dictionary(
3131
LIBNAME
3232
R3BEvtVis
3333
LINKDEF
34-
R3BEventDisplayLinkDef.h
34+
EventDisplayLinkDef.h
3535
HEADERS
3636
${HEADERS}
3737
SRCS
@@ -56,3 +56,5 @@ add_library_with_dictionary(
5656
# Graf3d
5757
# Geom
5858
# GeomPainter)
59+
60+
add_subdirectory(test)

evtvis/R3BCalifaClusterEventDisplay.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ R3BCalifaClusterEventDisplay::R3BCalifaClusterEventDisplay(const char* name, Int
111111
, fProjManager2(NULL)
112112
{
113113
}
114-
// -----------------------------------------------------------------------
115-
116-
// ----- Destructor ----------------------------------------------------
117-
R3BCalifaClusterEventDisplay::~R3BCalifaClusterEventDisplay() {}
118-
// -------------------------------------------------------------------------
119114

120115
// ----- Public method Init --------------------------------------------
121116
InitStatus R3BCalifaClusterEventDisplay::Init()
@@ -261,9 +256,6 @@ void R3BCalifaClusterEventDisplay::Reset()
261256
delete fLego;
262257
}
263258

264-
// ---- Public method Finish --------------------------------------------------
265-
void R3BCalifaClusterEventDisplay::Finish() {}
266-
267259
// ----- Private method CreateHistograms -------------------------------------
268260
void R3BCalifaClusterEventDisplay::CreateHistograms()
269261
{

evtvis/R3BCalifaClusterEventDisplay.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class R3BCalifaClusterEventDisplay : public FairTask
4444
R3BCalifaClusterEventDisplay(const char* name, Int_t iVerbose = 1);
4545

4646
/** Destructor **/
47-
~R3BCalifaClusterEventDisplay();
47+
~R3BCalifaClusterEventDisplay() = default;
4848

4949
/** Virtual method Exec **/
5050
virtual void Exec(Option_t* opt);
@@ -55,9 +55,6 @@ class R3BCalifaClusterEventDisplay : public FairTask
5555
/** Virtual method Init **/
5656
virtual InitStatus Init();
5757

58-
/** Virtual method Finish **/
59-
virtual void Finish();
60-
6158
/** Accessors **/
6259

6360
protected:

evtvis/R3BCalifaEventDisplay.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ R3BCalifaEventDisplay::R3BCalifaEventDisplay(const char* name, Int_t iVerbose)
118118
, fProjManager2(NULL)
119119
{
120120
}
121-
// -----------------------------------------------------------------------
122-
123-
// ----- Destructor ----------------------------------------------------
124-
R3BCalifaEventDisplay::~R3BCalifaEventDisplay() {}
125-
// -------------------------------------------------------------------------
126121

127122
// ----- Public method Init --------------------------------------------
128123
InitStatus R3BCalifaEventDisplay::Init()
@@ -270,9 +265,6 @@ void R3BCalifaEventDisplay::Reset()
270265
delete fLego;
271266
}
272267

273-
// ---- Public method Finish --------------------------------------------------
274-
void R3BCalifaEventDisplay::Finish() {}
275-
276268
// ----- Private method CreateHistograms -------------------------------------
277269
void R3BCalifaEventDisplay::CreateHistograms()
278270
{

evtvis/R3BCalifaEventDisplay.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// ----- Created 01/10/2012 by P.Cabanelas -----
1717
// -------------------------------------------------------------------------
1818

19-
#ifndef R3BCALIFAEVENTDISPLAY_H
20-
#define R3BCALIFAEVENTDISPLAY_H
19+
#pragma once
2120

2221
#include "FairTask.h"
2322

@@ -45,7 +44,7 @@ class R3BCalifaEventDisplay : public FairTask
4544
R3BCalifaEventDisplay(const char* name, Int_t iVerbose = 1);
4645

4746
/** Destructor **/
48-
~R3BCalifaEventDisplay();
47+
~R3BCalifaEventDisplay() = default;
4948

5049
/** Virtual method Exec **/
5150
virtual void Exec(Option_t* opt);
@@ -56,9 +55,6 @@ class R3BCalifaEventDisplay : public FairTask
5655
/** Virtual method Init **/
5756
virtual InitStatus Init();
5857

59-
/** Virtual method Finish **/
60-
virtual void Finish();
61-
6258
/** Public method SelectGeometryVersion
6359
**
6460
** Defines the geometry
@@ -120,5 +116,3 @@ class R3BCalifaEventDisplay : public FairTask
120116

121117
ClassDef(R3BCalifaEventDisplay, 2);
122118
};
123-
124-
#endif

evtvis/test/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
##############################################################################
2+
# Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH #
3+
# Copyright (C) 2019-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+
generate_root_test_script(${R3BROOT_SOURCE_DIR}/evtvis/test/testSimulation.C)
15+
add_test(NAME EvtSimulation COMMAND ${R3BROOT_BINARY_DIR}/evtvis/test/testSimulation.sh)
16+
set_tests_properties(EvtSimulation PROPERTIES TIMEOUT "2000")
17+
set_tests_properties(EvtSimulation PROPERTIES PASS_REGULAR_EXPRESSION
18+
"Macro finished successfully.")
19+
20+
generate_root_test_script(${R3BROOT_SOURCE_DIR}/evtvis/test/eventDisplay.C)
21+
add_test(NAME EvtDisplay COMMAND ${R3BROOT_BINARY_DIR}/evtvis/test/eventDisplay.sh)
22+
set_tests_properties(EvtDisplay PROPERTIES TIMEOUT "2000")
23+
set_tests_properties(EvtDisplay PROPERTIES PASS_REGULAR_EXPRESSION
24+
"Macro finished successfully.")

evtvis/test/eventDisplay.C

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/******************************************************************************
2+
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3+
* Copyright (C) 2019-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+
void eventDisplay()
15+
{
16+
auto fRun = new FairRunAna();
17+
fRun->SetSource(new FairFileSource("test.simu.root"));
18+
fRun->SetSink(new FairRootFileSink("event.test.root"));
19+
20+
auto rtdb = fRun->GetRuntimeDb();
21+
auto parIo1 = new FairParRootFileIo();
22+
parIo1->open("test.para.root");
23+
rtdb->setFirstInput(parIo1);
24+
rtdb->print();
25+
26+
auto fMan = new R3BEventManager();
27+
auto Track = new R3BMCTracks("Monte-Carlo Tracks");
28+
29+
fMan->AddTask(Track);
30+
fMan->Init();
31+
32+
std::cout << "Macro finished successfully." << std::endl;
33+
}

evtvis/test/testSimulation.C

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/******************************************************************************
2+
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3+
* Copyright (C) 2019-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+
#include <TStopwatch.h>
15+
#include <TString.h>
16+
#include <TSystem.h>
17+
#include <memory>
18+
19+
void testSimulation(const int nbevents = 10)
20+
{
21+
// Timer
22+
TStopwatch timer;
23+
timer.Start();
24+
25+
// Logging
26+
auto logger = FairLogger::GetLogger();
27+
logger->SetLogVerbosityLevel("low");
28+
logger->SetLogScreenLevel("warn");
29+
logger->SetColoredLog(true);
30+
31+
// System paths
32+
const TString workDirectory = getenv("VMCWORKDIR");
33+
gSystem->Setenv("GEOMPATH", workDirectory + "/geometry");
34+
gSystem->Setenv("CONFIG_DIR", workDirectory + "/gconfig");
35+
36+
// Output files
37+
const TString simufile = "test.simu.root";
38+
const TString parafile = "test.para.root";
39+
40+
// Basic simulation setup
41+
auto run = new FairRunSim();
42+
run->SetName("TGeant4");
43+
run->SetStoreTraj(false);
44+
run->SetMaterials("media_r3b.geo");
45+
run->SetSink(new FairRootFileSink(simufile));
46+
47+
auto rtdb = run->GetRuntimeDb();
48+
rtdb->initContainers(1);
49+
50+
// Primary particle generator
51+
auto boxGen = new FairBoxGenerator(2212, 3);
52+
boxGen->SetXYZ(0, 0, 0.);
53+
boxGen->SetThetaRange(0., 145.);
54+
boxGen->SetPhiRange(0., 360.);
55+
boxGen->SetEkinRange(0.4, 0.8);
56+
auto primGen = new FairPrimaryGenerator();
57+
primGen->AddGenerator(boxGen);
58+
run->SetGenerator(primGen);
59+
60+
// Geometry: Cave
61+
auto cave = new R3BCave("CAVE");
62+
cave->SetGeometryFileName("r3b_cave.geo");
63+
run->AddModule(cave);
64+
65+
// Geometry: Califa
66+
auto calsim = new R3BCalifa("califa_full.geo.root", { 0., 0., 0. });
67+
calsim->SelectGeometryVersion(0);
68+
run->AddModule(calsim);
69+
70+
// Digitizer: Califa
71+
auto califaDig = new R3BCalifaDigitizer();
72+
run->AddTask(califaDig);
73+
74+
auto califaCal2Cluster = new R3BCalifaCrystalCal2Cluster();
75+
califaCal2Cluster->SetCrystalThreshold(0.1); // 100 keV
76+
run->AddTask(califaCal2Cluster);
77+
78+
// Init
79+
run->Init();
80+
81+
// ----- Runtime database ---------------------------------------------
82+
auto parOut = new FairParRootFileIo(true);
83+
parOut->open(parafile.Data());
84+
rtdb->setOutput(parOut);
85+
rtdb->saveOutput();
86+
rtdb->print();
87+
88+
// Simulate
89+
run->Run(nbevents);
90+
91+
// Report
92+
timer.Stop();
93+
std::cout << "Real time: " << timer.RealTime() << "s, CPU time: " << timer.CpuTime() << "s" << std::endl;
94+
std::cout << "Macro finished successfully." << std::endl;
95+
}

0 commit comments

Comments
 (0)