ATLAS Offline Software
MuonSegmentPseudoJetAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 //**********************************************************************
11 
13  ATH_MSG_INFO("Initializing " << name() << "...");
14 
15  print();
16 
17  if(m_incoll.key().empty() || m_outcoll.key().empty()) {
18  ATH_MSG_ERROR("Either input or output collection is empty!");
19  return StatusCode::FAILURE;
20  }
21 
22  ATH_CHECK( m_incoll.initialize() );
24 
25  return StatusCode::SUCCESS;
26 }
27 
28 //**********************************************************************
29 
30 StatusCode MuonSegmentPseudoJetAlgorithm::execute(const EventContext& ctx) const {
31  ATH_MSG_VERBOSE("Executing " << name() << "...");
32 
33  auto incoll = SG::makeHandle<xAOD::MuonSegmentContainer>(m_incoll,ctx);
34  if( !incoll.isValid() ) {
35  // Return SUCCESS to avoid crashing T0 jobs
36  ATH_MSG_WARNING("Failed to retrieve " << m_incoll.key() << " for PseudoJet creation!" );
37  return StatusCode::SUCCESS;
38  }
39  ATH_MSG_DEBUG("Retrieved muon segment container " << m_incoll.key() );
40 
41  std::vector<fastjet::PseudoJet> vpj = createPseudoJets(*incoll);
42 
43  // create an extractor (MuonSegmentExtractors are always ghost extractors)
44  auto extractor = std::make_unique<MuonSegmentExtractor>(incoll.cptr(), m_label);
45  ATH_MSG_DEBUG("Created extractor: " << extractor->toString(0));
46 
47  // Put the PseudoJetContainer together
48  auto pjcont = std::make_unique<PseudoJetContainer>(std::move(extractor), vpj);
49 
50  auto outcoll = SG::makeHandle<PseudoJetContainer>(m_outcoll,ctx);
51  ATH_MSG_DEBUG("New PseudoJetContainer size " << pjcont->size());
52  ATH_CHECK(outcoll.record(std::move(pjcont)));
53 
54  return StatusCode::SUCCESS;
55 }
56 
57 //**********************************************************************
58 
59 std::vector<fastjet::PseudoJet>
61 
62  std::vector<fastjet::PseudoJet> vpj;
63  int index=0;
64  for(const xAOD::MuonSegment* part: ms) {
65  double pt = m_pt;
66  double x = part->x();
67  double y = part->y();
68  double z = part->z();
69  double xy = sqrt(x*x + y*y);
70  double r = sqrt(xy*xy + z*z);
71  double pfac = pt/xy;
72  double px = pfac*x;
73  double py = pfac*y;
74  double pz = pfac*z;
75  double e = pfac*r;
76  fastjet::PseudoJet psj(px, py, pz, e);
77  ATH_MSG_VERBOSE("Muon segment pseudojet y: " << psj.rap());
78  vpj.push_back(psj);
79  vpj.back().set_user_index(index); // Set the index !!
80  index++;
81  }
82 
83  return vpj;
84 }
85 
86 //**********************************************************************
87 
89  ATH_MSG_INFO("Properties for MuonSegmentPseudoJetGetter " << name());
90  ATH_MSG_INFO(" Label: " << m_label);
91  ATH_MSG_INFO(" Input container: " << m_incoll.key());
92  ATH_MSG_INFO(" Output container: " << m_outcoll.key());
93  ATH_MSG_INFO(" Pseudojet pT: " << m_pt);
94 }
95 
96 //**********************************************************************
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
WriteHandle.h
Handle class for recording to StoreGate.
beamspotman.r
def r
Definition: beamspotman.py:676
test_pyathena.px
px
Definition: test_pyathena.py:18
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
index
Definition: index.py:1
MuonSegmentPseudoJetAlgorithm::m_label
Gaudi::Property< std::string > m_label
Label for the collection.
Definition: MuonSegmentPseudoJetAlgorithm.h:57
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
MuonSegmentExtractor.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
x
#define x
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
MuonSegmentPseudoJetAlgorithm::m_outcoll
SG::WriteHandleKey< PseudoJetContainer > m_outcoll
Output collection name.
Definition: MuonSegmentPseudoJetAlgorithm.h:54
MuonSegmentPseudoJetAlgorithm::m_incoll
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_incoll
Input collection name.
Definition: MuonSegmentPseudoJetAlgorithm.h:51
MuonSegmentPseudoJetAlgorithm::m_pt
Gaudi::Property< float > m_pt
Definition: MuonSegmentPseudoJetAlgorithm.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
z
#define z
MuonSegmentPseudoJetAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: MuonSegmentPseudoJetAlgorithm.cxx:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ReadHandle.h
Handle class for reading from StoreGate.
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
MuonSegmentPseudoJetAlgorithm::initialize
virtual StatusCode initialize() override final
Athena algorithm's Hooks.
Definition: MuonSegmentPseudoJetAlgorithm.cxx:12
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonSegmentPseudoJetAlgorithm::print
virtual void print() const
Dump to properties to the log.
Definition: MuonSegmentPseudoJetAlgorithm.cxx:88
MuonSegmentPseudoJetAlgorithm.h
MuonSegmentPseudoJetAlgorithm::createPseudoJets
std::vector< fastjet::PseudoJet > createPseudoJets(const xAOD::MuonSegmentContainer &ms) const
Definition: MuonSegmentPseudoJetAlgorithm.cxx:60