ATLAS Offline Software
TIDAFeatureStore.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
15 #ifndef TIDA_FEATURESTORE_H
16 #define TIDA_FEATURESTORE_H
17 
18 #include <iostream>
19 #include <map>
20 
21 #include "TIDAFeature.h"
22 
23 
24 namespace TIDA {
25 
26 class FeatureStore : public std::map<std::string, TIDA::FeatureBase*> {
27 
28 public:
29 
30  typedef std::map<std::string, FeatureBase*> map_type;
31 
32 public:
33 
34  FeatureStore() { }
35 
37  const_iterator itr = begin();
38  const_iterator iend = end();
39  while( itr!=iend ) delete (itr++)->second;
40  }
41 
42 
43  template<typename T>
44  void insert( T* t, const std::string& key ) {
46  _insert( tt, key );
47  }
48 
49 
50  template<typename T>
51  int find( T*& t, const std::string& key ) {
53  if ( f ) {
54  TIDA::Feature<T>* fdptr = dynamic_cast<TIDA::Feature<T>*>(f);
55  if ( fdptr ) {
56  t = fdptr->cptr();
57  return 0;
58  }
59  else return -2;
60  }
61  return -1;
62  }
63 
64 private:
65 
66  void _insert( TIDA::FeatureBase* f, const std::string& key ) {
67  map_type::insert( value_type( key, f ) );
68  }
69 
70  TIDA::FeatureBase* _find( const std::string& key ) {
72  if ( itr!=end() ) return itr->second;
73  else return 0;
74  }
75 
76 
77 };
78 
79 }
80 
81 
82 
83 inline std::ostream& operator<<( std::ostream& s, const TIDA::FeatureStore& f ) {
84  TIDA::FeatureStore::const_iterator itr = f.begin();
85  TIDA::FeatureStore::const_iterator iend = f.end();
86  while( itr!=iend ) {
87  if ( itr->first.size()>5 ) s << "\t[ " << itr->first << ":\t" << itr->second << " ]\n";
88  else s << "\t[ " << itr->first << ":\t\t" << itr->second << " ]\n";
89  ++itr;
90  }
91  return s;
92 }
93 
94 
95 #endif // FEATURESTORE_H
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
TIDA
Test for xAOD.
Definition: Filter_AcceptAll.h:22
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TIDA::FeatureStore::FeatureStore
FeatureStore()
Definition: TIDAFeatureStore.h:34
operator<<
std::ostream & operator<<(std::ostream &s, const TIDA::FeatureStore &f)
Definition: TIDAFeatureStore.h:83
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TIDA::FeatureStore
Definition: TIDAFeatureStore.h:26
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TIDA::FeatureStore::map_type
std::map< std::string, FeatureBase * > map_type
Definition: TIDAFeatureStore.h:30
TIDA::FeatureStore::_insert
void _insert(TIDA::FeatureBase *f, const std::string &key)
Definition: TIDAFeatureStore.h:66
hist_file_dump.f
f
Definition: hist_file_dump.py:135
TIDA::FeatureStore::find
int find(T *&t, const std::string &key)
Definition: TIDAFeatureStore.h:51
TIDA::FeatureStore::insert
void insert(T *t, const std::string &key)
Definition: TIDAFeatureStore.h:44
TIDA::Feature
actual template of the Feature wrapper - stores a pointer to an object and inherits from FeatureBase
Definition: TIDAFeature.h:55
TIDA::FeatureStore::_find
TIDA::FeatureBase * _find(const std::string &key)
Definition: TIDAFeatureStore.h:70
TIDAFeature.h
wrapper class to wrap objects such that they can be added to a generic store
TIDA::FeatureBase
very basic Feature base class just so that we can store derived classes onto the store
Definition: TIDAFeature.h:29
value_type
Definition: EDM_MasterSearch.h:11
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
TIDA::Feature::cptr
T * cptr()
Definition: TIDAFeature.h:67
TIDA::FeatureStore::~FeatureStore
~FeatureStore()
Definition: TIDAFeatureStore.h:36
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37