ATLAS Offline Software
Loading...
Searching...
No Matches
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
14namespace 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)
105 DECLARE_ATTACHED_CONTAINER_NAMESPACE(Rec, TrackParticle, TrackParticleContainer)
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
144namespace TrigMatch {
145
146 // by default, we assume a class uses the DeltaRDistanceFunctor
147 template<typename T, typename U>
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
194class egamma;
195class EmTau_ROI;
196class TrigElectron;
197
198namespace Analysis {
199 class Electron;
200 class Photon;
201}
202
203//DECLARE_DEFAULT_METRIC_SINGLE(egamma, ClusterDistanceFunctor)
204namespace 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
An STL vector of pointers that by default owns its pointed-to elements.
#define DECLARE_ATTACHED_CONTAINER_OBJECT_NAMESPACE(a, x, y)
Definition TraitDefs.h:76
#define DECLARE_ATTACHED_CONTAINER(x, y)
Definition TraitDefs.h:58
#define DECLARE_L1_TRIGGER_OBJECT(x)
Definition TraitDefs.h:126
#define DECLARE_DEFAULT_METRIC_PAIR(x, y, z)
Definition TraitDefs.h:172
#define DECLARE_ATTACHED_CONTAINER_NAMESPACE(a, x, y)
Definition TraitDefs.h:66
@ TauJet
Container class for CaloCell.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
Principal data class for CaloCell clusters.
Container class for CaloShower.
Data class for cluster variables associated with a CaloCluster.
Definition CaloShower.h:12
Storable container class for CaloTower.
Data class for calorimeter cell towers.
The ClusterDistanceFunctor is a templated distance functor used for matching two objects based upon t...
Em/Tau RoI class for analysis.
Definition EmTau_ROI.h:34
Jet RoI class for analysis.
Definition Jet_ROI.h:30
Muon RoI class for analysis.
Definition Muon_ROI.h:35
Container of TrigEFBjet objects to be stored in POOL.
Class representing a b-jet candidate created at EF.
Definition TrigEFBjet.h:38
represents a LVL2 ID track
Container of TrigEFBjet objects to be stored in POOL.
Class representing a b-jet candidate created at L2.
Definition TrigL2Bjet.h:38
encapsulates LVL2 vertex parameters (in the global reference frame), covariance matrix,...
Definition TrigVertex.h:28
Container for detailed egamma information.
Base class for detailed egamma information.
Definition egDetail.h:29
This is a data object, containing a collection of egamma Objects.
elec/gamma data class.
Definition egamma.h:58
Class describing an electron.
Class describing an photon.
The namespace of all packages in PhysicsAnalysis/JetTagging.
Gaudi Tools.
helper namespace for calculating deltaR for unknown object types
Ensure that the ATLAS eigen extensions are properly loaded.
DirectAttached type
Definition TraitDefs.h:39
ClusterDistanceFunctor< egamma, egamma > type
Definition TraitDefs.h:204
DeltaRDistanceFunctor< T, U > type
Definition TraitDefs.h:149