ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelDumper.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
16#include "CxxUtils/StrFormat.h"
17#include <fstream>
18
19
25TileRawChannelDumper::TileRawChannelDumper (const std::string& name, ISvcLocator* svcloc)
26 : AthReentrantAlgorithm (name, svcloc)
27{
28}
29
30
35{
36 ATH_CHECK( m_contKey.initialize() );
37 if (!m_altContKey.key().empty()) {
38 ATH_CHECK( m_altContKey.initialize() );
39 }
40 return StatusCode::SUCCESS;
41}
42
43
48StatusCode TileRawChannelDumper::execute (const EventContext& ctx) const
49{
50 if (!m_altContKey.key().empty()) {
52 *altCont;
53 }
54
55 std::string fname = CxxUtils::strformat ("%s%s_%08u_%08lu.dump",
56 m_prefix.value().c_str(),
57 m_contKey.key().c_str(),
58 ctx.eventID().run_number(),
59 ctx.eventID().event_number());
60 std::ofstream fout (fname);
61 if (!fout) {
62 ATH_MSG_ERROR ("Cannot open dump file: " << fname);
63 return StatusCode::FAILURE;
64 }
65
67
68 fout << "TileRawChannelContainer/" << m_contKey.key() << " "
69 << "run " << ctx.eventID().run_number() << " "
70 << "event " << ctx.eventID().event_number() << std::endl;
71
72 fout << "Type: " << cont->get_type() << " ("
73 << TileFragHash::typeToString (cont->get_type()) << ") Units: "
74 << cont->get_unit() << " ("
75 << TileRawChannelUnit::unitToString (cont->get_unit())
76 << ") BSflags: 0x" << std::hex << cont->get_bsflags() << std::dec
77 << std::endl;
78
79 for (const TileRawChannelCollection* coll : *cont) {
80 fout << static_cast<std::string> (*coll);
81 fout << "\n";
82 }
83
84 fout.close();
85
86 return StatusCode::SUCCESS;
87}
88
#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.
static std::string typeToString(TYPE type)
Printable representation of a type.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Gaudi::Property< std::string > m_prefix
Output file name prefix.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
TileRawChannelDumper(const std::string &name, ISvcLocator *svcloc)
Constructor.
SG::ReadHandleKey< TileRawChannelContainer > m_altContKey
Optional additional input dependency — used when we access the object produced on the side by the con...
SG::ReadHandleKey< TileRawChannelContainer > m_contKey
Handle to access input tile digits.
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