CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MCTruthCompositeMatcher.h
Go to the documentation of this file.
1 #ifndef HepMCCandAlgos_MCTruthCompositeMatcher
2 #define HepMCCandAlgos_MCTruthCompositeMatcher
3 /* \class MCTruthCompositeMatcher
4  *
5  * \author Luca Lista, INFN
6  *
7  */
10 #include "PhysicsTools/HepMCCandAlgos/interface/MCCandMatcher.h"
11 
12 template<typename C1, typename C2 = C1>
14 public:
15  explicit MCTruthCompositeMatcher( const edm::ParameterSet & );
17 private:
20  std::vector<edm::InputTag> matchMaps_;
21  void produce( edm::Event & , const edm::EventSetup & );
22 };
23 
27 
28 template<typename C1, typename C2>
30  src_( cfg.template getParameter<edm::InputTag>( "src" ) ),
31  matchMaps_( cfg.template getParameter<std::vector<edm::InputTag> >( "matchMaps" ) ) {
32  produces<map_type>();
33 }
34 
35 template<typename C1, typename C2>
37 }
38 
39 template<typename C1, typename C2>
41  typedef typename CandMatcher<C1, C2>::reference_type reference_type;
42  Handle<C1> cands;
43  evt.getByLabel(src_, cands);
44 
45  size_t nMaps = matchMaps_.size();
46  std::vector<const map_type *> maps;
47  maps.reserve( nMaps );
48  for( size_t i = 0; i != nMaps; ++ i ) {
49  Handle<map_type> matchMap;
50  evt.getByLabel( matchMaps_[i], matchMap );
51  maps.push_back( & * matchMap );
52  }
53  MCCandMatcher<C1, C2> match( maps );
54  auto_ptr<map_type> matchMap( new map_type );
55  for( size_t i = 0; i != cands->size(); ++ i ) {
56  const typename C1::value_type & cand = ( * cands )[ i ];
57  reference_type mc(match( cand ));
58  if ( mc.isNonnull() ) {
59  matchMap->insert( reference_type( cands, i ), mc );
60  }
61  }
62 
63  evt.put( matchMap );
64 }
65 
66 #endif
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag > matchMaps_
MCTruthCompositeMatcher(const edm::ParameterSet &)
CandMatcher< C1, C2 >::map_type map_type
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
void produce(edm::Event &, const edm::EventSetup &)
map_type::key_type reference_type
concrete candidate reference type
Definition: CandMatcher.h:27
def template
Definition: svgfig.py:520