From bebf75b416ecb741598253e8db05bf6298bc1ceb Mon Sep 17 00:00:00 2001 From: P-A Loizeau <p.-a.loizeau@gsi.de> Date: Thu, 2 Jul 2020 15:01:01 +0200 Subject: [PATCH] In CbmEvent class, add match presence to ToString + add explicit Clear method --- core/data/CbmEvent.cxx | 4 +++- core/data/CbmEvent.h | 5 ++++- core/data/test/_GTestCbmEvent.cxx | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/data/CbmEvent.cxx b/core/data/CbmEvent.cxx index f9e86722cd..42b03a77da 100644 --- a/core/data/CbmEvent.cxx +++ b/core/data/CbmEvent.cxx @@ -60,7 +60,9 @@ std::string CbmEvent::ToString() const std::stringstream ss; ss << "Event " << fNumber << " at t = " << fTimeStart << " ns. Registered data types: " << fIndexMap.size() - << ", data objects: " << fNofData << "\n"; + << ", data objects: " << fNofData + << ( nullptr != fMatch ? ", with matches" : ", without matches" ) + << "\n"; for (auto it = fIndexMap.begin(); it != fIndexMap.end(); it++) { ss << " -- Data type " << it->first << ", number of data " << it->second.size() << "\n"; diff --git a/core/data/CbmEvent.h b/core/data/CbmEvent.h index e93a5eb928..2031bd18e5 100644 --- a/core/data/CbmEvent.h +++ b/core/data/CbmEvent.h @@ -18,7 +18,7 @@ #include "CbmDefs.h" // for ECbmDataType, ECbmModuleId::kStsTrack #include "CbmMatch.h" // for CbmMatch -#include "CbmVertex.h" // for CbmVertex +#include "CbmVertex.h" // for CbmVertex, found in core/data/global /** @class CbmEvent ** @brief Class characterising one event by a collection of links (indices) @@ -51,6 +51,9 @@ class CbmEvent: public TObject { if ( fMatch ) delete fMatch; } + /** Overload TObject Clear to clear the map! **/ + void Clear( Option_t * /*option*/ ) { fIndexMap.clear(); } + /** Add a data object to the index map ** @param DataType Type of data (for values see CbmDetectorList.h) diff --git a/core/data/test/_GTestCbmEvent.cxx b/core/data/test/_GTestCbmEvent.cxx index 984c2856d6..0c6a852a34 100644 --- a/core/data/test/_GTestCbmEvent.cxx +++ b/core/data/test/_GTestCbmEvent.cxx @@ -265,7 +265,7 @@ TEST(_GTestCbmEvent, CheckSettersAndGetters) compareEventMap(test, 9, 3, ECbmDataType::kStsTrack, ststrack); } - EXPECT_STREQ("Event -111 at t = 1 ns. Registered data types: 6, data objects: 9\n -- Data type 0, number of data 2\n -- Data type 200, number of data 1\n -- Data type 201, number of data 1\n -- Data type 202, number of data 1\n -- Data type 203, number of data 1\n -- Data type 204, number of data 3\n", test.ToString().c_str()); + EXPECT_STREQ("Event -111 at t = 1 ns. Registered data types: 6, data objects: 9, without matches\n -- Data type 0, number of data 2\n -- Data type 200, number of data 1\n -- Data type 201, number of data 1\n -- Data type 202, number of data 1\n -- Data type 203, number of data 1\n -- Data type 204, number of data 3\n", test.ToString().c_str()); } -- GitLab