ATLAS Offline Software
TileL2Dumper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 /*
5  */
14 #include "TileL2Dumper.h"
15 #include "StoreGate/ReadHandle.h"
16 #include "CxxUtils/StrFormat.h"
17 #include <fstream>
18 
19 
25 TileL2Dumper::TileL2Dumper (const std::string& name, ISvcLocator* svcloc)
26  : AthReentrantAlgorithm (name, svcloc)
27 {
28 }
29 
30 
35 {
36  ATH_CHECK( m_contKey.initialize() );
37  return StatusCode::SUCCESS;
38 }
39 
40 
45 StatusCode TileL2Dumper::execute (const EventContext& ctx) const
46 {
47  std::string fname = CxxUtils::strformat ("%s%s_%08u_%08lu.dump",
48  m_prefix.value().c_str(),
49  m_contKey.key().c_str(),
50  ctx.eventID().run_number(),
51  ctx.eventID().event_number());
52  std::ofstream fout (fname);
53  if (!fout) {
54  ATH_MSG_ERROR ("Cannot open dump file: " << fname);
55  return StatusCode::FAILURE;
56  }
57 
59 
60  fout << "TileL2Container/" << m_contKey.key() << " "
61  << "run " << ctx.eventID().run_number() << " "
62  << "event " << ctx.eventID().event_number() << std::endl;
63 
64  fout << static_cast<std::string> (*cont) << "\n";
65 
66  fout.close();
67 
68  return StatusCode::SUCCESS;
69 }
70 
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TileL2Dumper.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
StrFormat.h
Provide helper functions to create formatted strings.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
dqt_zlumi_alleff_HIST.fout
fout
Definition: dqt_zlumi_alleff_HIST.py:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TileL2Dumper::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: TileL2Dumper.cxx:34
TileL2Dumper::TileL2Dumper
TileL2Dumper(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: TileL2Dumper.cxx:25
TileL2Dumper::m_prefix
Gaudi::Property< std::string > m_prefix
Output file name prefix.
Definition: TileL2Dumper.h:62
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileL2Dumper::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: TileL2Dumper.cxx:45
CxxUtils::strformat
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
Definition: StrFormat.cxx:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
ReadHandle.h
Handle class for reading from StoreGate.
TileL2Dumper::m_contKey
SG::ReadHandleKey< TileL2Container > m_contKey
Handle to access input tile digits.
Definition: TileL2Dumper.h:58