|
1 | 1 | /******************************************************************************** |
2 | | - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * |
| 2 | + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * |
3 | 3 | * * |
4 | 4 | * This software is distributed under the terms of the * |
5 | 5 | * GNU Lesser General Public Licence (LGPL) version 3, * |
|
31 | 31 | #include <cmath> // floor, fmod |
32 | 32 | #include <fairlogger/Logger.h> |
33 | 33 |
|
| 34 | +using fairroot::detail::maybe_owning_ptr; |
| 35 | +using fairroot::detail::non_owning; |
| 36 | + |
34 | 37 | FairMixedSource::FairMixedSource(TFile* f, const char* Title, UInt_t) |
35 | | - : FairFileSourceBase() |
| 38 | + : FairFileSourceBase(maybe_owning_ptr<TFile>{f, non_owning}) |
36 | 39 | , fRootManager(0) |
37 | 40 | , fInputTitle(Title) |
38 | | - , fRootFile(f) |
39 | 41 | , fFriendFileList() |
40 | 42 | , fInputChainList() |
41 | 43 | , fFriendTypeList() |
@@ -74,19 +76,15 @@ FairMixedSource::FairMixedSource(TFile* f, const char* Title, UInt_t) |
74 | 76 | , fRunIdFromSG(kFALSE) |
75 | 77 | , fRunIdFromSG_identifier(0) |
76 | 78 | { |
77 | | - if ((!fRootFile) || fRootFile->IsZombie()) { |
78 | | - LOG(fatal) << "Error opening the Input file"; |
79 | | - } |
80 | 79 | LOG(info) << "FairMixedSource created------------"; |
81 | 80 |
|
82 | 81 | fRootManager = FairRootManager::Instance(); |
83 | 82 | } |
84 | 83 |
|
85 | 84 | FairMixedSource::FairMixedSource(const TString* RootFileName, const char* Title, UInt_t) |
86 | | - : FairFileSourceBase() |
| 85 | + : FairFileSourceBase(std::unique_ptr<TFile>{TFile::Open(RootFileName->Data())}) |
87 | 86 | , fRootManager(0) |
88 | 87 | , fInputTitle(Title) |
89 | | - , fRootFile(0) |
90 | 88 | , fFriendFileList() |
91 | 89 | , fInputChainList() |
92 | 90 | , fFriendTypeList() |
@@ -125,19 +123,14 @@ FairMixedSource::FairMixedSource(const TString* RootFileName, const char* Title, |
125 | 123 | , fRunIdFromSG(kFALSE) |
126 | 124 | , fRunIdFromSG_identifier(0) |
127 | 125 | { |
128 | | - fRootFile = TFile::Open(RootFileName->Data()); |
129 | | - if ((!fRootFile) || fRootFile->IsZombie()) { |
130 | | - LOG(fatal) << "Error opening the Input file"; |
131 | | - } |
132 | 126 | fRootManager = FairRootManager::Instance(); |
133 | 127 | LOG(info) << "FairMixedSource created------------"; |
134 | 128 | } |
135 | 129 |
|
136 | 130 | FairMixedSource::FairMixedSource(const TString RootFileName, const Int_t signalId, const char* Title, UInt_t) |
137 | | - : FairFileSourceBase() |
| 131 | + : FairFileSourceBase(std::unique_ptr<TFile>{TFile::Open(RootFileName.Data())}) |
138 | 132 | , fRootManager(0) |
139 | 133 | , fInputTitle(Title) |
140 | | - , fRootFile(0) |
141 | 134 | , fFriendFileList() |
142 | 135 | , fInputChainList() |
143 | 136 | , fFriendTypeList() |
@@ -176,11 +169,6 @@ FairMixedSource::FairMixedSource(const TString RootFileName, const Int_t signalI |
176 | 169 | , fRunIdFromSG(kFALSE) |
177 | 170 | , fRunIdFromSG_identifier(0) |
178 | 171 | { |
179 | | - fRootFile = TFile::Open(RootFileName.Data()); |
180 | | - if ((!fRootFile) || fRootFile->IsZombie()) { |
181 | | - LOG(fatal) << "Error opening the Input file"; |
182 | | - } |
183 | | - |
184 | 172 | if (signalId == 0) { |
185 | 173 | SetBackgroundFile(RootFileName); |
186 | 174 | } else { |
@@ -456,8 +444,8 @@ void FairMixedSource::SetBackgroundFile(TString name) |
456 | 444 | if (name.IsNull()) { |
457 | 445 | LOG(info) << "No background file defined."; |
458 | 446 | } |
459 | | - fRootFile = TFile::Open(name); |
460 | | - if (fRootFile->IsZombie()) { |
| 447 | + fRootFile = std::unique_ptr<TFile>{TFile::Open(name)}; |
| 448 | + if ((!fRootFile) || fRootFile->IsZombie()) { |
461 | 449 | LOG(fatal) << "Error opening the Background file " << name.Data(); |
462 | 450 | } |
463 | 451 | } |
|
0 commit comments