ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/interface/AssociationMap.h
(Generate patch)

Comparing UserCode/MitProd/TreeFiller/interface/AssociationMap.h (file contents):
Revision 1.1 by loizides, Tue Jul 1 14:39:28 2008 UTC vs.
Revision 1.2 by loizides, Tue Jul 1 21:11:12 2008 UTC

# Line 3 | Line 3
3   //
4   // Association Map
5   //
6 < // wrapper for std::map, used to resolve links during tree filling
6 > // Wrapper for std::map, used to resolve links during tree filling.
7 > // This class needs work! CL.
8   //
9 < // Authors: J.Bendavid
9 > // Authors: J.Bendavid, C.Loizides
10   //--------------------------------------------------------------------------------------------------
11  
12   #ifndef TREEFILLER_ASSOCIATIONMAP_H
# Line 25 | Line 26 | namespace mithep
26        AssociationMap() : edmProductId_(0) {}
27        ~AssociationMap() {}
28        
29 <      void Add(EdmClass edmObj, MitClass mitObj) {
30 <        fwdMap[edmObj]=mitObj;
31 <        //revMap[mitObj]=edmObj;
32 <        revMap.insert(std::pair<MitClass, EdmClass>(mitObj,edmObj));
33 <      }
34 <      
35 <      MitClass GetMit(EdmClass edmObj) const {
35 <        //MitClass iter = fwdMap.find(edmObj);
36 <        //fwdMapType::iterator iter;
37 <        //fwdIter = fwdMap.find(edmObj);
38 <        //if ( iter != fwdMap.end() )
39 <        //      return iter->second;
40 <        //else return 0;
41 <        return fwdMap.find(edmObj)->second;
42 <      }
43 <      
44 <       EdmClass GetEdmRef(MitClass mitObj) const {
45 < //         //EdmClass iter = revMap.find(mitObj);
46 < // //   revMapType::iterator iter = revMap.find(mitObj);
47 < // //   if ( iter != revMap.end() )
48 < // //           return iter->second;
49 < // //   else return 0;
50 <        return revMap.find(mitObj)->second;
51 <       }
52 <      
53 <      Int_t GetEntries() { return fwdMap.size(); }
54 <      
55 <      void Reset() {
56 <        fwdMap.clear();
57 <        revMap.clear();
58 <      }
59 <      
60 <        Int_t GetEdmProductId() const { return edmProductId_; }
61 <        void  SetEdmProductId(Int_t id) { edmProductId_ = id; }
29 >      void       Add(EdmClass edmObj, MitClass mitObj);
30 >      EdmClass   GetEdmRef(MitClass mitObj) const;
31 >      Int_t      GetEdmProductId()          const { return edmProductId_; }
32 >      Int_t      GetEntries()               const { return fwdMap_.size(); }
33 >      MitClass   GetMit(EdmClass edmObj)    const;
34 >      void       Reset()                          { fwdMap_.clear(); revMap_.clear(); }
35 >      void       SetEdmProductId(Int_t id)        { edmProductId_ = id; }
36  
37      protected:
38 <        fwdMapType fwdMap;
39 <        revMapType revMap;
40 <        Int_t edmProductId_;
67 <      
38 >      fwdMapType fwdMap_;       //map between edm ref and mit ptr
39 >      revMapType revMap_;       //map between mit ptr and edm ref
40 >      Int_t      edmProductId_; //product id for consistency check
41    };
42   }
43 +
44 + //--------------------------------------------------------------------------------------------------
45 + template <class EdmClass, class MitClass>
46 + inline void mithep::AssociationMap<EdmClass,MitClass>::Add(EdmClass edmObj, MitClass mitObj)
47 + {
48 +  fwdMap_[edmObj]=mitObj;
49 +  revMap_.insert(std::pair<MitClass, EdmClass>(mitObj,edmObj));
50 + }
51 +
52 + //--------------------------------------------------------------------------------------------------
53 + template <class EdmClass, class MitClass>
54 + inline MitClass mithep::AssociationMap<EdmClass,MitClass>::GetMit(EdmClass edmObj) const
55 + {
56 +  typename fwdMapType::const_iterator iter = fwdMap_.find(edmObj);
57 +
58 +  if (iter != fwdMap_.end())
59 +    return iter->second;
60 +  else return 0;
61 + }
62 +      
63 + //--------------------------------------------------------------------------------------------------
64 + template <class EdmClass, class MitClass>
65 + inline EdmClass mithep::AssociationMap<EdmClass,MitClass>::GetEdmRef(MitClass mitObj) const
66 + {
67 +  typename revMapType::const_iterator iter = revMap_.find(mitObj);
68 +  if (iter != revMap_.end())
69 +    return iter->second;
70 +  else return 0;
71 + }
72   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines