![]() |
|
|||
File indexing completed on 2025-09-17 08:53:37
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file celeritas/ext/RootFileManager.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Config.hh" 0010 0011 #include "corecel/Assert.hh" 0012 0013 #include "RootUniquePtr.hh" 0014 0015 // Forward declare ROOT 0016 class TFile; 0017 class TTree; 0018 0019 namespace celeritas 0020 { 0021 //---------------------------------------------------------------------------// 0022 /*! 0023 * ROOT TFile manager. 0024 * 0025 * Currently this class is *not* thread-safe. Since there 0026 * is only one TFile*, any writer class (such as `RootStepWriter.hh`) can just 0027 * create their own TTrees and ROOT will know how to handle them. 0028 * 0029 * If this is expanded to store one TFile per thread, we will need to expand 0030 * `make_tree("name, "title")` to include a thread id as input parameter. 0031 */ 0032 class RootFileManager 0033 { 0034 public: 0035 #if CELERITAS_USE_ROOT 0036 // Whether ROOT output is enabled 0037 static bool use_root(); 0038 #else 0039 // ROOT is never enabled if ROOT isn't available 0040 constexpr static bool use_root() { return false; } 0041 #endif 0042 0043 // Construct with filename 0044 explicit RootFileManager(char const* filename); 0045 0046 // Get the ROOT filename 0047 char const* filename() const; 0048 0049 // Create tree by passing a name and title 0050 UPRootTreeWritable make_tree(char const* name, char const* title); 0051 0052 // Manually write TFile 0053 void write(); 0054 0055 public: 0056 UPRootFileWritable tfile_; 0057 }; 0058 0059 //---------------------------------------------------------------------------// 0060 #if !CELERITAS_USE_ROOT 0061 inline RootFileManager::RootFileManager(char const*) 0062 { 0063 CELER_NOT_CONFIGURED("ROOT"); 0064 } 0065 #endif 0066 0067 //---------------------------------------------------------------------------// 0068 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |