1 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
|
|
// $Id: FillMuons.h,v 1.6 2008/06/20 17:52:57 loizides Exp $
|
3 |
|
|
//
|
4 |
|
|
// Association Map
|
5 |
|
|
//
|
6 |
|
|
// wrapper for std::map, used to resolve links during tree filling
|
7 |
|
|
//
|
8 |
|
|
// Authors: J.Bendavid
|
9 |
|
|
//--------------------------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
|
|
#ifndef TREEFILLER_ASSOCIATIONMAP_H
|
12 |
|
|
#define TREEFILLER_ASSOCIATIONMAP_H
|
13 |
|
|
|
14 |
|
|
#include <map>
|
15 |
|
|
#include <TObject.h>
|
16 |
|
|
|
17 |
|
|
namespace mithep
|
18 |
|
|
{
|
19 |
|
|
template <class EdmClass, class MitClass> class AssociationMap : public TObject
|
20 |
|
|
{
|
21 |
|
|
typedef std::map<EdmClass, MitClass> fwdMapType;
|
22 |
|
|
typedef std::map<MitClass, EdmClass> revMapType;
|
23 |
|
|
|
24 |
|
|
public:
|
25 |
|
|
AssociationMap() : edmProductId_(0) {}
|
26 |
|
|
~AssociationMap() {}
|
27 |
|
|
|
28 |
|
|
void Add(EdmClass edmObj, MitClass mitObj) {
|
29 |
|
|
fwdMap[edmObj]=mitObj;
|
30 |
|
|
//revMap[mitObj]=edmObj;
|
31 |
|
|
revMap.insert(std::pair<MitClass, EdmClass>(mitObj,edmObj));
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
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; }
|
62 |
|
|
|
63 |
|
|
protected:
|
64 |
|
|
fwdMapType fwdMap;
|
65 |
|
|
revMapType revMap;
|
66 |
|
|
Int_t edmProductId_;
|
67 |
|
|
|
68 |
|
|
};
|
69 |
|
|
}
|
70 |
|
|
#endif
|