Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ICPhotonElectronVetoCalculator.cc
Go to the documentation of this file.
2 #include <vector>
3 #include "FWCore/Framework/interface/Event.h"
4 #include "FWCore/Framework/interface/EventSetup.h"
5 #include "FWCore/Framework/interface/MakerMacros.h"
6 #include "FWCore/ParameterSet/interface/ParameterSet.h"
7 #include "FWCore/Utilities/interface/InputTag.h"
8 #include "DataFormats/Common/interface/Handle.h"
9 #include "DataFormats/Common/interface/ValueMap.h"
10 
11 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
12 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
13 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
14 #include "DataFormats/EgammaCandidates/interface/Photon.h"
15 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
16 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
17 #include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
19 
21  const edm::ParameterSet& config)
22  : input_(config.getParameter<edm::InputTag>("input")),
23  input_electrons_(config.getParameter<edm::InputTag>("electrons")),
24  input_beamspot_(config.getParameter<edm::InputTag>("beamspot")),
25  input_conversions_(config.getParameter<edm::InputTag>("conversions")) {
26  consumes<reco::PhotonCollection>(input_);
27  consumes<reco::GsfElectronCollection>(input_electrons_);
28  consumes<reco::BeamSpot>(input_beamspot_);
29  consumes<reco::ConversionCollection>(input_conversions_);
30  produces<edm::ValueMap<bool> >();
31 }
32 
34 
35 void ICPhotonElectronVetoCalculator::produce(edm::Event& event,
36  const edm::EventSetup& setup) {
37  std::auto_ptr<edm::ValueMap<bool> > product(new edm::ValueMap<bool>());
38 
39  edm::Handle<reco::PhotonCollection> photons_handle;
40  event.getByLabel(input_, photons_handle);
41 
42  edm::Handle<reco::GsfElectronCollection> elecs_handle;
43  event.getByLabel(input_electrons_, elecs_handle);
44 
45  edm::Handle<reco::BeamSpot> beamspot_handle;
46  event.getByLabel(input_beamspot_, beamspot_handle);
47 
48  edm::Handle<reco::ConversionCollection> conversions_handle;
49  event.getByLabel(input_conversions_, conversions_handle);
50 
51  std::vector<bool> values(photons_handle->size(), false);
52  for (unsigned i = 0; i < photons_handle->size(); ++i) {
53  reco::Photon const& src = photons_handle->at(i);
54  values[i] = !ConversionTools::hasMatchedPromptElectron(
55  src.superCluster(), elecs_handle, conversions_handle,
56  beamspot_handle->position());
57  }
58 
59  edm::ValueMap<bool>::Filler filler(*product);
60  filler.insert(photons_handle, values.begin(), values.end());
61  filler.fill();
62 
63  event.put(product);
64 }
65 
66 void ICPhotonElectronVetoCalculator::beginJob() {}
67 
68 void ICPhotonElectronVetoCalculator::endJob() {}
69 
70 // define this as a plug-in
Produces an edm::ValueMap for the photon electron-veto flag.
ICPhotonElectronVetoCalculator(const edm::ParameterSet &)
DEFINE_FWK_MODULE(ICPhotonElectronVetoCalculator)
Definition: Consumes.h:19