ATLAS Offline Software
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 
13 #include "DummyInitAlg.h"
15 #include "TDirectory.h"
16 #include "TFile.h"
17 #include "TError.h"
18 
19 
20 namespace {
21 
22 
23 class ATLAS_NOT_THREAD_SAFE DirectoryRestore
24  : public TDirectory::TContext
25 {
26 public:
27  DirectoryRestore();
28  ~DirectoryRestore();
29 
30 private:
31  TFile* m_file;
32  int m_ge;
33 };
34 
35 
36 DirectoryRestore::DirectoryRestore()
37  : TDirectory::TContext (0),
38  m_file (gFile),
39  m_ge (gErrorIgnoreLevel)
40 {
41 }
42 
43 
44 DirectoryRestore::~DirectoryRestore()
45 {
46  gFile = m_file;
47  gErrorIgnoreLevel = m_ge;
48 }
49 
50 
51 }
52 
53 
54 namespace D3PD {
55 
56 
57 DummyInitAlg::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 
70 {
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
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
D3PD::DummyInitAlg::DummyInitAlg
DummyInitAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition: DummyInitAlg.cxx:57
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
m_file
std::unique_ptr< TFile > m_file
description: this is a custom writer for the old-school drivers that don't use an actual writer
Definition: OutputStreamData.cxx:52
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::ATLAS_NOT_THREAD_SAFE
StatusCode DummyInitAlg::initialize ATLAS_NOT_THREAD_SAFE()
Standard Gaudi initialize method.
Definition: DummyInitAlg.cxx:69
AthAlgorithm
Definition: AthAlgorithm.h:47
D3PD::DummyInitAlg::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: DummyInitAlg.h:60
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
gErrorIgnoreLevel
int gErrorIgnoreLevel
DummyInitAlg.h
Work around initialization ordering problems.
D3PD::DummyInitAlg::execute
virtual StatusCode execute() override
Standard Gaudi execute method.
Definition: DummyInitAlg.cxx:98