ATLAS Offline Software
BPhysVertexTrackBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //============================================================================
6 // BPhysVertexTrackBase.h
7 //============================================================================
8 //
9 // Author : Wolfgang Walkowiak <Wolfgang.Walkowiak@cern.ch.>
10 // Changes:
11 //
12 // Base class for vertex-track related classes in need of
13 // track-to-vertex association handling.
14 //
15 // For an usage example see BVertexTrackIsoTool and BPHY8.py .
16 //
17 //============================================================================
18 //
19 #ifndef DERIVATIONFRAMEWORK_BPhysVertexTrackBase_H
20 #define DERIVATIONFRAMEWORK_BPhysVertexTrackBase_H
21 
25 #include "GaudiKernel/ToolHandle.h"
27 #include "xAODBPhys/BPhysHelper.h"
35 
36 #include <string>
37 #include <vector>
38 #include <map>
39 
40 // forward declarations
41 namespace InDet {
42  class IInDetTrackSelectionTool;
43 }
44 
45 class TVector3;
46 
47 namespace DerivationFramework {
48 
49  //
50  // typedefs -- to abbreviate long lines
51  //
52  typedef std::vector<const xAOD::TrackParticle*> TrackBag;
53  typedef std::vector<const xAOD::Muon*> MuonBag;
55 
57  virtual public IAugmentationTool {
58 
59  protected:
60  class BaseItem {
61 
62  public:
63  BaseItem(const std::string& Name="_none_",
64  const std::string& Bname="iso",
65  const std::string& Prefix="");
66  virtual ~BaseItem();
67 
68  virtual void setup(const std::string& Name,
69  const std::string& Bname="iso",
70  const std::string& Prefix="");
71  virtual void setPrefix(std::string Prefix);
72  virtual void resetVals();
73  virtual void copyVals(const BaseItem& item) = 0;
74  virtual std::string buildName(const std::string& qualifier="",
75  const std::string& suffix="") const;
76  virtual std::string toString() const;
77 
78  public:
79  std::string name;
80  std::string bname;
81  std::string prefix;
82  };
83 
84  protected:
86 
87  public:
88  TrackTypeCounter(BPhysVertexTrackBase& Parent, std::string Name);
90 
91  void addToCounter(uint64_t atype, uint64_t rtype=0,
92  const std::string &prefix="", const std::string &suffix="",
93  uint64_t counts=1);
94 
95  void addToCounter(const std::string &name, uint64_t atype=0,
96  uint64_t counts=1);
97 
98  std::string countsToString(uint indent=0) const;
99 
100  public:
101  std::string name;
102 
103  private:
104  typedef std::map<std::string, std::pair<uint64_t, uint64_t> >
108  };
109 
110  public:
111  //
112  // enumeration for types of tracks to be considered
113  //
114  enum track_type {ASSOCPV, PVTYPE0, PVTYPE1, PVTYPE2, PVTYPE3, NONE,
116  CAPVRFN3U0, CAPVNRN3U0, CAPVRF3DU0, CAPVNR3DU0,
117  CAPVRFN3U1, CAPVNRN3U1, CAPVRF3DU1, CAPVNR3DU1,
118  CAPVRFN3U2, CAPVNRN3U2, CAPVRF3DU2, CAPVNR3DU2,
119  CAPVRFNNU3, CAPVNRNNU3, CAPVRFNNU4, CAPVNRNNU4,
120  CAPVRFNNU5, CAPVNRNNU5, CAPVRFNNU6, CAPVNRNNU6,
121  CAPVRFNNU7, CAPVNRNNU7, CAPVRFNNU8, CAPVNRNNU8,
122  CAPVRFNNU9, CAPVNRNNU9 };
123  static const int n_track_types;
124  static const std::string track_type_str[];
125  static const uint64_t track_type_bit[];
126  private:
128 
129  public:
130  //
131  // convenience methods
132  //
133  static const std::string tts(track_type type);
134  static uint64_t ttb(track_type type);
135  static uint64_t ttall();
136  static uint64_t ttallMin();
137  static uint64_t rttor(const std::vector<uint64_t> &vtypes);
138  static std::string wrapLines(const std::string& lines,
139  const std::string& prefix);
140  static std::string trackToString(const xAOD::TrackParticle* track);
141 
142  public:
143  //
144  // public methods called by the framework
145  //
146  BPhysVertexTrackBase(const std::string& t, const std::string& n,
147  const IInterface* p);
148 
149  virtual StatusCode initialize() override;
150  virtual StatusCode finalize() override;
151  virtual StatusCode addBranches() const override;
152 
153  protected:
154  //
155  // Hook methods -- need be be overwritten in the concrete class
156  //
157  virtual StatusCode initializeHook();
158  virtual StatusCode finalizeHook();
159  virtual StatusCode addBranchesHook() const;
160  virtual StatusCode addBranchesVCSetupHook(size_t ivc) const;
161  virtual StatusCode addBranchesSVLoopHook(const xAOD::Vertex* vtx) const;
162  virtual StatusCode calcValuesHook(const xAOD::Vertex* vtx,
163  const unsigned int ipv,
164  const unsigned int its,
165  const unsigned int itt) const;
166  virtual bool fastFillHook(const xAOD::Vertex* vtx,
167  const int ipv) const;
168 
169  //
170  // Methods to be called from within addBranchesSVLoopHook()
171  //
172  StatusCode calculateValues(const xAOD::Vertex* vtx) const;
173 
174  //
175  // internal methods
176  //
177  // name string for vertex pointer and PV index
178  virtual std::string buildPvAssocCacheName(const xAOD::Vertex* vtx,
179  const int ipv) const;
180 
181  virtual void initPvAssocTypeVec();
182  TrackBag findAllTracksInDecay(xAOD::BPhysHelper& vtx) const;
183  void findAllTracksInDecay(xAOD::BPhysHelper& vtx,
184  TrackBag& tracks) const;
185  MuonBag findAllMuonsInDecay(xAOD::BPhysHelper& vtx) const;
186  void findAllMuonsInDecay(xAOD::BPhysHelper& vtx,
187  MuonBag& muons) const;
188  TrackBag findAllMuonIdTracksInDecay(xAOD::BPhysHelper& vtx,
189  MuonBag& muons) const;
190  std::vector<TVector3>
191  findMuonRefTrackMomenta(xAOD::BPhysHelper& vtx, MuonBag& muons) const;
192 
193  TrackBag selectTracks(const xAOD::TrackParticleContainer*
194  inpTracks,
195  xAOD::BPhysHelper& cand,
196  const unsigned int ipv,
197  const unsigned int its,
198  const unsigned int itt) const;
199  TrackBag selectTracks(const xAOD::TrackParticleContainer*
200  inpTracks,
201  const TrackBag& exclTracks,
202  xAOD::BPhysHelper& cand,
203  const unsigned int ipv,
204  const unsigned int its,
205  const unsigned int itt) const;
206  uint64_t detTrackTypes(const xAOD::TrackParticle* track,
207  const xAOD::Vertex* candPV,
208  const xAOD::Vertex* candRefPV) const;
209  double getTrackCandPVLogChi2(const xAOD::TrackParticle*
210  track,
211  const xAOD::Vertex* vtx,
212  bool doDCAin3D=false,
213  int chi2DefToUse=0) const;
214  std::vector<double> getTrackLogChi2DCA(const xAOD::TrackParticle*
215  track,
216  const xAOD::Vertex* vtx,
217  bool doDCAin3D=false,
218  int chi2DefToUse=0)
219  const;
220  std::string buildBranchBaseName(unsigned int its,
221  unsigned int ipv,
222  unsigned int itt,
223  const std::string& preSuffix="") const;
224 
225  std::pair<const xAOD::Vertex*, double>
226  findMinChi2PV(const xAOD::TrackParticle* track,
227  const xAOD::Vertex* candPV,
228  const xAOD::Vertex* candRefPV,
229  const std::vector<uint64_t>& pvtypes,
230  const int minNTracksInPV,
231  const bool useRefittedPvs,
232  const bool doDCAin3D,
233  const int chi2DefToUse) const;
234 
235  const xAOD::Vertex*
236  findAssocPV(const xAOD::TrackParticle* track,
237  const xAOD::Vertex* candPV,
238  const xAOD::Vertex* candRefPV,
239  const std::vector<uint64_t>& pvtypes,
240  const int minNTracksInPV,
241  const bool useRefittedPvs) const;
242 
243  protected:
244  // job options
245  std::vector<std::string> m_branchPrefixes;
246  std::string m_branchBaseName;
247  std::string m_branchSuffix;
248  std::vector<std::string> m_vertexContainerNames;
250  ToolHandleArray<TrkSelTool> m_trackSelectionTools;
251 
252  ToolHandle<Reco::ITrackToVertex> m_trackToVertexTool;
253 
254  ToolHandle<CP::ITrackVertexAssociationTool> m_tvaTool;
255 
256  std::string m_pvContainerName;
257  std::vector<std::string> m_refPVContainerNames;
258 
260  std::vector<uint64_t> m_useTrackTypes;
263  std::vector<uint64_t> m_pvTypesToConsider;
265  std::vector<uint64_t> m_debugTracksInEvents;
266 
267  // working point of TVA tool
269 
270  // containers
278 
279  // cache for individual vertex types
280  std::vector<xAOD::BPhysHelper::pv_type> m_pvAssocTypes;
281 
282  mutable unsigned int m_nEvtsSeen;
283 
284  // event info
285  mutable const xAOD::EventInfo* m_eventInfo;
286 
287  // cache for similar PV-to-SV associations
288  typedef std::map<std::string, int> StringIntMap_t;
290 
291  // track types considered
293 
294  // track type counter map (for debugging)
295  std::unique_ptr<TrackTypeCounter> m_mttc;
296 
297  // run and event numbers (see EventIDBase.h for types)
298  mutable unsigned int m_runNumber;
300 
301  // debug tracks in the current event?
303 
304  }; // class
305 } // namespace
306 
307 #endif // DERIVATIONFRAMEWORK_BPhysVertexTrackBase_H
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::m_parent
BPhysVertexTrackBase & m_parent
Definition: BPhysVertexTrackBase.h:107
DerivationFramework::BPhysVertexTrackBase::BaseItem::prefix
std::string prefix
Definition: BPhysVertexTrackBase.h:81
DerivationFramework::BPhysVertexTrackBase::BaseItem::name
std::string name
Definition: BPhysVertexTrackBase.h:79
DerivationFramework::BPhysVertexTrackBase::CAPVRFNNU6
@ CAPVRFNNU6
Definition: BPhysVertexTrackBase.h:120
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
xAOD::TrackParticleAuxContainer_v5
Temporary container used until we have I/O for AuxStoreInternal.
Definition: TrackParticleAuxContainer_v5.h:35
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
hotSpotInTAG.suffix
string suffix
Definition: hotSpotInTAG.py:186
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
DerivationFramework::BPhysVertexTrackBase::m_pvtxContainer
const xAOD::VertexContainer * m_pvtxContainer
Definition: BPhysVertexTrackBase.h:273
DerivationFramework::BPhysVertexTrackBase::CAPVRFNNU4
@ CAPVRFNNU4
Definition: BPhysVertexTrackBase.h:119
DerivationFramework::BPhysVertexTrackBase::m_pvAssocTypes
std::vector< xAOD::BPhysHelper::pv_type > m_pvAssocTypes
Definition: BPhysVertexTrackBase.h:280
DerivationFramework::BPhysVertexTrackBase::BaseItem::copyVals
virtual void copyVals(const BaseItem &item)=0
DerivationFramework::BPhysVertexTrackBase::m_pvContainerName
std::string m_pvContainerName
Definition: BPhysVertexTrackBase.h:256
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
DerivationFramework::BPhysVertexTrackBase::NULLVP
@ NULLVP
Definition: BPhysVertexTrackBase.h:115
DerivationFramework::BPhysVertexTrackBase::m_svtxContainer
const xAOD::VertexContainer * m_svtxContainer
Definition: BPhysVertexTrackBase.h:274
IAugmentationTool.h
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
DerivationFramework::BPhysVertexTrackBase::m_refPVContainer
const xAOD::VertexContainer * m_refPVContainer
Definition: BPhysVertexTrackBase.h:276
initialize
void initialize()
Definition: run_EoverP.cxx:894
DerivationFramework::BPhysVertexTrackBase::m_pvAssocResMap
StringIntMap_t m_pvAssocResMap
Definition: BPhysVertexTrackBase.h:289
DerivationFramework::BPhysVertexTrackBase::CAPVRFN3U2
@ CAPVRFN3U2
Definition: BPhysVertexTrackBase.h:118
DerivationFramework::BPhysVertexTrackBase::m_nEvtsSeen
unsigned int m_nEvtsSeen
Definition: BPhysVertexTrackBase.h:282
DerivationFramework::BPhysVertexTrackBase::m_runNumber
unsigned int m_runNumber
Definition: BPhysVertexTrackBase.h:298
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::NameCountMap_t
std::map< std::string, std::pair< uint64_t, uint64_t > > NameCountMap_t
Definition: BPhysVertexTrackBase.h:105
DerivationFramework::BPhysVertexTrackBase::m_evtNumber
uint64_t m_evtNumber
Definition: BPhysVertexTrackBase.h:299
DerivationFramework::BPhysVertexTrackBase::m_useTrackTypes
std::vector< uint64_t > m_useTrackTypes
Definition: BPhysVertexTrackBase.h:260
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::BPhysVertexTrackBase::m_trackTypesUsed
uint64_t m_trackTypesUsed
Definition: BPhysVertexTrackBase.h:292
DerivationFramework::MuonBag
std::vector< const xAOD::Muon * > MuonBag
Definition: BPhysAddMuonBasedInvMass.h:33
DerivationFramework::BPhysVertexTrackBase::CAPVRFNNU9
@ CAPVRFNNU9
Definition: BPhysVertexTrackBase.h:122
DerivationFramework::IAugmentationTool
Definition: IAugmentationTool.h:24
InDet::IInDetTrackSelectionTool
Interface for track selection tool.
Definition: IInDetTrackSelectionTool.h:53
DerivationFramework::BPhysVertexTrackBase::m_branchPrefixes
std::vector< std::string > m_branchPrefixes
Definition: BPhysVertexTrackBase.h:245
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
DerivationFramework::BPhysVertexTrackBase::m_svtxAuxContainer
const xAOD::VertexAuxContainer * m_svtxAuxContainer
Definition: BPhysVertexTrackBase.h:275
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
CaloCondBlobAlgs_fillNoiseFromASCII.lines
lines
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:104
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:18
DerivationFramework::BPhysVertexTrackBase::m_mttc
std::unique_ptr< TrackTypeCounter > m_mttc
Definition: BPhysVertexTrackBase.h:295
DerivationFramework::BPhysVertexTrackBase::m_pvTypesToConsider
std::vector< uint64_t > m_pvTypesToConsider
Definition: BPhysVertexTrackBase.h:263
TrackParticleAuxContainer.h
DerivationFramework::BPhysVertexTrackBase::m_tracks
const xAOD::TrackParticleContainer * m_tracks
Definition: BPhysVertexTrackBase.h:271
DerivationFramework::BPhysVertexTrackBase::m_branchSuffix
std::string m_branchSuffix
Definition: BPhysVertexTrackBase.h:247
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::BPhysVertexTrackBase::m_tvaTool
ToolHandle< CP::ITrackVertexAssociationTool > m_tvaTool
Definition: BPhysVertexTrackBase.h:254
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::BPhysVertexTrackBase::m_branchBaseName
std::string m_branchBaseName
Definition: BPhysVertexTrackBase.h:246
AthAlgTool.h
DerivationFramework::BPhysVertexTrackBase::m_tracksAux
const xAOD::TrackParticleAuxContainer * m_tracksAux
Definition: BPhysVertexTrackBase.h:272
DerivationFramework::BPhysVertexTrackBase::CAPVRFN3U0
@ CAPVRFN3U0
Definition: BPhysVertexTrackBase.h:116
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
DerivationFramework::BPhysVertexTrackBase::track_type
track_type
Definition: BPhysVertexTrackBase.h:114
DerivationFramework::BPhysVertexTrackBase::BaseItem::bname
std::string bname
Definition: BPhysVertexTrackBase.h:80
DerivationFramework::TrackBag
std::vector< const xAOD::TrackParticle * > TrackBag
Definition: BPhysAddMuonBasedInvMass.h:32
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DerivationFramework::BPhysVertexTrackBase::CAPVRFN3U1
@ CAPVRFN3U1
Definition: BPhysVertexTrackBase.h:117
ITrackVertexAssociationTool.h
DataVector< xAOD::TrackParticle_v1 >
DerivationFramework::BPhysVertexTrackBase::StringIntMap_t
std::map< std::string, int > StringIntMap_t
Definition: BPhysVertexTrackBase.h:288
ITrackToVertex.h
EventPrimitives.h
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::name
std::string name
Definition: BPhysVertexTrackBase.h:101
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
DerivationFramework::BPhysVertexTrackBase::m_debugTracksInEvents
std::vector< uint64_t > m_debugTracksInEvents
Definition: BPhysVertexTrackBase.h:265
DerivationFramework::BPhysVertexTrackBase::m_trackParticleContainerName
std::string m_trackParticleContainerName
Definition: BPhysVertexTrackBase.h:249
DerivationFramework::BPhysVertexTrackBase::m_tvaToolHasWpLoose
bool m_tvaToolHasWpLoose
Definition: BPhysVertexTrackBase.h:268
item
Definition: ItemListSvc.h:43
DerivationFramework::BPhysVertexTrackBase::m_trackSelectionTools
ToolHandleArray< TrkSelTool > m_trackSelectionTools
Definition: BPhysVertexTrackBase.h:250
DerivationFramework::BPhysVertexTrackBase::m_refPVContainerNames
std::vector< std::string > m_refPVContainerNames
Definition: BPhysVertexTrackBase.h:257
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
BPhysHelper.h
: B-physics xAOD helpers.
DerivationFramework::BPhysVertexTrackBase::m_incPrecVerticesInDecay
bool m_incPrecVerticesInDecay
Definition: BPhysVertexTrackBase.h:261
DerivationFramework::TrkSelTool
InDet::IInDetTrackSelectionTool TrkSelTool
Definition: BPhysVertexTrackBase.h:54
Name
JetDumper::Name Name
Definition: JetDumper.cxx:19
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
DerivationFramework::BPhysVertexTrackBase::m_vertexContainerNames
std::vector< std::string > m_vertexContainerNames
Definition: BPhysVertexTrackBase.h:248
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DerivationFramework::BPhysVertexTrackBase::m_debugTrackTypes
int m_debugTrackTypes
Definition: BPhysVertexTrackBase.h:264
DerivationFramework::BPhysVertexTrackBase::m_doVertexType
int m_doVertexType
Definition: BPhysVertexTrackBase.h:259
DerivationFramework::BPhysVertexTrackBase::BaseItem
Definition: BPhysVertexTrackBase.h:60
DerivationFramework::BPhysVertexTrackBase::m_debugTracksInThisEvent
bool m_debugTracksInThisEvent
Definition: BPhysVertexTrackBase.h:302
setup
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type)
mostly useful for athena, which will otherwise re-use the previous tool
Definition: fbtTestBasics.cxx:193
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::~TrackTypeCounter
~TrackTypeCounter()
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DerivationFramework::BPhysVertexTrackBase::s_track_type_all_cached
static uint64_t s_track_type_all_cached
Definition: BPhysVertexTrackBase.h:127
DerivationFramework::BPhysVertexTrackBase
Definition: BPhysVertexTrackBase.h:57
AthAlgTool
Definition: AthAlgTool.h:26
checker_macros.h
Define macros for attributes used to control the static checker.
DerivationFramework::BPhysVertexTrackBase::m_minNTracksInPV
int m_minNTracksInPV
Definition: BPhysVertexTrackBase.h:262
DerivationFramework::BPhysVertexTrackBase::n_track_types
static const int n_track_types
Definition: BPhysVertexTrackBase.h:123
DerivationFramework::BPhysVertexTrackBase::m_eventInfo
const xAOD::EventInfo * m_eventInfo
Definition: BPhysVertexTrackBase.h:285
TrackParticleContainer.h
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter::m_cnts
NameCountMap_t m_cnts
Definition: BPhysVertexTrackBase.h:106
DerivationFramework::BPhysVertexTrackBase::CAPVRFNNU8
@ CAPVRFNNU8
Definition: BPhysVertexTrackBase.h:121
VertexAuxContainer.h
DerivationFramework::BPhysVertexTrackBase::m_refPVAuxContainer
const xAOD::VertexAuxContainer * m_refPVAuxContainer
Definition: BPhysVertexTrackBase.h:277
DerivationFramework::BPhysVertexTrackBase::m_trackToVertexTool
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
Definition: BPhysVertexTrackBase.h:252
DerivationFramework::BPhysVertexTrackBase::TrackTypeCounter
Definition: BPhysVertexTrackBase.h:85