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