Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Reco_4mu.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Reco_4mu.cxx
8 // Author: James Catmore <james.catmore@cern.ch>
9 
10 #include "Reco_4mu.h"
14 #include "BPhysPVTools.h"
17 
18 namespace DerivationFramework {
19 
20  Reco_4mu::Reco_4mu(const std::string& t,
21  const std::string& n,
22  const IInterface* p) :
23  base_class(t,n,p),
24  m_v0Tools("Trk::V0Tools"),
25  m_fourMuonTool("DerivationFramework::FourMuonTool",this),
26  m_pvRefitter("Analysis::PrimaryVertexRefitter",this)
27  {
28 
29  // Declare tools
30  declareProperty("V0Tools" , m_v0Tools);
31  declareProperty("FourMuonTool", m_fourMuonTool);
32  declareProperty("PVRefitter", m_pvRefitter);
33 
34  // Declare user-defined properties
35  declareProperty("PairContainerName" , m_pairName = "Pairs");
36  declareProperty("QuadrupletContainerName", m_quadName = "Quadruplets");
37  declareProperty("PVContainerName" , m_pvContainerName = "PrimaryVertices");
38  declareProperty("RefPVContainerName" , m_refPVContainerName = "RefittedPrimaryVertices");
39  declareProperty("RefitPV" , m_refitPV = false);
40  declareProperty("MaxPVrefit" , m_PV_max = 1);
41  declareProperty("DoVertexType" , m_DoVertexType = 1);
42  }
43 
44  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
45 
47  {
48 
49  ATH_MSG_DEBUG("in initialize()");
50 
51  // retrieve V0 tools
52  CHECK( m_v0Tools.retrieve() );
53 
54  // get the JpsiFinder tool
55  CHECK( m_fourMuonTool.retrieve() );
56 
57  // get the PrimaryVertexRefitter tool
58  CHECK( m_pvRefitter.retrieve() );
59 
60  return StatusCode::SUCCESS;
61 
62  }
63 
64  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65 
67  {
68  // everything all right
69  return StatusCode::SUCCESS;
70  }
71 
72  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
73 
75  {
76  // Output containers and its auxilliary store
77  xAOD::VertexContainer* pairContainer = NULL;
78  xAOD::VertexAuxContainer* pairAuxContainer = NULL;
79  xAOD::VertexContainer* quadContainer = NULL;
80  xAOD::VertexAuxContainer* quadAuxContainer = NULL;
81  bool acceptEvent = false; // this is a dummy
82  //----------------------------------------------------
83  // call finder
84  //----------------------------------------------------
85  if( !m_fourMuonTool->performSearch(pairContainer, pairAuxContainer, quadContainer, quadAuxContainer, acceptEvent).isSuccess() ) {
86  ATH_MSG_FATAL("4mu tool (" << m_fourMuonTool << ") failed.");
87  return StatusCode::FAILURE;
88  }
89 
90  //----------------------------------------------------
91  // event selection
92  //----------------------------------------------------
93  /*if (quadContainer->size()==0) {
94  if (pairContainer!=NULL) delete pairContainer;
95  if (pairAuxContainer!=NULL) delete pairAuxContainer;
96  if (quadContainer!=NULL) delete quadContainer;
97  if (quadAuxContainer!=NULL) delete quadAuxContainer;
98  return(acceptEvent);
99  // acceptEvent based on muon selection only, not quads
100  }*/
101 
102  //----------------------------------------------------
103  // retrieve primary vertices
104  //----------------------------------------------------
105  const xAOD::VertexContainer* pvContainer = NULL;
106  auto sc = evtStore()->retrieve(pvContainer, m_pvContainerName);
107  if(sc.isFailure()){
108  ATH_MSG_FATAL("Cannot find PV Container");
109  return StatusCode::FAILURE;
110  }
111  //----------------------------------------------------
112  // Refit primary vertices
113  //----------------------------------------------------
114  xAOD::VertexContainer* refPvContainer = NULL;
115  xAOD::VertexAuxContainer* refPvAuxContainer = NULL;
116 
117  if(m_refitPV) {
118  refPvContainer = new xAOD::VertexContainer;
119  refPvAuxContainer = new xAOD::VertexAuxContainer;
120  refPvContainer->setStore(refPvAuxContainer);
121  }
122 
123  BPhysPVTools helper(&(*m_v0Tools));//Give the helper class the ptr to v0tools to use
124 
125  if(m_refitPV){
126  if(quadContainer->size() >0){
127  StatusCode SC = helper.FillCandwithRefittedVertices(quadContainer, pvContainer, refPvContainer, &(*m_pvRefitter) , m_PV_max, m_DoVertexType);
128  if(SC.isFailure()){
129  ATH_MSG_FATAL("refitting failed - check the vertices you passed");
130  return StatusCode::FAILURE;
131  }
132  }
133  if(pairContainer->size()>0) {
134  StatusCode SC = helper.FillCandwithRefittedVertices(pairContainer, pvContainer, refPvContainer, &(*m_pvRefitter) , m_PV_max, m_DoVertexType);
135  if(SC.isFailure()){
136  ATH_MSG_FATAL("refitting failed - check the vertices you passed");
137  return StatusCode::FAILURE;
138  }
139  }
140  }else{
141  if(quadContainer->size() >0){
142  auto sc = helper.FillCandExistingVertices(quadContainer, pvContainer, m_DoVertexType);
143  sc.ignore();
144  }
145  if(pairContainer->size() >0)
146  {
147  auto sc = helper.FillCandExistingVertices(pairContainer, pvContainer, m_DoVertexType);
148  sc.ignore();
149  }
150  }
151 
152  //----------------------------------------------------
153  // Mass-hypothesis dependent quantities
154  //----------------------------------------------------
155 
156  std::vector<double> muonPairMasses = std::vector<double>(2, 105.658);
157  std::vector<double> muonQuadMasses = std::vector<double>(4, 105.658);
158 
159  bool doPt = (m_DoVertexType & 1) != 0;
160  bool doA0 = (m_DoVertexType & 2) != 0;
161  bool doZ0 = (m_DoVertexType & 4) != 0;
162  bool doZ0BA = (m_DoVertexType & 8) != 0;
163 
164  // loop over pairs
165  xAOD::VertexContainer::iterator pairItr = pairContainer->begin();
166  ATH_MSG_DEBUG("Indices/masses of pairs follows....");
167  for(; pairItr!=pairContainer->end(); ++pairItr) {
168  // create BPhysHypoHelper
169  xAOD::BPhysHypoHelper pairHelper("PAIR", *pairItr);
170 
171  //----------------------------------------------------
172  // decorate the vertex
173  //----------------------------------------------------
174  // a) invariant mass and error
175  if( !pairHelper.setMass(muonPairMasses) ) ATH_MSG_WARNING("Decoration pair.setMass failed");
176 
177  double massErr = m_v0Tools->invariantMassError(pairHelper.vtx(), muonPairMasses);
178  if( !pairHelper.setMassErr(massErr) ) ATH_MSG_WARNING("Decoration pair.setMassErr failed");
179 
180  // b) proper decay time and error:
181  // retrieve the refitted PV (or the original one, if the PV refitting was turned off)
182  if(doPt) ProcessVertex(pairHelper, xAOD::BPhysHelper::PV_MAX_SUM_PT2, muonPairMasses);
183  if(doA0) ProcessVertex(pairHelper, xAOD::BPhysHelper::PV_MIN_A0, muonPairMasses);
184  if(doZ0) ProcessVertex(pairHelper, xAOD::BPhysHelper::PV_MIN_Z0, muonPairMasses);
185  if(doZ0BA) ProcessVertex(pairHelper, xAOD::BPhysHelper::PV_MIN_Z0_BA, muonPairMasses);
186  static const SG::ConstAccessor<std::string> CombinationCodeAcc("CombinationCode");
187  ATH_MSG_DEBUG(CombinationCodeAcc(**pairItr) << " : " << pairHelper.mass() << " +/- " << pairHelper.massErr());
188  }
189 
190  // loop over quadruplets
191  xAOD::VertexContainer::iterator quadItr = quadContainer->begin();
192  ATH_MSG_DEBUG("Indices/masses of quadruplets follows....");
193  for(; quadItr!=quadContainer->end(); ++quadItr) {
194  // create BPhysHypoHelper
195  xAOD::BPhysHypoHelper quadHelper("QUAD", *quadItr);
196 
197  //----------------------------------------------------
198  // decorate the vertex
199  //----------------------------------------------------
200  // a) invariant mass and error
201  if( !quadHelper.setMass(muonQuadMasses) ) ATH_MSG_WARNING("Decoration quad.setMass failed");
202 
203  double massErr = m_v0Tools->invariantMassError(quadHelper.vtx(), muonQuadMasses);
204  if( !quadHelper.setMassErr(massErr) ) ATH_MSG_WARNING("Decoration quad.setMassErr failed");
205 
206  // b) proper decay time and error:
207  // retrieve the refitted PV (or the original one, if the PV refitting was turned off)
208  if(doPt) ProcessVertex(quadHelper, xAOD::BPhysHelper::PV_MAX_SUM_PT2, muonQuadMasses);
209  if(doA0) ProcessVertex(quadHelper, xAOD::BPhysHelper::PV_MIN_A0, muonQuadMasses);
210  if(doZ0) ProcessVertex(quadHelper, xAOD::BPhysHelper::PV_MIN_Z0, muonQuadMasses);
211  if(doZ0BA) ProcessVertex(quadHelper, xAOD::BPhysHelper::PV_MIN_Z0_BA, muonQuadMasses);
212  static const SG::ConstAccessor<std::string> CombinationCodeAcc("CombinationCode");
213  ATH_MSG_DEBUG(CombinationCodeAcc(**quadItr) << " : " << quadHelper.mass() << " +/- " << quadHelper.massErr());
214  }
215 
216  //----------------------------------------------------
217  // save in the StoreGate
218  //----------------------------------------------------
219  // Pairs
220  if (!evtStore()->contains<xAOD::VertexContainer>(m_pairName))
221  evtStore()->record(pairContainer, m_pairName).ignore();
222  if (!evtStore()->contains<xAOD::VertexAuxContainer>(m_pairName+"Aux."))
223  evtStore()->record(pairAuxContainer, m_pairName+"Aux.").ignore();
224 
225  // Quads
226  if (!evtStore()->contains<xAOD::VertexContainer>(m_quadName))
227  evtStore()->record(quadContainer, m_quadName).ignore();
228  if (!evtStore()->contains<xAOD::VertexAuxContainer>(m_quadName+"Aux."))
229  evtStore()->record(quadAuxContainer, m_quadName+"Aux.").ignore();
230 
231  // Refitted PVs
232  if(m_refitPV) {
233  evtStore()->record(refPvContainer , m_refPVContainerName).ignore();
234  evtStore()->record(refPvAuxContainer, m_refPVContainerName+"Aux.").ignore();
235  }
236 
237  return StatusCode::SUCCESS;
238  }
239 
240 
241  void Reco_4mu::ProcessVertex(xAOD::BPhysHypoHelper &hypoHelper, xAOD::BPhysHelper::pv_type pv_t, std::vector<double> trackMasses) const{
242 
243  const xAOD::Vertex* pv = hypoHelper.pv(pv_t);
244  if(pv) {
245  // decorate the vertex.
246 
247  BPHYS_CHECK( hypoHelper.setTau( m_v0Tools->tau(hypoHelper.vtx(), pv, trackMasses),
248  pv_t,
250 
251  BPHYS_CHECK( hypoHelper.setTauErr( m_v0Tools->tauError(hypoHelper.vtx(), pv, trackMasses),
252  pv_t,
254 
255  //enum pv_type {PV_MAX_SUM_PT2, PV_MIN_A0, PV_MIN_Z0, PV_MIN_Z0BA};
256  }else{
257 
258  const float errConst = -9999999;
259  BPHYS_CHECK( hypoHelper.setTau( errConst,
260  pv_t,
262 
263  BPHYS_CHECK( hypoHelper.setTauErr( errConst,
264  pv_t,
266  }
267 
268  return;
269  }
270 
271 }
BPhysPVTools.h
xAOD::BPhysHypoHelper::setMass
bool setMass(const float val)
Set given invariant mass and its error.
Definition: BPhysHypoHelper.cxx:52
V0Tools.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::Reco_4mu::m_DoVertexType
int m_DoVertexType
Definition: Reco_4mu.h:59
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
xAOD::BPhysHypoHelper::setTauErr
bool setTauErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0, const tau_type tauType=BPhysHypoHelper::TAU_CONST_MASS)
proper decay time error
Definition: BPhysHypoHelper.cxx:179
DerivationFramework::Reco_4mu::m_pvContainerName
std::string m_pvContainerName
Definition: Reco_4mu.h:55
DerivationFramework::Reco_4mu::ProcessVertex
void ProcessVertex(xAOD::BPhysHypoHelper &, xAOD::BPhysHelper::pv_type, std::vector< double > trackMasses) const
tools
Definition: Reco_4mu.cxx:241
DerivationFramework::BPhysPVTools
Definition: BPhysPVTools.h:25
DerivationFramework::Reco_4mu::finalize
StatusCode finalize()
Definition: Reco_4mu.cxx:66
xAOD::BPhysHelper::PV_MIN_Z0
@ PV_MIN_Z0
Definition: BPhysHelper.h:475
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition: VertexContainer.h:14
xAOD::BPhysHypoHelper::massErr
float massErr() const
invariant mass error
Definition: BPhysHypoHelper.cxx:47
xAOD::BPhysHypoHelper::TAU_INV_MASS
@ TAU_INV_MASS
Definition: BPhysHypoHelper.h:140
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
DerivationFramework::Reco_4mu::m_pvRefitter
ToolHandle< Analysis::PrimaryVertexRefitter > m_pvRefitter
Definition: Reco_4mu.h:49
DerivationFramework::Reco_4mu::m_PV_max
int m_PV_max
Definition: Reco_4mu.h:58
xAOD::BPhysHypoHelper
Definition: BPhysHypoHelper.h:73
BPHYS_CHECK
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
Definition: BPhysHelper.h:738
xAOD::BPhysHypoHelper::mass
float mass() const
Get invariant mass and its error.
Definition: BPhysHypoHelper.cxx:42
DerivationFramework::Reco_4mu::m_pairName
std::string m_pairName
job options
Definition: Reco_4mu.h:53
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::Reco_4mu::m_v0Tools
ToolHandle< Trk::V0Tools > m_v0Tools
Definition: Reco_4mu.h:47
xAOD::BPhysHelper::pv_type
pv_type
: Enum type of the PV
Definition: BPhysHelper.h:475
DerivationFramework::Reco_4mu::m_quadName
std::string m_quadName
Definition: Reco_4mu.h:54
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
xAOD::VertexAuxContainer
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
Definition: VertexAuxContainer.h:19
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
BPhysHypoHelper.h
: B-physics xAOD helpers.
xAOD::BPhysHelper::PV_MIN_A0
@ PV_MIN_A0
Definition: BPhysHelper.h:475
TRT_PAI_gasdata::SC
const float SC[NC]
Cross sections for Carbon.
Definition: TRT_PAI_gasdata.h:255
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework::Reco_4mu::m_refPVContainerName
std::string m_refPVContainerName
Definition: Reco_4mu.h:56
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
Reco_4mu.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::Reco_4mu::m_fourMuonTool
ToolHandle< DerivationFramework::FourMuonTool > m_fourMuonTool
Definition: Reco_4mu.h:48
xAOD::BPhysHelper::vtx
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
Definition: BPhysHelper.h:108
xAOD::BPhysHelper::PV_MAX_SUM_PT2
@ PV_MAX_SUM_PT2
Definition: BPhysHelper.h:475
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DerivationFramework::Reco_4mu::Reco_4mu
Reco_4mu(const std::string &t, const std::string &n, const IInterface *p)
Definition: Reco_4mu.cxx:20
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::Reco_4mu::m_refitPV
bool m_refitPV
Definition: Reco_4mu.h:57
python.changerun.pv
pv
Definition: changerun.py:81
xAOD::BPhysHelper::pv
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
Definition: BPhysHelper.cxx:796
DerivationFramework::Reco_4mu::initialize
StatusCode initialize()
Definition: Reco_4mu.cxx:46
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
xAOD::BPhysHypoHelper::setTau
bool setTau(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0, const tau_type tauType=BPhysHypoHelper::TAU_CONST_MASS)
: Set the proper decay time and error.
Definition: BPhysHypoHelper.cxx:143
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::BPhysHelper::PV_MIN_Z0_BA
@ PV_MIN_Z0_BA
Definition: BPhysHelper.h:475
xAOD::BPhysHypoHelper::setMassErr
bool setMassErr(const float val)
invariant mass error
Definition: BPhysHypoHelper.cxx:57
DerivationFramework::Reco_4mu::addBranches
virtual StatusCode addBranches() const
Definition: Reco_4mu.cxx:74
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
VertexAuxContainer.h