ATLAS Offline Software
Loading...
Searching...
No Matches
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() );
23 ATH_CHECK( m_outcoll.initialize() );
24
25 return StatusCode::SUCCESS;
26}
27
28//**********************************************************************
29
30StatusCode MuonSegmentPseudoJetAlgorithm::execute(const EventContext& ctx) const {
31 ATH_MSG_VERBOSE("Executing " << name() << "...");
32
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
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
59std::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//**********************************************************************
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
#define y
#define x
#define z
virtual StatusCode initialize() override final
Athena algorithm's Hooks.
Gaudi::Property< std::string > m_label
Label for the collection.
std::vector< fastjet::PseudoJet > createPseudoJets(const xAOD::MuonSegmentContainer &ms) const
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_incoll
Input collection name.
SG::WriteHandleKey< PseudoJetContainer > m_outcoll
Output collection name.
virtual void print() const
Dump to properties to the log.
int r
Definition globals.cxx:22
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition index.py:1
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSegment_v1 MuonSegment
Reference the current persistent version: