Skip to content

Commit

Permalink
Merge branch 'dev' into feature_sensitive_volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhlig1 authored Jun 7, 2022
2 parents 011da54 + 8e817e6 commit ad6983f
Show file tree
Hide file tree
Showing 40 changed files with 460 additions and 318 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Deprecate some singleton-like APIs:
* `FairRunAnaProof::Instance()` - keep a pointer to the
object after `new` in your code.
* `FairRadGridManager::Instance()` - Consider using the
`GetRadGridMan()` method on `FairMCApplcation`.
* `FairRadMapManager::Instance`, `FairRadLenManager::Instance`
* Deprecated some other APIs
`FairGeoVector::round` was nonfunctional and never did anything.
* Many items were already deprecated in prior versions.
Marked them with proper C++14 deprecation warnings.
Scheduled them for removal in v20.
Expand Down
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SET(FAIRROOT_MAJOR_VERSION 19)
SET(FAIRROOT_MINOR_VERSION 0)
SET(FAIRROOT_PATCH_VERSION 0)

set(PROJECT_MIN_CXX_STANDARD 14)
set(PROJECT_MIN_CXX_STANDARD 17)

# Set name of our project to "FAIRROOT".
# Has to be done after check of cmake version
Expand Down Expand Up @@ -146,6 +146,12 @@ include(ROOTMacros)
#Check the compiler and set the compile and link flags
Check_Compiler()

if(CMAKE_CXX_CLANG_TIDY)
# Force clang-tidy to the same C++ Standard
list(APPEND CMAKE_CXX_CLANG_TIDY
"--extra-arg=-std=c++${CMAKE_CXX_STANDARD}")
endif()

fairroot_check_root_cxxstd_compatibility()

if(ROOT_vmc_FOUND)
Expand Down Expand Up @@ -213,7 +219,6 @@ EndIf (Boost_FOUND)

set(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
)
set(PROJECT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES})

Expand Down
22 changes: 12 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def jobMatrix(String prefix, String type, List specs) {
nodes[label] = {
node(selector) {
githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING')
def logpattern = 'build/Testing/Temporary/*.log'
try {
deleteDir()
checkout scm
Expand Down Expand Up @@ -62,7 +63,6 @@ def jobMatrix(String prefix, String type, List specs) {
sh "./slurm-submit.sh \"FairRoot \${JOB_BASE_NAME} ${label}\" ${jobscript}"
}
if (check == "warnings") {
def logpattern = 'build/Testing/Temporary/*.log'
discoverGitReferenceBuild()
recordIssues(tools: [clangTidy(pattern: logpattern)],
filters: [excludeFile('build/.*/G__.*[.]cxx')],
Expand All @@ -75,6 +75,9 @@ def jobMatrix(String prefix, String type, List specs) {
deleteDir()
githubNotify(context: "${prefix}/${label}", description: 'Success', status: 'SUCCESS')
} catch (e) {
if (check == "warnings") {
archiveArtifacts(artifacts: logpattern, allowEmptyArchive: true, fingerprint: true)
}
deleteDir()
githubNotify(context: "${prefix}/${label}", description: 'Error', status: 'ERROR')
throw e
Expand All @@ -92,31 +95,30 @@ pipeline{
steps{
script {
def builds = jobMatrix('alfa-ci', 'build', [
[os: 'centos', ver: '7', arch: 'x86_64', compiler: 'gcc-7', fairsoft: 'nov20_patches'],
[os: 'centos', ver: '7', arch: 'x86_64', compiler: 'gcc-7', fairsoft: 'nov20_patches_mt'],
[os: 'centos', ver: '7', arch: 'x86_64', compiler: 'gcc-7', fairsoft: 'apr21_patches'],
[os: 'centos', ver: '7', arch: 'x86_64', compiler: 'gcc-7', fairsoft: 'apr21_patches_mt'],
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'nov20_patches'],
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'nov20_patches_mt'],
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches'],
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches_mt'],
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches'],
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches_mt'],
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr22_patches'],
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr22_patches_mt'],
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'apr21_patches'],
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'apr21_patches_mt'],
[os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev',
check: 'warnings',
extra: '-DUSE_CLANG_TIDY=ON -DBUILD_MBS=OFF'],
[os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'apr21_patches'],
[os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'apr21_patches_mt'],
// [os: 'macos', ver: '10.15', arch: 'x86_64', compiler: 'apple-clang-11', fairsoft: '20.11'],
// [os: 'macos', ver: '11', arch: 'x86_64', compiler: 'apple-clang-12', fairsoft: '20.11'],
[os: 'macos', ver: '12', arch: 'x86_64', compiler: 'apple-clang-13', fairsoft: '21.4'],
[os: 'macos', ver: '11', arch: 'x86_64', compiler: 'apple-clang-13', fairsoft: '21.4'],
[os: 'macos', ver: '12', arch: 'arm64', compiler: 'apple-clang-13', fairsoft: '22.4'],
[os: 'macos', ver: '12', arch: 'x86_64', compiler: 'apple-clang-13', fairsoft: '22.4'],
[os: 'macos', ver: '11', arch: 'x86_64', compiler: 'apple-clang-13', fairsoft: '22.4'],
])

def checks = [:]
if (env.CHANGE_ID != null) { // only run checks for PRs
checks = jobMatrix('alfa-ci', 'check', [
[os: 'debian', ver: '10', arch: 'x86_64', check: 'format', fairsoft: 'nov20_patches'],
[os: 'debian', ver: '10', arch: 'x86_64', check: 'format', fairsoft: 'apr21_patches'],
])
}

Expand Down
15 changes: 11 additions & 4 deletions base/MQ/policies/Serialization/RootSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct RootSerializer
template<typename T>
void Serialize(fair::mq::Message& msg, T* input)
{
TMessage* tm = new TMessage(kMESS_OBJECT);
auto tm = new TMessage(kMESS_OBJECT);
tm->WriteObject(input);
msg.Rebuild(
tm->Buffer(), tm->BufferSize(), [](void*, void* tmsg) { delete static_cast<TMessage*>(tmsg); }, tm);
Expand All @@ -50,26 +50,33 @@ struct RootSerializer
template<typename T>
void Serialize(fair::mq::Message& msg, const std::unique_ptr<T>& input)
{
TMessage* tm = new TMessage(kMESS_OBJECT);
auto tm = new TMessage(kMESS_OBJECT);
tm->WriteObject(input.get());
msg.Rebuild(
tm->Buffer(), tm->BufferSize(), [](void*, void* tmsg) { delete static_cast<TMessage*>(tmsg); }, tm);
}

template<typename T>
void Deserialize(fair::mq::Message& msg, T*& output)
void Deserialize(const fair::mq::Message& msg, T*& output)
{
delete output;
FairTMessage tm(msg.GetData(), msg.GetSize());
output = static_cast<T*>(tm.ReadObjectAny(tm.GetClass()));
}

template<typename T>
void Deserialize(fair::mq::Message& msg, std::unique_ptr<T>& output)
void Deserialize(const fair::mq::Message& msg, std::unique_ptr<T>& output)
{
FairTMessage tm(msg.GetData(), msg.GetSize());
output.reset(static_cast<T*>(tm.ReadObjectAny(tm.GetClass())));
}

template<typename T>
[[nodiscard]] std::unique_ptr<T> DeserializeTo(const fair::mq::Message& msg)
{
FairTMessage tm(msg.GetData(), msg.GetSize());
return std::unique_ptr<T>{static_cast<T*>(tm.ReadObjectAny(tm.GetClass()))};
}
};

#endif /* ROOTSERIALIZER_H */
5 changes: 5 additions & 0 deletions base/sim/FairMCApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ class FairMCApplication : public TVirtualMCApplication
*/
FairVolume* GetFairVolume();

/**
* Return non-owning pointer to FairRadGridManager
*/
auto GetRadGridMan() { return fRadGridMan.get(); }

private:
// methods
Int_t GetIonPdg(Int_t z, Int_t a) const;
Expand Down
6 changes: 6 additions & 0 deletions base/sink/FairRootFileSink.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ void FairRootFileSink::RegisterImpl(const char* /* name */, const char* folderNa

void FairRootFileSink::RegisterAny(const char* brname, const std::type_info& oi, const std::type_info& pi, void* obj)
{
if (fPersistentBranchesDone) {
LOG(warning) << "FairRootFileSink::RegisterAny called for branch \"" << brname
<< "\" after FairRootFileSink::CreatePersistentBranchesAny has already completed. "
"The branch will not be registered.";
}
fPersistentBranchesMap[brname] = std::unique_ptr<TypeAddressPair const>(new TypeAddressPair(oi, pi, obj));
}

Expand Down Expand Up @@ -303,6 +308,7 @@ bool FairRootFileSink::CreatePersistentBranchesAny()
LOG(info) << "Creating branch for " << iter.first.c_str() << " with address " << obj;
fOutTree->Branch(iter.first.c_str(), tname.c_str(), obj);
}
fPersistentBranchesDone = true;
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions base/sink/FairRootFileSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class FairRootFileSink : public FairSink
/**File Header*/
FairFileHeader* fFileHeader; //!

bool fPersistentBranchesDone{false}; //!

ClassDef(FairRootFileSink, 1);
};

Expand Down
4 changes: 2 additions & 2 deletions base/steer/FairRadGridManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class FairRadGridManager
/**
* Default constructor.
* Creates the singleton object of FairRadGridManager class.
* The pointer to this object can be reached via FairRadGridManager::Instance().
*/
FairRadGridManager();
/**
Expand Down Expand Up @@ -112,8 +111,9 @@ class FairRadGridManager
* This function is used to access the methods of the class.
* @return Pointer to the singleton FairRadGridManager object, created
* with FairRadGridManager::FairRadGridManager().
* \deprecated Deprecated in v19, will be removed in v20.
*/
static FairRadGridManager* Instance();
[[deprecated("Maybe use FairMCApplcation::GetRadGridMan()")]] static FairRadGridManager* Instance();
};

#endif
6 changes: 0 additions & 6 deletions base/steer/FairRootManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ class FairRootManager : public TObject
/** create a new branch based on an arbitrary type T (for which a dictionary must exist) **/
template<typename T>
void RegisterAny(const char* name, T*& obj, Bool_t toFile);
/// for branches which are not managed by folders, we need a special function
/// to trigger persistent branch creation
/// return true if successful; false if problem
bool CreatePersistentBranchesAny();

void RegisterInputObject(const char* name, TObject* obj);

Expand Down Expand Up @@ -355,8 +351,6 @@ class FairRootManager : public TObject
/// used for branches registered with RegisterAny; use of ptr here
/// since type_info cannot be copied
std::map<std::string, std::unique_ptr<TypeAddressPair const>> fAnyBranchMap; //!
/// keeps track of branches which are supposed to be persistified
std::vector<std::string> fPersistentBranchesAny;

/**Branch id for this run */
Int_t fBranchSeqId;
Expand Down
5 changes: 5 additions & 0 deletions base/steer/FairRunSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ class FairRunSim : public FairRun

void StopMCRun() { fApp->StopMCRun(); }

/**
* Get non-owning pointer to FairMCApplication
*/
auto GetMCApplication() { return fApp; }

private:
FairRunSim(const FairRunSim& M);
FairRunSim& operator=(const FairRunSim&) { return *this; }
Expand Down
10 changes: 0 additions & 10 deletions eventdisplay/FairEventManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,10 @@ void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
fAxesPhi = new TEveProjectionAxes(fRPhiProjManager);
fAxesRho = new TEveProjectionAxes(fRhoZProjManager);

TEveWindowSlot *RPhiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
TEveWindowPack *RPhiPack = RPhiSlot->MakePack();
RPhiPack->SetElementName("RPhi View");
RPhiPack->SetShowTitleBar(kFALSE);
RPhiPack->NewSlot()->MakeCurrent();
fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
fRPhiScene = gEve->SpawnNewScene("RPhi", "Scene holding axis.");
fRPhiScene->AddElement(fAxesPhi);

TEveWindowSlot *RhoZSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
TEveWindowPack *RhoZPack = RhoZSlot->MakePack();
RhoZPack->SetElementName("RhoZ View");
RhoZPack->SetShowTitleBar(kFALSE);
RhoZPack->NewSlot()->MakeCurrent();
fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
fRhoZScene = gEve->SpawnNewScene("RhoZ", "Scene holding axis.");
fRhoZScene->AddElement(fAxesRho);
Expand Down
60 changes: 22 additions & 38 deletions examples/MQ/pixelDetector/src/devices/FairMQPixelFileSink.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

#include "RootSerializer.h"

#include <TFile.h>
#include <TObject.h>
#include <TTree.h>
#include <cstdlib>
#include <fairlogger/Logger.h>
#include <memory>
Expand All @@ -31,12 +29,6 @@ FairMQPixelFileSink::FairMQPixelFileSink()
, fFileName()
, fTreeName()
, fFileOption()
, fFlowMode(false)
, fWrite(false)
, fOutFile(nullptr)
, fTree(nullptr)
, fNObjects(0)
, fOutputObjects(new TObject*[1000])
{}

void FairMQPixelFileSink::InitTask()
Expand All @@ -49,47 +41,46 @@ void FairMQPixelFileSink::InitTask()
fFileOption = "RECREATE";
fTreeName = "cbmsim";

if (::getenv("DDS_SESSION_ID")) {
std::string DDS_SESSION_ID = ::getenv("DDS_SESSION_ID");
if (const char* dds_session_env = ::getenv("DDS_SESSION_ID")) {
std::string DDS_SESSION_ID{dds_session_env};
if (fFileName.length() > 5) {
DDS_SESSION_ID = "." + DDS_SESSION_ID + ".root";
fFileName.replace(fFileName.length() - 5, 5, DDS_SESSION_ID.c_str());
}
}

fOutFile = TFile::Open(fFileName.c_str(), fFileOption.c_str());
fOutFile.reset(TFile::Open(fFileName.c_str(), fFileOption.c_str()));

OnData(fInputChannelName, &FairMQPixelFileSink::StoreData);
}

bool FairMQPixelFileSink::StoreData(fair::mq::Parts& parts, int /*index*/)
{
bool creatingTree = false;
std::vector<TObject*> tempObjects;
auto numParts = parts.Size();
std::vector<std::unique_ptr<TObject>> cleanup;
std::vector<TObject*> objectsForBranches;

if (!fTree) {
creatingTree = true;
fTree = new TTree(fTreeName.c_str(), "/cbmout");
fTree = std::make_unique<TTree>(fTreeName.c_str(), "/cbmout");
}

for (int ipart = 0; ipart < parts.Size(); ipart++) {
fOutputObjects[ipart] = nullptr;
RootSerializer().Deserialize(*parts.At(ipart), fOutputObjects[ipart]);
tempObjects.push_back(fOutputObjects[ipart]);
if (creatingTree)
fTree->Branch(tempObjects.back()->GetName(), tempObjects.back()->ClassName(), &fOutputObjects[ipart]);
fTree->SetBranchAddress(tempObjects.back()->GetName(), &fOutputObjects[ipart]);
cleanup.reserve(numParts);
objectsForBranches.resize(numParts, nullptr);
for (int ipart = 0; ipart < numParts; ipart++) {
auto curobj = RootSerializer().DeserializeTo<TObject>(*parts.At(ipart));
objectsForBranches.at(ipart) = curobj.get();
if (creatingTree) {
fTree->Branch(curobj->GetName(), curobj->ClassName(), &objectsForBranches[ipart]);
}
fTree->SetBranchAddress(curobj->GetName(), &objectsForBranches[ipart]);
cleanup.emplace_back(std::move(curobj));
}
// LOG(INFO) << "Finished branches";
fTree->Fill();

for (unsigned int ipart = 0; ipart < tempObjects.size(); ipart++) {
if (tempObjects[ipart]) {
delete tempObjects[ipart];
}
}
tempObjects.clear();

if (fAckChannelName != "") {
if (!fAckChannelName.empty()) {
auto msg(NewMessage());
Send(msg, fAckChannelName);
}
Expand All @@ -100,6 +91,8 @@ void FairMQPixelFileSink::ResetTask()
{
if (fTree) {
fTree->Write();
// Delete the tree, because we're going to close the file
fTree.reset();
}

if (fOutFile) {
Expand All @@ -109,13 +102,4 @@ void FairMQPixelFileSink::ResetTask()
}
}

FairMQPixelFileSink::~FairMQPixelFileSink()
{
if (fTree) {
delete fTree;
}

if (fOutFile) {
delete fOutFile;
}
}
FairMQPixelFileSink::~FairMQPixelFileSink() = default;
Loading

0 comments on commit ad6983f

Please sign in to comment.