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