Index: trunk/Utilities/HepMC/interface/WeightContainer.h
===================================================================
--- trunk/Utilities/HepMC/interface/WeightContainer.h	(revision 349)
+++ trunk/Utilities/HepMC/interface/WeightContainer.h	(revision 572)
@@ -9,9 +9,13 @@
 //
 // Container for the Weights associated with an event or vertex.
-// Basically just an interface to STL vector.
+//
+// This implementation adds a map-like interface in addition to the 
+// vector-like interface.
 //////////////////////////////////////////////////////////////////////////
 
 #include <iostream>
 #include <vector>
+#include <string>
+#include <map>
 
 namespace HepMC {
@@ -21,28 +25,39 @@
     ///
     /// \class  WeightContainer
-    /// Basically just an interface to STL vector.
+    /// This class has both map-like and vector-like functionality.
+    /// Named weights are now supported.
     class WeightContainer {
+	friend class GenEvent;
 
     public:
+        /// defining the size type used by vector and map
+	typedef std::size_t size_type;
+        /// iterator for the weight container
+	typedef std::vector<double>::iterator iterator;
+        /// const iterator for the weight container
+	typedef std::vector<double>::const_iterator const_iterator;
+	
         /// default constructor
-	WeightContainer( unsigned int n = 0, const double& value = 0. );
+	explicit WeightContainer( size_type n = 0, double value = 0. );
         /// construct from a vector of weights
 	WeightContainer( const std::vector<double>& weights );
         /// copy
 	WeightContainer( const WeightContainer& in );
-	virtual ~WeightContainer();
+	~WeightContainer();
 
         /// swap
         void swap( WeightContainer & other);
-        /// copy
+        /// copy assignment
 	WeightContainer& operator=( const WeightContainer& );
-        /// copy
+        /// alternate assignment using a vector of doubles
 	WeightContainer& operator=( const std::vector<double>& in );
 
         /// print weights
 	void          print( std::ostream& ostr = std::cout ) const;
+        /// write weights in a readable table
+	void          write( std::ostream& ostr = std::cout ) const;
 
         /// size of weight container
-	int           size() const;
+	size_type     size() const;
 	/// return true if weight container is empty
 	bool          empty() const;
@@ -54,9 +69,21 @@
 	void          clear();
 
-        /// access the weight container
-	double&       operator[]( unsigned int n );  // unchecked access
-        /// access the weight container
-	const double& operator[]( unsigned int n ) const;
-	
+	/// check to see if a name exists in the map
+	bool          has_key( const std::string& s ) const;
+
+        /// access the weight container
+	double&       operator[]( size_type n );  // unchecked access
+        /// access the weight container
+	const double& operator[]( size_type n ) const;
+        /// access the weight container
+	double&       operator[]( const std::string& s );  // unchecked access
+        /// access the weight container
+	const double& operator[]( const std::string& s ) const;
+
+        /// equality
+	bool operator==( const WeightContainer & ) const;
+        /// inequality
+	bool operator!=( const WeightContainer & ) const;
+ 	
 	/// returns the first element
 	double&       front();
@@ -68,19 +95,42 @@
 	const double& back() const;
 
-        /// iterator for the weight container
-	typedef std::vector<double>::iterator iterator;
+	/// begining of the weight container
+	iterator            begin();
+	/// end of the weight container
+	iterator            end();
+	/// begining of the weight container
+	const_iterator      begin() const;
+	/// end of the weight container
+	const_iterator      end() const;
+
+    private:
+        // for internal use only
+
+        /// maplike iterator for the weight container
+	/// for internal use only
+	typedef std::map<std::string,size_type>::iterator       map_iterator;
         /// const iterator for the weight container
-	typedef std::vector<double>::const_iterator const_iterator;
-	/// begining of the weight container
-	iterator            begin();
-	/// end of the weight container
-	iterator            end();
-	/// begining of the weight container
-	const_iterator      begin() const;
-	/// end of the weight container
-	const_iterator      end() const;
+	/// for internal use only
+	typedef std::map<std::string,size_type>::const_iterator const_map_iterator;
+	/// begining of the weight container
+	/// for internal use only
+	map_iterator            map_begin();
+	/// end of the weight container
+	/// for internal use only
+	map_iterator            map_end();
+	/// begining of the weight container
+	/// for internal use only
+	const_map_iterator      map_begin() const;
+	/// end of the weight container
+	/// for internal use only
+	const_map_iterator      map_end() const;
+	
+	/// used by the constructors to set initial names
+	/// for internal use only
+	void set_default_names( size_type n );
 	
     private:
-	std::vector<double>  m_weights;
+	std::vector<double>          m_weights;
+	std::map<std::string,size_type> m_names;
     };
 
@@ -89,21 +139,15 @@
     ///////////////////////////
 
-    inline WeightContainer::WeightContainer( unsigned int n,
-					     const double& value ) 
-	: m_weights(n,value)
+    inline WeightContainer::WeightContainer( const WeightContainer& in )
+	: m_weights(in.m_weights), m_names(in.m_names)
     {}
 
-    inline WeightContainer::WeightContainer( const std::vector<double>& wgts )
-	: m_weights(wgts)
-    {}
-
-    inline WeightContainer::WeightContainer( const WeightContainer& in )
-	: m_weights(in.m_weights)
-    {}
-
     inline WeightContainer::~WeightContainer() {}
 
     inline void WeightContainer::swap( WeightContainer & other)
-    { m_weights.swap( other.m_weights ); }
+    { 
+        m_weights.swap( other.m_weights ); 
+        m_names.swap( other.m_names ); 
+    }
 
     inline WeightContainer& WeightContainer::operator=
@@ -123,29 +167,19 @@
     }
 
-    inline void WeightContainer::print( std::ostream& ostr ) const 
+    inline WeightContainer::size_type WeightContainer::size() const { return m_weights.size(); }
+
+    inline bool WeightContainer::empty() const { return m_weights.empty(); }
+
+    inline void WeightContainer::clear() 
     { 
-	for ( const_iterator w = begin(); w != end(); ++w ) 
-	{ 
-	    ostr << *w << " ";
-	}
-	ostr << std::endl; 
-    }
-
-    inline int WeightContainer::size() const { return m_weights.size(); }
-
-    inline bool WeightContainer::empty() const { return m_weights.empty(); }
-
-    inline void WeightContainer::push_back( const double& value) 
-    { m_weights.push_back(value); }
-
-    inline void WeightContainer::pop_back() { m_weights.pop_back(); }
-
-    inline void WeightContainer::clear() { m_weights.clear(); }
-
-    inline double& WeightContainer::operator[]( unsigned int n ) 
-    { return m_weights[(int)n]; }
-
-    inline const double& WeightContainer::operator[]( unsigned int n ) const
-    { return m_weights[(int)n]; }
+	m_weights.clear(); 
+	m_names.clear(); 
+    }
+
+    inline double& WeightContainer::operator[]( size_type n ) 
+    { return m_weights[n]; }
+
+    inline const double& WeightContainer::operator[]( size_type n ) const
+    { return m_weights[n]; }
 
     inline double& WeightContainer::front() { return m_weights.front(); }
@@ -171,4 +205,16 @@
     { return m_weights.end(); }
 
+    inline WeightContainer::map_iterator WeightContainer::map_begin() 
+    { return m_names.begin(); }
+
+    inline WeightContainer::map_iterator WeightContainer::map_end() 
+    { return m_names.end(); }
+
+    inline WeightContainer::const_map_iterator WeightContainer::map_begin() const 
+    { return m_names.begin(); }
+
+    inline WeightContainer::const_map_iterator WeightContainer::map_end() const 
+    { return m_names.end(); }
+
 } // HepMC
 
