ATLAS Offline Software
TrigObjectMatcher.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
11 #ifndef TRIGOBJECTMATCHER_H
12 #define TRIGOBJECTMATCHER_H
13 
14 #include <iostream>
15 #include <map>
16 
20 
21 
23 
24 public:
25 
26  typedef std::map<unsigned long, const TrackTrigObject*> map_type;
27 
28 public:
29 
31 
32  TrigObjectMatcher( const std::vector<TIDA::Track*>& tracks,
33  const std::vector<TrackTrigObject>& objects )
34  : m_status(1) {
35  for ( size_t i=tracks.size() ; i-- ; ) match( tracks[i]->id(), objects );
36  }
37 
38 
40  const std::vector<TrackTrigObject>& objects,
41  bool (*select_function)(const TrackTrigObject& )=0 )
42  : m_status(1) {
43  const std::vector<TIDA::Track*> tracks = selector->tracks();
44  for ( size_t i=tracks.size() ; i-- ; ) if ( match( tracks[i]->id(), objects, select_function )==false ) selector->delete_track( tracks[i] );
45  }
46 
48  const std::vector<TrackTrigObject>& objects,
49  bool (*select_function)(const TrackTrigObject& , TIDA::Track* )=0 )
50  : m_status(1) {
51  const std::vector<TIDA::Track*> tracks = selector->tracks();
52  for ( size_t i=tracks.size() ; i-- ; ) if ( match( tracks[i], objects, select_function )==false ) selector->delete_track( tracks[i] );
53  }
54 
55 
56  virtual ~TrigObjectMatcher() { }
57 
58 
59  const TrackTrigObject* object( unsigned long track_id) {
60  map_type::const_iterator itr = m_objectmap.find( track_id );
61  if ( itr==m_objectmap.end() ) return 0;
62  return itr->second;
63  }
64 
65  bool status() const { return m_status; }
66 
67  map_type::const_iterator begin() const { return m_objectmap.begin(); }
68  map_type::const_iterator end() const { return m_objectmap.end(); }
69 
70  size_t size() const { return m_objectmap.size(); }
71 
72  void print( std::ostream& s ) const {
73  s << "TrigObjectMatch size: " << m_objectmap.size();
74  for ( map_type::const_iterator itr = m_objectmap.begin() ; itr!=m_objectmap.end() ; ++itr ) {
75  s << "\n[ id: 0x" << std::hex << itr->first << std::dec << " :: " << *(itr->second) << " ]";
76  }
77  }
78 
79 private:
80 
81  bool match( unsigned long track_id, const std::vector<TrackTrigObject>& objects, bool (*select_function)(const TrackTrigObject& t)=0 ) {
82  for ( size_t j=objects.size() ; j-- ; ) {
83  for ( size_t k=objects[j].children().size() ; k-- ; ) {
84  if ( track_id == objects[j].children()[k] ) {
85  if ( select_function==0 || select_function(objects[j]) ) {
86  m_objectmap.insert( map_type::value_type( track_id, &objects[j] ) );
87  return true;
88  }
89  else return false;
90  }
91  }
92  }
93  return false;
94  }
95 
96 
97  bool match( TIDA::Track* track, const std::vector<TrackTrigObject>& objects, bool (*select_function)(const TrackTrigObject& , TIDA::Track* )=0 ) {
98  for ( size_t j=objects.size() ; j-- ; ) {
99  for ( size_t k=objects[j].children().size() ; k-- ; ) {
100  if ( track->id() == objects[j].children()[k] ) {
101  if ( select_function==0 || select_function(objects[j], track) ) {
102  m_objectmap.insert( map_type::value_type( track->id(), &objects[j] ) );
103  return true;
104  }
105  else return false;
106  }
107  }
108  }
109  return false;
110  }
111 
112 
113 private:
114 
115  int m_status;
117 
118 };
119 
120 inline std::ostream& operator<<( std::ostream& s, const TrigObjectMatcher& o ) {
121  o.print( s );
122  return s;
123 }
124 
125 
126 #endif // TRIGOBJECTMATCHER_H
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
Track.h
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
LArConditions2Ntuple.objects
objects
Definition: LArConditions2Ntuple.py:59
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TrigObjectMatcher::m_objectmap
map_type m_objectmap
Definition: TrigObjectMatcher.h:116
TrigObjectMatcher::m_status
int m_status
Definition: TrigObjectMatcher.h:115
TrigObjectMatcher::begin
map_type::const_iterator begin() const
Definition: TrigObjectMatcher.h:67
TrackSelector
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h:24
TrigObjectMatcher::match
bool match(TIDA::Track *track, const std::vector< TrackTrigObject > &objects, bool(*select_function)(const TrackTrigObject &, TIDA::Track *)=0)
Definition: TrigObjectMatcher.h:97
operator<<
std::ostream & operator<<(std::ostream &s, const TrigObjectMatcher &o)
Definition: TrigObjectMatcher.h:120
TrigObjectMatcher
Definition: TrigObjectMatcher.h:22
TrigObjectMatcher::TrigObjectMatcher
TrigObjectMatcher()
Definition: TrigObjectMatcher.h:30
TrigObjectMatcher::map_type
std::map< unsigned long, const TrackTrigObject * > map_type
Definition: TrigObjectMatcher.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigObjectMatcher::TrigObjectMatcher
TrigObjectMatcher(TrackSelector *selector, const std::vector< TrackTrigObject > &objects, bool(*select_function)(const TrackTrigObject &)=0)
Definition: TrigObjectMatcher.h:39
TrackSelector.h
TrigObjectMatcher::status
bool status() const
Definition: TrigObjectMatcher.h:65
TrigObjectMatcher::TrigObjectMatcher
TrigObjectMatcher(const std::vector< TIDA::Track * > &tracks, const std::vector< TrackTrigObject > &objects)
Definition: TrigObjectMatcher.h:32
TrigObjectMatcher::size
size_t size() const
Definition: TrigObjectMatcher.h:70
TrigObjectMatcher::print
void print(std::ostream &s) const
Definition: TrigObjectMatcher.h:72
TrackTrigObject.h
TrigObjectMatcher::~TrigObjectMatcher
virtual ~TrigObjectMatcher()
Definition: TrigObjectMatcher.h:56
TrackTrigObject
Definition: TrackTrigObject.h:21
python.selector.AtlRunQuerySelectorLhcOlc.selector
selector
Definition: AtlRunQuerySelectorLhcOlc.py:611
TIDA::Track
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:26
python.DecayParser.children
children
Definition: DecayParser.py:32
TrigObjectMatcher::TrigObjectMatcher
TrigObjectMatcher(TrackSelector *selector, const std::vector< TrackTrigObject > &objects, bool(*select_function)(const TrackTrigObject &, TIDA::Track *)=0)
Definition: TrigObjectMatcher.h:47
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
TrigObjectMatcher::match
bool match(unsigned long track_id, const std::vector< TrackTrigObject > &objects, bool(*select_function)(const TrackTrigObject &t)=0)
Definition: TrigObjectMatcher.h:81
TrigObjectMatcher::object
const TrackTrigObject * object(unsigned long track_id)
Definition: TrigObjectMatcher.h:59
TrigObjectMatcher::end
map_type::const_iterator end() const
Definition: TrigObjectMatcher.h:68
fitman.k
k
Definition: fitman.py:528