CMS 3D CMS Logo

PATElectronProducer.cc
Go to the documentation of this file.
1 
57 
58 #include <memory>
59 #include <string>
60 #include <vector>
61 
62 namespace pat {
63 
64  class TrackerIsolationPt;
65  class CaloIsolationEnergy;
66  class LeptonLRCalc;
67 
69  public:
70  explicit PATElectronProducer(const edm::ParameterSet& iConfig);
71  ~PATElectronProducer() override;
72 
73  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
74 
75  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
76 
77  private:
78  // configurables
82  const bool embedGsfTrack_;
83  const bool embedSuperCluster_;
85  const bool embedSeedCluster_;
86  const bool embedBasicClusters_;
90  const bool embedTrack_;
93  const bool embedRecHits_;
94  // for mini-iso calculation
97  std::vector<double> miniIsoParamsE_;
98  std::vector<double> miniIsoParamsB_;
99 
100  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> GenAssociations;
101 
102  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection>>> genMatchTokens_;
103 
105  const bool useParticleFlow_;
110  const bool embedPFCandidate_;
111 
113  const bool addMVAVariables_;
119 
120  const bool addPFClusterIso_;
121  const bool addPuppiIsolation_;
124 
129 
131  typedef std::vector<edm::Handle<edm::ValueMap<IsoDeposit>>> IsoDepositMaps;
132  typedef std::vector<edm::Handle<edm::ValueMap<double>>> IsolationValueMaps;
133 
135  void fillElectron(Electron& aElectron,
136  const ElectronBaseRef& electronRef,
137  const reco::CandidateBaseRef& baseRef,
138  const GenAssociations& genMatches,
139  const IsoDepositMaps& deposits,
140  const bool pfId,
143 
144  void fillElectron2(Electron& anElectron,
145  const reco::CandidatePtr& candPtrForIsolation,
146  const reco::CandidatePtr& candPtrForGenMatch,
147  const reco::CandidatePtr& candPtrForLoader,
148  const GenAssociations& genMatches,
149  const IsoDepositMaps& deposits,
150  const IsolationValueMaps& isolationValues) const;
151 
152  // set the mini-isolation variables
154 
155  // embed various impact parameters with errors
156  // embed high level selection
157  void embedHighLevel(pat::Electron& anElectron,
161  bool primaryVertexIsValid,
163  bool beamspotIsValid);
164 
165  typedef std::pair<pat::IsolationKeys, edm::InputTag> IsolationLabel;
166  typedef std::vector<IsolationLabel> IsolationLabels;
167 
170  template <typename T>
171  void readIsolationLabels(const edm::ParameterSet& iConfig,
172  const char* psetName,
175 
176  const bool addElecID_;
177  typedef std::pair<std::string, edm::InputTag> NameTag;
178  std::vector<NameTag> elecIDSrcs_;
179  std::vector<edm::EDGetTokenT<edm::ValueMap<float>>> elecIDTokens_;
180 
181  // tools
183 
185  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
187  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit>>> isoDepositTokens_;
189  std::vector<edm::EDGetTokenT<edm::ValueMap<double>>> isolationValueTokens_;
191  std::vector<edm::EDGetTokenT<edm::ValueMap<double>>> isolationValueNoPFIdTokens_;
192 
193  const bool addEfficiencies_;
195 
196  const bool addResolutions_;
198 
199  const bool useUserData_;
200  //PUPPI isolation tokens
204  //PUPPINoLeptons isolation tokens
209 
212 
214  };
215 } // namespace pat
216 
217 template <typename T>
219  const char* psetName,
222  labels.clear();
223 
224  if (iConfig.exists(psetName)) {
226 
227  if (depconf.exists("tracker"))
228  labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
229  if (depconf.exists("ecal"))
230  labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
231  if (depconf.exists("hcal"))
232  labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
233  if (depconf.exists("pfAllParticles")) {
234  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
235  }
236  if (depconf.exists("pfChargedHadrons")) {
237  labels.push_back(
238  std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
239  }
240  if (depconf.exists("pfChargedAll")) {
241  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
242  }
243  if (depconf.exists("pfPUChargedHadrons")) {
244  labels.push_back(
245  std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
246  }
247  if (depconf.exists("pfNeutralHadrons")) {
248  labels.push_back(
249  std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
250  }
251  if (depconf.exists("pfPhotons")) {
252  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
253  }
254  if (depconf.exists("user")) {
255  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag>>("user");
256  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
258  for (; it != ed; ++it, ++key) {
259  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
260  }
261  }
262  }
263  tokens = edm::vector_transform(
264  labels, [this](IsolationLabel const& label) { return consumes<edm::ValueMap<T>>(label.second); });
265 }
266 
267 using namespace pat;
268 using namespace std;
269 
271  : // general configurables
272  electronToken_(consumes<edm::View<reco::GsfElectron>>(iConfig.getParameter<edm::InputTag>("electronSource"))),
273  hConversionsToken_(consumes<reco::ConversionCollection>(edm::InputTag("allConversions"))),
274  embedGsfElectronCore_(iConfig.getParameter<bool>("embedGsfElectronCore")),
275  embedGsfTrack_(iConfig.getParameter<bool>("embedGsfTrack")),
276  embedSuperCluster_(iConfig.getParameter<bool>("embedSuperCluster")),
277  embedPflowSuperCluster_(iConfig.getParameter<bool>("embedPflowSuperCluster")),
278  embedSeedCluster_(iConfig.getParameter<bool>("embedSeedCluster")),
279  embedBasicClusters_(iConfig.getParameter<bool>("embedBasicClusters")),
280  embedPreshowerClusters_(iConfig.getParameter<bool>("embedPreshowerClusters")),
281  embedPflowBasicClusters_(iConfig.getParameter<bool>("embedPflowBasicClusters")),
282  embedPflowPreshowerClusters_(iConfig.getParameter<bool>("embedPflowPreshowerClusters")),
283  embedTrack_(iConfig.getParameter<bool>("embedTrack")),
284  addGenMatch_(iConfig.getParameter<bool>("addGenMatch")),
285  embedGenMatch_(addGenMatch_ ? iConfig.getParameter<bool>("embedGenMatch") : false),
286  embedRecHits_(iConfig.getParameter<bool>("embedRecHits")),
287  // pflow configurables
288  useParticleFlow_(iConfig.getParameter<bool>("useParticleFlow")),
289  usePfCandidateMultiMap_(iConfig.getParameter<bool>("usePfCandidateMultiMap")),
290  pfElecToken_(!usePfCandidateMultiMap_
291  ? consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfElectronSource"))
292  : edm::EDGetTokenT<reco::PFCandidateCollection>()),
293  pfCandidateMapToken_(!usePfCandidateMultiMap_ ? mayConsume<edm::ValueMap<reco::PFCandidatePtr>>(
294  iConfig.getParameter<edm::InputTag>("pfCandidateMap"))
295  : edm::EDGetTokenT<edm::ValueMap<reco::PFCandidatePtr>>()),
296  pfCandidateMultiMapToken_(usePfCandidateMultiMap_
297  ? consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
298  iConfig.getParameter<edm::InputTag>("pfCandidateMultiMap"))
299  : edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef>>>()),
300  embedPFCandidate_(iConfig.getParameter<bool>("embedPFCandidate")),
301  // mva input variables
302  addMVAVariables_(iConfig.getParameter<bool>("addMVAVariables")),
303  reducedBarrelRecHitCollection_(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection")),
304  reducedBarrelRecHitCollectionToken_(mayConsume<EcalRecHitCollection>(reducedBarrelRecHitCollection_)),
305  reducedEndcapRecHitCollection_(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection")),
306  reducedEndcapRecHitCollectionToken_(mayConsume<EcalRecHitCollection>(reducedEndcapRecHitCollection_)),
307  ecalClusterToolsESGetTokens_{consumesCollector()},
308  // PFCluster Isolation maps
309  addPFClusterIso_(iConfig.getParameter<bool>("addPFClusterIso")),
310  addPuppiIsolation_(iConfig.getParameter<bool>("addPuppiIsolation")),
311  ecalPFClusterIsoT_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("ecalPFClusterIsoMap"))),
312  hcalPFClusterIsoT_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("hcalPFClusterIsoMap"))),
313  // embed high level selection variables?
314  embedHighLevelSelection_(iConfig.getParameter<bool>("embedHighLevelSelection")),
315  beamLineToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"))),
316  pvToken_(mayConsume<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("pvSrc"))),
317  addElecID_(iConfig.getParameter<bool>("addElectronID")),
318  pTComparator_(),
319  isolator_(iConfig.getParameter<edm::ParameterSet>("userIsolation"), consumesCollector(), false),
320  addEfficiencies_(iConfig.getParameter<bool>("addEfficiencies")),
321  addResolutions_(iConfig.getParameter<bool>("addResolutions")),
322  useUserData_(iConfig.exists("userData")),
323  ecalTopologyToken_{esConsumes()},
324  trackBuilderToken_{esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))} {
325  // MC matching configurables (scheduled mode)
326 
327  if (addGenMatch_) {
328  genMatchTokens_.push_back(consumes<edm::Association<reco::GenParticleCollection>>(
329  iConfig.getParameter<edm::InputTag>("genParticleMatch")));
330  }
331  // resolution configurables
332  if (addResolutions_) {
333  resolutionLoader_ =
334  pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"), consumesCollector());
335  }
336  if (addPuppiIsolation_) {
337  //puppi
338  PUPPIIsolation_charged_hadrons_ =
339  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationChargedHadrons"));
340  PUPPIIsolation_neutral_hadrons_ =
341  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationNeutralHadrons"));
342  PUPPIIsolation_photons_ =
343  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationPhotons"));
344  //puppiNoLeptons
345  PUPPINoLeptonsIsolation_charged_hadrons_ =
346  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons"));
347  PUPPINoLeptonsIsolation_neutral_hadrons_ =
348  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons"));
349  PUPPINoLeptonsIsolation_photons_ =
350  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationPhotons"));
351  }
352  // electron ID configurables
353  if (addElecID_) {
354  // it might be a single electron ID
355  if (iConfig.existsAs<edm::InputTag>("electronIDSource")) {
356  elecIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("electronIDSource")));
357  }
358  // or there might be many of them
359  if (iConfig.existsAs<edm::ParameterSet>("electronIDSources")) {
360  // please don't configure me twice
361  if (!elecIDSrcs_.empty()) {
362  throw cms::Exception("Configuration")
363  << "PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
364  }
365  // read the different electron ID names
366  edm::ParameterSet idps = iConfig.getParameter<edm::ParameterSet>("electronIDSources");
367  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
368  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
369  elecIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
370  }
371  }
372  // but in any case at least once
373  if (elecIDSrcs_.empty()) {
374  throw cms::Exception("Configuration")
375  << "PATElectronProducer: id addElectronID is true, you must specify either:\n"
376  << "\tInputTag electronIDSource = <someTag>\n"
377  << "or\n"
378  << "\tPSet electronIDSources = { \n"
379  << "\t\tInputTag <someName> = <someTag> // as many as you want \n "
380  << "\t}\n";
381  }
382  }
383  elecIDTokens_ = edm::vector_transform(
384  elecIDSrcs_, [this](NameTag const& tag) { return mayConsume<edm::ValueMap<float>>(tag.second); });
385  // construct resolution calculator
386 
387  // // IsoDeposit configurables
388  // if (iConfig.exists("isoDeposits")) {
389  // edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
390  // if (depconf.exists("tracker")) isoDepositLabels_.push_back(std::make_pair(TrackerIso, depconf.getParameter<edm::InputTag>("tracker")));
391  // if (depconf.exists("ecal")) isoDepositLabels_.push_back(std::make_pair(ECalIso, depconf.getParameter<edm::InputTag>("ecal")));
392  // if (depconf.exists("hcal")) isoDepositLabels_.push_back(std::make_pair(HCalIso, depconf.getParameter<edm::InputTag>("hcal")));
393 
394  // if (depconf.exists("user")) {
395  // std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
396  // std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
397  // int key = UserBaseIso;
398  // for ( ; it != ed; ++it, ++key) {
399  // isoDepositLabels_.push_back(std::make_pair(IsolationKeys(key), *it));
400  // }
401  // }
402  // }
403  // isoDepositTokens_ = edm::vector_transform(isoDepositLabels_, [this](std::pair<IsolationKeys,edm::InputTag> const & label){return consumes<edm::ValueMap<IsoDeposit> >(label.second);});
404 
405  // for mini-iso
406  computeMiniIso_ = iConfig.getParameter<bool>("computeMiniIso");
407  miniIsoParamsE_ = iConfig.getParameter<std::vector<double>>("miniIsoParamsE");
408  miniIsoParamsB_ = iConfig.getParameter<std::vector<double>>("miniIsoParamsB");
409  if (computeMiniIso_ && (miniIsoParamsE_.size() != 9 || miniIsoParamsB_.size() != 9)) {
410  throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n";
411  }
412  if (computeMiniIso_)
413  pcToken_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
414 
415  // read isoDeposit labels, for direct embedding
416  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
417  // read isolation value labels, for direct embedding
418  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_, isolationValueTokens_);
419  // read isolation value labels for non PF identified electron, for direct embedding
420  readIsolationLabels(iConfig, "isolationValuesNoPFId", isolationValueLabelsNoPFId_, isolationValueNoPFIdTokens_);
421  // Efficiency configurables
422  if (addEfficiencies_) {
423  efficiencyLoader_ =
424  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
425  }
426  // Check to see if the user wants to add user data
427  if (useUserData_) {
428  userDataHelper_ =
429  PATUserDataHelper<Electron>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
430  }
431 
432  // consistency check
433  if (useParticleFlow_ && usePfCandidateMultiMap_)
434  throw cms::Exception("Configuration", "usePfCandidateMultiMap not supported when useParticleFlow is set to true");
435 
436  // produces vector of muons
437  produces<std::vector<Electron>>();
438 }
439 
441 
443  // switch off embedding (in unschedules mode)
444  if (iEvent.isRealData()) {
445  addGenMatch_ = false;
446  embedGenMatch_ = false;
447  }
448 
450 
451  // Get the collection of electrons from the event
453  iEvent.getByToken(electronToken_, electrons);
454 
456  if (computeMiniIso_)
457  iEvent.getByToken(pcToken_, pc);
458 
459  // for additional mva variables
460  edm::InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB"));
461  edm::InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE"));
462  //EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection);
463  EcalClusterLazyTools lazyTools(iEvent,
467 
468  // for conversion veto selection
470  iEvent.getByToken(hConversionsToken_, hConversions);
471 
472  // Get the ESHandle for the transient track builder, if needed for
473  // high level selection embedding
475 
476  if (isolator_.enabled())
477  isolator_.beginEvent(iEvent, iSetup);
478 
483 
485  for (size_t j = 0, nd = isoDepositTokens_.size(); j < nd; ++j) {
486  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
487  }
488 
490  for (size_t j = 0; j < isolationValueTokens_.size(); ++j) {
492  }
493 
495  for (size_t j = 0; j < isolationValueNoPFIdTokens_.size(); ++j) {
497  }
498 
499  // prepare the MC matching
500  GenAssociations genMatches(genMatchTokens_.size());
501  if (addGenMatch_) {
502  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
503  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
504  }
505  }
506 
507  // prepare ID extraction
508  std::vector<edm::Handle<edm::ValueMap<float>>> idhandles;
509  std::vector<pat::Electron::IdPair> ids;
510  if (addElecID_) {
511  idhandles.resize(elecIDSrcs_.size());
512  ids.resize(elecIDSrcs_.size());
513  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
514  iEvent.getByToken(elecIDTokens_[i], idhandles[i]);
515  ids[i].first = elecIDSrcs_[i].first;
516  }
517  }
518 
519  // prepare the high level selection:
520  // needs beamline
521  reco::TrackBase::Point beamPoint(0, 0, 0);
524  bool beamSpotIsValid = false;
525  bool primaryVertexIsValid = false;
526 
527  // Get the beamspot
528  edm::Handle<reco::BeamSpot> beamSpotHandle;
529  iEvent.getByToken(beamLineToken_, beamSpotHandle);
530 
532  // Get the primary vertex
534  iEvent.getByToken(pvToken_, pvHandle);
535 
536  // This is needed by the IPTools methods from the tracking group
537  trackBuilder = iSetup.getHandle(trackBuilderToken_);
538 
539  if (pvHandle.isValid() && !pvHandle->empty()) {
540  primaryVertex = pvHandle->at(0);
541  primaryVertexIsValid = true;
542  } else {
543  edm::LogError("DataNotAvailable")
544  << "No primary vertex available from EventSetup, not adding high level selection \n";
545  }
546  }
547  //value maps for puppi isolation
548  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_charged_hadrons;
549  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_neutral_hadrons;
550  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_photons;
551  //value maps for puppiNoLeptons isolation
552  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_charged_hadrons;
553  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_neutral_hadrons;
554  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_photons;
555  if (addPuppiIsolation_) {
556  //puppi
557  iEvent.getByToken(PUPPIIsolation_charged_hadrons_, PUPPIIsolation_charged_hadrons);
558  iEvent.getByToken(PUPPIIsolation_neutral_hadrons_, PUPPIIsolation_neutral_hadrons);
559  iEvent.getByToken(PUPPIIsolation_photons_, PUPPIIsolation_photons);
560  //puppiNoLeptons
561  iEvent.getByToken(PUPPINoLeptonsIsolation_charged_hadrons_, PUPPINoLeptonsIsolation_charged_hadrons);
562  iEvent.getByToken(PUPPINoLeptonsIsolation_neutral_hadrons_, PUPPINoLeptonsIsolation_neutral_hadrons);
563  iEvent.getByToken(PUPPINoLeptonsIsolation_photons_, PUPPINoLeptonsIsolation_photons);
564  }
565 
566  std::vector<Electron>* patElectrons = new std::vector<Electron>();
567 
568  if (useParticleFlow_) {
570  iEvent.getByToken(pfElecToken_, pfElectrons);
571  unsigned index = 0;
572 
573  for (reco::PFCandidateConstIterator i = pfElectrons->begin(); i != pfElectrons->end(); ++i, ++index) {
575  reco::PFCandidatePtr ptrToPFElectron(pfElectrons, index);
576  // reco::CandidateBaseRef pfBaseRef( pfRef );
577 
578  reco::GsfTrackRef PfTk = i->gsfTrackRef();
579 
580  bool Matched = false;
581  bool MatchedToAmbiguousGsfTrack = false;
582  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end();
583  ++itElectron) {
584  unsigned int idx = itElectron - electrons->begin();
585  auto elePtr = electrons->ptrAt(idx);
586  if (Matched || MatchedToAmbiguousGsfTrack)
587  continue;
588 
589  reco::GsfTrackRef EgTk = itElectron->gsfTrack();
590 
591  if (itElectron->gsfTrack() == i->gsfTrackRef()) {
592  Matched = true;
593  } else {
594  for (auto const& it : itElectron->ambiguousGsfTracks()) {
595  MatchedToAmbiguousGsfTrack |= (bool)(i->gsfTrackRef() == it);
596  }
597  }
598 
599  if (Matched || MatchedToAmbiguousGsfTrack) {
600  // ptr needed for finding the matched gen particle
601  reco::CandidatePtr ptrToGsfElectron(electrons, idx);
602 
603  // ref to base needed for the construction of the pat object
604  const edm::RefToBase<reco::GsfElectron>& elecsRef = electrons->refAt(idx);
605  Electron anElectron(elecsRef);
606  anElectron.setPFCandidateRef(pfRef);
607  if (addPuppiIsolation_) {
608  anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
609  (*PUPPIIsolation_neutral_hadrons)[elePtr],
610  (*PUPPIIsolation_photons)[elePtr]);
611  anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
612  (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
613  (*PUPPINoLeptonsIsolation_photons)[elePtr]);
614  } else {
615  anElectron.setIsolationPUPPI(-999., -999., -999.);
616  anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
617  }
618 
619  //it should be always true when particleFlow electrons are used.
620  anElectron.setIsPF(true);
621 
622  if (embedPFCandidate_)
623  anElectron.embedPFCandidate();
624 
625  if (useUserData_) {
626  userDataHelper_.add(anElectron, iEvent, iSetup);
627  }
628 
629  double ip3d = -999; // for mva variable
630 
631  // embed high level selection
633  // get the global track
634  const reco::GsfTrackRef& track = PfTk;
635 
636  // Make sure the collection it points to is there
637  if (track.isNonnull() && track.isAvailable()) {
638  reco::TransientTrack tt = trackBuilder->build(track);
639  embedHighLevel(anElectron, track, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
640 
641  std::pair<bool, Measurement1D> ip3dpv = IPTools::absoluteImpactParameter3D(tt, primaryVertex);
642  ip3d = ip3dpv.second.value(); // for mva variable
643  }
644  }
645 
646  //Electron Id
647 
648  if (addElecID_) {
649  //STANDARD EL ID
650  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
651  ids[i].second = (*idhandles[i])[elecsRef];
652  }
653  //SPECIFIC PF ID
654  ids.push_back(std::make_pair("pf_evspi", pfRef->mva_e_pi()));
655  ids.push_back(std::make_pair("pf_evsmu", pfRef->mva_e_mu()));
656  anElectron.setElectronIDs(ids);
657  }
658 
659  if (addMVAVariables_) {
660  // add missing mva variables
661  const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
662  anElectron.setMvaVariables(vCov[1], ip3d);
663  }
664  // PFClusterIso
665  if (addPFClusterIso_) {
666  // Get PFCluster Isolation
667  edm::Handle<edm::ValueMap<float>> ecalPFClusterIsoMapH;
668  iEvent.getByToken(ecalPFClusterIsoT_, ecalPFClusterIsoMapH);
669  edm::Handle<edm::ValueMap<float>> hcalPFClusterIsoMapH;
670  iEvent.getByToken(hcalPFClusterIsoT_, hcalPFClusterIsoMapH);
672  newPFIsol.sumEcalClusterEt = (*ecalPFClusterIsoMapH)[elecsRef];
673  newPFIsol.sumHcalClusterEt = (*hcalPFClusterIsoMapH)[elecsRef];
674  anElectron.setPfIsolationVariables(newPFIsol);
675  }
676 
677  std::vector<DetId> selectedCells;
678  bool barrel = itElectron->isEB();
679  //loop over sub clusters
680  if (embedBasicClusters_) {
681  for (reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin();
682  clusIt != itElectron->superCluster()->clustersEnd();
683  ++clusIt) {
684  //get seed (max energy xtal)
685  DetId seed = lazyTools.getMaximum(**clusIt).first;
686  //get all xtals in 5x5 window around the seed
687  std::vector<DetId> dets5x5 =
690  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
691 
692  //get all xtals belonging to cluster
693  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
694  selectedCells.push_back(hit.first);
695  }
696  }
697  }
698 
699  if (embedPflowBasicClusters_ && itElectron->parentSuperCluster().isNonnull()) {
700  for (reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin();
701  clusIt != itElectron->parentSuperCluster()->clustersEnd();
702  ++clusIt) {
703  //get seed (max energy xtal)
704  DetId seed = lazyTools.getMaximum(**clusIt).first;
705  //get all xtals in 5x5 window around the seed
706  std::vector<DetId> dets5x5 =
709  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
710 
711  //get all xtals belonging to cluster
712  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
713  selectedCells.push_back(hit.first);
714  }
715  }
716  }
717 
718  //remove duplicates
719  std::sort(selectedCells.begin(), selectedCells.end());
720  std::unique(selectedCells.begin(), selectedCells.end());
721 
722  // Retrieve the corresponding RecHits
723 
725  if (barrel)
726  iEvent.getByToken(reducedBarrelRecHitCollectionToken_, rechitsH);
727  else
728  iEvent.getByToken(reducedEndcapRecHitCollectionToken_, rechitsH);
729 
730  EcalRecHitCollection selectedRecHits;
731  const EcalRecHitCollection* recHits = rechitsH.product();
732 
733  unsigned nSelectedCells = selectedCells.size();
734  for (unsigned icell = 0; icell < nSelectedCells; ++icell) {
735  EcalRecHitCollection::const_iterator it = recHits->find(selectedCells[icell]);
736  if (it != recHits->end()) {
737  selectedRecHits.push_back(*it);
738  }
739  }
740  selectedRecHits.sort();
741  if (embedRecHits_)
742  anElectron.embedRecHits(&selectedRecHits);
743 
744  // set conversion veto selection
745  bool passconversionveto = false;
746  if (hConversions.isValid()) {
747  // this is recommended method
748  passconversionveto =
749  !ConversionTools::hasMatchedConversion(*itElectron, *hConversions, beamSpotHandle->position());
750  } else {
751  // use missing hits without vertex fit method
752  passconversionveto =
753  itElectron->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < 1;
754  }
755 
756  anElectron.setPassConversionVeto(passconversionveto);
757 
758  // fillElectron(anElectron,elecsRef,pfBaseRef,
759  // genMatches, deposits, isolationValues);
760 
761  //COLIN small warning !
762  // we are currently choosing to take the 4-momentum of the PFCandidate;
763  // the momentum of the GsfElectron is saved though
764  // we must therefore match the GsfElectron.
765  // because of this, we should not change the source of the electron matcher
766  // to the collection of PFElectrons in the python configuration
767  // I don't know what to do with the efficiencyLoader, since I don't know
768  // what this class is for.
770  anElectron, ptrToPFElectron, ptrToGsfElectron, ptrToGsfElectron, genMatches, deposits, isolationValues);
771 
772  //COLIN need to use fillElectron2 in the non-pflow case as well, and to test it.
773 
774  if (computeMiniIso_)
775  setElectronMiniIso(anElectron, pc.product());
776 
777  patElectrons->push_back(anElectron);
778  }
779  }
780  //if( !Matched && !MatchedToAmbiguousGsfTrack) std::cout << "!!!!A pf electron could not be matched to a gsf!!!!" << std::endl;
781  }
782  }
783 
784  else {
788  bool pfCandsPresent = false, valMapPresent = false;
790  iEvent.getByToken(pfCandidateMultiMapToken_, ValMultiMapH);
791  } else {
792  pfCandsPresent = iEvent.getByToken(pfElecToken_, pfElectrons);
793  valMapPresent = iEvent.getByToken(pfCandidateMapToken_, ValMapH);
794  }
795 
796  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end();
797  ++itElectron) {
798  // construct the Electron from the ref -> save ref to original object
799  //FIXME: looks like a lot of instances could be turned into const refs
800  unsigned int idx = itElectron - electrons->begin();
802  reco::CandidateBaseRef elecBaseRef(elecsRef);
803  Electron anElectron(elecsRef);
804  auto elePtr = electrons->ptrAt(idx);
805 
806  // Is this GsfElectron also identified as an e- in the particle flow?
807  bool pfId = false;
808 
810  for (const reco::PFCandidateRef& pf : (*ValMultiMapH)[elePtr]) {
811  if (pf->particleId() == reco::PFCandidate::e) {
812  pfId = true;
813  anElectron.setPFCandidateRef(pf);
814  break;
815  }
816  }
817  } else if (pfCandsPresent) {
818  // PF electron collection not available.
819  const reco::GsfTrackRef& trkRef = itElectron->gsfTrack();
820  int index = 0;
821  for (reco::PFCandidateConstIterator ie = pfElectrons->begin(); ie != pfElectrons->end(); ++ie, ++index) {
822  if (ie->particleId() != reco::PFCandidate::e)
823  continue;
824  const reco::GsfTrackRef& pfTrkRef = ie->gsfTrackRef();
825  if (trkRef == pfTrkRef) {
826  pfId = true;
828  anElectron.setPFCandidateRef(pfRef);
829  break;
830  }
831  }
832  } else if (valMapPresent) {
833  // use value map if PF collection not available
834  const edm::ValueMap<reco::PFCandidatePtr>& myValMap(*ValMapH);
835  // Get the PFCandidate
836  const reco::PFCandidatePtr& pfElePtr(myValMap[elecsRef]);
837  pfId = pfElePtr.isNonnull();
838  }
839  // set PFId function
840  anElectron.setIsPF(pfId);
841 
842  // add resolution info
843 
844  // Isolation
845  if (isolator_.enabled()) {
847  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
848  // better to loop backwards, so the vector is resized less times
849  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(),
850  ed = isolatorTmpStorage_.rend();
851  it != ed;
852  ++it) {
853  anElectron.setIsolation(it->first, it->second);
854  }
855  }
856 
857  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
858  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[elecsRef]);
859  }
860 
861  // add electron ID info
862  if (addElecID_) {
863  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
864  ids[i].second = (*idhandles[i])[elecsRef];
865  }
866  anElectron.setElectronIDs(ids);
867  }
868 
869  if (useUserData_) {
870  userDataHelper_.add(anElectron, iEvent, iSetup);
871  }
872 
873  double ip3d = -999; //for mva variable
874 
875  // embed high level selection
877  // get the global track
878  reco::GsfTrackRef track = itElectron->gsfTrack();
879 
880  // Make sure the collection it points to is there
881  if (track.isNonnull() && track.isAvailable()) {
882  reco::TransientTrack tt = trackBuilder->build(track);
883  embedHighLevel(anElectron, track, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
884 
885  std::pair<bool, Measurement1D> ip3dpv = IPTools::absoluteImpactParameter3D(tt, primaryVertex);
886  ip3d = ip3dpv.second.value(); // for mva variable
887  }
888  }
889 
890  if (addMVAVariables_) {
891  // add mva variables
892  const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
893  anElectron.setMvaVariables(vCov[1], ip3d);
894  }
895 
896  // PFCluster Isolation
897  if (addPFClusterIso_) {
898  // Get PFCluster Isolation
899  edm::Handle<edm::ValueMap<float>> ecalPFClusterIsoMapH;
900  iEvent.getByToken(ecalPFClusterIsoT_, ecalPFClusterIsoMapH);
901  edm::Handle<edm::ValueMap<float>> hcalPFClusterIsoMapH;
902  iEvent.getByToken(hcalPFClusterIsoT_, hcalPFClusterIsoMapH);
904  newPFIsol.sumEcalClusterEt = (*ecalPFClusterIsoMapH)[elecsRef];
905  newPFIsol.sumHcalClusterEt = (*hcalPFClusterIsoMapH)[elecsRef];
906  anElectron.setPfIsolationVariables(newPFIsol);
907  }
908 
909  if (addPuppiIsolation_) {
910  anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
911  (*PUPPIIsolation_neutral_hadrons)[elePtr],
912  (*PUPPIIsolation_photons)[elePtr]);
913  anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
914  (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
915  (*PUPPINoLeptonsIsolation_photons)[elePtr]);
916  } else {
917  anElectron.setIsolationPUPPI(-999., -999., -999.);
918  anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
919  }
920 
921  std::vector<DetId> selectedCells;
922  bool barrel = itElectron->isEB();
923  //loop over sub clusters
924  if (embedBasicClusters_) {
925  for (reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin();
926  clusIt != itElectron->superCluster()->clustersEnd();
927  ++clusIt) {
928  //get seed (max energy xtal)
929  DetId seed = lazyTools.getMaximum(**clusIt).first;
930  //get all xtals in 5x5 window around the seed
931  std::vector<DetId> dets5x5 =
934  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
935 
936  //get all xtals belonging to cluster
937  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
938  selectedCells.push_back(hit.first);
939  }
940  }
941  }
942 
943  if (embedPflowBasicClusters_ && itElectron->parentSuperCluster().isNonnull()) {
944  for (reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin();
945  clusIt != itElectron->parentSuperCluster()->clustersEnd();
946  ++clusIt) {
947  //get seed (max energy xtal)
948  DetId seed = lazyTools.getMaximum(**clusIt).first;
949  //get all xtals in 5x5 window around the seed
950  std::vector<DetId> dets5x5 =
953  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
954 
955  //get all xtals belonging to cluster
956  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
957  selectedCells.push_back(hit.first);
958  }
959  }
960  }
961 
962  //remove duplicates
963  std::sort(selectedCells.begin(), selectedCells.end());
964  std::unique(selectedCells.begin(), selectedCells.end());
965 
966  // Retrieve the corresponding RecHits
967 
969  if (barrel)
970  iEvent.getByToken(reducedBarrelRecHitCollectionToken_, rechitsH);
971  else
972  iEvent.getByToken(reducedEndcapRecHitCollectionToken_, rechitsH);
973 
974  EcalRecHitCollection selectedRecHits;
975  const EcalRecHitCollection* recHits = rechitsH.product();
976 
977  unsigned nSelectedCells = selectedCells.size();
978  for (unsigned icell = 0; icell < nSelectedCells; ++icell) {
979  EcalRecHitCollection::const_iterator it = recHits->find(selectedCells[icell]);
980  if (it != recHits->end()) {
981  selectedRecHits.push_back(*it);
982  }
983  }
984  selectedRecHits.sort();
985  if (embedRecHits_)
986  anElectron.embedRecHits(&selectedRecHits);
987 
988  // set conversion veto selection
989  bool passconversionveto = false;
990  if (hConversions.isValid()) {
991  // this is recommended method
992  passconversionveto =
993  !ConversionTools::hasMatchedConversion(*itElectron, *hConversions, beamSpotHandle->position());
994  } else {
995  // use missing hits without vertex fit method
996  passconversionveto =
997  itElectron->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < 1;
998  }
999  anElectron.setPassConversionVeto(passconversionveto);
1000 
1001  // add sel to selected
1002  fillElectron(
1003  anElectron, elecsRef, elecBaseRef, genMatches, deposits, pfId, isolationValues, isolationValuesNoPFId);
1004 
1005  if (computeMiniIso_)
1006  setElectronMiniIso(anElectron, pc.product());
1007 
1008  patElectrons->push_back(anElectron);
1009  }
1010  }
1011 
1012  // sort electrons in pt
1013  std::sort(patElectrons->begin(), patElectrons->end(), pTComparator_);
1014 
1015  // add the electrons to the event output
1016  std::unique_ptr<std::vector<Electron>> ptr(patElectrons);
1017  iEvent.put(std::move(ptr));
1018 
1019  // clean up
1020  if (isolator_.enabled())
1021  isolator_.endEvent();
1022 }
1023 
1025  const edm::RefToBase<reco::GsfElectron>& elecRef,
1026  const reco::CandidateBaseRef& baseRef,
1027  const GenAssociations& genMatches,
1028  const IsoDepositMaps& deposits,
1029  const bool pfId,
1032  //COLIN: might want to use the PFCandidate 4-mom. Which one is in use now?
1033  // if (useParticleFlow_)
1034  // aMuon.setP4( aMuon.pfCandidateRef()->p4() );
1035 
1036  //COLIN:
1037  //In the embedding case, the reference cannot be used to look into a value map.
1038  //therefore, one has to had the PFCandidateRef to this function, which becomes a bit
1039  //too much specific.
1040 
1041  // in fact, this function needs a baseref or ptr for genmatch
1042  // and a baseref or ptr for isodeposits and isolationvalues.
1043  // baseref is not needed
1044  // the ptrForIsolation and ptrForMatching should be defined upstream.
1045 
1046  // is the concrete elecRef needed for the efficiency loader? what is this loader?
1047  // how can we make it compatible with the particle flow electrons?
1048 
1050  anElectron.embedGsfElectronCore();
1051  if (embedGsfTrack_)
1052  anElectron.embedGsfTrack();
1053  if (embedSuperCluster_)
1054  anElectron.embedSuperCluster();
1056  anElectron.embedPflowSuperCluster();
1057  if (embedSeedCluster_)
1058  anElectron.embedSeedCluster();
1059  if (embedBasicClusters_)
1060  anElectron.embedBasicClusters();
1062  anElectron.embedPreshowerClusters();
1064  anElectron.embedPflowBasicClusters();
1066  anElectron.embedPflowPreshowerClusters();
1067  if (embedTrack_)
1068  anElectron.embedTrack();
1069 
1070  // store the match to the generated final state muons
1071  if (addGenMatch_) {
1072  for (size_t i = 0, n = genMatches.size(); i < n; ++i) {
1073  if (useParticleFlow_) {
1074  reco::GenParticleRef genElectron = (*genMatches[i])[anElectron.pfCandidateRef()];
1075  anElectron.addGenParticleRef(genElectron);
1076  } else {
1077  reco::GenParticleRef genElectron = (*genMatches[i])[elecRef];
1078  anElectron.addGenParticleRef(genElectron);
1079  }
1080  }
1081  if (embedGenMatch_)
1082  anElectron.embedGenParticle();
1083  }
1084 
1085  if (efficiencyLoader_.enabled()) {
1086  efficiencyLoader_.setEfficiencies(anElectron, elecRef);
1087  }
1088 
1089  if (resolutionLoader_.enabled()) {
1090  resolutionLoader_.setResolutions(anElectron);
1091  }
1092 
1093  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
1094  if (useParticleFlow_) {
1095  reco::PFCandidateRef pfcandref = anElectron.pfCandidateRef();
1096  assert(!pfcandref.isNull());
1097  reco::CandidatePtr source = pfcandref->sourceCandidatePtr(0);
1098  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
1099  } else
1100  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[elecRef]);
1101  }
1102 
1103  for (size_t j = 0; j < isolationValues.size(); ++j) {
1104  if (useParticleFlow_) {
1105  reco::CandidatePtr source = anElectron.pfCandidateRef()->sourceCandidatePtr(0);
1107  } else if (pfId) {
1108  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[elecRef]);
1109  }
1110  }
1111 
1112  //for electrons not identified as PF electrons
1113  for (size_t j = 0; j < isolationValuesNoPFId.size(); ++j) {
1114  if (!pfId) {
1116  }
1117  }
1118 }
1119 
1121  const reco::CandidatePtr& candPtrForIsolation,
1122  const reco::CandidatePtr& candPtrForGenMatch,
1123  const reco::CandidatePtr& candPtrForLoader,
1124  const GenAssociations& genMatches,
1125  const IsoDepositMaps& deposits,
1126  const IsolationValueMaps& isolationValues) const {
1127  //COLIN/Florian: use the PFCandidate 4-mom.
1128  anElectron.setEcalDrivenMomentum(anElectron.p4());
1129  anElectron.setP4(anElectron.pfCandidateRef()->p4());
1130 
1131  // is the concrete elecRef needed for the efficiency loader? what is this loader?
1132  // how can we make it compatible with the particle flow electrons?
1133 
1135  anElectron.embedGsfElectronCore();
1136  if (embedGsfTrack_)
1137  anElectron.embedGsfTrack();
1138  if (embedSuperCluster_)
1139  anElectron.embedSuperCluster();
1141  anElectron.embedPflowSuperCluster();
1142  if (embedSeedCluster_)
1143  anElectron.embedSeedCluster();
1144  if (embedBasicClusters_)
1145  anElectron.embedBasicClusters();
1147  anElectron.embedPreshowerClusters();
1149  anElectron.embedPflowBasicClusters();
1151  anElectron.embedPflowPreshowerClusters();
1152  if (embedTrack_)
1153  anElectron.embedTrack();
1154 
1155  // store the match to the generated final state muons
1156 
1157  if (addGenMatch_) {
1158  for (size_t i = 0, n = genMatches.size(); i < n; ++i) {
1159  reco::GenParticleRef genElectron = (*genMatches[i])[candPtrForGenMatch];
1160  anElectron.addGenParticleRef(genElectron);
1161  }
1162  if (embedGenMatch_)
1163  anElectron.embedGenParticle();
1164  }
1165 
1166  //COLIN what's this? does it have to be GsfElectron specific?
1167  if (efficiencyLoader_.enabled()) {
1168  efficiencyLoader_.setEfficiencies(anElectron, candPtrForLoader);
1169  }
1170 
1171  if (resolutionLoader_.enabled()) {
1172  resolutionLoader_.setResolutions(anElectron);
1173  }
1174 
1175  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
1177  isoDepositLabels_[j].first == pat::HcalIso || deposits[j]->contains(candPtrForGenMatch.id())) {
1178  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[candPtrForGenMatch]);
1179  } else if (deposits[j]->contains(candPtrForIsolation.id())) {
1180  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[candPtrForIsolation]);
1181  } else {
1182  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
1183  }
1184  }
1185 
1186  for (size_t j = 0; j < isolationValues.size(); ++j) {
1188  isolationValueLabels_[j].first == pat::HcalIso || isolationValues[j]->contains(candPtrForGenMatch.id())) {
1189  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[candPtrForGenMatch]);
1190  } else if (isolationValues[j]->contains(candPtrForIsolation.id())) {
1191  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[candPtrForIsolation]);
1192  } else {
1194  (*isolationValues[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
1195  }
1196  }
1197 }
1198 
1200  pat::PFIsolation miniiso;
1201  if (anElectron.isEE())
1202  miniiso = pat::getMiniPFIsolation(pc,
1203  anElectron.polarP4(),
1204  miniIsoParamsE_[0],
1205  miniIsoParamsE_[1],
1206  miniIsoParamsE_[2],
1207  miniIsoParamsE_[3],
1208  miniIsoParamsE_[4],
1209  miniIsoParamsE_[5],
1210  miniIsoParamsE_[6],
1211  miniIsoParamsE_[7],
1212  miniIsoParamsE_[8]);
1213  else
1214  miniiso = pat::getMiniPFIsolation(pc,
1215  anElectron.polarP4(),
1216  miniIsoParamsB_[0],
1217  miniIsoParamsB_[1],
1218  miniIsoParamsB_[2],
1219  miniIsoParamsB_[3],
1220  miniIsoParamsB_[4],
1221  miniIsoParamsB_[5],
1222  miniIsoParamsB_[6],
1223  miniIsoParamsB_[7],
1224  miniIsoParamsB_[8]);
1225  anElectron.setMiniPFIsolation(miniiso);
1226 }
1227 
1228 // ParameterSet description for module
1231  iDesc.setComment("PAT electron producer module");
1232 
1233  // input source
1234  iDesc.add<edm::InputTag>("pfCandidateMap", edm::InputTag("no default"))->setComment("input collection");
1235  iDesc.add<edm::InputTag>("electronSource", edm::InputTag("no default"))->setComment("input collection");
1236 
1237  iDesc.ifValue(
1238  edm::ParameterDescription<bool>("addPFClusterIso", false, true),
1240  "ecalPFClusterIsoMap", edm::InputTag("electronEcalPFClusterIsolationProducer"), true) and
1242  "hcalPFClusterIsoMap", edm::InputTag("electronHcalPFClusterIsolationProducer"), true)) or
1243  false >> (edm::ParameterDescription<edm::InputTag>("ecalPFClusterIsoMap", edm::InputTag(""), true) and
1244  edm::ParameterDescription<edm::InputTag>("hcalPFClusterIsoMap", edm::InputTag(""), true)));
1245 
1246  iDesc.ifValue(edm::ParameterDescription<bool>("addPuppiIsolation", false, true),
1248  "puppiIsolationChargedHadrons",
1249  edm::InputTag("egmElectronPUPPIIsolation", "h+-DR030-BarVeto000-EndVeto001"),
1250  true) and
1252  "puppiIsolationNeutralHadrons",
1253  edm::InputTag("egmElectronPUPPIIsolation", "h0-DR030-BarVeto000-EndVeto000"),
1254  true) and
1256  "puppiIsolationPhotons",
1257  edm::InputTag("egmElectronPUPPIIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1258  true) and
1260  "puppiNoLeptonsIsolationChargedHadrons",
1261  edm::InputTag("egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1262  true) and
1264  "puppiNoLeptonsIsolationNeutralHadrons",
1265  edm::InputTag("egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1266  true) and
1268  "puppiNoLeptonsIsolationPhotons",
1269  edm::InputTag("egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1270  true)) or
1271  false >> edm::EmptyGroupDescription());
1272 
1273  // embedding
1274  iDesc.add<bool>("embedGsfElectronCore", true)->setComment("embed external gsf electron core");
1275  iDesc.add<bool>("embedGsfTrack", true)->setComment("embed external gsf track");
1276  iDesc.add<bool>("embedSuperCluster", true)->setComment("embed external super cluster");
1277  iDesc.add<bool>("embedPflowSuperCluster", true)->setComment("embed external super cluster");
1278  iDesc.add<bool>("embedSeedCluster", true)->setComment("embed external seed cluster");
1279  iDesc.add<bool>("embedBasicClusters", true)->setComment("embed external basic clusters");
1280  iDesc.add<bool>("embedPreshowerClusters", true)->setComment("embed external preshower clusters");
1281  iDesc.add<bool>("embedPflowBasicClusters", true)->setComment("embed external pflow basic clusters");
1282  iDesc.add<bool>("embedPflowPreshowerClusters", true)->setComment("embed external pflow preshower clusters");
1283  iDesc.add<bool>("embedTrack", false)->setComment("embed external track");
1284  iDesc.add<bool>("embedRecHits", true)->setComment("embed external RecHits");
1285 
1286  // pf specific parameters
1287  iDesc.add<edm::InputTag>("pfElectronSource", edm::InputTag("pfElectrons"))
1288  ->setComment("particle flow input collection");
1289  auto&& usePfCandidateMultiMap = edm::ParameterDescription<bool>("usePfCandidateMultiMap", false, true);
1290  usePfCandidateMultiMap.setComment(
1291  "take ParticleFlow candidates from pfCandidateMultiMap instead of matching to pfElectrons by Gsf track "
1292  "reference");
1293  iDesc.ifValue(usePfCandidateMultiMap,
1294  true >> edm::ParameterDescription<edm::InputTag>("pfCandidateMultiMap", true) or
1295  false >> edm::EmptyGroupDescription());
1296  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
1297  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
1298 
1299  // MC matching configurables
1300  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
1301  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
1302  std::vector<edm::InputTag> emptySourceVector;
1303  iDesc
1304  .addNode(edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
1305  edm::ParameterDescription<std::vector<edm::InputTag>>("genParticleMatch", emptySourceVector, true))
1306  ->setComment("input with MC match information");
1307 
1308  // electron ID configurables
1309  iDesc.add<bool>("addElectronID", true)->setComment("add electron ID variables");
1310  edm::ParameterSetDescription electronIDSourcesPSet;
1311  electronIDSourcesPSet.setAllowAnything();
1312  iDesc
1313  .addNode(
1314  edm::ParameterDescription<edm::InputTag>("electronIDSource", edm::InputTag(), true) xor
1315  edm::ParameterDescription<edm::ParameterSetDescription>("electronIDSources", electronIDSourcesPSet, true))
1316  ->setComment("input with electron ID variables");
1317 
1318  // mini-iso
1319  iDesc.add<bool>("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation");
1320  iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))
1321  ->setComment("collection to use to compute mini-iso");
1322  iDesc.add<std::vector<double>>("miniIsoParamsE", std::vector<double>())
1323  ->setComment("mini-iso parameters to use for endcap electrons");
1324  iDesc.add<std::vector<double>>("miniIsoParamsB", std::vector<double>())
1325  ->setComment("mini-iso parameters to use for barrel electrons");
1326 
1327  // IsoDeposit configurables
1328  edm::ParameterSetDescription isoDepositsPSet;
1329  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
1330  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
1331  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
1332  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
1333  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1334  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
1335  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1336  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1337  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
1338  isoDepositsPSet.addOptional<std::vector<edm::InputTag>>("user");
1339  iDesc.addOptional("isoDeposits", isoDepositsPSet);
1340 
1341  // isolation values configurables
1342  edm::ParameterSetDescription isolationValuesPSet;
1343  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
1344  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
1345  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
1346  isolationValuesPSet.addOptional<edm::InputTag>("pfAllParticles");
1347  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1348  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
1349  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1350  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1351  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
1352  isolationValuesPSet.addOptional<std::vector<edm::InputTag>>("user");
1353  iDesc.addOptional("isolationValues", isolationValuesPSet);
1354 
1355  // isolation values configurables
1356  edm::ParameterSetDescription isolationValuesNoPFIdPSet;
1357  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("tracker");
1358  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("ecal");
1359  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("hcal");
1360  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfAllParticles");
1361  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1362  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfChargedAll");
1363  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1364  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1365  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfPhotons");
1366  isolationValuesNoPFIdPSet.addOptional<std::vector<edm::InputTag>>("user");
1367  iDesc.addOptional("isolationValuesNoPFId", isolationValuesNoPFIdPSet);
1368 
1369  // Efficiency configurables
1370  edm::ParameterSetDescription efficienciesPSet;
1371  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1372  iDesc.add("efficiencies", efficienciesPSet);
1373  iDesc.add<bool>("addEfficiencies", false);
1374 
1375  // Check to see if the user wants to add user data
1376  edm::ParameterSetDescription userDataPSet;
1378  iDesc.addOptional("userData", userDataPSet);
1379 
1380  // electron shapes
1381  iDesc.add<bool>("addMVAVariables", true)->setComment("embed extra variables in pat::Electron : sip3d, sigmaIEtaIPhi");
1382  iDesc.add<edm::InputTag>("reducedBarrelRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
1383  iDesc.add<edm::InputTag>("reducedEndcapRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
1384 
1385  edm::ParameterSetDescription isolationPSet;
1386  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1387  iDesc.add("userIsolation", isolationPSet);
1388 
1389  // Resolution configurables
1391 
1392  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
1393  edm::ParameterSetDescription highLevelPSet;
1394  highLevelPSet.setAllowAnything();
1395  iDesc.addNode(edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true))
1396  ->setComment("input with high level selection");
1398  ->setComment("input with high level selection");
1399 
1400  descriptions.add("PATElectronProducer", iDesc);
1401 }
1402 
1403 // embed various impact parameters with errors
1404 // embed high level selection
1409  bool primaryVertexIsValid,
1411  bool beamspotIsValid) {
1412  // Correct to PV
1413  // PV2D
1414  anElectron.setDB(track->dxy(primaryVertex.position()),
1415  track->dxyError(primaryVertex.position(), primaryVertex.covariance()),
1417 
1418  // PV3D
1419  std::pair<bool, Measurement1D> result =
1421  double d0_corr = result.second.value();
1422  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1423  anElectron.setDB(d0_corr, d0_err, pat::Electron::PV3D);
1424 
1425  // Correct to beam spot
1426  // BS2D
1427  anElectron.setDB(track->dxy(beamspot), track->dxyError(beamspot), pat::Electron::BS2D);
1428 
1429  // make a fake vertex out of beam spot
1430  reco::Vertex vBeamspot(beamspot.position(), beamspot.covariance3D());
1431 
1432  // BS3D
1433  result = IPTools::signedImpactParameter3D(tt, GlobalVector(track->px(), track->py(), track->pz()), vBeamspot);
1434  d0_corr = result.second.value();
1435  d0_err = beamspotIsValid ? result.second.error() : -1.0;
1436  anElectron.setDB(d0_corr, d0_err, pat::Electron::BS3D);
1437 
1438  // PVDZ
1439  anElectron.setDB(
1440  track->dz(primaryVertex.position()), std::hypot(track->dzError(), primaryVertex.zError()), pat::Electron::PVDZ);
1441 }
1442 
void setMvaVariables(double sigmaIetaIphi, double ip3d)
set missing mva input variables
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void setComment(std::string const &value)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:194
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
const edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:115
const GreaterByPt< Electron > pTComparator_
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T >>> &tokens)
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:55
const bool useParticleFlow_
pflow specific
void setElectronIDs(const std::vector< IdPair > &ids)
Store multiple electron ID values, discarding existing ones. The first one in the list becomes the &#39;d...
Definition: Electron.h:141
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:160
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
const Point & position() const
position
Definition: BeamSpot.h:59
std::vector< double > miniIsoParamsE_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
void setAllowAnything()
allow any parameter label/value pairs
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:86
bool exists(std::string const &parameterName) const
checks if a parameter exists
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
T const * product() const
Definition: Handle.h:70
std::vector< pat::PackedCandidate > PackedCandidateCollection
void embedHighLevel(pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
std::vector< EcalRecHit >::const_iterator const_iterator
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:38
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Electron.h:179
const edm::InputTag reducedBarrelRecHitCollection_
void push_back(T const &t)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:81
void embedGsfElectronCore()
method to store the electron&#39;s core internally
void setPassConversionVeto(bool flag)
Definition: Electron.h:257
edm::RefToBase< reco::GsfElectron > ElectronBaseRef
const edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
Log< level::Error, false > LogError
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
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
void setEcalDrivenMomentum(const Candidate::LorentzVector &mom)
Definition: Electron.h:204
assert(be >=bs)
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:738
const std::string names[nVars_]
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopologyToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const bool addMVAVariables_
mva input variables
std::vector< double > miniIsoParamsB_
void embedPflowSuperCluster()
method to store the electron&#39;s PflowSuperCluster internally
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:84
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Lepton.h:191
Definition: HeavyIon.h:7
static void fillDescription(edm::ParameterSetDescription &iDesc)
reco::TransientTrack build(const reco::Track *p) const
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
const edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
char const * label
void setComment(std::string const &value)
ESData get(edm::EventSetup const &eventSetup) const
const PflowIsolationVariables & pfIsolationVariables() const
Definition: GsfElectron.h:729
pat::helper::MultiIsolator isolator_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
void setDB(double dB, double edB, IPTYPE type)
Set impact parameter of a certain type and its uncertainty.
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
Produces pat::Electron&#39;s.
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
PATElectronProducer(const edm::ParameterSet &iConfig)
const bool embedHighLevelSelection_
embed high level selection variables?
void embedGenParticle()
Definition: PATObject.h:768
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
static bool hasMatchedConversion(const reco::GsfElectron &ele, const reco::ConversionCollection &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
def unique(seq, keepstr=True)
Definition: tier0.py:24
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
void setIsolationPUPPINoLeptons(float chargedhadrons_, float neutralhadrons_, float photons_)
sets PUPPINoLeptons isolations
Definition: Electron.h:167
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::InputTag reducedEndcapRecHitCollection_
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void embedBasicClusters()
method to store the electron&#39;s basic clusters
bool isNull() const
Checks for null.
Definition: Ref.h:235
std::pair< std::string, edm::InputTag > NameTag
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
std::vector< Conversion > ConversionCollection
Definition: Conversion.h:13
Definition: DetId.h:17
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:17
const edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:751
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
pat::helper::EfficiencyLoader efficiencyLoader_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
void setIsPF(bool hasPFCandidate)
Definition: Electron.h:174
bool isEE() const
Definition: GsfElectron.h:329
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > pfCandidateMultiMapToken_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
void fillElectron2(Electron &anElectron, const reco::CandidatePtr &candPtrForIsolation, const reco::CandidatePtr &candPtrForGenMatch, const reco::CandidatePtr &candPtrForLoader, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
Analysis-level electron class.
Definition: Electron.h:51
const CaloTopology * ecalTopology_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:217
IsolationLabels isolationValueLabelsNoPFId_
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
bool isValid() const
Definition: HandleBase.h:70
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
std::vector< IsolationLabel > IsolationLabels
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
IsolationLabels isolationValueLabels_
Calculates a lepton&#39;s calorimetric isolation energy.
pat::helper::KinResolutionsLoader resolutionLoader_
PFIsolation getMiniPFIsolation(const pat::PackedCandidateCollection *pfcands, const reco::Candidate::PolarLorentzVector &p4, float mindr=0.05, float maxdr=0.2, float kt_scale=10.0, float ptthresh=0.5, float deadcone_ch=0.0001, float deadcone_pu=0.01, float deadcone_ph=0.01, float deadcone_nh=0.01, float dZ_cut=0.0)
void embedPflowPreshowerClusters()
method to store the electron&#39;s pflow preshower clusters
edm::Ref< l1t::PFCandidateCollection > PFCandidateRef
Definition: PFCandidate.h:87
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void embedTrack()
method to store the electron&#39;s Track internally
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
primaryVertex
hltOfflineBeamSpot for HLTMON
edm::Ptr< PFCandidate > PFCandidatePtr
persistent Ptr to a PFCandidate
void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_)
sets PUPPI isolations
Definition: Electron.h:161
static std::string const source
Definition: EdmProvDump.cc:49
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
def move(src, dest)
Definition: eostools.py:511
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
void fillElectron(Electron &aElectron, const ElectronBaseRef &electronRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const bool pfId, const IsolationValueMaps &isolationValues, const IsolationValueMaps &isolationValuesNoPFId) const
common electron filling, for both the standard and PF2PAT case
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Calculates a lepton&#39;s tracker isolation pt.
std::vector< NameTag > elecIDSrcs_