CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
reco::modulesNew::MCTruthCompositeMatcher Class Reference
Inheritance diagram for reco::modulesNew::MCTruthCompositeMatcher:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MCTruthCompositeMatcher (const edm::ParameterSet &)
 
 ~MCTruthCompositeMatcher ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

std::vector< edm::EDGetTokenT
< reco::GenParticleMatch > > 
matchMapTokens_
 
std::vector< int > pdgId_
 
edm::EDGetTokenT< CandidateViewsrcToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 20 of file MCTruthCompositeMatcherNew.cc.

Constructor & Destructor Documentation

Definition at line 31 of file MCTruthCompositeMatcherNew.cc.

References GlobalPosition_Frontier_DevDB_cff::tag.

31  :
32  srcToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("src"))),
33  matchMapTokens_( edm::vector_transform(cfg.template getParameter<std::vector<edm::InputTag> >( "matchMaps" ), [this](edm::InputTag const & tag){return consumes<reco::GenParticleMatch>(tag);} ) ),
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< reco::GenParticleMatch > > matchMapTokens_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11

Definition at line 38 of file MCTruthCompositeMatcherNew.cc.

38  {
39  }

Member Function Documentation

void MCTruthCompositeMatcher< C1, C2 >::produce ( edm::Event evt,
const edm::EventSetup  
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 41 of file MCTruthCompositeMatcherNew.cc.

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

41  {
42  using namespace edm;
43  using namespace std;
45  evt.getByToken(srcToken_, cands);
46  size_t nMaps = matchMapTokens_.size();
47  std::vector<const GenParticleMatch *> maps;
48  maps.reserve( nMaps );
49  for( size_t i = 0; i != nMaps; ++ i ) {
51  evt.getByToken(matchMapTokens_[i], matchMap);
52  maps.push_back(& * matchMap);
53  }
54  utilsNew::CandMatcher<GenParticleCollection> match(maps);
55  auto_ptr<GenParticleMatch> matchMap(new GenParticleMatch(match.ref()));
56  int size = cands->size();
57  vector<int>::const_iterator begin = pdgId_.begin(), end = pdgId_.end();
58  if(size != 0) {
59  GenParticleMatch::Filler filler(*matchMap);
60  vector<int> indices(size);
61  for(int i = 0; i != size; ++ i) {
62  const Candidate & cand = (* cands)[i];
63  GenParticleRef mc = match[cand];
64  if(mc.isNull()) {
65  indices[i] = -1;
66  } else {
67  bool found = true;
68  if(begin!=end) found = find(begin, end, std::abs(mc->pdgId())) != end;
69  indices[i] = found ? int(mc.key()) : -1;
70  }
71  }
72  CandidateBaseRefProd ref(cands->refAt(0));
73  filler.insert(ref, indices.begin(), indices.end());
74  filler.fill();
75  }
76  evt.put(matchMap);
77  }
int i
Definition: DBlmapReader.cc:9
std::vector< edm::EDGetTokenT< reco::GenParticleMatch > > matchMapTokens_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::RefToBaseProd< Candidate > CandidateBaseRefProd
vector of references to objects in the same collection of Candidate objects via base type ...
Definition: CandidateFwd.h:39
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool isNull() const
Checks for null.
Definition: Ref.h:247
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define end
Definition: vmac.h:37
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:156
key_type key() const
Accessor for product key.
Definition: Ref.h:266
#define begin
Definition: vmac.h:30
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
tuple size
Write out results.
edm::Association< GenParticleCollection > GenParticleMatch
vector of reference to GenParticle in the same collection

Member Data Documentation

std::vector<edm::EDGetTokenT<reco::GenParticleMatch> > reco::modulesNew::MCTruthCompositeMatcher::matchMapTokens_
private

Definition at line 26 of file MCTruthCompositeMatcherNew.cc.

Referenced by produce().

std::vector<int> reco::modulesNew::MCTruthCompositeMatcher::pdgId_
private

Definition at line 27 of file MCTruthCompositeMatcherNew.cc.

Referenced by produce().

edm::EDGetTokenT<CandidateView> reco::modulesNew::MCTruthCompositeMatcher::srcToken_
private

Definition at line 25 of file MCTruthCompositeMatcherNew.cc.

Referenced by produce().