ATLAS Offline Software
TraitDefs.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef TRIG_OBJECT_MATCHING_TRAIT_DEFS_H
8 #define TRIG_OBJECT_MATCHING_TRAIT_DEFS_H
9 
11 
13 
14 namespace TrigMatch {
15 
16  // Here we define the trait classes. The basic problem is
17  // this:
18  //
19  // Some classes are attached to the navigation as basic objects
20  // for example - MuonFeature
21  // Other classes are attached to the navigation as containers of
22  // objects for example - egamma's are attached as egammaContainers
23  // Still other classes are not attached at all, but can be gotten
24  // from the ancestor method in the TDT, such as the L1 items
25  // We need to make this complexity invisible to the user, so they
26  // can just call whatever they want to match to and not worry
27  // about how it interacts with the navigation
28  // We solve this with traits classes (thanks to Scott Snyder for
29  // the suggestion) which tell us whether or not a class is a
30  // container and if it is, allows us to map from the class to
31  // the container class and similarly for ancest style objects
32 
33  struct DirectAttached {}; // identifies objects as attached directly
34  struct AncestorAttached {}; // identifies objects as attached via ancest
35 
36  // by default, we assume a class is attached directly
37  template<typename T>
38  struct ClassTraits {
40  };
41 
42 }
43 
44 // now we specialize for the container classes
45 
46 // This macro specializes the definition of the
47 // ContainerForClass trait class
48 #define SPECIALIZE_CONTAINER_FOR_CLASS(x,y) \
49  namespace TrigMatch { \
50  template<> \
51  struct ClassTraits<x> { \
52  typedef y type; \
53  }; \
54  }
55 
56 // This macro does the forward declaration
57 // for objects without a namespace
58 #define DECLARE_ATTACHED_CONTAINER(x,y) \
59  class x; \
60  class y; \
61  SPECIALIZE_CONTAINER_FOR_CLASS(x,y)
62 
63 // This macro does the forward declaration
64 // for objects with the same namespace
65 // as the container
66 #define DECLARE_ATTACHED_CONTAINER_NAMESPACE(a,x,y) \
67  namespace a { \
68  class x; \
69  class y; \
70  } \
71  SPECIALIZE_CONTAINER_FOR_CLASS(a::x,a::y)
72 
73 // This macro does the forward declaration
74 // for objects with a namespace, but not namespace
75 // on the container
76 #define DECLARE_ATTACHED_CONTAINER_OBJECT_NAMESPACE(a,x,y) \
77  namespace a { \
78  class x; \
79  } \
80  class y; \
81  SPECIALIZE_CONTAINER_FOR_CLASS(a::x,y)
82 
83 // This macro does the forward declaration
84 // for objects with a namespace, and containers
85 // that are a typedef
86 #define DECLARE_ATTACHED_CONTAINER_TYPEDEF(a, x, y) \
87  namespace a { \
88  class x; \
89  } \
90  SPECIALZE_CONTAINER_FOR_CLASS(a::x, y)
91 
96  //DECLARE_ATTACHED_CONTAINER(CosmicMuon, CosmicMuonCollection)
97  //DECLARE_ATTACHED_CONTAINER(MdtTrackSegment, MdtTrackSegmentCollection)
106  DECLARE_ATTACHED_CONTAINER_NAMESPACE(Analysis, TauDetails, TauDetailsContainer)
113 // DECLARE_ATTACHED_CONTAINER_TYPEDEF(Trk, Track, DataVector<Trk::Track>)
115 
116 #undef SPECIALIZE_CONTAINER_FOR_CLASS
117 #undef DECLARE_ATTACHED_CONTAINER
118 #undef DECLARE_ATTACHED_CONTAINER_NAMESPACE
119 #undef DECLARE_ATTACHED_CONTAINER_TYPEDEF
120 #undef DECLARE_ATTACHED_CONTAINER_OBJECT_NAMESPACE
121 
122 // now we set up the traits for the L1 items
123 
124 // this macro setups a template specialization
125 // for the L1 objects
126 #define DECLARE_L1_TRIGGER_OBJECT(x) \
127  class x; \
128  namespace TrigMatch { \
129  template<> \
130  struct ClassTraits<x> { \
131  typedef AncestorAttached type; \
132  }; \
133  }
134 
138 
139 #undef DECLARE_L1_TRIGGER_OBJECT
140 
141 // We can use a similar solution to set the default metrics for various types
142 // of objects
143 
144 namespace TrigMatch {
145 
146  // by default, we assume a class uses the DeltaRDistanceFunctor
147  template<typename T, typename U>
148  struct MetricTraits {
150  };
151 
152 }
153 
154 // this macro is how we add a new delta metric for a type
155 // DECLARE_DEFAULT_METRIC(x,y,z) sets y as the default left
156 // metric for x, and z as the default right metric for x
157 #define DECLARE_DEFAULT_METRIC(x, y, z) \
158  class x; \
159  namespace TrigMatch { \
160  template<typename U> \
161  struct MetricTraits<x,U> { \
162  typedef y<U> type; \
163  }; \
164  template<typename U> \
165  struct MetricTraits<U,x> {\
166  typedef z<U> type; \
167  }; \
168  }
169 
170 // this macro is used to set a default metric for a pair
171 // This sets z as the default metric for pairs x,y
172 #define DECLARE_DEFAULT_METRIC_PAIR(x,y,z) \
173  namespace TrigMatch { \
174  template<> \
175  struct MetricTraits<x,y> { \
176  typedef z<x,y> type; \
177  }; \
178  template<> \
179  struct MetricTraits<y,x> { \
180  typedef z<y,x> type; \
181  }; \
182  }
183 
184 // this macro is used to set a default metric for an
185 // object with itself
186 #define DECLARE_DEFALUT_METRIC_SINGLE(x,z) \
187  namespace TrigMatch { \
188  template<> \
189  struct MetricTraits<x,x> { \
190  typedef z<x,x> type; \
191  }; \
192  }
193 
194 class egamma;
195 class EmTau_ROI;
196 class TrigElectron;
197 
198 namespace Analysis {
199  class Electron;
200  class Photon;
201 }
202 
203 //DECLARE_DEFAULT_METRIC_SINGLE(egamma, ClusterDistanceFunctor)
204 namespace TrigMatch { template<> struct MetricTraits<egamma,egamma> { typedef ClusterDistanceFunctor<egamma,egamma> type; }; }
213 
214 #undef DECLARE_DEFAULT_METRIC
215 #undef DECLARE_DEFAULT_METRIC_PAIR
216 #undef DECLARE_DEFAULT_METRIC_SINGLE
217 
218 #endif
DECLARE_ATTACHED_CONTAINER_OBJECT_NAMESPACE
#define DECLARE_ATTACHED_CONTAINER_OBJECT_NAMESPACE(a, x, y)
Definition: TraitDefs.h:76
TrigEFBphys
Definition: TrigEFBphys.h:42
CaloShowerContainer
Container class for CaloShower.
Definition: CaloShowerContainer.h:15
AthCUDAExamples::TrackParticleContainer
vecmem::edm::container< TrackParticleInterface, vecmem::edm::type::vector< float >, vecmem::edm::type::vector< float >, vecmem::edm::type::vector< float > > TrackParticleContainer
SoA, GPU friendly TrackParticleContainer.
Definition: Control/AthenaExamples/AthExCUDA/src/TrackParticleContainer.h:46
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
ClusterDistanceFunctor
The ClusterDistanceFunctor is a templated distance functor used for matching two objects based upon t...
Definition: ClusterDistanceFunctor.h:43
TrigInDetTrackCollection
Definition: TrigInDetTrackCollection.h:13
Jet_ROI
Jet RoI class for analysis.
Definition: Jet_ROI.h:30
DECLARE_ATTACHED_CONTAINER
#define DECLARE_ATTACHED_CONTAINER(x, y)
Definition: TraitDefs.h:58
CaloClusterContainer
Storable container for CaloCluster.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloClusterContainer.h:37
TrigMatch::AncestorAttached
Definition: TraitDefs.h:34
TrigEFBjetContainer
Container of TrigEFBjet objects to be stored in POOL.
Definition: TrigEFBjetContainer.h:31
Analysis::Electron
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/Electron.h:20
TrigMatch::MetricTraits< egamma, egamma >::type
ClusterDistanceFunctor< egamma, egamma > type
Definition: TraitDefs.h:204
DECLARE_ATTACHED_CONTAINER_NAMESPACE
#define DECLARE_ATTACHED_CONTAINER_NAMESPACE(a, x, y)
Definition: TraitDefs.h:66
DeltaRDistanceFunctor
Definition: DistanceFunctor.h:30
TrigL2Bphys
Definition: TrigL2Bphys.h:43
Analysis::Photon
Definition: Reconstruction/egamma/egammaEvent/egammaEvent/Photon.h:20
TrigElectron
File: TrigElectron.h.
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigElectron.h:63
DECLARE_DEFAULT_METRIC_PAIR
#define DECLARE_DEFAULT_METRIC_PAIR(x, y, z)
Definition: TraitDefs.h:172
CaloShower
Data class for cluster variables associated with a CaloCluster.
Definition: CaloShower.h:12
Muon_ROI
Muon RoI class for analysis.
Definition: Muon_ROI.h:35
Photon
Class describing an photon
TrigInDetTrack
Definition: TrigInDetTrack.h:34
egamma
Definition: egamma.h:58
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
TrigEFBjet
Class representing a b-jet candidate created at EF.
Definition: TrigEFBjet.h:38
CaloTowerContainer
Storable container class for CaloTower.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h:77
TrigL2Bjet
Class representing a b-jet candidate created at L2.
Definition: TrigL2Bjet.h:38
TrigMatch::MetricTraits::type
DeltaRDistanceFunctor< T, U > type
Definition: TraitDefs.h:149
Rec
Name: MuonSpContainer.h Package : offline/Reconstruction/MuonIdentification/muonEvent.
Definition: FakeTrackBuilder.h:10
TrigMuonEF
Definition: TrigMuonEF.h:26
ClusterDistanceFunctor.h
egammaContainer
Definition: egammaContainer.h:41
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
DECLARE_L1_TRIGGER_OBJECT
#define DECLARE_L1_TRIGGER_OBJECT(x)
Definition: TraitDefs.h:126
TrigMatch
helper namespace for calculating deltaR for unknown object types
Definition: ClusterDistanceFunctor.h:20
VxContainer
Definition: VxContainer.h:28
TrigMatch::MetricTraits
Definition: TraitDefs.h:148
CaloTower
Data class for calorimeter cell towers.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTower.h:55
TrigL2BjetContainer
Container of TrigEFBjet objects to be stored in POOL.
Definition: TrigL2BjetContainer.h:32
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Analysis
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition: BTaggingCnvAlg.h:20
xAOD::TauJetContainer
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
Definition: Event/xAOD/xAODTau/xAODTau/TauJetContainer.h:17
TrigVertexCollection
Definition: TrigVertexCollection.h:13
TrigMatch::ClassTraits
Definition: TraitDefs.h:38
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
TrigPhotonContainer
File: TrigPhotonContainer.h.
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhotonContainer.h:32
TauJet
@ TauJet
Definition: TruthClasses.h:47
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
TrigVertex
Definition: TrigVertex.h:28
JetCollection
Container for Jets
Definition: JetCollection.h:30
EmTau_ROI
Em/Tau RoI class for analysis.
Definition: EmTau_ROI.h:34
Electron
Class describing an electron.
TrigMatch::DirectAttached
Definition: TraitDefs.h:33
TrigL2BphysContainer
Definition: TrigL2BphysContainer.h:33
TrigMuonEFContainer
Definition: TrigMuonEFContainer.h:27
TrigMatch::ClassTraits::type
DirectAttached type
Definition: TraitDefs.h:39
TrigEFBphysContainer
Definition: TrigEFBphysContainer.h:34
TrigElectronContainer
File: TrigElectronContainer.h.
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigElectronContainer.h:32
egDetail
Definition: egDetail.h:29
TrigPhoton
File: TrigPhoton.h.
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:44
egDetailContainer
Definition: egDetailContainer.h:18