CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
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,
141  const IsolationValueMaps& isolationValues,
142  const IsolationValueMaps& isolationValuesNoPFId) const;
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)) {
225  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(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.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation")
320  : edm::ParameterSet(),
321  consumesCollector(),
322  false),
323  addEfficiencies_(iConfig.getParameter<bool>("addEfficiencies")),
324  addResolutions_(iConfig.getParameter<bool>("addResolutions")),
325  useUserData_(iConfig.exists("userData")),
326  ecalTopologyToken_{esConsumes()},
327  trackBuilderToken_{esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))} {
328  // MC matching configurables (scheduled mode)
329 
330  if (addGenMatch_) {
331  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
332  genMatchTokens_.push_back(consumes<edm::Association<reco::GenParticleCollection>>(
333  iConfig.getParameter<edm::InputTag>("genParticleMatch")));
334  } else {
335  genMatchTokens_ = edm::vector_transform(
336  iConfig.getParameter<std::vector<edm::InputTag>>("genParticleMatch"),
337  [this](edm::InputTag const& tag) { return consumes<edm::Association<reco::GenParticleCollection>>(tag); });
338  }
339  }
340  // resolution configurables
341  if (addResolutions_) {
342  resolutionLoader_ =
343  pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"), consumesCollector());
344  }
345  if (addPuppiIsolation_) {
346  //puppi
347  PUPPIIsolation_charged_hadrons_ =
348  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationChargedHadrons"));
349  PUPPIIsolation_neutral_hadrons_ =
350  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationNeutralHadrons"));
351  PUPPIIsolation_photons_ =
352  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiIsolationPhotons"));
353  //puppiNoLeptons
354  PUPPINoLeptonsIsolation_charged_hadrons_ =
355  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons"));
356  PUPPINoLeptonsIsolation_neutral_hadrons_ =
357  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons"));
358  PUPPINoLeptonsIsolation_photons_ =
359  consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationPhotons"));
360  }
361  // electron ID configurables
362  if (addElecID_) {
363  // it might be a single electron ID
364  if (iConfig.existsAs<edm::InputTag>("electronIDSource")) {
365  elecIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("electronIDSource")));
366  }
367  // or there might be many of them
368  if (iConfig.existsAs<edm::ParameterSet>("electronIDSources")) {
369  // please don't configure me twice
370  if (!elecIDSrcs_.empty()) {
371  throw cms::Exception("Configuration")
372  << "PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
373  }
374  // read the different electron ID names
375  edm::ParameterSet idps = iConfig.getParameter<edm::ParameterSet>("electronIDSources");
376  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
377  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
378  elecIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
379  }
380  }
381  // but in any case at least once
382  if (elecIDSrcs_.empty()) {
383  throw cms::Exception("Configuration")
384  << "PATElectronProducer: id addElectronID is true, you must specify either:\n"
385  << "\tInputTag electronIDSource = <someTag>\n"
386  << "or\n"
387  << "\tPSet electronIDSources = { \n"
388  << "\t\tInputTag <someName> = <someTag> // as many as you want \n "
389  << "\t}\n";
390  }
391  }
392  elecIDTokens_ = edm::vector_transform(
393  elecIDSrcs_, [this](NameTag const& tag) { return mayConsume<edm::ValueMap<float>>(tag.second); });
394  // construct resolution calculator
395 
396  // // IsoDeposit configurables
397  // if (iConfig.exists("isoDeposits")) {
398  // edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
399  // if (depconf.exists("tracker")) isoDepositLabels_.push_back(std::make_pair(TrackerIso, depconf.getParameter<edm::InputTag>("tracker")));
400  // if (depconf.exists("ecal")) isoDepositLabels_.push_back(std::make_pair(ECalIso, depconf.getParameter<edm::InputTag>("ecal")));
401  // if (depconf.exists("hcal")) isoDepositLabels_.push_back(std::make_pair(HCalIso, depconf.getParameter<edm::InputTag>("hcal")));
402 
403  // if (depconf.exists("user")) {
404  // std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
405  // std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
406  // int key = UserBaseIso;
407  // for ( ; it != ed; ++it, ++key) {
408  // isoDepositLabels_.push_back(std::make_pair(IsolationKeys(key), *it));
409  // }
410  // }
411  // }
412  // isoDepositTokens_ = edm::vector_transform(isoDepositLabels_, [this](std::pair<IsolationKeys,edm::InputTag> const & label){return consumes<edm::ValueMap<IsoDeposit> >(label.second);});
413 
414  // for mini-iso
415  computeMiniIso_ = iConfig.getParameter<bool>("computeMiniIso");
416  miniIsoParamsE_ = iConfig.getParameter<std::vector<double>>("miniIsoParamsE");
417  miniIsoParamsB_ = iConfig.getParameter<std::vector<double>>("miniIsoParamsB");
418  if (computeMiniIso_ && (miniIsoParamsE_.size() != 9 || miniIsoParamsB_.size() != 9)) {
419  throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n";
420  }
421  if (computeMiniIso_)
422  pcToken_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
423 
424  // read isoDeposit labels, for direct embedding
425  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
426  // read isolation value labels, for direct embedding
427  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_, isolationValueTokens_);
428  // read isolation value labels for non PF identified electron, for direct embedding
429  readIsolationLabels(iConfig, "isolationValuesNoPFId", isolationValueLabelsNoPFId_, isolationValueNoPFIdTokens_);
430  // Efficiency configurables
431  if (addEfficiencies_) {
432  efficiencyLoader_ =
433  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
434  }
435  // Check to see if the user wants to add user data
436  if (useUserData_) {
437  userDataHelper_ =
438  PATUserDataHelper<Electron>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
439  }
440 
441  // consistency check
442  if (useParticleFlow_ && usePfCandidateMultiMap_)
443  throw cms::Exception("Configuration", "usePfCandidateMultiMap not supported when useParticleFlow is set to true");
444 
445  // produces vector of muons
446  produces<std::vector<Electron>>();
447 }
448 
449 PATElectronProducer::~PATElectronProducer() {}
450 
452  // switch off embedding (in unschedules mode)
453  if (iEvent.isRealData()) {
454  addGenMatch_ = false;
455  embedGenMatch_ = false;
456  }
457 
459 
460  // Get the collection of electrons from the event
462  iEvent.getByToken(electronToken_, electrons);
463 
465  if (computeMiniIso_)
466  iEvent.getByToken(pcToken_, pc);
467 
468  // for additional mva variables
469  edm::InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB"));
470  edm::InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE"));
471  //EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection);
472  EcalClusterLazyTools lazyTools(iEvent,
476 
477  // for conversion veto selection
479  iEvent.getByToken(hConversionsToken_, hConversions);
480 
481  // Get the ESHandle for the transient track builder, if needed for
482  // high level selection embedding
484 
485  if (isolator_.enabled())
486  isolator_.beginEvent(iEvent, iSetup);
487 
489  efficiencyLoader_.newEvent(iEvent);
491  resolutionLoader_.newEvent(iEvent, iSetup);
492 
493  IsoDepositMaps deposits(isoDepositTokens_.size());
494  for (size_t j = 0, nd = isoDepositTokens_.size(); j < nd; ++j) {
495  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
496  }
497 
498  IsolationValueMaps isolationValues(isolationValueTokens_.size());
499  for (size_t j = 0; j < isolationValueTokens_.size(); ++j) {
500  iEvent.getByToken(isolationValueTokens_[j], isolationValues[j]);
501  }
502 
503  IsolationValueMaps isolationValuesNoPFId(isolationValueNoPFIdTokens_.size());
504  for (size_t j = 0; j < isolationValueNoPFIdTokens_.size(); ++j) {
505  iEvent.getByToken(isolationValueNoPFIdTokens_[j], isolationValuesNoPFId[j]);
506  }
507 
508  // prepare the MC matching
509  GenAssociations genMatches(genMatchTokens_.size());
510  if (addGenMatch_) {
511  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
512  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
513  }
514  }
515 
516  // prepare ID extraction
517  std::vector<edm::Handle<edm::ValueMap<float>>> idhandles;
518  std::vector<pat::Electron::IdPair> ids;
519  if (addElecID_) {
520  idhandles.resize(elecIDSrcs_.size());
521  ids.resize(elecIDSrcs_.size());
522  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
523  iEvent.getByToken(elecIDTokens_[i], idhandles[i]);
524  ids[i].first = elecIDSrcs_[i].first;
525  }
526  }
527 
528  // prepare the high level selection:
529  // needs beamline
530  reco::TrackBase::Point beamPoint(0, 0, 0);
533  bool beamSpotIsValid = false;
534  bool primaryVertexIsValid = false;
535 
536  // Get the beamspot
537  edm::Handle<reco::BeamSpot> beamSpotHandle;
538  iEvent.getByToken(beamLineToken_, beamSpotHandle);
539 
541  // Get the primary vertex
543  iEvent.getByToken(pvToken_, pvHandle);
544 
545  // This is needed by the IPTools methods from the tracking group
546  trackBuilder = iSetup.getHandle(trackBuilderToken_);
547 
548  if (pvHandle.isValid() && !pvHandle->empty()) {
549  primaryVertex = pvHandle->at(0);
550  primaryVertexIsValid = true;
551  } else {
552  edm::LogError("DataNotAvailable")
553  << "No primary vertex available from EventSetup, not adding high level selection \n";
554  }
555  }
556  //value maps for puppi isolation
557  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_charged_hadrons;
558  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_neutral_hadrons;
559  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_photons;
560  //value maps for puppiNoLeptons isolation
561  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_charged_hadrons;
562  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_neutral_hadrons;
563  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_photons;
564  if (addPuppiIsolation_) {
565  //puppi
566  iEvent.getByToken(PUPPIIsolation_charged_hadrons_, PUPPIIsolation_charged_hadrons);
567  iEvent.getByToken(PUPPIIsolation_neutral_hadrons_, PUPPIIsolation_neutral_hadrons);
568  iEvent.getByToken(PUPPIIsolation_photons_, PUPPIIsolation_photons);
569  //puppiNoLeptons
570  iEvent.getByToken(PUPPINoLeptonsIsolation_charged_hadrons_, PUPPINoLeptonsIsolation_charged_hadrons);
571  iEvent.getByToken(PUPPINoLeptonsIsolation_neutral_hadrons_, PUPPINoLeptonsIsolation_neutral_hadrons);
572  iEvent.getByToken(PUPPINoLeptonsIsolation_photons_, PUPPINoLeptonsIsolation_photons);
573  }
574 
575  std::vector<Electron>* patElectrons = new std::vector<Electron>();
576 
577  if (useParticleFlow_) {
579  iEvent.getByToken(pfElecToken_, pfElectrons);
580  unsigned index = 0;
581 
582  for (reco::PFCandidateConstIterator i = pfElectrons->begin(); i != pfElectrons->end(); ++i, ++index) {
583  reco::PFCandidateRef pfRef(pfElectrons, index);
584  reco::PFCandidatePtr ptrToPFElectron(pfElectrons, index);
585  // reco::CandidateBaseRef pfBaseRef( pfRef );
586 
587  reco::GsfTrackRef PfTk = i->gsfTrackRef();
588 
589  bool Matched = false;
590  bool MatchedToAmbiguousGsfTrack = false;
591  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end();
592  ++itElectron) {
593  unsigned int idx = itElectron - electrons->begin();
594  auto elePtr = electrons->ptrAt(idx);
595  if (Matched || MatchedToAmbiguousGsfTrack)
596  continue;
597 
598  reco::GsfTrackRef EgTk = itElectron->gsfTrack();
599 
600  if (itElectron->gsfTrack() == i->gsfTrackRef()) {
601  Matched = true;
602  } else {
603  for (auto const& it : itElectron->ambiguousGsfTracks()) {
604  MatchedToAmbiguousGsfTrack |= (bool)(i->gsfTrackRef() == it);
605  }
606  }
607 
608  if (Matched || MatchedToAmbiguousGsfTrack) {
609  // ptr needed for finding the matched gen particle
610  reco::CandidatePtr ptrToGsfElectron(electrons, idx);
611 
612  // ref to base needed for the construction of the pat object
613  const edm::RefToBase<reco::GsfElectron>& elecsRef = electrons->refAt(idx);
614  Electron anElectron(elecsRef);
615  anElectron.setPFCandidateRef(pfRef);
616  if (addPuppiIsolation_) {
617  anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
618  (*PUPPIIsolation_neutral_hadrons)[elePtr],
619  (*PUPPIIsolation_photons)[elePtr]);
620  anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
621  (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
622  (*PUPPINoLeptonsIsolation_photons)[elePtr]);
623  } else {
624  anElectron.setIsolationPUPPI(-999., -999., -999.);
625  anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
626  }
627 
628  //it should be always true when particleFlow electrons are used.
629  anElectron.setIsPF(true);
630 
631  if (embedPFCandidate_)
632  anElectron.embedPFCandidate();
633 
634  if (useUserData_) {
635  userDataHelper_.add(anElectron, iEvent, iSetup);
636  }
637 
638  double ip3d = -999; // for mva variable
639 
640  // embed high level selection
642  // get the global track
643  const reco::GsfTrackRef& track = PfTk;
644 
645  // Make sure the collection it points to is there
646  if (track.isNonnull() && track.isAvailable()) {
647  reco::TransientTrack tt = trackBuilder->build(track);
648  embedHighLevel(anElectron, track, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
649 
650  std::pair<bool, Measurement1D> ip3dpv = IPTools::absoluteImpactParameter3D(tt, primaryVertex);
651  ip3d = ip3dpv.second.value(); // for mva variable
652  }
653  }
654 
655  //Electron Id
656 
657  if (addElecID_) {
658  //STANDARD EL ID
659  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
660  ids[i].second = (*idhandles[i])[elecsRef];
661  }
662  //SPECIFIC PF ID
663  ids.push_back(std::make_pair("pf_evspi", pfRef->mva_e_pi()));
664  ids.push_back(std::make_pair("pf_evsmu", pfRef->mva_e_mu()));
665  anElectron.setElectronIDs(ids);
666  }
667 
668  if (addMVAVariables_) {
669  // add missing mva variables
670  const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
671  anElectron.setMvaVariables(vCov[1], ip3d);
672  }
673  // PFClusterIso
674  if (addPFClusterIso_) {
675  // Get PFCluster Isolation
676  edm::Handle<edm::ValueMap<float>> ecalPFClusterIsoMapH;
677  iEvent.getByToken(ecalPFClusterIsoT_, ecalPFClusterIsoMapH);
678  edm::Handle<edm::ValueMap<float>> hcalPFClusterIsoMapH;
679  iEvent.getByToken(hcalPFClusterIsoT_, hcalPFClusterIsoMapH);
681  newPFIsol.sumEcalClusterEt = (*ecalPFClusterIsoMapH)[elecsRef];
682  newPFIsol.sumHcalClusterEt = (*hcalPFClusterIsoMapH)[elecsRef];
683  anElectron.setPfIsolationVariables(newPFIsol);
684  }
685 
686  std::vector<DetId> selectedCells;
687  bool barrel = itElectron->isEB();
688  //loop over sub clusters
689  if (embedBasicClusters_) {
690  for (reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin();
691  clusIt != itElectron->superCluster()->clustersEnd();
692  ++clusIt) {
693  //get seed (max energy xtal)
694  DetId seed = lazyTools.getMaximum(**clusIt).first;
695  //get all xtals in 5x5 window around the seed
696  std::vector<DetId> dets5x5 =
699  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
700 
701  //get all xtals belonging to cluster
702  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
703  selectedCells.push_back(hit.first);
704  }
705  }
706  }
707 
708  if (embedPflowBasicClusters_ && itElectron->parentSuperCluster().isNonnull()) {
709  for (reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin();
710  clusIt != itElectron->parentSuperCluster()->clustersEnd();
711  ++clusIt) {
712  //get seed (max energy xtal)
713  DetId seed = lazyTools.getMaximum(**clusIt).first;
714  //get all xtals in 5x5 window around the seed
715  std::vector<DetId> dets5x5 =
718  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
719 
720  //get all xtals belonging to cluster
721  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
722  selectedCells.push_back(hit.first);
723  }
724  }
725  }
726 
727  //remove duplicates
728  std::sort(selectedCells.begin(), selectedCells.end());
729  std::unique(selectedCells.begin(), selectedCells.end());
730 
731  // Retrieve the corresponding RecHits
732 
734  if (barrel)
736  else
738 
739  EcalRecHitCollection selectedRecHits;
740  const EcalRecHitCollection* recHits = rechitsH.product();
741 
742  unsigned nSelectedCells = selectedCells.size();
743  for (unsigned icell = 0; icell < nSelectedCells; ++icell) {
744  EcalRecHitCollection::const_iterator it = recHits->find(selectedCells[icell]);
745  if (it != recHits->end()) {
746  selectedRecHits.push_back(*it);
747  }
748  }
749  selectedRecHits.sort();
750  if (embedRecHits_)
751  anElectron.embedRecHits(&selectedRecHits);
752 
753  // set conversion veto selection
754  bool passconversionveto = false;
755  if (hConversions.isValid()) {
756  // this is recommended method
757  passconversionveto =
758  !ConversionTools::hasMatchedConversion(*itElectron, *hConversions, beamSpotHandle->position());
759  } else {
760  // use missing hits without vertex fit method
761  passconversionveto =
762  itElectron->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < 1;
763  }
764 
765  anElectron.setPassConversionVeto(passconversionveto);
766 
767  // fillElectron(anElectron,elecsRef,pfBaseRef,
768  // genMatches, deposits, isolationValues);
769 
770  //COLIN small warning !
771  // we are currently choosing to take the 4-momentum of the PFCandidate;
772  // the momentum of the GsfElectron is saved though
773  // we must therefore match the GsfElectron.
774  // because of this, we should not change the source of the electron matcher
775  // to the collection of PFElectrons in the python configuration
776  // I don't know what to do with the efficiencyLoader, since I don't know
777  // what this class is for.
779  anElectron, ptrToPFElectron, ptrToGsfElectron, ptrToGsfElectron, genMatches, deposits, isolationValues);
780 
781  //COLIN need to use fillElectron2 in the non-pflow case as well, and to test it.
782 
783  if (computeMiniIso_)
784  setElectronMiniIso(anElectron, pc.product());
785 
786  patElectrons->push_back(anElectron);
787  }
788  }
789  //if( !Matched && !MatchedToAmbiguousGsfTrack) std::cout << "!!!!A pf electron could not be matched to a gsf!!!!" << std::endl;
790  }
791  }
792 
793  else {
797  bool pfCandsPresent = false, valMapPresent = false;
799  iEvent.getByToken(pfCandidateMultiMapToken_, ValMultiMapH);
800  } else {
801  pfCandsPresent = iEvent.getByToken(pfElecToken_, pfElectrons);
802  valMapPresent = iEvent.getByToken(pfCandidateMapToken_, ValMapH);
803  }
804 
805  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end();
806  ++itElectron) {
807  // construct the Electron from the ref -> save ref to original object
808  //FIXME: looks like a lot of instances could be turned into const refs
809  unsigned int idx = itElectron - electrons->begin();
810  edm::RefToBase<reco::GsfElectron> elecsRef = electrons->refAt(idx);
811  reco::CandidateBaseRef elecBaseRef(elecsRef);
812  Electron anElectron(elecsRef);
813  auto elePtr = electrons->ptrAt(idx);
814 
815  // Is this GsfElectron also identified as an e- in the particle flow?
816  bool pfId = false;
817 
819  for (const reco::PFCandidateRef& pf : (*ValMultiMapH)[elePtr]) {
820  if (pf->particleId() == reco::PFCandidate::e) {
821  pfId = true;
822  anElectron.setPFCandidateRef(pf);
823  break;
824  }
825  }
826  } else if (pfCandsPresent) {
827  // PF electron collection not available.
828  const reco::GsfTrackRef& trkRef = itElectron->gsfTrack();
829  int index = 0;
830  for (reco::PFCandidateConstIterator ie = pfElectrons->begin(); ie != pfElectrons->end(); ++ie, ++index) {
831  if (ie->particleId() != reco::PFCandidate::e)
832  continue;
833  const reco::GsfTrackRef& pfTrkRef = ie->gsfTrackRef();
834  if (trkRef == pfTrkRef) {
835  pfId = true;
836  reco::PFCandidateRef pfRef(pfElectrons, index);
837  anElectron.setPFCandidateRef(pfRef);
838  break;
839  }
840  }
841  } else if (valMapPresent) {
842  // use value map if PF collection not available
843  const edm::ValueMap<reco::PFCandidatePtr>& myValMap(*ValMapH);
844  // Get the PFCandidate
845  const reco::PFCandidatePtr& pfElePtr(myValMap[elecsRef]);
846  pfId = pfElePtr.isNonnull();
847  }
848  // set PFId function
849  anElectron.setIsPF(pfId);
850 
851  // add resolution info
852 
853  // Isolation
854  if (isolator_.enabled()) {
855  isolator_.fill(*electrons, idx, isolatorTmpStorage_);
856  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
857  // better to loop backwards, so the vector is resized less times
858  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(),
859  ed = isolatorTmpStorage_.rend();
860  it != ed;
861  ++it) {
862  anElectron.setIsolation(it->first, it->second);
863  }
864  }
865 
866  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
867  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[elecsRef]);
868  }
869 
870  // add electron ID info
871  if (addElecID_) {
872  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
873  ids[i].second = (*idhandles[i])[elecsRef];
874  }
875  anElectron.setElectronIDs(ids);
876  }
877 
878  if (useUserData_) {
879  userDataHelper_.add(anElectron, iEvent, iSetup);
880  }
881 
882  double ip3d = -999; //for mva variable
883 
884  // embed high level selection
886  // get the global track
887  reco::GsfTrackRef track = itElectron->gsfTrack();
888 
889  // Make sure the collection it points to is there
890  if (track.isNonnull() && track.isAvailable()) {
891  reco::TransientTrack tt = trackBuilder->build(track);
892  embedHighLevel(anElectron, track, tt, primaryVertex, primaryVertexIsValid, beamSpot, beamSpotIsValid);
893 
894  std::pair<bool, Measurement1D> ip3dpv = IPTools::absoluteImpactParameter3D(tt, primaryVertex);
895  ip3d = ip3dpv.second.value(); // for mva variable
896  }
897  }
898 
899  if (addMVAVariables_) {
900  // add mva variables
901  const auto& vCov = lazyTools.localCovariances(*(itElectron->superCluster()->seed()));
902  anElectron.setMvaVariables(vCov[1], ip3d);
903  }
904 
905  // PFCluster Isolation
906  if (addPFClusterIso_) {
907  // Get PFCluster Isolation
908  edm::Handle<edm::ValueMap<float>> ecalPFClusterIsoMapH;
909  iEvent.getByToken(ecalPFClusterIsoT_, ecalPFClusterIsoMapH);
910  edm::Handle<edm::ValueMap<float>> hcalPFClusterIsoMapH;
911  iEvent.getByToken(hcalPFClusterIsoT_, hcalPFClusterIsoMapH);
913  newPFIsol.sumEcalClusterEt = (*ecalPFClusterIsoMapH)[elecsRef];
914  newPFIsol.sumHcalClusterEt = (*hcalPFClusterIsoMapH)[elecsRef];
915  anElectron.setPfIsolationVariables(newPFIsol);
916  }
917 
918  if (addPuppiIsolation_) {
919  anElectron.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[elePtr],
920  (*PUPPIIsolation_neutral_hadrons)[elePtr],
921  (*PUPPIIsolation_photons)[elePtr]);
922  anElectron.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[elePtr],
923  (*PUPPINoLeptonsIsolation_neutral_hadrons)[elePtr],
924  (*PUPPINoLeptonsIsolation_photons)[elePtr]);
925  } else {
926  anElectron.setIsolationPUPPI(-999., -999., -999.);
927  anElectron.setIsolationPUPPINoLeptons(-999., -999., -999.);
928  }
929 
930  std::vector<DetId> selectedCells;
931  bool barrel = itElectron->isEB();
932  //loop over sub clusters
933  if (embedBasicClusters_) {
934  for (reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin();
935  clusIt != itElectron->superCluster()->clustersEnd();
936  ++clusIt) {
937  //get seed (max energy xtal)
938  DetId seed = lazyTools.getMaximum(**clusIt).first;
939  //get all xtals in 5x5 window around the seed
940  std::vector<DetId> dets5x5 =
943  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
944 
945  //get all xtals belonging to cluster
946  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
947  selectedCells.push_back(hit.first);
948  }
949  }
950  }
951 
952  if (embedPflowBasicClusters_ && itElectron->parentSuperCluster().isNonnull()) {
953  for (reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin();
954  clusIt != itElectron->parentSuperCluster()->clustersEnd();
955  ++clusIt) {
956  //get seed (max energy xtal)
957  DetId seed = lazyTools.getMaximum(**clusIt).first;
958  //get all xtals in 5x5 window around the seed
959  std::vector<DetId> dets5x5 =
962  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
963 
964  //get all xtals belonging to cluster
965  for (const std::pair<DetId, float>& hit : (*clusIt)->hitsAndFractions()) {
966  selectedCells.push_back(hit.first);
967  }
968  }
969  }
970 
971  //remove duplicates
972  std::sort(selectedCells.begin(), selectedCells.end());
973  std::unique(selectedCells.begin(), selectedCells.end());
974 
975  // Retrieve the corresponding RecHits
976 
978  if (barrel)
980  else
982 
983  EcalRecHitCollection selectedRecHits;
984  const EcalRecHitCollection* recHits = rechitsH.product();
985 
986  unsigned nSelectedCells = selectedCells.size();
987  for (unsigned icell = 0; icell < nSelectedCells; ++icell) {
988  EcalRecHitCollection::const_iterator it = recHits->find(selectedCells[icell]);
989  if (it != recHits->end()) {
990  selectedRecHits.push_back(*it);
991  }
992  }
993  selectedRecHits.sort();
994  if (embedRecHits_)
995  anElectron.embedRecHits(&selectedRecHits);
996 
997  // set conversion veto selection
998  bool passconversionveto = false;
999  if (hConversions.isValid()) {
1000  // this is recommended method
1001  passconversionveto =
1002  !ConversionTools::hasMatchedConversion(*itElectron, *hConversions, beamSpotHandle->position());
1003  } else {
1004  // use missing hits without vertex fit method
1005  passconversionveto =
1006  itElectron->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < 1;
1007  }
1008  anElectron.setPassConversionVeto(passconversionveto);
1009 
1010  // add sel to selected
1011  fillElectron(
1012  anElectron, elecsRef, elecBaseRef, genMatches, deposits, pfId, isolationValues, isolationValuesNoPFId);
1013 
1014  if (computeMiniIso_)
1015  setElectronMiniIso(anElectron, pc.product());
1016 
1017  patElectrons->push_back(anElectron);
1018  }
1019  }
1020 
1021  // sort electrons in pt
1022  std::sort(patElectrons->begin(), patElectrons->end(), pTComparator_);
1023 
1024  // add the electrons to the event output
1025  std::unique_ptr<std::vector<Electron>> ptr(patElectrons);
1026  iEvent.put(std::move(ptr));
1027 
1028  // clean up
1029  if (isolator_.enabled())
1030  isolator_.endEvent();
1031 }
1032 
1034  const edm::RefToBase<reco::GsfElectron>& elecRef,
1035  const reco::CandidateBaseRef& baseRef,
1036  const GenAssociations& genMatches,
1037  const IsoDepositMaps& deposits,
1038  const bool pfId,
1039  const IsolationValueMaps& isolationValues,
1040  const IsolationValueMaps& isolationValuesNoPFId) const {
1041  //COLIN: might want to use the PFCandidate 4-mom. Which one is in use now?
1042  // if (useParticleFlow_)
1043  // aMuon.setP4( aMuon.pfCandidateRef()->p4() );
1044 
1045  //COLIN:
1046  //In the embedding case, the reference cannot be used to look into a value map.
1047  //therefore, one has to had the PFCandidateRef to this function, which becomes a bit
1048  //too much specific.
1049 
1050  // in fact, this function needs a baseref or ptr for genmatch
1051  // and a baseref or ptr for isodeposits and isolationvalues.
1052  // baseref is not needed
1053  // the ptrForIsolation and ptrForMatching should be defined upstream.
1054 
1055  // is the concrete elecRef needed for the efficiency loader? what is this loader?
1056  // how can we make it compatible with the particle flow electrons?
1057 
1059  anElectron.embedGsfElectronCore();
1060  if (embedGsfTrack_)
1061  anElectron.embedGsfTrack();
1062  if (embedSuperCluster_)
1063  anElectron.embedSuperCluster();
1065  anElectron.embedPflowSuperCluster();
1066  if (embedSeedCluster_)
1067  anElectron.embedSeedCluster();
1068  if (embedBasicClusters_)
1069  anElectron.embedBasicClusters();
1071  anElectron.embedPreshowerClusters();
1073  anElectron.embedPflowBasicClusters();
1075  anElectron.embedPflowPreshowerClusters();
1076  if (embedTrack_)
1077  anElectron.embedTrack();
1078 
1079  // store the match to the generated final state muons
1080  if (addGenMatch_) {
1081  for (size_t i = 0, n = genMatches.size(); i < n; ++i) {
1082  if (useParticleFlow_) {
1083  reco::GenParticleRef genElectron = (*genMatches[i])[anElectron.pfCandidateRef()];
1084  anElectron.addGenParticleRef(genElectron);
1085  } else {
1086  reco::GenParticleRef genElectron = (*genMatches[i])[elecRef];
1087  anElectron.addGenParticleRef(genElectron);
1088  }
1089  }
1090  if (embedGenMatch_)
1091  anElectron.embedGenParticle();
1092  }
1093 
1094  if (efficiencyLoader_.enabled()) {
1095  efficiencyLoader_.setEfficiencies(anElectron, elecRef);
1096  }
1097 
1098  if (resolutionLoader_.enabled()) {
1099  resolutionLoader_.setResolutions(anElectron);
1100  }
1101 
1102  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
1103  if (useParticleFlow_) {
1104  reco::PFCandidateRef pfcandref = anElectron.pfCandidateRef();
1105  assert(!pfcandref.isNull());
1106  reco::CandidatePtr source = pfcandref->sourceCandidatePtr(0);
1107  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
1108  } else
1109  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[elecRef]);
1110  }
1111 
1112  for (size_t j = 0; j < isolationValues.size(); ++j) {
1113  if (useParticleFlow_) {
1114  reco::CandidatePtr source = anElectron.pfCandidateRef()->sourceCandidatePtr(0);
1115  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
1116  } else if (pfId) {
1117  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[elecRef]);
1118  }
1119  }
1120 
1121  //for electrons not identified as PF electrons
1122  for (size_t j = 0; j < isolationValuesNoPFId.size(); ++j) {
1123  if (!pfId) {
1124  anElectron.setIsolation(isolationValueLabelsNoPFId_[j].first, (*isolationValuesNoPFId[j])[elecRef]);
1125  }
1126  }
1127 }
1128 
1130  const reco::CandidatePtr& candPtrForIsolation,
1131  const reco::CandidatePtr& candPtrForGenMatch,
1132  const reco::CandidatePtr& candPtrForLoader,
1133  const GenAssociations& genMatches,
1134  const IsoDepositMaps& deposits,
1135  const IsolationValueMaps& isolationValues) const {
1136  //COLIN/Florian: use the PFCandidate 4-mom.
1137  anElectron.setEcalDrivenMomentum(anElectron.p4());
1138  anElectron.setP4(anElectron.pfCandidateRef()->p4());
1139 
1140  // is the concrete elecRef needed for the efficiency loader? what is this loader?
1141  // how can we make it compatible with the particle flow electrons?
1142 
1144  anElectron.embedGsfElectronCore();
1145  if (embedGsfTrack_)
1146  anElectron.embedGsfTrack();
1147  if (embedSuperCluster_)
1148  anElectron.embedSuperCluster();
1150  anElectron.embedPflowSuperCluster();
1151  if (embedSeedCluster_)
1152  anElectron.embedSeedCluster();
1153  if (embedBasicClusters_)
1154  anElectron.embedBasicClusters();
1156  anElectron.embedPreshowerClusters();
1158  anElectron.embedPflowBasicClusters();
1160  anElectron.embedPflowPreshowerClusters();
1161  if (embedTrack_)
1162  anElectron.embedTrack();
1163 
1164  // store the match to the generated final state muons
1165 
1166  if (addGenMatch_) {
1167  for (size_t i = 0, n = genMatches.size(); i < n; ++i) {
1168  reco::GenParticleRef genElectron = (*genMatches[i])[candPtrForGenMatch];
1169  anElectron.addGenParticleRef(genElectron);
1170  }
1171  if (embedGenMatch_)
1172  anElectron.embedGenParticle();
1173  }
1174 
1175  //COLIN what's this? does it have to be GsfElectron specific?
1176  if (efficiencyLoader_.enabled()) {
1177  efficiencyLoader_.setEfficiencies(anElectron, candPtrForLoader);
1178  }
1179 
1180  if (resolutionLoader_.enabled()) {
1181  resolutionLoader_.setResolutions(anElectron);
1182  }
1183 
1184  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
1186  isoDepositLabels_[j].first == pat::HcalIso || deposits[j]->contains(candPtrForGenMatch.id())) {
1187  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[candPtrForGenMatch]);
1188  } else if (deposits[j]->contains(candPtrForIsolation.id())) {
1189  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[candPtrForIsolation]);
1190  } else {
1191  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
1192  }
1193  }
1194 
1195  for (size_t j = 0; j < isolationValues.size(); ++j) {
1197  isolationValueLabels_[j].first == pat::HcalIso || isolationValues[j]->contains(candPtrForGenMatch.id())) {
1198  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[candPtrForGenMatch]);
1199  } else if (isolationValues[j]->contains(candPtrForIsolation.id())) {
1200  anElectron.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[candPtrForIsolation]);
1201  } else {
1203  (*isolationValues[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
1204  }
1205  }
1206 }
1207 
1209  pat::PFIsolation miniiso;
1210  if (anElectron.isEE())
1211  miniiso = pat::getMiniPFIsolation(pc,
1212  anElectron.polarP4(),
1213  miniIsoParamsE_[0],
1214  miniIsoParamsE_[1],
1215  miniIsoParamsE_[2],
1216  miniIsoParamsE_[3],
1217  miniIsoParamsE_[4],
1218  miniIsoParamsE_[5],
1219  miniIsoParamsE_[6],
1220  miniIsoParamsE_[7],
1221  miniIsoParamsE_[8]);
1222  else
1223  miniiso = pat::getMiniPFIsolation(pc,
1224  anElectron.polarP4(),
1225  miniIsoParamsB_[0],
1226  miniIsoParamsB_[1],
1227  miniIsoParamsB_[2],
1228  miniIsoParamsB_[3],
1229  miniIsoParamsB_[4],
1230  miniIsoParamsB_[5],
1231  miniIsoParamsB_[6],
1232  miniIsoParamsB_[7],
1233  miniIsoParamsB_[8]);
1234  anElectron.setMiniPFIsolation(miniiso);
1235 }
1236 
1237 // ParameterSet description for module
1240  iDesc.setComment("PAT electron producer module");
1241 
1242  // input source
1243  iDesc.add<edm::InputTag>("pfCandidateMap", edm::InputTag("no default"))->setComment("input collection");
1244  iDesc.add<edm::InputTag>("electronSource", edm::InputTag("no default"))->setComment("input collection");
1245 
1246  iDesc.ifValue(
1247  edm::ParameterDescription<bool>("addPFClusterIso", false, true),
1249  "ecalPFClusterIsoMap", edm::InputTag("electronEcalPFClusterIsolationProducer"), true) and
1251  "hcalPFClusterIsoMap", edm::InputTag("electronHcalPFClusterIsolationProducer"), true)) or
1252  false >> (edm::ParameterDescription<edm::InputTag>("ecalPFClusterIsoMap", edm::InputTag(""), true) and
1253  edm::ParameterDescription<edm::InputTag>("hcalPFClusterIsoMap", edm::InputTag(""), true)));
1254 
1255  iDesc.ifValue(edm::ParameterDescription<bool>("addPuppiIsolation", false, true),
1257  "puppiIsolationChargedHadrons",
1258  edm::InputTag("egmElectronPUPPIIsolation", "h+-DR030-BarVeto000-EndVeto001"),
1259  true) and
1261  "puppiIsolationNeutralHadrons",
1262  edm::InputTag("egmElectronPUPPIIsolation", "h0-DR030-BarVeto000-EndVeto000"),
1263  true) and
1265  "puppiIsolationPhotons",
1266  edm::InputTag("egmElectronPUPPIIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1267  true) and
1269  "puppiNoLeptonsIsolationChargedHadrons",
1270  edm::InputTag("egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1271  true) and
1273  "puppiNoLeptonsIsolationNeutralHadrons",
1274  edm::InputTag("egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1275  true) and
1277  "puppiNoLeptonsIsolationPhotons",
1278  edm::InputTag("egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008"),
1279  true)) or
1280  false >> edm::EmptyGroupDescription());
1281 
1282  // embedding
1283  iDesc.add<bool>("embedGsfElectronCore", true)->setComment("embed external gsf electron core");
1284  iDesc.add<bool>("embedGsfTrack", true)->setComment("embed external gsf track");
1285  iDesc.add<bool>("embedSuperCluster", true)->setComment("embed external super cluster");
1286  iDesc.add<bool>("embedPflowSuperCluster", true)->setComment("embed external super cluster");
1287  iDesc.add<bool>("embedSeedCluster", true)->setComment("embed external seed cluster");
1288  iDesc.add<bool>("embedBasicClusters", true)->setComment("embed external basic clusters");
1289  iDesc.add<bool>("embedPreshowerClusters", true)->setComment("embed external preshower clusters");
1290  iDesc.add<bool>("embedPflowBasicClusters", true)->setComment("embed external pflow basic clusters");
1291  iDesc.add<bool>("embedPflowPreshowerClusters", true)->setComment("embed external pflow preshower clusters");
1292  iDesc.add<bool>("embedTrack", false)->setComment("embed external track");
1293  iDesc.add<bool>("embedRecHits", true)->setComment("embed external RecHits");
1294 
1295  // pf specific parameters
1296  iDesc.add<edm::InputTag>("pfElectronSource", edm::InputTag("pfElectrons"))
1297  ->setComment("particle flow input collection");
1298  auto&& usePfCandidateMultiMap = edm::ParameterDescription<bool>("usePfCandidateMultiMap", false, true);
1299  usePfCandidateMultiMap.setComment(
1300  "take ParticleFlow candidates from pfCandidateMultiMap instead of matching to pfElectrons by Gsf track "
1301  "reference");
1302  iDesc.ifValue(usePfCandidateMultiMap,
1303  true >> edm::ParameterDescription<edm::InputTag>("pfCandidateMultiMap", true) or
1304  false >> edm::EmptyGroupDescription());
1305  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
1306  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
1307 
1308  // MC matching configurables
1309  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
1310  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
1311  std::vector<edm::InputTag> emptySourceVector;
1312  iDesc
1313  .addNode(edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
1314  edm::ParameterDescription<std::vector<edm::InputTag>>("genParticleMatch", emptySourceVector, true))
1315  ->setComment("input with MC match information");
1316 
1317  // electron ID configurables
1318  iDesc.add<bool>("addElectronID", true)->setComment("add electron ID variables");
1319  edm::ParameterSetDescription electronIDSourcesPSet;
1320  electronIDSourcesPSet.setAllowAnything();
1321  iDesc
1322  .addNode(
1323  edm::ParameterDescription<edm::InputTag>("electronIDSource", edm::InputTag(), true) xor
1324  edm::ParameterDescription<edm::ParameterSetDescription>("electronIDSources", electronIDSourcesPSet, true))
1325  ->setComment("input with electron ID variables");
1326 
1327  // mini-iso
1328  iDesc.add<bool>("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation");
1329  iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))
1330  ->setComment("collection to use to compute mini-iso");
1331  iDesc.add<std::vector<double>>("miniIsoParamsE", std::vector<double>())
1332  ->setComment("mini-iso parameters to use for endcap electrons");
1333  iDesc.add<std::vector<double>>("miniIsoParamsB", std::vector<double>())
1334  ->setComment("mini-iso parameters to use for barrel electrons");
1335 
1336  // IsoDeposit configurables
1337  edm::ParameterSetDescription isoDepositsPSet;
1338  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
1339  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
1340  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
1341  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
1342  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1343  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
1344  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1345  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1346  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
1347  isoDepositsPSet.addOptional<std::vector<edm::InputTag>>("user");
1348  iDesc.addOptional("isoDeposits", isoDepositsPSet);
1349 
1350  // isolation values configurables
1351  edm::ParameterSetDescription isolationValuesPSet;
1352  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
1353  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
1354  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
1355  isolationValuesPSet.addOptional<edm::InputTag>("pfAllParticles");
1356  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1357  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
1358  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1359  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1360  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
1361  isolationValuesPSet.addOptional<std::vector<edm::InputTag>>("user");
1362  iDesc.addOptional("isolationValues", isolationValuesPSet);
1363 
1364  // isolation values configurables
1365  edm::ParameterSetDescription isolationValuesNoPFIdPSet;
1366  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("tracker");
1367  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("ecal");
1368  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("hcal");
1369  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfAllParticles");
1370  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfChargedHadrons");
1371  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfChargedAll");
1372  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
1373  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
1374  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfPhotons");
1375  isolationValuesNoPFIdPSet.addOptional<std::vector<edm::InputTag>>("user");
1376  iDesc.addOptional("isolationValuesNoPFId", isolationValuesNoPFIdPSet);
1377 
1378  // Efficiency configurables
1379  edm::ParameterSetDescription efficienciesPSet;
1380  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1381  iDesc.add("efficiencies", efficienciesPSet);
1382  iDesc.add<bool>("addEfficiencies", false);
1383 
1384  // Check to see if the user wants to add user data
1385  edm::ParameterSetDescription userDataPSet;
1387  iDesc.addOptional("userData", userDataPSet);
1388 
1389  // electron shapes
1390  iDesc.add<bool>("addMVAVariables", true)->setComment("embed extra variables in pat::Electron : sip3d, sigmaIEtaIPhi");
1391  iDesc.add<edm::InputTag>("reducedBarrelRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
1392  iDesc.add<edm::InputTag>("reducedEndcapRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
1393 
1394  edm::ParameterSetDescription isolationPSet;
1395  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1396  iDesc.add("userIsolation", isolationPSet);
1397 
1398  // Resolution configurables
1400 
1401  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
1402  edm::ParameterSetDescription highLevelPSet;
1403  highLevelPSet.setAllowAnything();
1404  iDesc.addNode(edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true))
1405  ->setComment("input with high level selection");
1407  ->setComment("input with high level selection");
1408 
1409  descriptions.add("PATElectronProducer", iDesc);
1410 }
1411 
1412 // embed various impact parameters with errors
1413 // embed high level selection
1418  bool primaryVertexIsValid,
1420  bool beamspotIsValid) {
1421  // Correct to PV
1422  // PV2D
1423  anElectron.setDB(track->dxy(primaryVertex.position()),
1424  track->dxyError(primaryVertex.position(), primaryVertex.covariance()),
1426 
1427  // PV3D
1428  std::pair<bool, Measurement1D> result =
1429  IPTools::signedImpactParameter3D(tt, GlobalVector(track->px(), track->py(), track->pz()), primaryVertex);
1430  double d0_corr = result.second.value();
1431  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1432  anElectron.setDB(d0_corr, d0_err, pat::Electron::PV3D);
1433 
1434  // Correct to beam spot
1435  // BS2D
1436  anElectron.setDB(track->dxy(beamspot), track->dxyError(beamspot), pat::Electron::BS2D);
1437 
1438  // make a fake vertex out of beam spot
1439  reco::Vertex vBeamspot(beamspot.position(), beamspot.covariance3D());
1440 
1441  // BS3D
1442  result = IPTools::signedImpactParameter3D(tt, GlobalVector(track->px(), track->py(), track->pz()), vBeamspot);
1443  d0_corr = result.second.value();
1444  d0_err = beamspotIsValid ? result.second.error() : -1.0;
1445  anElectron.setDB(d0_corr, d0_err, pat::Electron::BS3D);
1446 
1447  // PVDZ
1448  anElectron.setDB(
1449  track->dz(primaryVertex.position()), std::hypot(track->dzError(), primaryVertex.zError()), pat::Electron::PVDZ);
1450 }
1451 
const PflowIsolationVariables & pfIsolationVariables() const
Definition: GsfElectron.h:729
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
bool isAvailable() const
Definition: Ref.h:537
void setComment(std::string const &value)
Assists in assimilating all pat::UserData into pat objects.
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.
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:194
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
const edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
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
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
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
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:112
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< double > miniIsoParamsE_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void setAllowAnything()
allow any parameter label/value pairs
double zError() const
error on z
Definition: Vertex.h:141
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:57
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
std::vector< pat::PackedCandidate > PackedCandidateCollection
def unique
Definition: tier0.py:24
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
bool exists(std::string const &parameterName) const
checks if a parameter exists
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Electron.h:179
const edm::InputTag reducedBarrelRecHitCollection_
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
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_
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:148
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
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
assert(be >=bs)
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:738
bool isRealData() const
Definition: EventBase.h:62
const Point & position() const
position
Definition: Vertex.h:127
const std::string names[nVars_]
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopologyToken_
bool isEE() const
Definition: GsfElectron.h:329
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
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
tuple result
Definition: mps_fire.py:311
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
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:55
const edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
char const * label
void setComment(std::string const &value)
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
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?
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
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.
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)
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
void setIsolationPUPPINoLeptons(float chargedhadrons_, float neutralhadrons_, float photons_)
sets PUPPINoLeptons isolations
Definition: Electron.h:167
def move
Definition: eostools.py:511
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
tuple key
prepare the HTCondor submission files and eventually submit them
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
const edm::InputTag reducedEndcapRecHitCollection_
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void embedBasicClusters()
method to store the electron&#39;s basic clusters
bool isValid() const
Definition: HandleBase.h:70
std::pair< std::string, edm::InputTag > NameTag
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
bool isNull() const
Checks for null.
Definition: Ref.h:235
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
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
std::vector< Conversion > ConversionCollection
Definition: Conversion.h:13
const_iterator end() const
Definition: DetId.h:17
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:17
ESData get(edm::EventSetup const &eventSetup) const
const edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
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
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:751
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
T const * product() const
Definition: Handle.h:70
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
pat::helper::EfficiencyLoader efficiencyLoader_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
void setIsPF(bool hasPFCandidate)
Definition: Electron.h:174
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > pfCandidateMultiMapToken_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
Analysis-level electron class.
Definition: Electron.h:51
const CaloTopology * ecalTopology_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:217
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
IsolationLabels isolationValueLabelsNoPFId_
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
iterator find(key_type k)
std::vector< IsolationLabel > IsolationLabels
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_
const Point & position() const
position
Definition: BeamSpot.h:59
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
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
edm::Ref< l1t::PFCandidateCollection > PFCandidateRef
Definition: PFCandidate.h:58
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void embedTrack()
method to store the electron&#39;s Track internally
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
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:46
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Calculates a lepton&#39;s tracker isolation pt.
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:84