ATLAS Offline Software
Loading...
Searching...
No Matches
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
12#include "GaudiKernel/DataObject.h"
13#include "GaudiKernel/MsgStream.h"
15#include <string>
16#include <vector>
17#include <algorithm>
18
19class 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
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:
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
58CLASS_DEF( DetStatusMap , 264405569 , 1 )
59
61
62inline unsigned int DetStatusMap::size() const { return m_statmap.size(); }
63
65{ return m_statmap.begin(); }
66
68{ return m_statmap.end(); }
69
70inline 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
79inline void DetStatusMap::clear() { m_statmap.clear(); }
80
81inline 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
87inline 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
#define endmsg
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
#define y
#define x
bool operator()(const DetStatusPair &x, const DetStatusPair &y)
const_iterator iterator
virtual ~DetStatusMap()
MsgStream & toOutputStream(MsgStream &os) const
StatusMap m_statmap
StatusMap::const_iterator const_iterator
std::vector< DetStatusPair > StatusMap
std::pair< std::string, DetStatus > DetStatusPair
friend class DetStatusMapCnv_p1
unsigned int size() const
void add(const std::string &name, const DetStatus &status)
const_iterator find(const std::string &name) const
const_iterator end() const
const_iterator begin() const
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.