CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EgammaPhotonTkIsolationProducer.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaPhotonTkIsolationProducer.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 
21 
23 public:
25 
26  void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
27 
28 private:
32 
33  const double ptMin_;
34  const double intRadiusBarrel_;
35  const double intRadiusEndcap_;
36  const double stripBarrel_;
37  const double stripEndcap_;
38  const double extRadius_;
39  const double maxVtxDist_;
40  const double drb_;
41 };
42 
45 
47  :
48 
49  photonProducer_{consumes(config.getParameter<edm::InputTag>("photonProducer"))},
50 
51  trackProducer_{consumes(config.getParameter<edm::InputTag>("trackProducer"))},
52  beamspotProducer_{consumes(config.getParameter<edm::InputTag>("BeamspotProducer"))},
53 
54  ptMin_(config.getParameter<double>("ptMin")),
55  intRadiusBarrel_(config.getParameter<double>("intRadiusBarrel")),
56  intRadiusEndcap_(config.getParameter<double>("intRadiusEndcap")),
57  stripBarrel_(config.getParameter<double>("stripBarrel")),
58  stripEndcap_(config.getParameter<double>("stripEndcap")),
59  extRadius_(config.getParameter<double>("extRadius")),
60  maxVtxDist_(config.getParameter<double>("maxVtxDist")),
61  drb_(config.getParameter<double>("maxVtxDistXY")) {
62  //register your products
63  produces<edm::ValueMap<double>>();
64 }
65 
66 // ------------ method called to produce the data ------------
69  const edm::EventSetup& iSetup) const {
70  // Get the filtered objects
71  auto photonHandle = iEvent.getHandle(photonProducer_);
72 
73  //prepare product
74  auto isoMap = std::make_unique<edm::ValueMap<double>>();
75  edm::ValueMap<double>::Filler filler(*isoMap);
76  std::vector<double> retV(photonHandle->size(), 0);
77 
78  PhotonTkIsolation myTkIsolation(extRadius_,
83  ptMin_,
85  drb_,
86  &iEvent.get(trackProducer_),
87  iEvent.get(beamspotProducer_).position());
88 
89  for (unsigned int i = 0; i < photonHandle->size(); ++i) {
90  double isoValue = myTkIsolation.getIso(&(photonHandle->at(i))).second;
91  retV[i] = isoValue;
92  }
93 
94  //fill and insert valuemap
95  filler.insert(photonHandle, retV.begin(), retV.end());
96  filler.fill();
97  iEvent.put(std::move(isoMap));
98 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< reco::BeamSpot > beamspotProducer_
const edm::EDGetTokenT< edm::View< reco::Candidate > > photonProducer_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
ptMin_(conf.getParameter< double >("ptMin"))
int iEvent
Definition: GenABIO.cc:224
EgammaPhotonTkIsolationProducer(const edm::ParameterSet &)
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
std::pair< int, float > getIso(const reco::Candidate *) const
const edm::EDGetTokenT< reco::TrackCollection > trackProducer_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
tuple config
parse the configuration file