CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronIDExternalProducerRemapper.cc
Go to the documentation of this file.
2 
6 
8 
10  emObjectProducer_ (consumes<reco::GsfElectronCollection >(config.getParameter<edm::InputTag>("candidateProducer"))),
11  newToOldObjectMap_ (consumes<CRefMap>(config.getParameter<edm::InputTag>("newToOldObjectMap"))),
12  idMap_ (consumes<edm::ValueMap<float> >(config.getParameter<edm::InputTag>("idMap")))
13 {
14  produces<edm::ValueMap<float> >();
15 }
16 
18 {
19 }
20 
22 {
24  iEvent.getByToken(emObjectProducer_, emObjectHandle);
25 
26  edm::Handle<CRefMap> objectMapHandle;
27  iEvent.getByToken(newToOldObjectMap_, objectMapHandle);
28  auto& objectMap(*objectMapHandle);
29 
31  iEvent.getByToken(idMap_, idMapHandle);
32  auto& idMap(*idMapHandle);
33 
34  std::vector<float> retV(emObjectHandle->size(), 0.);
35 
36  for (unsigned iO(0); iO != emObjectHandle->size(); ++iO) {
37  CRef ref(emObjectHandle, iO);
38  auto oldRef(objectMap[ref]);
39  retV[iO] = idMap[oldRef];
40  }
41 
42  std::auto_ptr<edm::ValueMap<float> > isoMap(new edm::ValueMap<float>);
43  edm::ValueMap<float>::Filler filler(*isoMap);
44 
45  filler.insert(emObjectHandle, retV.begin(), retV.end());
46  filler.fill();
47 
48  iEvent.put(isoMap);
49 }
50 
51 
void produce(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
ElectronIDExternalProducerRemapper(const edm::ParameterSet &)
edm::EDGetTokenT< edm::ValueMap< float > > idMap_
edm::EDGetTokenT< reco::GsfElectronCollection > emObjectProducer_