ATLAS Offline Software
Loading...
Searching...
No Matches
JpsiAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// JpsiAlg.cxx
6// Author: James Catmore (James.Catmore@cern.ch), E. Bouhova-Thacker (e.bouhova@cern.ch)
7// James Walder (jwalder@cern.ch)
8// This algorithm calls the JpsiFinder tool and writes the resulting ExtendedVxCandidates to
9// StoreGate. All analyses requiring J/psi and upsilon should therefore call this first in job
10// options and collect the J/psi candidates from StoreGate. Example is in JpsiExample.
11
15
16
18
19JpsiAlg::JpsiAlg(const std::string& name, ISvcLocator* pSvcLocator) :
20 AthAlgorithm(name, pSvcLocator),
22 m_jpsiFinder("Analysis::JpsiFinder", this),
23 m_jpsiContainerName("JpsiCandidates")
24{
25
26 // Declare user-defined properties - cuts and vertexing method
27 declareProperty("JpsiFinderName",m_jpsiFinder);
28 declareProperty("JpsiCandidatesOutputName",m_jpsiContainerName="JpsiCandidates");
29}
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
32
34
35
36 ATH_MSG_DEBUG("in initialize()");
37
38 // get the JpsiFinder tool
39 ATH_CHECK(m_jpsiFinder.retrieve());
40 ATH_CHECK(m_jpsiContainerName.initialize());
41 m_eventCntr = 0;
42 m_jpsiCntr = 0;
43
44 return StatusCode::SUCCESS;
45}
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
48
49StatusCode JpsiAlg::execute(const EventContext& ctx) {
50
51
52 ATH_MSG_DEBUG("in execute()");
53
54 // Increment counter
56
57 // Jpsi container and its auxilliary store
58 std::unique_ptr<xAOD::VertexContainer> jpsiContainer = std::make_unique<xAOD::VertexContainer>();
59 std::unique_ptr<xAOD::VertexAuxContainer> jpsiAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
60 jpsiContainer->setStore(jpsiAuxContainer.get());
61 // call Jpsi finder
62 if( !m_jpsiFinder->performSearch(ctx, *jpsiContainer).isSuccess() ) {
63 ATH_MSG_FATAL("Jpsi finder (" << m_jpsiFinder << ") failed.");
64 return StatusCode::FAILURE;
65 }
66
67 // Extracting information from the Jpsi candidates
68 m_jpsiCntr += jpsiContainer->size(); // Count the Jpsis
69
70 // save in the StoreGate
71 ATH_MSG_DEBUG("Recording to StoreGate: " << m_jpsiContainerName.key() << " size:" <<jpsiContainer->size());
72
74 ATH_CHECK(whandle.record(std::move(jpsiContainer), std::move(jpsiAuxContainer)));
75 // END OF ANALYSIS
76 return StatusCode::SUCCESS;
77}
78
79// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
80
81StatusCode JpsiAlg::finalize() {
82
83 ATH_MSG_DEBUG("in finalize()");
84 ATH_MSG_INFO("===================");
85 ATH_MSG_INFO("SUMMARY OF ANALYSIS");
86 ATH_MSG_INFO("===================");
87 ATH_MSG_INFO(" ");
88 ATH_MSG_INFO("Total number of events analysed: " << m_eventCntr);
89 ATH_MSG_INFO("Total number of jpsi candidates: " << m_jpsiCntr);
90
91 return StatusCode::SUCCESS;
92}
93
94// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
95
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StatusCode finalize() override
Definition JpsiAlg.cxx:81
ToolHandle< Analysis::ICandidateSearch > m_jpsiFinder
Definition JpsiAlg.h:23
int m_jpsiCntr
Definition JpsiAlg.h:21
JpsiAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition JpsiAlg.cxx:19
SG::WriteHandleKey< xAOD::VertexContainer > m_jpsiContainerName
Name of output container to store results.
Definition JpsiAlg.h:24
StatusCode execute(const EventContext &ctx) override
Execute method.
Definition JpsiAlg.cxx:49
StatusCode initialize() override
Definition JpsiAlg.cxx:33
int m_eventCntr
Definition JpsiAlg.h:20
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.