ATLAS Offline Software
Loading...
Searching...
No Matches
DummyInitAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12
13#include "DummyInitAlg.h"
15#include "TDirectory.h"
16#include "TFile.h"
17#include "TError.h"
18
19
20namespace {
21
22
23class ATLAS_NOT_THREAD_SAFE DirectoryRestore
24 : public TDirectory::TContext
25{
26public:
27 DirectoryRestore();
28 ~DirectoryRestore();
29
30private:
31 TFile* m_file;
32 int m_ge;
33};
34
35
36DirectoryRestore::DirectoryRestore()
37 : TDirectory::TContext (0),
38 m_file (gFile),
40{
41}
42
43
44DirectoryRestore::~DirectoryRestore()
45{
46 gFile = m_file;
47 gErrorIgnoreLevel = m_ge;
48}
49
50
51}
52
53
54namespace D3PD {
55
56
57DummyInitAlg::DummyInitAlg (const std::string& name,
58 ISvcLocator* svcloc)
59 : AthAlgorithm (name, svcloc),
60 m_histSvc ("THistSvc", name)
61{
62 declareProperty ("HistSvc", m_histSvc);
63}
64
65
69StatusCode DummyInitAlg::initialize ATLAS_NOT_THREAD_SAFE()
70{
71 CHECK( AthAlgorithm::initialize() );
72
73 // THistSvc has a bug whereby if it opens output files,
74 // then it leaves the root directory pointing at the last output
75 // file when initialize returns. This means that other root
76 // objects that are meant to be transient can end up in this file.
77 // Worse, we can get a double-delete, as these transient objects
78 // will then be deleted when the file is closed.
79 //
80 // We do this here in the hope that we're the first to call THistSvc.
81 // Maybe we should also bash the current directory back to TROOT?
82 //
83 // This can be removed once this is fixed in THistSvc.
84 // https://savannah.cern.ch/bugs/index.php?60162
85 {
86 DirectoryRestore save;
87 CHECK( m_histSvc.retrieve() );
88 }
89
90 CHECK( detStore().retrieve() );
91 return StatusCode::SUCCESS;
92}
93
94
99{
100 return StatusCode::SUCCESS;
101}
102
103
104} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Work around initialization ordering problems.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
DummyInitAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
ServiceHandle< ITHistSvc > m_histSvc
virtual StatusCode execute() override
Standard Gaudi execute method.
StatusCode DummyInitAlg::initialize ATLAS_NOT_THREAD_SAFE()
Standard Gaudi initialize method.