ATLAS Offline Software
Reco_mumu.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Reco_mumu.cxx
8 // Author: Daniel Scheirich <daniel.scheirich@cern.ch>
9 // Based on the Integrated Simulation Framework
10 //
11 // Basic Jpsi->mu mu derivation example
12 
18 
19 
20 namespace DerivationFramework {
21 
22  Reco_mumu::Reco_mumu(const std::string& t,
23  const std::string& n,
24  const IInterface* p) :
25  AthAlgTool(t,n,p) {
26  declareInterface<DerivationFramework::IAugmentationTool>(this);
27  }
28 
29  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
30 
32  {
33 
34  ATH_MSG_DEBUG("in initialize()");
35 
36  // retrieve V0 tools
37  CHECK( m_v0Tools.retrieve() );
38 
39  // get the JpsiFinder tool
40  CHECK( m_jpsiFinder.retrieve() );
41 
42  // get the PrimaryVertexRefitter tool
43  CHECK( m_pvRefitter.retrieve() );
44 
45  // Get the beam spot service
47 
48  ATH_CHECK(m_CollectionsToCheck.initialize());
49  ATH_CHECK(m_pvContainerKey.initialize());
50  ATH_CHECK(m_outContainerKey.initialize());
52  return StatusCode::SUCCESS;
53  }
54 
55 
56 
57  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
58 
60  {
61  bool callJpsiFinder = true;
62  const EventContext& ctx = Gaudi::Hive::currentContext();
63  if(m_checkCollections) {
64  for( SG::ReadHandle<xAOD::VertexContainer> vertContainer : m_CollectionsToCheck.makeHandles(ctx)){
65  if (!vertContainer.isValid()){
66  ATH_MSG_FATAL("Failed to retrieve "<<vertContainer.key());
67  return StatusCode::FAILURE;
68  }
69  if(vertContainer->size() == 0) {
70  callJpsiFinder = false;
71  ATH_MSG_DEBUG("Container VertexContainer (" << vertContainer.key() << ") is empty");
72  break;//No point checking other containers
73  }
74  }
75  }
76 
77  // Jpsi container and its auxilliary store
78  std::unique_ptr<xAOD::VertexContainer> vtxContainer = std::make_unique<xAOD::VertexContainer>();
79  std::unique_ptr<xAOD::VertexAuxContainer> vtxAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
80  vtxContainer->setStore(vtxAuxContainer.get());
81 
82  std::unique_ptr<xAOD::VertexContainer> refPvContainer =std::make_unique<xAOD::VertexContainer>();
83  std::unique_ptr<xAOD::VertexAuxContainer> refPvAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
84  refPvContainer->setStore(refPvAuxContainer.get());
85 
86 
87  if(callJpsiFinder) {
88  //----------------------------------------------------
89  // call Jpsi finder
90  //----------------------------------------------------
91  ATH_CHECK(m_jpsiFinder->performSearch(ctx, *vtxContainer));
92 
93  //----------------------------------------------------
94  // retrieve primary vertices
95  //----------------------------------------------------
97  if (!pvContainer.isValid()){
98  ATH_MSG_FATAL("Failed to retrive "<<m_pvContainerKey.fullKey());
99  return StatusCode::FAILURE;
100  }
101  //----------------------------------------------------
102  // Try to retrieve refitted primary vertices
103  //----------------------------------------------------
104 
105  // Give the helper class the ptr to v0tools and beamSpotsSvc to use
107  if(not evt.isValid()) ATH_MSG_ERROR("Cannot Retrieve " << m_eventInfo_key.key() );
108 
109  // Give the helper class the ptr to v0tools and beamSpotsSvc to use
110  BPhysPVTools helper(&(*m_v0Tools), evt.cptr());
111  helper.SetMinNTracksInPV(m_PV_minNTracks);
112  helper.SetSave3d(m_do3d);
113 
114  if(m_refitPV && vtxContainer->size()){
115  ATH_CHECK(helper.FillCandwithRefittedVertices(vtxContainer.get(), pvContainer.cptr(), refPvContainer.get(), &(*m_pvRefitter) , m_PV_max, m_DoVertexType));
116  }else if (!m_refitPV && vtxContainer->size()){
117  ATH_CHECK(helper.FillCandExistingVertices(vtxContainer.get(), pvContainer.cptr(), m_DoVertexType));
118  }
119  }
120  //----------------------------------------------------
121  // save in the StoreGate
122  //----------------------------------------------------
124  ATH_CHECK(out_handle.record(std::move(vtxContainer), std::move(vtxAuxContainer)));
125  if(m_refitPV) {
127  ATH_CHECK(refitHandle.record(std::move(refPvContainer), std::move(refPvAuxContainer)));
128  }
129 
130  return StatusCode::SUCCESS;
131  }
132 }
BPhysPVTools.h
DerivationFramework::Reco_mumu::m_do3d
Gaudi::Property< bool > m_do3d
Definition: Reco_mumu.h:50
V0Tools.h
DerivationFramework::Reco_mumu::m_eventInfo_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
Definition: Reco_mumu.h:41
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::Reco_mumu::m_pvRefitter
ToolHandle< Analysis::PrimaryVertexRefitter > m_pvRefitter
Definition: Reco_mumu.h:40
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
DerivationFramework::Reco_mumu::m_DoVertexType
Gaudi::Property< int > m_DoVertexType
Definition: Reco_mumu.h:48
DerivationFramework::Reco_mumu::m_checkCollections
Gaudi::Property< bool > m_checkCollections
Definition: Reco_mumu.h:51
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::Reco_mumu::m_refitPV
Gaudi::Property< bool > m_refitPV
Definition: Reco_mumu.h:46
DerivationFramework::BPhysPVTools
Definition: BPhysPVTools.h:25
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::Reco_mumu::addBranches
StatusCode addBranches() const override
Pass the thinning service
Definition: Reco_mumu.cxx:59
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
DerivationFramework::Reco_mumu::initialize
StatusCode initialize() override
Definition: Reco_mumu.cxx:31
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
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
DerivationFramework::Reco_mumu::m_refContainerKey
SG::WriteHandleKey< xAOD::VertexContainer > m_refContainerKey
Definition: Reco_mumu.h:56
Reco_mumu.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
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
DerivationFramework::Reco_mumu::Reco_mumu
Reco_mumu(const std::string &t, const std::string &n, const IInterface *p)
Definition: Reco_mumu.cxx:22
DerivationFramework::Reco_mumu::m_pvContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerKey
Definition: Reco_mumu.h:54
DerivationFramework::Reco_mumu::m_outContainerKey
SG::WriteHandleKey< xAOD::VertexContainer > m_outContainerKey
Definition: Reco_mumu.h:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
VertexContainer.h
DerivationFramework::Reco_mumu::m_PV_max
Gaudi::Property< int > m_PV_max
Definition: Reco_mumu.h:47
DerivationFramework::Reco_mumu::m_CollectionsToCheck
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_CollectionsToCheck
Definition: Reco_mumu.h:53
DerivationFramework::Reco_mumu::m_v0Tools
ToolHandle< Trk::V0Tools > m_v0Tools
tools
Definition: Reco_mumu.h:38
DerivationFramework::Reco_mumu::m_PV_minNTracks
Gaudi::Property< unsigned int > m_PV_minNTracks
Definition: Reco_mumu.h:49
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DerivationFramework::Reco_mumu::m_jpsiFinder
ToolHandle< Analysis::ICandidateSearch > m_jpsiFinder
Definition: Reco_mumu.h:39
VertexAuxContainer.h