CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATElectronProducer.cc
Go to the documentation of this file.
1 //
3 
7 
12 
15 
18 
21 
22 
25 
30 
39 
41 
42 #include <vector>
43 #include <memory>
44 
45 
46 using namespace pat;
47 using namespace std;
48 
49 
51  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false) ,
52  useUserData_(iConfig.exists("userData"))
53 {
54  // general configurables
55  electronToken_ = consumes<edm::View<reco::GsfElectron> >(iConfig.getParameter<edm::InputTag>( "electronSource" ));
56  hConversionsToken_ = consumes<reco::ConversionCollection>(edm::InputTag("allConversions"));
57  embedGsfElectronCore_ = iConfig.getParameter<bool>( "embedGsfElectronCore" );
58  embedGsfTrack_ = iConfig.getParameter<bool>( "embedGsfTrack" );
59  embedSuperCluster_ = iConfig.getParameter<bool> ( "embedSuperCluster" );
60  embedPflowSuperCluster_ = iConfig.getParameter<bool> ( "embedPflowSuperCluster" );
61  embedSeedCluster_ = iConfig.getParameter<bool>( "embedSeedCluster" );
62  embedBasicClusters_ = iConfig.getParameter<bool>( "embedBasicClusters" );
63  embedPreshowerClusters_ = iConfig.getParameter<bool>( "embedPreshowerClusters" );
64  embedPflowBasicClusters_ = iConfig.getParameter<bool>( "embedPflowBasicClusters" );
65  embedPflowPreshowerClusters_ = iConfig.getParameter<bool>( "embedPflowPreshowerClusters" );
66  embedTrack_ = iConfig.getParameter<bool>( "embedTrack" );
67  embedRecHits_ = iConfig.getParameter<bool>( "embedRecHits" );
68  // pflow configurables
69  pfElecToken_ = consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>( "pfElectronSource" ));
70  pfCandidateMapToken_ = mayConsume<edm::ValueMap<reco::PFCandidatePtr> >(iConfig.getParameter<edm::InputTag>( "pfCandidateMap" ));
71  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
72  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
73  // mva input variables
74  reducedBarrelRecHitCollection_ = iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection");
75  reducedBarrelRecHitCollectionToken_ = mayConsume<EcalRecHitCollection>(reducedBarrelRecHitCollection_);
76  reducedEndcapRecHitCollection_ = iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection");
77  reducedEndcapRecHitCollectionToken_ = mayConsume<EcalRecHitCollection>(reducedEndcapRecHitCollection_);
78  // MC matching configurables (scheduled mode)
79  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
80  if (addGenMatch_) {
81  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
82  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
84  }
85  else {
86  genMatchTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" ), [this](edm::InputTag const & tag){return consumes<edm::Association<reco::GenParticleCollection> >(tag);});
87  }
88  }
89  // resolution configurables
90  addResolutions_ = iConfig.getParameter<bool>( "addResolutions" );
91  if (addResolutions_) {
92  resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"));
93  }
94  // electron ID configurables
95  addElecID_ = iConfig.getParameter<bool>( "addElectronID" );
96  if (addElecID_) {
97  // it might be a single electron ID
98  if (iConfig.existsAs<edm::InputTag>("electronIDSource")) {
99  elecIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("electronIDSource")));
100  }
101  // or there might be many of them
102  if (iConfig.existsAs<edm::ParameterSet>("electronIDSources")) {
103  // please don't configure me twice
104  if (!elecIDSrcs_.empty()){
105  throw cms::Exception("Configuration") << "PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
106  }
107  // read the different electron ID names
108  edm::ParameterSet idps = iConfig.getParameter<edm::ParameterSet>("electronIDSources");
109  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
110  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
111  elecIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
112  }
113  }
114  // but in any case at least once
115  if (elecIDSrcs_.empty()){
116  throw cms::Exception("Configuration") <<
117  "PATElectronProducer: id addElectronID is true, you must specify either:\n" <<
118  "\tInputTag electronIDSource = <someTag>\n" << "or\n" <<
119  "\tPSet electronIDSources = { \n" <<
120  "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
121  "\t}\n";
122  }
123  }
124  elecIDTokens_ = edm::vector_transform(elecIDSrcs_, [this](NameTag const & tag){return mayConsume<edm::ValueMap<float> >(tag.second);});
125  // construct resolution calculator
126 
127  // // IsoDeposit configurables
128  // if (iConfig.exists("isoDeposits")) {
129  // edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
130  // if (depconf.exists("tracker")) isoDepositLabels_.push_back(std::make_pair(TrackerIso, depconf.getParameter<edm::InputTag>("tracker")));
131  // if (depconf.exists("ecal")) isoDepositLabels_.push_back(std::make_pair(ECalIso, depconf.getParameter<edm::InputTag>("ecal")));
132  // if (depconf.exists("hcal")) isoDepositLabels_.push_back(std::make_pair(HCalIso, depconf.getParameter<edm::InputTag>("hcal")));
133 
134 
135  // if (depconf.exists("user")) {
136  // std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
137  // std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
138  // int key = UserBaseIso;
139  // for ( ; it != ed; ++it, ++key) {
140  // isoDepositLabels_.push_back(std::make_pair(IsolationKeys(key), *it));
141  // }
142  // }
143  // }
144  // isoDepositTokens_ = edm::vector_transform(isoDepositLabels_, [this](std::pair<IsolationKeys,edm::InputTag> const & label){return consumes<edm::ValueMap<IsoDeposit> >(label.second);});
145 
146  // read isoDeposit labels, for direct embedding
147  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
148  // read isolation value labels, for direct embedding
149  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_, isolationValueTokens_);
150  // read isolation value labels for non PF identified electron, for direct embedding
151  readIsolationLabels(iConfig, "isolationValuesNoPFId", isolationValueLabelsNoPFId_, isolationValueNoPFIdTokens_);
152  // Efficiency configurables
153  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
154  if (addEfficiencies_) {
155  efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
156  }
157  // Check to see if the user wants to add user data
158  if ( useUserData_ ) {
159  userDataHelper_ = PATUserDataHelper<Electron>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
160  }
161  // embed high level selection variables?
162  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
163  beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
164  if ( embedHighLevelSelection_ ) {
165  usePV_ = iConfig.getParameter<bool>("usePV");
166  pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("pvSrc"));
167  }
168  // produces vector of muons
169  produces<std::vector<Electron> >();
170  }
171 
172 
173  PATElectronProducer::~PATElectronProducer()
174 {
175 }
176 
177 
179 {
180  // switch off embedding (in unschedules mode)
181  if (iEvent.isRealData()){
182  addGenMatch_ = false;
183  embedGenMatch_ = false;
184  }
185 
186  edm::ESHandle<CaloTopology> theCaloTopology;
187  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
188  ecalTopology_ = & (*theCaloTopology);
189 
190  // Get the collection of electrons from the event
192  iEvent.getByToken(electronToken_, electrons);
193 
194  // for additional mva variables
195  edm::InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB"));
196  edm::InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE"));
197  //EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection);
199 
200  // for conversion veto selection
202  iEvent.getByToken(hConversionsToken_, hConversions);
203 
204  // Get the ESHandle for the transient track builder, if needed for
205  // high level selection embedding
207 
208  if (isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
209 
211  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
212 
213  IsoDepositMaps deposits(isoDepositTokens_.size());
214  for (size_t j = 0, nd = isoDepositTokens_.size(); j < nd; ++j) {
215  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
216  }
217 
218  IsolationValueMaps isolationValues(isolationValueTokens_.size());
219  for (size_t j = 0; j<isolationValueTokens_.size(); ++j) {
220  iEvent.getByToken(isolationValueTokens_[j], isolationValues[j]);
221  }
222 
223  IsolationValueMaps isolationValuesNoPFId(isolationValueNoPFIdTokens_.size());
224  for (size_t j = 0; j<isolationValueNoPFIdTokens_.size(); ++j) {
225  iEvent.getByToken(isolationValueNoPFIdTokens_[j], isolationValuesNoPFId[j]);
226  }
227 
228  // prepare the MC matching
229  GenAssociations genMatches(genMatchTokens_.size());
230  if (addGenMatch_) {
231  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
232  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
233  }
234  }
235 
236  // prepare ID extraction
237  std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
238  std::vector<pat::Electron::IdPair> ids;
239  if (addElecID_) {
240  idhandles.resize(elecIDSrcs_.size());
241  ids.resize(elecIDSrcs_.size());
242  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
243  iEvent.getByToken(elecIDTokens_[i], idhandles[i]);
244  ids[i].first = elecIDSrcs_[i].first;
245  }
246  }
247 
248 
249  // prepare the high level selection:
250  // needs beamline
251  reco::TrackBase::Point beamPoint(0,0,0);
252  reco::Vertex primaryVertex;
254  bool beamSpotIsValid = false;
255  bool primaryVertexIsValid = false;
256 
257  // Get the beamspot
258  edm::Handle<reco::BeamSpot> beamSpotHandle;
259  iEvent.getByToken(beamLineToken_, beamSpotHandle);
260 
261  if ( embedHighLevelSelection_ ) {
262  // Get the primary vertex
264  iEvent.getByToken( pvToken_, pvHandle );
265 
266  // This is needed by the IPTools methods from the tracking group
267  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
268 
269  if ( ! usePV_ ) {
270 
271  if ( beamSpotHandle.isValid() ){
272  beamSpot = *beamSpotHandle;
273  beamSpotIsValid = true;
274  } else{
275  edm::LogError("DataNotAvailable")
276  << "No beam spot available from EventSetup, not adding high level selection \n";
277  }
278 
279  double x0 = beamSpot.x0();
280  double y0 = beamSpot.y0();
281  double z0 = beamSpot.z0();
282 
283  beamPoint = reco::TrackBase::Point ( x0, y0, z0 );
284  } else {
285  if ( pvHandle.isValid() && !pvHandle->empty() ) {
286  primaryVertex = pvHandle->at(0);
287  primaryVertexIsValid = true;
288  } else {
289  edm::LogError("DataNotAvailable")
290  << "No primary vertex available from EventSetup, not adding high level selection \n";
291  }
292  }
293  }
294 
295  std::vector<Electron> * patElectrons = new std::vector<Electron>();
296 
297  if( useParticleFlow_ ) {
299  iEvent.getByToken(pfElecToken_, pfElectrons);
300  unsigned index=0;
301 
302  for( reco::PFCandidateConstIterator i = pfElectrons->begin();
303  i != pfElectrons->end(); ++i, ++index) {
304 
305  reco::PFCandidateRef pfRef(pfElectrons, index);
306  reco::PFCandidatePtr ptrToPFElectron(pfElectrons,index);
307 // reco::CandidateBaseRef pfBaseRef( pfRef );
308 
309  reco::GsfTrackRef PfTk= i->gsfTrackRef();
310 
311  bool Matched=false;
312  bool MatchedToAmbiguousGsfTrack=false;
313  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {
314  unsigned int idx = itElectron - electrons->begin();
315  if (Matched || MatchedToAmbiguousGsfTrack) continue;
316 
317  reco::GsfTrackRef EgTk= itElectron->gsfTrack();
318 
319  if (itElectron->gsfTrack()==i->gsfTrackRef()){
320  Matched=true;
321  }
322  else {
323  for( reco::GsfTrackRefVector::const_iterator it = itElectron->ambiguousGsfTracksBegin() ;
324  it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
325  MatchedToAmbiguousGsfTrack |= (bool)(i->gsfTrackRef()==(*it));
326  }
327  }
328 
329  if (Matched || MatchedToAmbiguousGsfTrack){
330 
331  // ptr needed for finding the matched gen particle
332  reco::CandidatePtr ptrToGsfElectron(electrons,idx);
333 
334  // ref to base needed for the construction of the pat object
335  const edm::RefToBase<reco::GsfElectron>& elecsRef = electrons->refAt(idx);
336  Electron anElectron(elecsRef);
337  anElectron.setPFCandidateRef( pfRef );
338 
339  //it should be always true when particleFlow electrons are used.
340  anElectron.setIsPF( true );
341 
342  if( embedPFCandidate_ ) anElectron.embedPFCandidate();
343 
344  if ( useUserData_ ) {
345  userDataHelper_.add( anElectron, iEvent, iSetup );
346  }
347 
348  double ip3d = -999; // for mva variable
349 
350  // embed high level selection
351  if ( embedHighLevelSelection_ ) {
352  // get the global track
353  reco::GsfTrackRef track = PfTk;
354 
355  // Make sure the collection it points to is there
356  if ( track.isNonnull() && track.isAvailable() ) {
357 
358  reco::TransientTrack tt = trackBuilder->build(track);
359  embedHighLevel( anElectron,
360  track,
361  tt,
362  primaryVertex,
363  primaryVertexIsValid,
364  beamSpot,
365  beamSpotIsValid );
366 
367  std::pair<bool,Measurement1D> ip3dpv = IPTools::absoluteImpactParameter3D(tt, primaryVertex);
368  ip3d = ip3dpv.second.value(); // for mva variable
369 
370  if ( !usePV_ ) {
371  double corr_d0 = track->dxy( beamPoint );
372  anElectron.setDB( corr_d0, -1.0 );
373  } else {
374  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
375  double d0_corr = result.second.value();
376  double d0_err = result.second.error();
377  anElectron.setDB( d0_corr, d0_err );
378  }
379  }
380  }
381 
382  //Electron Id
383 
384  if (addElecID_) {
385  //STANDARD EL ID
386  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
387  ids[i].second = (*idhandles[i])[elecsRef];
388  }
389  //SPECIFIC PF ID
390  ids.push_back(std::make_pair("pf_evspi",pfRef->mva_e_pi()));
391  ids.push_back(std::make_pair("pf_evsmu",pfRef->mva_e_mu()));
392  anElectron.setElectronIDs(ids);
393  }
394 
395  // add missing mva variables
396  double r9 = lazyTools.e3x3( *( itElectron->superCluster()->seed())) / itElectron->superCluster()->rawEnergy() ;
397  double sigmaIphiIphi;
398  double sigmaIetaIphi;
399  std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
400  if( !edm::isNotFinite(vCov[2])) sigmaIphiIphi = sqrt(vCov[2]);
401  else sigmaIphiIphi = 0;
402  sigmaIetaIphi = vCov[1];
403  anElectron.setMvaVariables( r9, sigmaIphiIphi, sigmaIetaIphi, ip3d);
404 
405  // get list of EcalDetId within 5x5 around the seed
406  bool barrel = itElectron->isEB();
407  DetId seed = lazyTools.getMaximum(*(itElectron->superCluster()->seed())).first;
408  std::vector<DetId> selectedCells = (barrel) ? ecalTopology_->getSubdetectorTopology(DetId::Ecal,EcalBarrel)->getWindow(seed,5,5):
410 
411  // Do it for all basic clusters in 5x5
412  reco::CaloCluster_iterator itscl = itElectron->superCluster()->clustersBegin();
413  reco::CaloCluster_iterator itsclE = itElectron->superCluster()->clustersEnd();
414  std::vector<DetId> cellsIn5x5;
415  for ( ; itscl!= itsclE ; ++ itscl) {
416  DetId seed=lazyTools.getMaximum(*(*itscl)).first;
417  bool bcbarrel = seed.subdetId()==EcalBarrel;
418  std::vector<DetId> cellsToAdd = (bcbarrel) ? ecalTopology_->getSubdetectorTopology(DetId::Ecal,EcalBarrel)->getWindow(seed,5,5):
420  cellsIn5x5.insert(cellsIn5x5.end(),cellsToAdd.begin(), cellsToAdd.end());
421 
422  }
423 
424  // Add to the list of selectedCells checking that there is no duplicate
425  unsigned nCellsIn5x5 = cellsIn5x5.size() ;
426 
427  for(unsigned i=0; i< nCellsIn5x5 ; ++i ) {
428  std::vector<DetId>::const_iterator itcheck = find(selectedCells.begin(), selectedCells.end(),cellsIn5x5[i]);
429  if (itcheck == selectedCells.end())
430  selectedCells.push_back(cellsIn5x5[i]);
431  }
432 
433 
434  // add the DetId of the SC
435  std::vector< std::pair<DetId, float> >::const_iterator it=itElectron->superCluster()->hitsAndFractions().begin();
436  std::vector< std::pair<DetId, float> >::const_iterator itend=itElectron->superCluster()->hitsAndFractions().end();
437  for( ; it!=itend ; ++it) {
438  DetId id=it->first;
439  // check if already saved
440  std::vector<DetId>::const_iterator itcheck = find(selectedCells.begin(),selectedCells.end(),id);
441  if ( itcheck == selectedCells.end()) {
442  selectedCells.push_back(id);
443  }
444  }
445  // Retrieve the corresponding RecHits
446 
448  if(barrel)
450  else
452 
453  EcalRecHitCollection selectedRecHits;
454  const EcalRecHitCollection *recHits = rechitsH.product();
455 
456  unsigned nSelectedCells = selectedCells.size();
457  for (unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
458  EcalRecHitCollection::const_iterator it = recHits->find( selectedCells[icell] );
459  if ( it != recHits->end() ) {
460  selectedRecHits.push_back(*it);
461  }
462  }
463  selectedRecHits.sort();
464  if (embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
465 
466  // set conversion veto selection
467  bool passconversionveto = false;
468  if( hConversions.isValid()){
469  // this is recommended method
470  passconversionveto = !ConversionTools::hasMatchedConversion( *itElectron, hConversions, beamSpotHandle->position());
471  }else{
472  // use missing hits without vertex fit method
473  passconversionveto = itElectron->gsfTrack()->trackerExpectedHitsInner().numberOfLostHits() < 1;
474  }
475 
476  anElectron.setPassConversionVeto( passconversionveto );
477 
478 
479 // fillElectron(anElectron,elecsRef,pfBaseRef,
480 // genMatches, deposits, isolationValues);
481 
482  //COLIN small warning !
483  // we are currently choosing to take the 4-momentum of the PFCandidate;
484  // the momentum of the GsfElectron is saved though
485  // we must therefore match the GsfElectron.
486  // because of this, we should not change the source of the electron matcher
487  // to the collection of PFElectrons in the python configuration
488  // I don't know what to do with the efficiencyLoader, since I don't know
489  // what this class is for.
490  fillElectron2( anElectron,
491  ptrToPFElectron,
492  ptrToGsfElectron,
493  ptrToGsfElectron,
494  genMatches, deposits, isolationValues );
495 
496  //COLIN need to use fillElectron2 in the non-pflow case as well, and to test it.
497 
498  patElectrons->push_back(anElectron);
499  }
500  }
501  //if( !Matched && !MatchedToAmbiguousGsfTrack) std::cout << "!!!!A pf electron could not be matched to a gsf!!!!" << std::endl;
502  }
503  }
504 
505  else{
506  // Try to access PF electron collection
508  bool valMapPresent = iEvent.getByToken(pfCandidateMapToken_,ValMapH);
509  // Try to access a PFCandidate collection, as supplied by the user
511  bool pfCandsPresent = iEvent.getByToken(pfElecToken_, pfElectrons);
512 
513  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {
514  // construct the Electron from the ref -> save ref to original object
515  //FIXME: looks like a lot of instances could be turned into const refs
516  unsigned int idx = itElectron - electrons->begin();
517  edm::RefToBase<reco::GsfElectron> elecsRef = electrons->refAt(idx);
518  reco::CandidateBaseRef elecBaseRef(elecsRef);
519  Electron anElectron(elecsRef);
520 
521  // Is this GsfElectron also identified as an e- in the particle flow?
522  bool pfId = false;
523 
524  if ( pfCandsPresent ) {
525  // PF electron collection not available.
526  const reco::GsfTrackRef& trkRef = itElectron->gsfTrack();
527  int index = 0;
528  for( reco::PFCandidateConstIterator ie = pfElectrons->begin();
529  ie != pfElectrons->end(); ++ie, ++index) {
530  if(ie->particleId()!=reco::PFCandidate::e) continue;
531  const reco::GsfTrackRef& pfTrkRef= ie->gsfTrackRef();
532  if( trkRef == pfTrkRef ) {
533  pfId = true;
534  reco::PFCandidateRef pfRef(pfElectrons, index);
535  anElectron.setPFCandidateRef( pfRef );
536  break;
537  }
538  }
539  }
540  else if( valMapPresent ) {
541  // use value map if PF collection not available
542  const edm::ValueMap<reco::PFCandidatePtr> & myValMap(*ValMapH);
543  // Get the PFCandidate
544  const reco::PFCandidatePtr& pfElePtr(myValMap[elecsRef]);
545  pfId= pfElePtr.isNonnull();
546  }
547  // set PFId function
548  anElectron.setIsPF( pfId );
549 
550  // add resolution info
551 
552  // Isolation
553  if (isolator_.enabled()) {
554  isolator_.fill(*electrons, idx, isolatorTmpStorage_);
555  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
556  // better to loop backwards, so the vector is resized less times
557  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
558  anElectron.setIsolation(it->first, it->second);
559  }
560  }
561 
562  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
563  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[elecsRef]);
564  }
565 
566  // add electron ID info
567  if (addElecID_) {
568  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
569  ids[i].second = (*idhandles[i])[elecsRef];
570  }
571  anElectron.setElectronIDs(ids);
572  }
573 
574 
575  if ( useUserData_ ) {
576  userDataHelper_.add( anElectron, iEvent, iSetup );
577  }
578 
579 
580  double ip3d = -999; //for mva variable
581 
582  // embed high level selection
583  if ( embedHighLevelSelection_ ) {
584  // get the global track
585  reco::GsfTrackRef track = itElectron->gsfTrack();
586 
587  // Make sure the collection it points to is there
588  if ( track.isNonnull() && track.isAvailable() ) {
589 
590  reco::TransientTrack tt = trackBuilder->build(track);
591  embedHighLevel( anElectron,
592  track,
593  tt,
594  primaryVertex,
595  primaryVertexIsValid,
596  beamSpot,
597  beamSpotIsValid );
598 
599  std::pair<bool,Measurement1D> ip3dpv = IPTools::absoluteImpactParameter3D(tt, primaryVertex);
600  ip3d = ip3dpv.second.value(); // for mva variable
601 
602  if ( !usePV_ ) {
603  double corr_d0 = track->dxy( beamPoint );
604  anElectron.setDB( corr_d0, -1.0 );
605  } else {
606  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
607  double d0_corr = result.second.value();
608  double d0_err = result.second.error();
609  anElectron.setDB( d0_corr, d0_err );
610  }
611  }
612  }
613 
614  // add mva variables
615  double r9 = lazyTools.e3x3( *( itElectron->superCluster()->seed())) / itElectron->superCluster()->rawEnergy() ;
616  double sigmaIphiIphi;
617  double sigmaIetaIphi;
618  std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
619  if( !edm::isNotFinite(vCov[2])) sigmaIphiIphi = sqrt(vCov[2]);
620  else sigmaIphiIphi = 0;
621  sigmaIetaIphi = vCov[1];
622  anElectron.setMvaVariables( r9, sigmaIphiIphi, sigmaIetaIphi, ip3d);
623 
624  // get list of EcalDetId within 5x5 around the seed
625  bool barrel= itElectron->isEB();
626 
627  DetId seed=lazyTools.getMaximum(*(itElectron->superCluster()->seed())).first;
628  std::vector<DetId> selectedCells = (barrel) ? ecalTopology_->getSubdetectorTopology(DetId::Ecal,EcalBarrel)->getWindow(seed,5,5):
630 
631 
632  // Do it for all basic clusters in 5x5
633  reco::CaloCluster_iterator itscl = itElectron->superCluster()->clustersBegin();
634  reco::CaloCluster_iterator itsclE = itElectron->superCluster()->clustersEnd();
635  std::vector<DetId> cellsIn5x5;
636  for ( ; itscl!= itsclE ; ++ itscl) {
637  DetId seed=lazyTools.getMaximum(*(*itscl)).first;
638  bool bcbarrel = seed.subdetId()==EcalBarrel;
639  std::vector<DetId> cellsToAdd = (bcbarrel) ? ecalTopology_->getSubdetectorTopology(DetId::Ecal,EcalBarrel)->getWindow(seed,5,5):
641  cellsIn5x5.insert(cellsIn5x5.end(),cellsToAdd.begin(), cellsToAdd.end());
642 
643  }
644  // Add to the list of selectedCells checking that there is no duplicate
645  unsigned nCellsIn5x5 = cellsIn5x5.size() ;
646 
647  for(unsigned i=0; i< nCellsIn5x5 ; ++i ) {
648  std::vector<DetId>::const_iterator itcheck = find(selectedCells.begin(), selectedCells.end(),cellsIn5x5[i]);
649  if (itcheck == selectedCells.end())
650  selectedCells.push_back(cellsIn5x5[i]);
651  }
652 
653  // Add all RecHits of the SC if not already present
654  std::vector< std::pair<DetId, float> >::const_iterator it=itElectron->superCluster()->hitsAndFractions().begin();
655  std::vector< std::pair<DetId, float> >::const_iterator itend=itElectron->superCluster()->hitsAndFractions().end();
656  for( ; it!=itend ; ++it) {
657  DetId id=it->first;
658  // check if already saved
659  std::vector<DetId>::const_iterator itcheck = find(selectedCells.begin(),selectedCells.end(),id);
660  if ( itcheck == selectedCells.end()) {
661  selectedCells.push_back(id);
662  }
663  }
664  // Retrieve the corresponding RecHits
665 
667  if(barrel)
669  else
671 
672  EcalRecHitCollection selectedRecHits;
673  const EcalRecHitCollection *recHits = rechitsH.product();
674 
675  unsigned nSelectedCells = selectedCells.size();
676  for (unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
677  EcalRecHitCollection::const_iterator it = recHits->find( selectedCells[icell] );
678  if ( it != recHits->end() ) {
679  selectedRecHits.push_back(*it);
680  }
681  }
682  selectedRecHits.sort();
683  if (embedRecHits_) anElectron.embedRecHits(& selectedRecHits);
684 
685  // set conversion veto selection
686  bool passconversionveto = false;
687  if( hConversions.isValid()){
688  // this is recommended method
689  passconversionveto = !ConversionTools::hasMatchedConversion( *itElectron, hConversions, beamSpotHandle->position());
690  }else{
691  // use missing hits without vertex fit method
692  passconversionveto = itElectron->gsfTrack()->trackerExpectedHitsInner().numberOfLostHits() < 1;
693  }
694  anElectron.setPassConversionVeto( passconversionveto );
695 
696  // add sel to selected
697  fillElectron( anElectron, elecsRef,elecBaseRef,
698  genMatches, deposits, pfId, isolationValues, isolationValuesNoPFId);
699  patElectrons->push_back(anElectron);
700  }
701  }
702 
703  // sort electrons in pt
704  std::sort(patElectrons->begin(), patElectrons->end(), pTComparator_);
705 
706  // add the electrons to the event output
707  std::auto_ptr<std::vector<Electron> > ptr(patElectrons);
708  iEvent.put(ptr);
709 
710  // clean up
712 
713 }
714 
716  const edm::RefToBase<reco::GsfElectron>& elecRef,
717  const reco::CandidateBaseRef& baseRef,
718  const GenAssociations& genMatches,
719  const IsoDepositMaps& deposits,
720  const bool pfId,
721  const IsolationValueMaps& isolationValues,
722  const IsolationValueMaps& isolationValuesNoPFId
723  ) const {
724 
725  //COLIN: might want to use the PFCandidate 4-mom. Which one is in use now?
726  // if (useParticleFlow_)
727  // aMuon.setP4( aMuon.pfCandidateRef()->p4() );
728 
729  //COLIN:
730  //In the embedding case, the reference cannot be used to look into a value map.
731  //therefore, one has to had the PFCandidateRef to this function, which becomes a bit
732  //too much specific.
733 
734  // in fact, this function needs a baseref or ptr for genmatch
735  // and a baseref or ptr for isodeposits and isolationvalues.
736  // baseref is not needed
737  // the ptrForIsolation and ptrForMatching should be defined upstream.
738 
739  // is the concrete elecRef needed for the efficiency loader? what is this loader?
740  // how can we make it compatible with the particle flow electrons?
741 
743  if (embedGsfTrack_) anElectron.embedGsfTrack();
744  if (embedSuperCluster_) anElectron.embedSuperCluster();
746  if (embedSeedCluster_) anElectron.embedSeedCluster();
747  if (embedBasicClusters_) anElectron.embedBasicClusters();
751  if (embedTrack_) anElectron.embedTrack();
752 
753  // store the match to the generated final state muons
754  if (addGenMatch_) {
755  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
756  if(useParticleFlow_) {
757  reco::GenParticleRef genElectron = (*genMatches[i])[anElectron.pfCandidateRef()];
758  anElectron.addGenParticleRef(genElectron);
759  }
760  else {
761  reco::GenParticleRef genElectron = (*genMatches[i])[elecRef];
762  anElectron.addGenParticleRef(genElectron);
763  }
764  }
765  if (embedGenMatch_) anElectron.embedGenParticle();
766  }
767 
768  if (efficiencyLoader_.enabled()) {
769  efficiencyLoader_.setEfficiencies( anElectron, elecRef );
770  }
771 
772  if (resolutionLoader_.enabled()) {
773  resolutionLoader_.setResolutions(anElectron);
774  }
775 
776  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
777  if(useParticleFlow_) {
778 
779  reco::PFCandidateRef pfcandref = anElectron.pfCandidateRef();
780  assert(!pfcandref.isNull());
781  reco::CandidatePtr source = pfcandref->sourceCandidatePtr(0);
783  (*deposits[j])[source]);
784  }
785  else
787  (*deposits[j])[elecRef]);
788  }
789 
790  for (size_t j = 0; j<isolationValues.size(); ++j) {
791  if(useParticleFlow_) {
792  reco::CandidatePtr source = anElectron.pfCandidateRef()->sourceCandidatePtr(0);
794  (*isolationValues[j])[source]);
795  }
796  else
797  if(pfId){
798  anElectron.setIsolation(isolationValueLabels_[j].first,(*isolationValues[j])[elecRef]);
799  }
800  }
801 
802  //for electrons not identified as PF electrons
803  for (size_t j = 0; j<isolationValuesNoPFId.size(); ++j) {
804  if( !pfId) {
805  anElectron.setIsolation(isolationValueLabelsNoPFId_[j].first,(*isolationValuesNoPFId[j])[elecRef]);
806  }
807  }
808 
809 }
810 
812  const reco::CandidatePtr& candPtrForIsolation,
813  const reco::CandidatePtr& candPtrForGenMatch,
814  const reco::CandidatePtr& candPtrForLoader,
815  const GenAssociations& genMatches,
816  const IsoDepositMaps& deposits,
817  const IsolationValueMaps& isolationValues) const {
818 
819  //COLIN/Florian: use the PFCandidate 4-mom.
820  anElectron.setEcalDrivenMomentum(anElectron.p4()) ;
821  anElectron.setP4( anElectron.pfCandidateRef()->p4() );
822 
823 
824  // is the concrete elecRef needed for the efficiency loader? what is this loader?
825  // how can we make it compatible with the particle flow electrons?
826 
828  if (embedGsfTrack_) anElectron.embedGsfTrack();
829  if (embedSuperCluster_) anElectron.embedSuperCluster();
831  if (embedSeedCluster_) anElectron.embedSeedCluster();
832  if (embedBasicClusters_) anElectron.embedBasicClusters();
836  if (embedTrack_) anElectron.embedTrack();
837 
838  // store the match to the generated final state muons
839 
840  if (addGenMatch_) {
841  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
842  reco::GenParticleRef genElectron = (*genMatches[i])[candPtrForGenMatch];
843  anElectron.addGenParticleRef(genElectron);
844  }
845  if (embedGenMatch_) anElectron.embedGenParticle();
846  }
847 
848  //COLIN what's this? does it have to be GsfElectron specific?
849  if (efficiencyLoader_.enabled()) {
850  efficiencyLoader_.setEfficiencies( anElectron, candPtrForLoader );
851  }
852 
853  if (resolutionLoader_.enabled()) {
854  resolutionLoader_.setResolutions(anElectron);
855  }
856 
857  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
861  deposits[j]->contains(candPtrForGenMatch.id())) {
863  (*deposits[j])[candPtrForGenMatch]);
864  }
865  else if (deposits[j]->contains(candPtrForIsolation.id())) {
867  (*deposits[j])[candPtrForIsolation]);
868  }
869  else {
871  (*deposits[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
872  }
873  }
874 
875  for (size_t j = 0; j<isolationValues.size(); ++j) {
879  isolationValues[j]->contains(candPtrForGenMatch.id())) {
881  (*isolationValues[j])[candPtrForGenMatch]);
882  }
883  else if (isolationValues[j]->contains(candPtrForIsolation.id())) {
885  (*isolationValues[j])[candPtrForIsolation]);
886  }
887  else {
889  (*isolationValues[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
890  }
891  }
892 }
893 
894 
895 // ParameterSet description for module
897 {
899  iDesc.setComment("PAT electron producer module");
900 
901  // input source
902  iDesc.add<edm::InputTag>("pfCandidateMap", edm::InputTag("no default"))->setComment("input collection");
903  iDesc.add<edm::InputTag>("electronSource", edm::InputTag("no default"))->setComment("input collection");
904 
905  // embedding
906  iDesc.add<bool>("embedGsfElectronCore", true)->setComment("embed external gsf electron core");
907  iDesc.add<bool>("embedGsfTrack", true)->setComment("embed external gsf track");
908  iDesc.add<bool>("embedSuperCluster", true)->setComment("embed external super cluster");
909  iDesc.add<bool>("embedPflowSuperCluster", true)->setComment("embed external super cluster");
910  iDesc.add<bool>("embedSeedCluster", true)->setComment("embed external seed cluster");
911  iDesc.add<bool>("embedBasicClusters", true)->setComment("embed external basic clusters");
912  iDesc.add<bool>("embedPreshowerClusters", true)->setComment("embed external preshower clusters");
913  iDesc.add<bool>("embedPflowBasicClusters", true)->setComment("embed external pflow basic clusters");
914  iDesc.add<bool>("embedPflowPreshowerClusters", true)->setComment("embed external pflow preshower clusters");
915  iDesc.add<bool>("embedTrack", false)->setComment("embed external track");
916  iDesc.add<bool>("embedRecHits", true)->setComment("embed external RecHits");
917 
918  // pf specific parameters
919  iDesc.add<edm::InputTag>("pfElectronSource", edm::InputTag("pfElectrons"))->setComment("particle flow input collection");
920  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
921  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
922 
923  // MC matching configurables
924  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
925  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
926  std::vector<edm::InputTag> emptySourceVector;
927  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
928  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
929  )->setComment("input with MC match information");
930 
931  // electron ID configurables
932  iDesc.add<bool>("addElectronID",true)->setComment("add electron ID variables");
933  edm::ParameterSetDescription electronIDSourcesPSet;
934  electronIDSourcesPSet.setAllowAnything();
935  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("electronIDSource", edm::InputTag(), true) xor
936  edm::ParameterDescription<edm::ParameterSetDescription>("electronIDSources", electronIDSourcesPSet, true)
937  )->setComment("input with electron ID variables");
938 
939 
940  // IsoDeposit configurables
941  edm::ParameterSetDescription isoDepositsPSet;
942  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
943  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
944  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
945  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
946  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
947  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
948  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
949  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
950  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
951  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
952  iDesc.addOptional("isoDeposits", isoDepositsPSet);
953 
954  // isolation values configurables
955  edm::ParameterSetDescription isolationValuesPSet;
956  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
957  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
958  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
959  isolationValuesPSet.addOptional<edm::InputTag>("pfAllParticles");
960  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
961  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
962  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
963  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
964  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
965  isolationValuesPSet.addOptional<std::vector<edm::InputTag> >("user");
966  iDesc.addOptional("isolationValues", isolationValuesPSet);
967 
968  // isolation values configurables
969  edm::ParameterSetDescription isolationValuesNoPFIdPSet;
970  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("tracker");
971  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("ecal");
972  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("hcal");
973  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfAllParticles");
974  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfChargedHadrons");
975  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfChargedAll");
976  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
977  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
978  isolationValuesNoPFIdPSet.addOptional<edm::InputTag>("pfPhotons");
979  isolationValuesNoPFIdPSet.addOptional<std::vector<edm::InputTag> >("user");
980  iDesc.addOptional("isolationValuesNoPFId", isolationValuesNoPFIdPSet);
981 
982  // Efficiency configurables
983  edm::ParameterSetDescription efficienciesPSet;
984  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
985  iDesc.add("efficiencies", efficienciesPSet);
986  iDesc.add<bool>("addEfficiencies", false);
987 
988  // Check to see if the user wants to add user data
989  edm::ParameterSetDescription userDataPSet;
991  iDesc.addOptional("userData", userDataPSet);
992 
993  // electron shapes
994  iDesc.add<bool>("addElectronShapes", true);
995  iDesc.add<edm::InputTag>("reducedBarrelRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
996  iDesc.add<edm::InputTag>("reducedEndcapRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
997 
998  edm::ParameterSetDescription isolationPSet;
999  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
1000  iDesc.add("userIsolation", isolationPSet);
1001 
1002  // Resolution configurables
1004 
1005  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
1006  edm::ParameterSetDescription highLevelPSet;
1007  highLevelPSet.setAllowAnything();
1008  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
1009  )->setComment("input with high level selection");
1011  )->setComment("input with high level selection");
1012  iDesc.addNode( edm::ParameterDescription<bool>("usePV", bool(), true)
1013  )->setComment("input with high level selection, use primary vertex (true) or beam line (false)");
1014 
1015  descriptions.add("PATElectronProducer", iDesc);
1016 
1017 }
1018 
1019 
1020 // embed various impact parameters with errors
1021 // embed high level selection
1023  reco::GsfTrackRef track,
1025  reco::Vertex & primaryVertex,
1026  bool primaryVertexIsValid,
1027  reco::BeamSpot & beamspot,
1028  bool beamspotIsValid
1029  )
1030 {
1031  // Correct to PV
1032 
1033  // PV2D
1034  std::pair<bool,Measurement1D> result =
1036  GlobalVector(track->px(),
1037  track->py(),
1038  track->pz()),
1039  primaryVertex);
1040  double d0_corr = result.second.value();
1041  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1042  anElectron.setDB( d0_corr, d0_err, pat::Electron::PV2D);
1043 
1044 
1045  // PV3D
1046  result =
1048  GlobalVector(track->px(),
1049  track->py(),
1050  track->pz()),
1051  primaryVertex);
1052  d0_corr = result.second.value();
1053  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1054  anElectron.setDB( d0_corr, d0_err, pat::Electron::PV3D);
1055 
1056 
1057  // Correct to beam spot
1058  // make a fake vertex out of beam spot
1059  reco::Vertex vBeamspot(beamspot.position(), beamspot.covariance3D());
1060 
1061  // BS2D
1062  result =
1064  GlobalVector(track->px(),
1065  track->py(),
1066  track->pz()),
1067  vBeamspot);
1068  d0_corr = result.second.value();
1069  d0_err = beamspotIsValid ? result.second.error() : -1.0;
1070  anElectron.setDB( d0_corr, d0_err, pat::Electron::BS2D);
1071 
1072  // BS3D
1073  result =
1075  GlobalVector(track->px(),
1076  track->py(),
1077  track->pz()),
1078  vBeamspot);
1079  d0_corr = result.second.value();
1080  d0_err = beamspotIsValid ? result.second.error() : -1.0;
1081  anElectron.setDB( d0_corr, d0_err, pat::Electron::BS3D);
1082 }
1083 
1085 
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
T getParameter(std::string const &) const
void setComment(std::string const &value)
double z0() const
z coordinate
Definition: BeamSpot.h:68
Assists in assimilating all pat::UserData into pat objects.
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:178
void embedTrack()
method to store the electron&#39;s Track internally
Definition: Electron.cc:284
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
Definition: Electron.cc:227
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:98
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
void embedGsfElectronCore()
method to store the electron&#39;s core internally
Definition: Electron.cc:190
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
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:144
void embedPflowBasicClusters()
method to store the electron&#39;s pflow basic clusters
Definition: Electron.cc:260
static const HistoName names[]
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:118
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:204
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
Definition: Electron.cc:209
void setAllowAnything()
allow any parameter label/value pairs
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
Definition: Electron.cc:347
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void setDB(double dB, double edB, IpType type=None)
Set impact parameter of a certain type and its uncertainty.
Definition: Electron.cc:423
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
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:37
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Electron.h:163
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
float e3x3(const reco::BasicCluster &cluster)
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:71
void setPassConversionVeto(bool flag)
Definition: Electron.h:234
bool isAvailable() const
Definition: Ref.h:276
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:186
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
bool isRealData() const
Definition: EventBase.h:60
void setMvaVariables(double r9, double sigmaIphiIphi, double sigmaIetaIphi, double ip3d)
set missing mva input variables
Definition: Electron.cc:435
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
Definition: Electron.cc:248
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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:175
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:192
void embedBasicClusters()
method to store the electron&#39;s basic clusters
Definition: Electron.cc:236
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void setComment(std::string const &value)
GreaterByPt< Electron > pTComparator_
pat::helper::MultiIsolator isolator_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
int iEvent
Definition: GenABIO.cc:243
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
Produces pat::Electron&#39;s.
bool isNull() const
Checks for null.
Definition: Ref.h:247
PATElectronProducer(const edm::ParameterSet &iConfig)
bool isNotFinite(T x)
Definition: isFinite.h:10
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
Definition: Electron.cc:293
void embedGenParticle()
Definition: PATObject.h:673
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:164
tuple result
Definition: query.py:137
edm::InputTag reducedEndcapRecHitCollection_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
int j
Definition: DBlmapReader.cc:9
edm::InputTag reducedBarrelRecHitCollection_
mva input variables
edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
Definition: Electron.cc:338
math::XYZPoint Point
point in the space
Definition: TrackBase.h:74
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool embedHighLevelSelection_
embed high level selection variables?
bool first
Definition: L1TdeRCT.cc:79
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
static bool hasMatchedConversion(const reco::GsfElectron &ele, const edm::Handle< reco::ConversionCollection > &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
Definition: Electron.cc:199
const_iterator end() const
Definition: DetId.h:18
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
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:657
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
pat::helper::EfficiencyLoader efficiencyLoader_
void setIsPF(bool hasPFCandidate)
Definition: Electron.h:158
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & get() const
Definition: EventSetup.h:55
pat::PATUserDataHelper< pat::Electron > userDataHelper_
void embedPflowSuperCluster()
method to store the electron&#39;s PflowSuperCluster internally
Definition: Electron.cc:218
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
bool useParticleFlow_
pflow specific
Analysis-level electron class.
Definition: Electron.h:50
const CaloTopology * ecalTopology_
std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster)
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:26
IsolationLabels isolationValueLabelsNoPFId_
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
std::pair< bool, Measurement1D > absoluteTransverseImpactParameter(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:43
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
iterator find(key_type k)
IsolationLabels isolationValueLabels_
double y0() const
y coordinate
Definition: BeamSpot.h:66
pat::helper::KinResolutionsLoader resolutionLoader_
const Point & position() const
position
Definition: BeamSpot.h:62
volatile std::atomic< bool > shutdown_flag false
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
static std::string const source
Definition: EdmProvDump.cc:43
void embedPflowPreshowerClusters()
method to store the electron&#39;s pflow preshower clusters
Definition: Electron.cc:272
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
Global3DVector GlobalVector
Definition: GlobalVector.h:10
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
double x0() const
x coordinate
Definition: BeamSpot.h:64
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps