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() {
50
51
52 ATH_MSG_DEBUG("in execute()");
53 const EventContext& ctx = Gaudi::Hive::currentContext();
54
55 // Increment counter
57
58 // Jpsi container and its auxilliary store
59 std::unique_ptr<xAOD::VertexContainer> jpsiContainer = std::make_unique<xAOD::VertexContainer>();
60 std::unique_ptr<xAOD::VertexAuxContainer> jpsiAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
61 jpsiContainer->setStore(jpsiAuxContainer.get());
62 // call Jpsi finder
63 if( !m_jpsiFinder->performSearch(ctx, *jpsiContainer).isSuccess() ) {
64 ATH_MSG_FATAL("Jpsi finder (" << m_jpsiFinder << ") failed.");
65 return StatusCode::FAILURE;
66 }
67
68 // Extracting information from the Jpsi candidates
69 m_jpsiCntr += jpsiContainer->size(); // Count the Jpsis
70
71 // save in the StoreGate
72 ATH_MSG_DEBUG("Recording to StoreGate: " << m_jpsiContainerName.key() << " size:" <<jpsiContainer->size());
73
75 ATH_CHECK(whandle.record(std::move(jpsiContainer), std::move(jpsiAuxContainer)));
76 // END OF ANALYSIS
77 return StatusCode::SUCCESS;
78}
79
80// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
81
82StatusCode JpsiAlg::finalize() {
83
84 ATH_MSG_DEBUG("in finalize()");
85 ATH_MSG_INFO("===================");
86 ATH_MSG_INFO("SUMMARY OF ANALYSIS");
87 ATH_MSG_INFO("===================");
88 ATH_MSG_INFO(" ");
89 ATH_MSG_INFO("Total number of events analysed: " << m_eventCntr);
90 ATH_MSG_INFO("Total number of jpsi candidates: " << m_jpsiCntr);
91
92 return StatusCode::SUCCESS;
93}
94
95// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
96
#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 with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StatusCode finalize() override
Definition JpsiAlg.cxx:82
ToolHandle< Analysis::ICandidateSearch > m_jpsiFinder
Definition JpsiAlg.h:23
int m_jpsiCntr
Definition JpsiAlg.h:21
StatusCode execute() override
Definition JpsiAlg.cxx:49
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 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.