CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EgammaElectronTkIsolationProducer.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaElectronTkIsolationProducer.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 
17 
19 public:
21 
22  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
23 
24 private:
28 
29  const double ptMin_;
30  const double intRadiusBarrel_;
31  const double intRadiusEndcap_;
32  const double stripBarrel_;
33  const double stripEndcap_;
34  const double extRadius_;
35  const double maxVtxDist_;
36  const double drb_;
37 };
38 
41 
43  : electronProducer_{consumes(config.getParameter<edm::InputTag>("electronProducer"))},
44  trackProducer_{consumes(config.getParameter<edm::InputTag>("trackProducer"))},
45  beamspotProducer_{consumes(config.getParameter<edm::InputTag>("BeamspotProducer"))},
46 
47  ptMin_{config.getParameter<double>("ptMin")},
48  intRadiusBarrel_{config.getParameter<double>("intRadiusBarrel")},
49  intRadiusEndcap_{config.getParameter<double>("intRadiusEndcap")},
50  stripBarrel_{config.getParameter<double>("stripBarrel")},
51  stripEndcap_{config.getParameter<double>("stripEndcap")},
52  extRadius_{config.getParameter<double>("extRadius")},
53  maxVtxDist_{config.getParameter<double>("maxVtxDist")},
54  drb_{config.getParameter<double>("maxVtxDistXY")}
55 
56 {
57  produces<edm::ValueMap<double>>();
58 }
59 
61  // Get the filtered objects
62  auto electronHandle = iEvent.getHandle(electronProducer_);
63 
64  //prepare product
65  auto isoMap = std::make_unique<edm::ValueMap<double>>();
66  edm::ValueMap<double>::Filler filler(*isoMap);
67  std::vector<double> retV(electronHandle->size(), 0);
68 
69  ElectronTkIsolation myTkIsolation(extRadius_,
74  ptMin_,
76  drb_,
77  &iEvent.get(trackProducer_),
78  iEvent.get(beamspotProducer_).position());
79 
80  for (unsigned int i = 0; i < electronHandle->size(); ++i) {
81  double isoValue = myTkIsolation.getPtTracks(&(electronHandle->at(i)));
82  retV[i] = isoValue;
83  }
84 
85  //fill and insert valuemap
86  filler.insert(electronHandle, retV.begin(), retV.end());
87  filler.fill();
88  iEvent.put(std::move(isoMap));
89 }
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
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
ptMin_(conf.getParameter< double >("ptMin"))
const edm::EDGetTokenT< reco::TrackCollection > trackProducer_
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
const edm::EDGetTokenT< reco::BeamSpot > beamspotProducer_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double getPtTracks(const reco::GsfElectron *) const
tuple config
parse the configuration file
const edm::EDGetTokenT< reco::GsfElectronCollection > electronProducer_
EgammaElectronTkIsolationProducer(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override