ATLAS Offline Software
TileDigitsDumper.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 "TileDigitsDumper.h"
15 #include "StoreGate/ReadHandle.h"
16 #include "CxxUtils/StrFormat.h"
17 #include <fstream>
18 
19 
25 TileDigitsDumper::TileDigitsDumper (const std::string& name, ISvcLocator* svcloc)
26  : AthReentrantAlgorithm (name, svcloc)
27 {
28 }
29 
30 
35 {
37  if (!m_altContKey.key().empty()) {
39  }
40  return StatusCode::SUCCESS;
41 }
42 
43 
48 StatusCode TileDigitsDumper::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 << "TileDigitsContainer/" << 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() << " ("
76  << ") BSflags: 0x" << std::hex << cont->get_bsflags() << std::dec
77  << std::endl;
78 
79  for (const TileDigitsCollection* coll : *cont) {
80  fout << static_cast<std::string> (*coll);
81  coll->printExtra (fout);
82  fout << "\n";
83  }
84 
85  fout.close();
86 
87  return StatusCode::SUCCESS;
88 }
89 
TileDigitsDumper::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: TileDigitsDumper.cxx:34
TileDigitsDumper::m_altContKey
SG::ReadHandleKey< TileDigitsContainer > m_altContKey
Optional additional input dependency — used when we access the object produced on the side by the con...
Definition: TileDigitsDumper.h:63
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
StrFormat.h
Provide helper functions to create formatted strings.
TileFragHash::typeToString
static std::string typeToString(TYPE type)
Printable representation of a type.
Definition: TileFragHash.cxx:85
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
TileRawDataContainer::get_bsflags
uint32_t get_bsflags() const
Definition: TileRawDataContainer.h:64
TileDigitsDumper::m_contKey
SG::ReadHandleKey< TileDigitsContainer > m_contKey
Handle to access input tile digits.
Definition: TileDigitsDumper.h:58
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TileDigitsCollection
Definition: TileDigitsCollection.h:18
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
TileDigitsDumper.h
TileRawDataContainer::get_type
TYPE get_type() const
Definition: TileRawDataContainer.h:62
TileRawChannelUnit::unitToString
static std::string unitToString(UNIT type)
Printable representation of a unit.
Definition: TileRawChannelUnit.cxx:14
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
TileRawDataContainer::get_unit
UNIT get_unit() const
Definition: TileRawDataContainer.h:60
TileDigitsDumper::m_prefix
Gaudi::Property< std::string > m_prefix
Output file name prefix.
Definition: TileDigitsDumper.h:67
TileDigitsDumper::TileDigitsDumper
TileDigitsDumper(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: TileDigitsDumper.cxx:25
ReadHandle.h
Handle class for reading from StoreGate.
TileDigitsDumper::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: TileDigitsDumper.cxx:48