ATLAS Offline Software
Loading...
Searching...
No Matches
JetHypoExerciserAlg.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
14#include <fstream>
15#include <sstream>
16
17std::ostream& operator<<( std::ostream& s, std::pair<double, double > p )
18{
19 s << p.first << " " << p.second;
20 return s;
21}
22
24 ISvcLocator* pSvcLocator) :
25 AthAlgorithm(name, pSvcLocator){
26}
27
29
30
32
33 ATH_MSG_INFO ("initialize()");
34
35
37 (" " << m_helper.propertyName()
38 << " = " << m_helper.type());
39
40 if ( m_helper.retrieve().isFailure() ) {
42 (m_helper.propertyName() << ": Failed to retrieve tool "
43 << m_helper.type());
44 return StatusCode::FAILURE;
45 } else {
47 (m_helper.propertyName() << ": Retrieved tool "
48 << m_helper.type());
49 }
50
51 DebugInfoCollector collector(name());
52 CHECK(m_helper->getDescription(collector));
53 auto s = collector.toString();
54 s += '\n' + m_generator->toString();
55
56 for(const auto& l : lineSplitter(s)){
57 ATH_MSG_INFO(l);
58 }
59
60 if (m_visitDebug){
61 std::ofstream outfile;
62 outfile.open(m_logname);
63 outfile << s;
64 }
65
66 return StatusCode::SUCCESS; return StatusCode::SUCCESS;
67}
68
69// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
70
72
73 // Part 1: print where you are
74 ATH_MSG_INFO ("execute()");
75 ++m_ncall;
76
77 // make a HypoJet, add to vector and send to helper tool
78
79 HypoJetVector jv = m_generator->get();
80
81 std::unique_ptr<ITrigJetHypoInfoCollector> debugInfoCollector(nullptr);
82 if(m_visitDebug){
83 auto collectorName = name() + "debugInfoCollector";
84 debugInfoCollector.reset(new DebugInfoCollector(collectorName));
85 }
86
87 xAODJetCollector jetCollector;
88
89 ATH_MSG_INFO ("Event pass "
90 << m_helper->pass(jv, jetCollector, debugInfoCollector));
91
92 std::stringstream ss;
93 ss << "========= ncall: "<<m_ncall << "==========\n";
94 if(m_visitDebug) ss << debugInfoCollector->toString() + '\n';
95 auto s = ss.str();
96 std::ofstream outfile;
97 outfile.open(m_logname, std::ios_base::app);
98 outfile << s;
99 return StatusCode::SUCCESS;
100}
101
102// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
103
105
106 // Part 1: print where you are
107 ATH_MSG_INFO ("finalize()");
108
109 return StatusCode::SUCCESS;
110}
111
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
std::vector< pHypoJet > HypoJetVector
Definition HypoJetDefs.h:27
std::ostream & operator<<(std::ostream &s, std::pair< double, double > p)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual std::string toString() const override
Gaudi::Property< bool > m_visitDebug
JetHypoExerciserAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_logname
ToolHandle< ITrigJetHypoToolHelper > m_helper
ToolHandle< IHypoJetVectorGenerator > m_generator
std::vector< std::string > lineSplitter(const std::string &s, char delimiter)