CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

reco::modulesNew::MCTruthCompositeMatcher Class Reference

Inheritance diagram for reco::modulesNew::MCTruthCompositeMatcher:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 MCTruthCompositeMatcher (const edm::ParameterSet &)
 ~MCTruthCompositeMatcher ()

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

std::vector< edm::InputTagmatchMaps_
std::vector< int > pdgId_
edm::InputTag src_

Detailed Description

Definition at line 19 of file MCTruthCompositeMatcherNew.cc.


Constructor & Destructor Documentation

MCTruthCompositeMatcher< C1, C2 >::MCTruthCompositeMatcher ( const edm::ParameterSet cfg) [explicit]

Definition at line 30 of file MCTruthCompositeMatcherNew.cc.

                                                                                  :
      src_(cfg.getParameter<edm::InputTag>("src")),
      matchMaps_(cfg.getParameter<std::vector<edm::InputTag> >("matchMaps")),
      pdgId_(cfg.getParameter<std::vector<int> >("matchPDGId")) {
      produces<reco::GenParticleMatch>();
    }

Definition at line 37 of file MCTruthCompositeMatcherNew.cc.

                                                      {
    }

Member Function Documentation

void MCTruthCompositeMatcher< C1, C2 >::produce ( edm::Event evt,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 40 of file MCTruthCompositeMatcherNew.cc.

References abs, begin, end, edm::helper::Filler< Map >::fill(), spr::find(), newFWLiteAna::found, edm::Event::getByLabel(), i, edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNull(), edm::Ref< C, T, F >::key(), match(), matchMaps_, pdgId_, edm::Event::put(), reco::utilsNew::CandMatcher< C >::ref(), findQualityFiles::size, and src_.

                                                                                  {
      using namespace edm;
      using namespace std;
      Handle<CandidateView> cands;
      evt.getByLabel(src_, cands);
      size_t nMaps = matchMaps_.size();
      std::vector<const GenParticleMatch *> maps;
      maps.reserve( nMaps );
      for( size_t i = 0; i != nMaps; ++ i ) {
        Handle<reco::GenParticleMatch> matchMap;
        evt.getByLabel(matchMaps_[i], matchMap);
        maps.push_back(& * matchMap);
      } 
      utilsNew::CandMatcher<GenParticleCollection> match(maps); 
      auto_ptr<GenParticleMatch> matchMap(new GenParticleMatch(match.ref()));
      int size = cands->size();
      vector<int>::const_iterator begin = pdgId_.begin(), end = pdgId_.end();
      if(size != 0) {
        GenParticleMatch::Filler filler(*matchMap);
        vector<int> indices(size);
        for(int i = 0; i != size; ++ i) {
          const Candidate & cand = (* cands)[i];
          GenParticleRef mc = match[cand];
          if(mc.isNull()) {
            indices[i] = -1; 
          } else {
            bool found = true;
            if(begin!=end) found = find(begin, end, std::abs(mc->pdgId())) != end;
            indices[i] = found ? int(mc.key()) : -1;
          }
        }
        CandidateBaseRefProd ref(cands->refAt(0));
        filler.insert(ref, indices.begin(), indices.end());
        filler.fill();
      }
      evt.put(matchMap);
    }

Member Data Documentation

Definition at line 25 of file MCTruthCompositeMatcherNew.cc.

Referenced by produce().

Definition at line 26 of file MCTruthCompositeMatcherNew.cc.

Referenced by produce().

Definition at line 24 of file MCTruthCompositeMatcherNew.cc.

Referenced by produce().