ATLAS Offline Software
Feature.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2019 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 
26 #include "AsgMessaging/MsgStream.h"
27 
29 #include "xAODTrigger/EmTauRoI.h"
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
51 class Muon_ROI;
52 class EmTau_ROI;
53 class Jet_ROI;
54 #endif
55 
56 #include "xAODBase/IParticle.h"
57 
58 namespace Trig {
77  template<typename T> struct is_storable_type{
78 #if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full Athena
79  static const bool value =
80  !(
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 
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  operator const std::string() const { return m_label; }
187 
191  const std::string& label() const { return m_label; }
192 
196  bool empty() const { return (!m_te || !m_feature); }
197 
198  bool owned() const { return m_owned; }
199 
200  #ifndef __GCCXML__
201  link_type link() const {return m_link;}
202  #endif
203 
204  private:
205  std::shared_ptr<const T> m_owning_feature;
206  const T* m_feature;
208  std::string m_label;
209  bool m_owned;
210  #ifndef __GCCXML__
212  #endif
213  };
214 
215 
219  template<class T>
220  bool sameObject(const Feature<T>& a, const Feature<T>& b) {
221  return a.cptr() == b.cptr();
222  }
223 
224 } // End of namespace
225 
226 template<class T>
227 MsgStream& operator<< ( MsgStream& m, const Trig::Feature<T>& d ) {
228  m << "TE id: " << d.te()->getId() << "obj ptr: " << d.cptr()
229  << " obj type: " << ClassID_traits<T>::typeName() << " label: " << d.label();
230  return m;
231 }
232 #endif
Trig::Feature
Definition: Feature.h:112
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
IParticle.h
Trig::Feature::m_link
link_type m_link
Definition: Feature.h:211
Trig::Feature::ValueType
T ValueType
$brief constructor of empty Feature
Definition: Feature.h:117
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
EmTauRoI.h
Jet_ROI
Jet RoI class for analysis.
Definition: Jet_ROI.h:30
MuonRoIContainer.h
Trig::Feature::Feature
Feature(const TypelessFeature &feat, const T *const feature)
Definition: Feature.h:127
hist_file_dump.d
d
Definition: hist_file_dump.py:137
Trig::is_storable_type::value
static const bool value
Definition: Feature.h:79
Trig::Feature::link
link_type link() const
Definition: Feature.h:201
Trig::Feature::label
const std::string & label() const
explicit conversion to feature label
Definition: Feature.h:191
athena.value
value
Definition: athena.py:122
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
Muon_ROI
Muon RoI class for analysis.
Definition: Muon_ROI.h:35
Trig::Feature::empty
bool empty() const
test method to check if the object is truly there
Definition: Feature.h:196
Trig::is_storable_type
Definition: Feature.h:77
Trig::Feature::Feature
Feature()
Definition: Feature.h:124
Trig::Feature::te
const HLT::TriggerElement * te() const
explicit conversion to TriggerElement
Definition: Feature.h:181
Trig::Feature::~Feature
~Feature()
destructor taking care of removal
Definition: Feature.h:160
ClassID_traits::typeName
static const std::string & typeName()
the demangled type name of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:56
Trig::Feature::m_owned
bool m_owned
Definition: Feature.h:209
Trig::TypelessFeature
Feature class, holding information on Feature attached to navigation.
Definition: TypelessFeature.h:20
Trig::Feature::owned
bool owned() const
Definition: Feature.h:198
HLT::TriggerElement
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:27
TriggerElement.h
Trig::Feature::Feature
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
operator<<
MsgStream & operator<<(MsgStream &m, const Trig::Feature< T > &d)
Definition: Feature.h:227
JetRoIContainer.h
Trig::Feature::link_type
link_or_not< T, is_storable_type< T >::value >::type link_type
Definition: Feature.h:121
Trig::Feature::m_feature
const T * m_feature
Definition: Feature.h:206
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Features2LinkHelper::type
lnk_helper< CONTAINER, isCont >::type type
Definition: EDM_TypeInfoMethods.h:74
Trig::Feature::Feature
Feature(Feature &&) noexcept=default
Add move operator.
EmTauRoIContainer.h
a
TList * a
Definition: liststreamerinfos.cxx:10
Trig::Feature::PointerType
T * PointerType
Definition: Feature.h:118
IsKnownFeature
Definition: EDM_TypeInfoMethods.h:13
EmTau_ROI
Em/Tau RoI class for analysis.
Definition: EmTau_ROI.h:34
known
Definition: TrigBStoxAODTool.cxx:107
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JetRoI.h
MuonRoI.h
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
TypelessFeature.h
Trig::Feature::Feature
Feature(const TypelessFeature &feat, const std::shared_ptr< const T > &feature)
Definition: Feature.h:131
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
Trig::Feature::m_owning_feature
std::shared_ptr< const T > m_owning_feature
Definition: Feature.h:205
Trig::Feature::m_te
const HLT::TriggerElement * m_te
Definition: Feature.h:207
Trig::Feature::m_label
std::string m_label
Definition: Feature.h:208
Features2Container::type
master_search< typename EDMLIST::map, HLT::TypeInformation::get_feat, FEATURE >::result::search_result::container type
Definition: EDM_TypeInfoMethods.h:45
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
Trig::Feature::cptr
const T * cptr() const
explicit conversion to object
Definition: Feature.h:171
Trig::sameObject
bool sameObject(const Feature< T > &a, const Feature< T > &b)
comarison
Definition: Feature.h:220
EDM_TypeInfo.h
MsgStream.h