ATLAS Offline Software
DetStatusMap.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef DETDESCRCOND_DETSTATUSMAP_H
6 #define DETDESCRCOND_DETSTATUSMAP_H
7 // DetStatusMap.h - class to hold details of all subdetector status
8 // can be written to POOL for ESD/AOD files
9 // Richard Hawkings, started 13/12/06
10 
11 #include "AthenaKernel/CLASS_DEF.h"
12 #include "GaudiKernel/DataObject.h"
13 #include "GaudiKernel/MsgStream.h"
15 #include <string>
16 #include <vector>
17 #include <algorithm>
18 
19 class DetStatusMap : public DataObject {
20  public:
21  typedef std::pair<std::string,DetStatus> DetStatusPair;
22  typedef std::vector<DetStatusPair> StatusMap;
23  typedef StatusMap::const_iterator const_iterator;
24 
25  // Add this to allow python iteration over the contents.
27 
28  DetStatusMap();
29  virtual ~DetStatusMap();
30 
31  // access methods to map
32  unsigned int size() const;
33  const_iterator begin() const;
34  const_iterator end() const;
35  const_iterator find(const std::string& name) const;
36 
37  // set methods
38  void clear();
39  void add(const std::string& name, const DetStatus& status);
40 
41  // print method
42  MsgStream& toOutputStream(MsgStream& os) const;
43 
44  private:
45  friend class DetStatusMapCnv_p1;
46 
47  class PairSort {
48  public:
49  bool operator () (const DetStatusPair& x, const DetStatusPair& y)
50  { return (x.first < y.first); }
51  bool operator () (const DetStatusPair& x, const std::string& y)
52  { return (x.first < y); }
53  };
54 
56 };
57 
58 CLASS_DEF( DetStatusMap , 264405569 , 1 )
59 
61 
62 inline unsigned int DetStatusMap::size() const { return m_statmap.size(); }
63 
65 { return m_statmap.begin(); }
66 
68 { return m_statmap.end(); }
69 
70 inline DetStatusMap::const_iterator DetStatusMap::find(const std::string& name) const
71 {
72  const_iterator result = std::lower_bound(m_statmap.begin(),
73  m_statmap.end(),
74  name, PairSort()) ;
75  if ( result != m_statmap.end() && (*result).first == name ) return (result) ;
76  return m_statmap.end() ;
77 }
78 
79 inline void DetStatusMap::clear() { m_statmap.clear(); }
80 
81 inline void DetStatusMap::add(const std::string& name, const DetStatus& status)
82 {
83  m_statmap.emplace_back( name, status ) ;
84  std::sort( m_statmap.begin() , m_statmap.end() , PairSort() );
85 }
86 
87 inline MsgStream& DetStatusMap::toOutputStream(MsgStream& os) const {
88  os << "DetStatusMap of size: " << m_statmap.size() << endmsg;
89  for (StatusMap::const_iterator itr=m_statmap.begin();itr!=m_statmap.end();
90  ++itr) os << itr->first << " : " << itr->second.colour() << " (" <<
91  itr->second.deadFrac() << "," << itr->second.deadThrust() <<
92  ")" << endmsg;
93  return os;
94 }
95 
96 #endif // DETDESCRCOND_DETSTATUSMAP_H
DetStatusMap::DetStatusPair
std::pair< std::string, DetStatus > DetStatusPair
Definition: DetStatusMap.h:21
DetStatusMap::find
const_iterator find(const std::string &name) const
Definition: DetStatusMap.h:70
get_generator_info.result
result
Definition: get_generator_info.py:21
DetStatusMap::StatusMap
std::vector< DetStatusPair > StatusMap
Definition: DetStatusMap.h:22
DetStatusMap::PairSort
Definition: DetStatusMap.h:47
DetStatusMap::clear
void clear()
Definition: DetStatusMap.h:79
DetStatusMap::const_iterator
StatusMap::const_iterator const_iterator
Definition: DetStatusMap.h:23
DetStatusMap::size
unsigned int size() const
Definition: DetStatusMap.h:62
x
#define x
DetStatusMap::~DetStatusMap
virtual ~DetStatusMap()
Definition: DetStatusMap.h:60
DetStatusMap::end
const_iterator end() const
Definition: DetStatusMap.h:67
DetStatus.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
DetStatusMap
Definition: DetStatusMap.h:19
DetStatusMap::m_statmap
StatusMap m_statmap
Definition: DetStatusMap.h:55
DetStatusMap::DetStatusMap
DetStatusMap()
Definition: DetStatusMap.cxx:9
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
DetStatusMap::add
void add(const std::string &name, const DetStatus &status)
Definition: DetStatusMap.h:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DetStatus
Definition: DetStatus.h:12
DetStatusMap::toOutputStream
MsgStream & toOutputStream(MsgStream &os) const
Definition: DetStatusMap.h:87
DetStatusMapCnv_p1
Definition: DetStatusMapCnv_p1.h:13
y
#define y
DetStatusMap::iterator
const_iterator iterator
Definition: DetStatusMap.h:26
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
merge.status
status
Definition: merge.py:17
DetStatusMap::begin
const_iterator begin() const
Definition: DetStatusMap.h:64
DetStatusMap::PairSort::operator()
bool operator()(const DetStatusPair &x, const DetStatusPair &y)
Definition: DetStatusMap.h:49
CLASS_DEF.h
macros to associate a CLID to a type