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