ATLAS Offline Software
Loading...
Searching...
No Matches
Feature.h
Go to the documentation of this file.
1// -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef TRIGGER_DECISION_TOOL_Feature_H
8#define TRIGGER_DECISION_TOOL_Feature_H
9
10/**********************************************************************************
11 * @Project:
12 * @Package: TrigDecision
13 * @class : Feature
14 *
15 *
16 * @author Nicolas Berger <Nicolas.Berger@cern.ch> - LAPP Annecy
17 * @author Tomasz Bold <tomasz.bold@cern.ch> - UC Irvine, AGH-UST Krakow
18 * @author Lukas Heinrich <lukas.heinrich@cern.ch> - NYU
19 *
20 ***********************************************************************************/
21
22#include <string>
23#include <set>
24#include <type_traits>
25
27
31
32#include "xAODTrigger/MuonRoI.h"
34
35#include "xAODTrigger/JetRoI.h"
37
39
40#if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full Athena
42#endif
43
44
45//forward declare ROI types used in is_storable_type use below
46//it's important for this to happen outside of Trig
47//e.g. not in the std::is_same call directly a la
48// std::is_same<T,struct Muon_ROI>::value
49//so that it does not end up to be a check on is_same<T,Trig::Muon_ROI>
50#if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full Athena
51class Muon_ROI;
52class EmTau_ROI;
53class Jet_ROI;
54#endif
55
56#include "xAODBase/IParticle.h"
57
58namespace Trig {
75
76
77 template<typename T> struct is_storable_type{
78#if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full Athena
79 static const bool value =
80 !(
81 std::is_same<T,Muon_ROI>::value ||
82 std::is_same<T,EmTau_ROI>::value ||
83 std::is_same<T,Jet_ROI>::value ||
84 std::is_same<T,xAOD::EmTauRoI>::value ||
85 std::is_same<T,xAOD::MuonRoI>::value ||
86 std::is_same<T,xAOD::JetRoI>::value ||
87 std::is_same<T,xAOD::IParticle>::value
88 );
89#else // AnalysisBase or AthAnalysis
90 static const bool value = false;
91#endif
92 };
93
94 template<typename T,bool> struct link_or_not;
95
96
97#if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full Athena
98 template<typename T> struct link_or_not<T,true>{
99 static const bool known = IsKnownFeature<T>::value; //will cause compile error if not
102 };
103#endif
104
106
107 template<typename T> struct link_or_not<T,false>{
109 };
110
111 template<class T>
112 class Feature {
113 public:
117 typedef T ValueType;
118 typedef T* PointerType;
119
120 #ifndef __GCCXML__
122 #endif
123
125 : m_feature((const T*)0), m_te(0), m_label(""), m_owned(false) { }
126
127 Feature(const TypelessFeature& feat, const T* const feature)
128 : m_feature(feature), m_te(feat.te()),
129 m_label(feat.label()), m_owned(false) { }
130
131 Feature(const TypelessFeature& feat, const std::shared_ptr<const T>& feature)
132 : m_owning_feature(feature),
134 m_te(feat.te()), m_label(feat.label()), m_owned(true) { }
135
137 Feature(Feature&&) noexcept = default;
138
140 Feature(const Feature&) = default;
141
142 Feature& operator=(const Feature&) = default;
143
144 Feature& operator=(Feature&&) = default;
145
149 #ifndef __GCCXML__
150 Feature(const T* feature, const HLT::TriggerElement* te, const std::string& label = "", const bool own = false, const link_type link = link_type())
151 : m_feature(feature), m_te(te), m_label(label), m_owned(own), m_link(link) {
152 //in Athena if we own this feature, it will be deleted by AnyTypeDeleter in CGM
153 //so we're fine by just setting the non-owning ptr.
154 }
155 #endif
156
161 }
162
166 operator const T*() const { return cptr(); }
167
171 const T* cptr() const { return m_feature; }
172
176 operator const HLT::TriggerElement*() const { return m_te; }
177
181 const HLT::TriggerElement* te() const { return m_te; }
182
186 // cppcheck-suppress returnByReference
187 operator const std::string() const { return m_label; }
188
192 const std::string& label() const { return m_label; }
193
197 bool empty() const { return (!m_te || !m_feature); }
198
199 bool owned() const { return m_owned; }
200
201 #ifndef __GCCXML__
202 link_type link() const {return m_link;}
203 #endif
204
205 private:
206 std::shared_ptr<const T> m_owning_feature;
207 const T* m_feature;
209 std::string m_label;
210 bool m_owned;
211 #ifndef __GCCXML__
213 #endif
214 };
215
216
220 template<class T>
221 bool sameObject(const Feature<T>& a, const Feature<T>& b) {
222 return a.cptr() == b.cptr();
223 }
224
225} // End of namespace
226
227template<class T>
228MsgStream& operator<< ( MsgStream& m, const Trig::Feature<T>& d ) {
229 m << "TE id: " << d.te()->getId() << "obj ptr: " << d.cptr()
230 << " obj type: " << ClassID_traits<T>::typeName() << " label: " << d.label();
231 return m;
232}
233#endif
MsgStream & operator<<(MsgStream &m, const Trig::Feature< T > &d)
Definition Feature.h:228
static Double_t a
Em/Tau RoI class for analysis.
Definition EmTau_ROI.h:34
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Jet RoI class for analysis.
Definition Jet_ROI.h:30
Muon RoI class for analysis.
Definition Muon_ROI.h:35
is basic vehicle of object access in TDT
Definition Feature.h:112
const HLT::TriggerElement * m_te
Definition Feature.h:208
link_or_not< T, is_storable_type< T >::value >::type link_type
Definition Feature.h:121
const T * cptr() const
explicit conversion to object
Definition Feature.h:171
~Feature()
destructor taking care of removal
Definition Feature.h:160
const HLT::TriggerElement * te() const
explicit conversion to TriggerElement
Definition Feature.h:181
bool owned() const
Definition Feature.h:199
link_type m_link
Definition Feature.h:212
std::shared_ptr< const T > m_owning_feature
Definition Feature.h:206
Feature(const TypelessFeature &feat, const std::shared_ptr< const T > &feature)
Definition Feature.h:131
Feature(const TypelessFeature &feat, const T *const feature)
Definition Feature.h:127
T * PointerType
Definition Feature.h:118
T ValueType
$brief constructor of empty Feature
Definition Feature.h:117
Feature(Feature &&) noexcept=default
Add move operator.
const T * m_feature
Definition Feature.h:207
const std::string & label() const
explicit conversion to feature label
Definition Feature.h:192
std::string m_label
Definition Feature.h:209
bool empty() const
test method to check if the object is truly there
Definition Feature.h:197
link_type link() const
Definition Feature.h:202
Feature(const T *feature, const HLT::TriggerElement *te, const std::string &label="", const bool own=false, const link_type link=link_type())
constructor of valid Feature object
Definition Feature.h:150
Feature class, holding information on Feature attached to navigation.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
The common trigger namespace for trigger analysis tools.
bool sameObject(const Feature< T > &a, const Feature< T > &b)
comarison
Definition Feature.h:221
master_search< typenameEDMLIST::map, HLT::TypeInformation::get_feat, FEATURE >::result::search_result::container type
lnk_helper< CONTAINER, isCont >::type type
static const bool value
static const bool value
Definition Feature.h:79