ATLAS Offline Software
Loading...
Searching...
No Matches
TileBeamElemDumper.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 */
12
13
14#include "TileBeamElemDumper.h"
16#include "CxxUtils/StrFormat.h"
17#include <fstream>
18
19
25TileBeamElemDumper::TileBeamElemDumper (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
45StatusCode TileBeamElemDumper::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 << "TileBeamElemContainer/" << m_contKey.key() << " "
61 << "run " << ctx.eventID().run_number() << " "
62 << "event " << ctx.eventID().event_number() << std::endl;
63
64 fout << "Type: " << cont->get_type() << " ("
65 << TileFragHash::typeToString (cont->get_type()) << ") Units: "
66 << cont->get_unit() << " ("
67 << TileRawChannelUnit::unitToString (cont->get_unit())
68 << ") BSflags: 0x" << std::hex << cont->get_bsflags() << std::dec
69 << std::endl;
70
71 for (auto coll : *cont) {
72 fout << static_cast<std::string> (*coll);
73 fout << "\n";
74 }
75
76 fout.close();
77
78 return StatusCode::SUCCESS;
79}
80
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for reading from StoreGate.
Provide helper functions to create formatted strings.
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< std::string > m_prefix
Output file name prefix.
TileBeamElemDumper(const std::string &name, ISvcLocator *svcloc)
Constructor.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
SG::ReadHandleKey< TileBeamElemContainer > m_contKey
Handle to access input tile digits.
static std::string typeToString(TYPE type)
Printable representation of a type.
static std::string unitToString(UNIT type)
Printable representation of a unit.
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
Definition StrFormat.cxx:49