ATLAS Offline Software
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 
17 std::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 
lineSplitter.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TLorentzVectorFactory.h
DebugInfoCollector::toString
virtual std::string toString() const override
Definition: DebugInfoCollector.cxx:70
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JetHypoExerciserAlg::JetHypoExerciserAlg
JetHypoExerciserAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JetHypoExerciserAlg.cxx:23
HypoJetDefs.h
JetHypoExerciserAlg::m_helper
ToolHandle< ITrigJetHypoToolHelper > m_helper
Definition: JetHypoExerciserAlg.h:30
operator<<
std::ostream & operator<<(std::ostream &s, std::pair< double, double > p)
Definition: JetHypoExerciserAlg.cxx:17
JetHypoExerciserAlg::m_visitDebug
Gaudi::Property< bool > m_visitDebug
Definition: JetHypoExerciserAlg.h:38
JetHypoExerciserAlg::finalize
StatusCode finalize()
Definition: JetHypoExerciserAlg.cxx:104
JetHypoExerciserAlg::m_generator
ToolHandle< IHypoJetVectorGenerator > m_generator
Definition: JetHypoExerciserAlg.h:33
lineSplitter
std::vector< std::string > lineSplitter(const std::string &s, char delimiter)
Definition: lineSplitter.cxx:8
TLorentzVectorAsIJet.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DebugInfoCollector.h
DebugInfoCollector
Definition: DebugInfoCollector.h:13
xAODJetCollector.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
HypoJetVector
std::vector< pHypoJet > HypoJetVector
Definition: HypoJetDefs.h:27
AthAlgorithm
Definition: AthAlgorithm.h:47
JetHypoExerciserAlg::m_ncall
std::size_t m_ncall
Definition: JetHypoExerciserAlg.h:43
ITrigJetHypoToolHelper.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAODJetCollector
Definition: xAODJetCollector.h:20
JetHypoExerciserAlg::~JetHypoExerciserAlg
virtual ~JetHypoExerciserAlg()
Definition: JetHypoExerciserAlg.cxx:28
JetHypoExerciserAlg.h
JetHypoExerciserAlg::initialize
StatusCode initialize()
Definition: JetHypoExerciserAlg.cxx:31
JetHypoExerciserAlg::m_logname
Gaudi::Property< std::string > m_logname
Definition: JetHypoExerciserAlg.h:41
JetHypoExerciserAlg::execute
StatusCode execute()
Definition: JetHypoExerciserAlg.cxx:71
ITrigJetHypoInfoCollector::toString
virtual std::string toString() const =0
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42