Commit 1a94d85e authored by Jan de Cuveland's avatar Jan de Cuveland Committed by Volker Friese
Browse files

Migrate core/data to C/C++ std integer types

parent 5ee591f9
......@@ -10,7 +10,7 @@
#ifndef CBMADDRESS_H
#define CBMADDRESS_H 1
#include <RtypesCore.h> // for ROOT data classes
#include <cstdint>
/** @class CbmAddress
** @brief Base class for interfaces to the unique address
......@@ -18,7 +18,7 @@
** @version 1.0
**
** CbmAddress is the base class for the concrete interfaces to the
** unique address, which is encoded in a 32-bit field (Int_t).
** unique address, which is encoded in a 32-bit field (int32_t).
** The definition of this bit field is different for the various
** detector systems; common for all is that the first four bits are
** reserved for the system identifier.
......@@ -37,19 +37,19 @@ public:
/** Number of bits for system Id in the address field
** @return Number of bits
**/
static Int_t GetNofSystemBits() { return fgkSystemBits; }
static int32_t GetNofSystemBits() { return fgkSystemBits; }
/** Get the system Id from the address
** @param address Unique address
** @return systemId
**/
static Int_t GetSystemId(UInt_t address) { return address & ((1 << fgkSystemBits) - 1); }
static int32_t GetSystemId(uint32_t address) { return address & ((1 << fgkSystemBits) - 1); }
protected:
/** Number of bits for system Id in the address field **/
static const Int_t fgkSystemBits = 4;
static const int32_t fgkSystemBits = 4;
};
#endif /* CBMADDRESS_H */
......@@ -20,7 +20,7 @@
using namespace std;
CbmCluster::CbmCluster() : TObject(), fDigis(), fAddress(0), fMatch(nullptr) {}
CbmCluster::CbmCluster(const std::vector<Int_t>& indices, Int_t address)
CbmCluster::CbmCluster(const std::vector<int32_t>& indices, int32_t address)
: TObject()
, fDigis()
, fAddress(address)
......@@ -88,9 +88,9 @@ string CbmCluster::ToString() const
{
stringstream ss;
ss << "CbmCluster: ";
Int_t nofDigis = GetNofDigis();
int32_t nofDigis = GetNofDigis();
ss << "nofDigis=" << nofDigis << " | ";
for (Int_t i = 0; i < nofDigis; i++) {
for (int32_t i = 0; i < nofDigis; i++) {
ss << fDigis[i] << " ";
}
ss << " | address=" << fAddress << endl;
......
......@@ -13,9 +13,9 @@
#define CBMCLUSTER_H_
#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
#include <RtypesCore.h> // for Int_t
#include <TObject.h> // for TObject
#include <cstdint>
#include <string> // for string
#include <vector> // for vector
......@@ -33,7 +33,7 @@ public:
* \brief Constructor.
*/
CbmCluster();
CbmCluster(const std::vector<Int_t>& indices, Int_t address);
CbmCluster(const std::vector<int32_t>& indices, int32_t address);
CbmCluster(const CbmCluster&);
CbmCluster(CbmCluster&& other) noexcept;
CbmCluster& operator=(const CbmCluster&);
......@@ -48,38 +48,38 @@ public:
* \brief Add digi to cluster.
* \param[in] index Digi index in TClonesArray.
*/
void AddDigi(Int_t index) { fDigis.push_back(index); }
void AddDigi(int32_t index) { fDigis.push_back(index); }
/**
* \brief Add array of digi to cluster.
* \param[in] indices Array of digi indices in TClonesArray.
*/
void AddDigis(const std::vector<Int_t>& indices) { fDigis.insert(fDigis.end(), indices.begin(), indices.end()); }
void AddDigis(const std::vector<int32_t>& indices) { fDigis.insert(fDigis.end(), indices.begin(), indices.end()); }
/**
* \brief Set array of digi to cluster. Overwrites existing array.
* \param[in] indices Array of digi indices in TClonesArray.
*/
void SetDigis(const std::vector<Int_t>& indices) { fDigis.assign(indices.begin(), indices.end()); }
void SetDigis(const std::vector<int32_t>& indices) { fDigis.assign(indices.begin(), indices.end()); }
/**
* \brief Number of digis in cluster.
* \return Number of digis in cluster.
*/
Int_t GetNofDigis() const { return fDigis.size(); }
int32_t GetNofDigis() const { return fDigis.size(); }
/**
* \brief Get digi at position index.
* \param[in] index Position of digi in array.
* \return Digi index in TClonesArray.
*/
Int_t GetDigi(Int_t index) const { return fDigis[index]; }
int32_t GetDigi(int32_t index) const { return fDigis[index]; }
/**
* \brief Get array of digi indices.
* \return Array of digi indices in TClonesArray.
*/
const std::vector<Int_t>& GetDigis() const { return fDigis; }
const std::vector<int32_t>& GetDigis() const { return fDigis; }
/**
* \brief Remove all digis.
......@@ -87,11 +87,11 @@ public:
void ClearDigis() { fDigis.clear(); }
/** Accessors **/
Int_t GetAddress() const { return fAddress; }
int32_t GetAddress() const { return fAddress; }
CbmMatch* GetMatch() const { return fMatch; }
/** Modifiers **/
void SetAddress(Int_t address) { fAddress = address; }
void SetAddress(int32_t address) { fAddress = address; }
void SetMatch(CbmMatch* match);
/**
......@@ -101,8 +101,8 @@ public:
virtual std::string ToString() const;
private:
std::vector<Int_t> fDigis; ///< Array of digi indices
Int_t fAddress; ///< Unique detector ID
std::vector<int32_t> fDigis; ///< Array of digi indices
int32_t fAddress; ///< Unique detector ID
CbmMatch* fMatch; ///< link to Monte-Carlo information
ClassDef(CbmCluster, 2);
......
......@@ -13,7 +13,8 @@
#include <string> // for char_traits
// ----- Standard constructor ------------------------------------------
CbmErrorMessage::CbmErrorMessage(ECbmModuleId sysId, Double_t dTime, UInt_t uAddress, UInt_t uFlags, UInt_t uPayload)
CbmErrorMessage::CbmErrorMessage(ECbmModuleId sysId, double dTime, uint32_t uAddress, uint32_t uFlags,
uint32_t uPayload)
: fModuleId(sysId)
, fdTime(dTime)
, fuAddress(uAddress)
......
......@@ -18,12 +18,12 @@
/// Fairsoft (Root, Boost, ...) headers
#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
#include <RtypesCore.h> // for UInt_t, Double_t, Int_t
#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
/// C/C++ headers
#include <cstdint>
#include <memory> // for unique_ptr
#include <string> // for string
......@@ -55,7 +55,7 @@ public:
* \param[in] uFlags Flags/error pattern, 32b available.
* \param[in] uPayload Optional error payload, 32b available.
**/
CbmErrorMessage(ECbmModuleId sysId, Double_t dTime, UInt_t uAddress, UInt_t uFlags, UInt_t uPayload = 0);
CbmErrorMessage(ECbmModuleId sysId, double dTime, uint32_t uAddress, uint32_t uFlags, uint32_t uPayload = 0);
/** Destructor **/
......@@ -73,19 +73,19 @@ public:
/** @brief Absolute time [ns] **/
Double_t GetTime() const { return fdTime; }
double GetTime() const { return fdTime; }
/** @brief Origin address **/
UInt_t GetAddress() const { return fuAddress; }
uint32_t GetAddress() const { return fuAddress; }
/** @brief Flags (bitfield) **/
UInt_t GetFlags() const { return fuFlags; }
uint32_t GetFlags() const { return fuFlags; }
/** @brief Payload (optional) **/
UInt_t GetPayload() const { return fuPayload; }
uint32_t GetPayload() const { return fuPayload; }
/** @brief Output information **/
......@@ -106,10 +106,10 @@ private:
friend class boost::serialization::access;
ECbmModuleId fModuleId = ECbmModuleId::kLastModule;
Double_t fdTime = -1.0;
UInt_t fuAddress = 0;
UInt_t fuFlags = 0;
UInt_t fuPayload = 0;
double fdTime = -1.0;
uint32_t fuAddress = 0;
uint32_t fuFlags = 0;
uint32_t fuPayload = 0;
ClassDefNV(CbmErrorMessage, 1);
......
......@@ -16,7 +16,7 @@
// ----- Add data to event ---------------------------------------------
void CbmEvent::AddData(ECbmDataType type, UInt_t index)
void CbmEvent::AddData(ECbmDataType type, uint32_t index)
{
fIndexMap[type].push_back(index);
......@@ -26,7 +26,7 @@ void CbmEvent::AddData(ECbmDataType type, UInt_t index)
// ----- Get a data index ----------------------------------------------
UInt_t CbmEvent::GetIndex(ECbmDataType type, UInt_t iData)
uint32_t CbmEvent::GetIndex(ECbmDataType type, uint32_t iData)
{
if (fIndexMap.find(type) == fIndexMap.end()) return -1;
......@@ -37,7 +37,7 @@ UInt_t CbmEvent::GetIndex(ECbmDataType type, UInt_t iData)
// ----- Get number of data of a type in this event --------------------
Int_t CbmEvent::GetNofData(ECbmDataType type) const
int32_t CbmEvent::GetNofData(ECbmDataType type) const
{
if (fIndexMap.find(type) == fIndexMap.end()) return -1;
......@@ -48,7 +48,7 @@ Int_t CbmEvent::GetNofData(ECbmDataType type) const
// ----- Set the vertex parameters -------------------------------------
void CbmEvent::SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks,
void CbmEvent::SetVertex(double x, double y, double z, double chi2, int32_t ndf, int32_t nTracks,
const TMatrixFSym& covMat)
{
fVertex.SetVertex(x, y, z, chi2, ndf, nTracks, covMat);
......
......@@ -16,10 +16,10 @@
#include "CbmVertex.h" // for CbmVertex, found in core/data/global
#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
#include <RtypesCore.h> // for Double_t, UInt_t, Int_t
#include <TMatrixFSymfwd.h> // for TMatrixFSym
#include <TObject.h> // for TObject
#include <cstdint>
#include <map> // for map, map<>::mapped_type
#include <string> // for string
#include <vector> // for vector
......@@ -42,7 +42,7 @@ public:
** @param[in] startTime Event start time [ns]
** @param[in] endTime Event start time [ns]
**/
CbmEvent(Int_t number, Double_t startTime = 0., Double_t endTime = 0.)
CbmEvent(int32_t number, double startTime = 0., double endTime = 0.)
: TObject()
, fNumber(number)
, fTimeStart(startTime)
......@@ -70,13 +70,13 @@ public:
** @param DataType Type of data (for values see CbmDetectorList.h)
** @param Index Index of the data object in its TClonesArray
*/
void AddData(ECbmDataType type, UInt_t index);
void AddData(ECbmDataType type, uint32_t index);
/** Add an STS track to the event
** @param Index of STS track in its TClonesArray
**/
void AddStsTrack(UInt_t index) { AddData(ECbmDataType::kStsTrack, index); }
void AddStsTrack(uint32_t index) { AddData(ECbmDataType::kStsTrack, index); }
/** Get the index of a data object in its TClonesArray
......@@ -84,7 +84,7 @@ public:
** @param iData Running number of data object in event
** @value Index of data object in its TClonesArray
**/
UInt_t GetIndex(ECbmDataType type, UInt_t iData);
uint32_t GetIndex(ECbmDataType type, uint32_t iData);
/** Get match object
......@@ -94,7 +94,7 @@ public:
/** Get total number of data (of all types) in the event **/
Int_t GetNofData() const { return fNofData; }
int32_t GetNofData() const { return fNofData; }
/** Get number of data objects of a given type in this event
......@@ -102,48 +102,48 @@ public:
** @value Number of objects of type DataType in the event.
** -1 is data type is not registered.
**/
Int_t GetNofData(ECbmDataType type) const;
int32_t GetNofData(ECbmDataType type) const;
/** Get number of STS tracks
** @value Number of STS tracks in the event. -1 if not registered.
**/
Int_t GetNofStsTracks() const { return GetNofData(ECbmDataType::kStsTrack); }
int32_t GetNofStsTracks() const { return GetNofData(ECbmDataType::kStsTrack); }
/** Get event number
** @value Event number
**/
Int_t GetNumber() const { return fNumber; }
int32_t GetNumber() const { return fNumber; }
/** Get STS track index
** @param iTrack Running number of STS track in the event
** @value index Index of STS track in TClonesArray
**/
Int_t GetStsTrackIndex(Int_t iTrack) { return GetIndex(ECbmDataType::kStsTrack, iTrack); }
int32_t GetStsTrackIndex(int32_t iTrack) { return GetIndex(ECbmDataType::kStsTrack, iTrack); }
/** Get event end time
** @value End time of event [ns]
**/
Double_t GetEndTime() const { return fTimeEnd; }
double GetEndTime() const { return fTimeEnd; }
/** Get event start time
** @value Start time of event [ns]
**/
Double_t GetStartTime() const { return fTimeStart; }
double GetStartTime() const { return fTimeStart; }
/** Set event number
** @value Event number
**/
void SetNumber(Int_t number) { fNumber = number; }
void SetNumber(int32_t number) { fNumber = number; }
/** Set end time
** @param endTime End time of event [ns]
**/
void SetEndTime(Double_t endTime) { fTimeEnd = endTime; }
void SetEndTime(double endTime) { fTimeEnd = endTime; }
/** Set a match object
......@@ -155,7 +155,7 @@ public:
/** Set start time
** @param endTime Start time of event [ns]
**/
void SetStartTime(Double_t startTime) { fTimeStart = startTime; }
void SetStartTime(double startTime) { fTimeStart = startTime; }
/** Set the STS track index array
......@@ -163,7 +163,7 @@ public:
** Old content will be overwritten.
** @param indexVector Vector with indices of STS tracks
**/
void SetStsTracks(std::vector<UInt_t>& indexVector)
void SetStsTracks(std::vector<uint32_t>& indexVector)
{
fNofData -= fIndexMap[ECbmDataType::kStsTrack].size();
fIndexMap[ECbmDataType::kStsTrack] = indexVector;
......@@ -180,8 +180,7 @@ public:
*@param nTracks Number of tracks used for vertex fit
*@param covMat Covariance Matrix (symmetric, 3x3)
**/
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks,
const TMatrixFSym& covMat);
void SetVertex(double x, double y, double z, double chi2, int32_t ndf, int32_t nTracks, const TMatrixFSym& covMat);
/** String output **/
......@@ -198,15 +197,15 @@ public:
private:
/** Event meta data **/
Int_t fNumber; ///< Event number
Double_t fTimeStart; ///< Event start time [ns]
Double_t fTimeEnd; ///< Event end time [ns]
Int_t fNofData; ///< Number of data objects in the event
int32_t fNumber; ///< Event number
double fTimeStart; ///< Event start time [ns]
double fTimeEnd; ///< Event end time [ns]
int32_t fNofData; ///< Number of data objects in the event
CbmVertex fVertex; ///< Primary Vertex
CbmMatch* fMatch; ///< Match object to MCEvent
/** Arrays of indices to data types **/
std::map<ECbmDataType, std::vector<UInt_t>> fIndexMap;
std::map<ECbmDataType, std::vector<uint32_t>> fIndexMap;
CbmEvent(const CbmEvent&);
CbmEvent& operator=(const CbmEvent&);
......
......@@ -13,13 +13,11 @@
#include "CbmMatch.h" // for CbmMatch
#include "CbmModuleList.h" // for CbmModuleList
#include <TString.h> // for operator<<
#include <iostream> // for operator<<, basic_ostream, stringstream
// ----- Constructor ---------------------------------------------------
CbmEventStore::CbmEventStore(UInt_t eventId, Bool_t hasMatches) : fEventId(eventId), fHasMatches(hasMatches)
CbmEventStore::CbmEventStore(uint32_t eventId, bool hasMatches) : fEventId(eventId), fHasMatches(hasMatches)
{
// fDigis = new TObjArray(ToIntegralType(ECbmModuleId::kNofSystems));
}
......@@ -50,27 +48,27 @@ CbmEventStore::~CbmEventStore()
// ----- Test for being empty ------------------------------------------
Bool_t CbmEventStore::IsEmpty() const
bool CbmEventStore::IsEmpty() const
{
UInt_t nDigis = 0;
uint32_t nDigis = 0;
for (auto system : fDigis) {
auto* digis = dynamic_cast<CbmDigiContainer*>(system.second);
nDigis += digis->GetNofDigis();
}
/*
for ( Int_t system = 0; system < fDigis->GetEntriesFast(); system++) {
for ( int32_t system = 0; system < fDigis->GetEntriesFast(); system++) {
auto* digis = dynamic_cast<CbmDigiContainer*>(fDigis->At(system));
if ( digis ) nDigis += digis->GetNofDigis();
}
*/
return (nDigis > 0 ? kFALSE : kTRUE);
return (nDigis > 0 ? false : true);
}
// -------------------------------------------------------------------------
// ----- Get number of data for a given system -------------------------
UInt_t CbmEventStore::GetNofDigis(ECbmModuleId system) const
uint32_t CbmEventStore::GetNofDigis(ECbmModuleId system) const
{
if (system >= ECbmModuleId::kNofSystems) return 0;
auto* digis = dynamic_cast<CbmDigiContainer*>(fDigis.at(system));
......@@ -88,10 +86,10 @@ void CbmEventStore::MatchToMC(CbmMatch& result) const
for (auto system : fDigis) {
auto* digis = dynamic_cast<CbmDigiContainer*>(system.second);
if (!digis) continue;
for (UInt_t index = 0; index < digis->GetNofDigis(); index++) {
for (uint32_t index = 0; index < digis->GetNofDigis(); index++) {
const CbmMatch* match = digis->GetDigiMatch(index);
assert(match);
for (Int_t iLink = 0; iLink < match->GetNofLinks(); iLink++) {
for (int32_t iLink = 0; iLink < match->GetNofLinks(); iLink++) {
const CbmLink& link = match->GetLink(iLink);
result.AddLink(link.GetWeight(), 0, link.GetEntry(), link.GetFile());
} //# Links in match
......@@ -100,13 +98,13 @@ void CbmEventStore::MatchToMC(CbmMatch& result) const
/*
for (Int_t system = 0; system < fDigis->GetEntriesFast(); system++) {
for (int32_t system = 0; system < fDigis->GetEntriesFast(); system++) {
auto* digis = dynamic_cast<CbmDigiContainer*>(fDigis->At(system));
if ( ! digis ) continue;
for (UInt_t index = 0; index < digis->GetNofDigis(); index++) {
for (uint32_t index = 0; index < digis->GetNofDigis(); index++) {
const CbmMatch* match = digis->GetDigiMatch(index);
assert(match);
for (Int_t iLink = 0; iLink < match->GetNofLinks(); iLink++) {
for (int32_t iLink = 0; iLink < match->GetNofLinks(); iLink++) {
const CbmLink& link = match->GetLink(iLink);
result.AddLink(link.GetWeight(), 0, link.GetEntry(), link.GetFile());
} //# Links in match
......@@ -127,7 +125,7 @@ std::string CbmEventStore::ToString() const
ss << " Data: ";
for (auto system : fDigis) {
auto* vec = dynamic_cast<CbmDigiContainer*>(system.second);
// for ( Int_t system = 0; system < fDigis->GetEntriesFast(); system++) {
// for ( int32_t system = 0; system < fDigis->GetEntriesFast(); system++) {
// if ( fDigis->At(system) ) {
// auto vec = static_cast<CbmDigiContainer*>(fDigis->At(system));
assert(vec);
......
......@@ -18,16 +18,15 @@
#include <Logger.h> // for LOG
#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
#include <RtypesCore.h> // for UInt_t, Bool_t, kFALSE, kTRUE
#include <TObjArray.h> // for TObjArray
#include <TObject.h> // for TObject
#include <boost/any.hpp> // for any_cast
#include <cassert> // for assert
#include <cstdint>
#include <string> // for string
#include <assert.h> // for assert
class CbmMatch;
/** @class CbmEventStore
......@@ -48,7 +47,7 @@ public:
** @param eventId Unique event identifier
** @param has Matches True if matches to MC are stored
**/
CbmEventStore(UInt_t eventId = 0, Bool_t hasMatches = kFALSE);
CbmEventStore(uint32_t eventId = 0, bool hasMatches = false);
/** @brief Copy constructor **/
......@@ -81,7 +80,7 @@ public:
assert(digi);
ECbmModuleId system = Digi::GetSystem();
assert(system < ECbmModuleId::kNofSystems);
if (!fDigis[system]) fDigis[system] = new CbmDigiVector<Digi>(kFALSE);
if (!fDigis[system]) fDigis[system] = new CbmDigiVector<Digi>(false);
auto digis = static_cast<CbmDigiContainer*>(fDigis.at(system));
assert(digis);
digis->AddDigi(digi, nullptr);
......@@ -108,7 +107,7 @@ public:
assert(match);
ECbmModuleId system = Digi::GetSystem();
assert(system < ECbmModuleId::kNofSystems);
if (!fDigis[system]) fDigis[system] = new CbmDigiVector<Digi>(kTRUE);
if (!fDigis[system]) fDigis[system] = new CbmDigiVector<Digi>(true);
auto digis = static_cast<CbmDigiContainer*>(fDigis.at(system));
assert(digis);
digis->AddDigi(digi, match);
......@@ -123,7 +122,7 @@ public:
** present or the index is out of range.
**/
template<class Digi>
const Digi* GetDigi(UInt_t index) const
const Digi* GetDigi(uint32_t index) const
{
ECbmModuleId system = Digi::GetSystem();
assert(system < ECbmModuleId::kNofSystems);
......@@ -136,26 +135,26 @@ public:
/** @brief Get event ID
** @return Event identifier
**/
UInt_t GetEventId() const { return fEventId; }
uint32_t GetEventId() const { return fEventId; }
/** @brief Number of digis for a given system
** @param system System identifier [ECbmModuleId]
** @return Number of digis for system in event
**/
UInt_t GetNofDigis(ECbmModuleId system) const;
uint32_t GetNofDigis(ECbmModuleId system) const;
/** @brief Presence of match objects
** @param If true, match objects are stored
**/
Bool_t HasMatches() const { return fHasMatches; }
bool HasMatches() const { return fHasMatches; }
/** @brief Indicate whether event contains no digis
** @return True is event is empty
**/
Bool_t IsEmpty() const;
bool IsEmpty() const;
/** @brief Match to MC event
......@@ -176,8 +175,8 @@ public:
private:
UInt_t fEventId = -1; ///< Event identifier
Bool_t fHasMatches = kFALSE; ///< Presence of matches to MC
uint32_t fEventId = -1; ///< Event identifier
bool fHasMatches = false; ///< Presence of matches to MC
// TObjArray* fDigis = nullptr; ///< Array of CbmDigiVector
std::map<ECbmModuleId, TObject*> fDigis; ///< Map of CbmDigiVector
......
......@@ -17,8 +17,7 @@
CbmHit::CbmHit() : CbmHit(kHIT, 0., 0., -1, -1, -1., -1.) {}
CbmHit::CbmHit(HitType _type, Double_t _z, Double_t _dz, Int_t _refId, Int_t _address, Double_t _time,
Double_t _timeError)
CbmHit::CbmHit(HitType _type, double _z, double _dz, int32_t _refId, int32_t _address, double _time, double _timeError)
: TObject()
, fType(_type)
, fZ(_z)
......
......@@ -33,9 +33,9 @@ enum HitType
};
#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
#include <RtypesCore.h> // for Double_t, Int_t
#include <TObject.h> // for TObject
#include <cstdint>
#include <string> // for string, basic_string
class CbmMatch;
......@@ -57,8 +57,8 @@ public:
* \param[in] _time Hit time [ns].
* \param[in] _timeError Error of hit time [ns].