ATLAS Offline Software
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 
19 JpsiAlg::JpsiAlg(const std::string& name, ISvcLocator* pSvcLocator) :
20  AthAlgorithm(name, pSvcLocator),
21  m_eventCntr(0), m_jpsiCntr(0),
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 
50 
51 
52  ATH_MSG_DEBUG("in execute()");
53  const EventContext& ctx = Gaudi::Hive::currentContext();
54 
55  // Increment counter
56  ++m_eventCntr;
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 
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 
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
JpsiAlg::m_jpsiCntr
int m_jpsiCntr
Definition: JpsiAlg.h:21
JpsiAlg::m_eventCntr
int m_eventCntr
Definition: JpsiAlg.h:20
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JpsiAlg.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JpsiAlg::m_jpsiContainerName
SG::WriteHandleKey< xAOD::VertexContainer > m_jpsiContainerName
Name of output container to store results.
Definition: JpsiAlg.h:24
JpsiAlg::m_jpsiFinder
ToolHandle< Analysis::ICandidateSearch > m_jpsiFinder
Definition: JpsiAlg.h:23
JpsiAlg::execute
StatusCode execute() override
Definition: JpsiAlg.cxx:49
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
JpsiAlg::JpsiAlg
JpsiAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JpsiAlg.cxx:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
JpsiAlg::finalize
StatusCode finalize() override
Definition: JpsiAlg.cxx:82
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
JpsiAlg::initialize
StatusCode initialize() override
Definition: JpsiAlg.cxx:33
VertexContainer.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
VertexAuxContainer.h