CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFElectronTranslator.cc
Go to the documentation of this file.
20 
21 
24  = iConfig.getParameter<edm::InputTag>("PFCandidate");
26  = iConfig.getParameter<edm::InputTag>("PFCandidateElectron");
28  = iConfig.getParameter<edm::InputTag>("GSFTracks");
29 
30  bool useIsolationValues = iConfig.getParameter<bool>("useIsolationValues") ;
31  if ( useIsolationValues ) {
32  if( ! iConfig.exists("isolationValues") )
33  throw cms::Exception("PFElectronTranslator|InternalError")
34  <<"Missing ParameterSet isolationValues" ;
35  else {
36  edm::ParameterSet isoVals =
37  iConfig.getParameter<edm::ParameterSet> ("isolationValues");
38  inputTagIsoVals_.push_back
39  (isoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
40  inputTagIsoVals_.push_back
41  (isoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
42  inputTagIsoVals_.push_back
43  (isoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
44  inputTagIsoVals_.push_back
45  (isoVals.getParameter<edm::InputTag>("pfSumPUPt"));
46  }
47  }
48 
49  PFBasicClusterCollection_ = iConfig.getParameter<std::string>("PFBasicClusters");
50  PFPreshowerClusterCollection_ = iConfig.getParameter<std::string>("PFPreshowerClusters");
51  PFSuperClusterCollection_ = iConfig.getParameter<std::string>("PFSuperClusters");
52  GsfElectronCoreCollection_ = iConfig.getParameter<std::string>("PFGsfElectronCore");
53  GsfElectronCollection_ = iConfig.getParameter<std::string>("PFGsfElectron");
54 
55  PFMVAValueMap_ = iConfig.getParameter<std::string>("ElectronMVA");
56  PFSCValueMap_ = iConfig.getParameter<std::string>("ElectronSC");
57  MVACut_ = (iConfig.getParameter<edm::ParameterSet>("MVACutBlock")).getParameter<double>("MVACut");
58  checkStatusFlag_ = iConfig.getParameter<bool>("CheckStatusFlag");
59 
60  if (iConfig.exists("emptyIsOk")) emptyIsOk_ = iConfig.getParameter<bool>("emptyIsOk");
61  else emptyIsOk_=false;
62 
63  produces<reco::BasicClusterCollection>(PFBasicClusterCollection_);
64  produces<reco::PreshowerClusterCollection>(PFPreshowerClusterCollection_);
65  produces<reco::SuperClusterCollection>(PFSuperClusterCollection_);
66  produces<reco::GsfElectronCoreCollection>(GsfElectronCoreCollection_);
67  produces<reco::GsfElectronCollection>(GsfElectronCollection_);
68  produces<edm::ValueMap<float> >(PFMVAValueMap_);
69  produces<edm::ValueMap<reco::SuperClusterRef> >(PFSCValueMap_);
70 }
71 
73 
75  const edm::EventSetup& iSetup) {
76 
77  std::auto_ptr<reco::GsfElectronCoreCollection>
78  gsfElectronCores_p(new reco::GsfElectronCoreCollection);
79 
80  std::auto_ptr<reco::GsfElectronCollection>
81  gsfElectrons_p(new reco::GsfElectronCollection);
82 
83  std::auto_ptr<reco::SuperClusterCollection>
84  superClusters_p(new reco::SuperClusterCollection);
85 
86  std::auto_ptr<reco::BasicClusterCollection>
87  basicClusters_p(new reco::BasicClusterCollection);
88 
89  std::auto_ptr<reco::PreshowerClusterCollection>
90  psClusters_p(new reco::PreshowerClusterCollection);
91 
92  std::auto_ptr<edm::ValueMap<float> > mvaMap_p(new edm::ValueMap<float>());
93  edm::ValueMap<float>::Filler mvaFiller(*mvaMap_p);
94 
95  std::auto_ptr<edm::ValueMap<reco::SuperClusterRef> >
98 
99 
101  bool status=fetchCandidateCollection(pfCandidates,
103  iEvent );
104 
105  IsolationValueMaps isolationValues(inputTagIsoVals_.size());
106  for (size_t j = 0; j<inputTagIsoVals_.size(); ++j) {
107  iEvent.getByLabel(inputTagIsoVals_[j], isolationValues[j]);
108  }
109 
110 
111  // clear the vectors
112  GsfTrackRef_.clear();
113  CandidatePtr_.clear();
114  ambiguousGsfTracks_.clear();
115  kfTrackRef_.clear();
116  basicClusters_.clear();
117  pfClusters_.clear();
118  preshowerClusters_.clear();
119  superClusters_.clear();
120  basicClusterPtr_.clear();
121  preshowerClusterPtr_.clear();
122  gsfPFCandidateIndex_.clear();
123  gsfElectronCoreRefs_.clear();
124  scMap_.clear();
125 
126 
127  // loop on the candidates
128  //CC@@
129  // we need first to create AND put the SuperCluster,
130  // basic clusters and presh clusters collection
131  // in order to get a working Handle
132  unsigned ncand=(status)?pfCandidates->size():0;
133  unsigned iGSF=0;
134  for( unsigned i=0; i<ncand; ++i ) {
135 
136  const reco::PFCandidate& cand = (*pfCandidates)[i];
137  if(cand.particleId()!=reco::PFCandidate::e) continue;
138  if(cand.gsfTrackRef().isNull()) continue;
139  // Note that -1 will still cut some total garbage candidates
140  // Fill the MVA map
141  if(cand.mva_e_pi()<MVACut_) continue;
142 
143  // Check the status flag
145  continue;
146  }
147 
148  GsfTrackRef_.push_back(cand.gsfTrackRef());
149  kfTrackRef_.push_back(cand.trackRef());
150  gsfPFCandidateIndex_.push_back(i);
151 
152  reco::PFCandidatePtr ptrToPFElectron(pfCandidates,i);
153  //CandidatePtr_.push_back(ptrToPFElectron->sourceCandidatePtr(0));
154  CandidatePtr_.push_back(ptrToPFElectron);
155 
157  pfClusters_.push_back(std::vector<const reco::PFCluster *>());
159  ambiguousGsfTracks_.push_back(std::vector<reco::GsfTrackRef>());
160 
161  for(unsigned iele=0; iele<cand.elementsInBlocks().size(); ++iele) {
162  // first get the block
163  reco::PFBlockRef blockRef = cand.elementsInBlocks()[iele].first;
164  //
165  unsigned elementIndex = cand.elementsInBlocks()[iele].second;
166  // check it actually exists
167  if(blockRef.isNull()) continue;
168 
169  // then get the elements of the block
170  const edm::OwnVector< reco::PFBlockElement >& elements = (*blockRef).elements();
171 
172  const reco::PFBlockElement & pfbe (elements[elementIndex]);
173  // The first ECAL element should be the cluster associated to the GSF; defined as the seed
174  if(pfbe.type()==reco::PFBlockElement::ECAL)
175  {
176  // const reco::PFCandidate * coCandidate = &cand;
177  // the Brem photons are saved as daughter PFCandidate; this
178  // is convenient to access the corrected energy
179  // std::cout << " Found candidate " << correspondingDaughterCandidate(coCandidate,pfbe) << " " << coCandidate << std::endl;
181  }
182  if(pfbe.type()==reco::PFBlockElement::PS1)
183  {
185  }
186  if(pfbe.type()==reco::PFBlockElement::PS2)
187  {
189  }
190  if(pfbe.type()==reco::PFBlockElement::GSF)
191  {
193  }
194 
195  } // loop on the elements
196 
197  // save the basic clusters
198  basicClusters_p->insert(basicClusters_p->end(),basicClusters_[iGSF].begin(), basicClusters_[iGSF].end());
199  // save the preshower clusters
200  psClusters_p->insert(psClusters_p->end(),preshowerClusters_[iGSF].begin(),preshowerClusters_[iGSF].end());
201 
202  ++iGSF;
203  } // loop on PFCandidates
204 
205 
206  //Save the basic clusters and get an handle as to be able to create valid Refs (thanks to Claude)
207  // std::cout << " Number of basic clusters " << basicClusters_p->size() << std::endl;
209  iEvent.put(basicClusters_p,PFBasicClusterCollection_);
210 
211  //preshower clusters
213  iEvent.put(psClusters_p,PFPreshowerClusterCollection_);
214 
215  // now that the Basic clusters are in the event, the Ref can be created
216  createBasicClusterPtrs(bcRefProd);
217  // now that the preshower clusters are in the event, the Ref can be created
218  createPreshowerClusterPtrs(psRefProd);
219 
220  // and now the Super cluster can be created with valid references
221  if(status) createSuperClusters(*pfCandidates,*superClusters_p);
222 
223  // Let's put the super clusters in the event
224  const edm::OrphanHandle<reco::SuperClusterCollection> scRefProd = iEvent.put(superClusters_p,PFSuperClusterCollection_);
225  // create the super cluster Ref
226  createSuperClusterGsfMapRefs(scRefProd);
227 
228  // Now create the GsfElectronCoers
229  createGsfElectronCores(*gsfElectronCores_p);
230  // Put them in the as to get to be able to build a Ref
231  const edm::OrphanHandle<reco::GsfElectronCoreCollection> gsfElectronCoreRefProd =
232  iEvent.put(gsfElectronCores_p,GsfElectronCoreCollection_);
233 
234  // now create the Refs
235  createGsfElectronCoreRefs(gsfElectronCoreRefProd);
236 
237  // now make the GsfElectron
238  createGsfElectrons(*pfCandidates,isolationValues,*gsfElectrons_p);
239  iEvent.put(gsfElectrons_p,GsfElectronCollection_);
240 
241  fillMVAValueMap(iEvent,mvaFiller);
242  mvaFiller.fill();
243 
244  fillSCRefValueMap(iEvent,scRefFiller);
245  scRefFiller.fill();
246 
247  // MVA map
248  iEvent.put(mvaMap_p,PFMVAValueMap_);
249  // Gsf-SC map
250  iEvent.put(scMap_p,PFSCValueMap_);
251 
252 
253 
254 }
255 
256 
257 
259  const edm::InputTag& tag,
260  const edm::Event& iEvent) const {
261  bool found = iEvent.getByLabel(tag, c);
262 
263  if(!found && !emptyIsOk_)
264  {
265  std::ostringstream err;
266  err<<" cannot get PFCandidates: "
267  <<tag<<std::endl;
268  edm::LogError("PFElectronTranslator")<<err.str();
269  }
270  return found;
271 
272 }
273 
275  const edm::InputTag& tag,
276  const edm::Event& iEvent) const {
277  bool found = iEvent.getByLabel(tag, c);
278 
279  if(!found ) {
280  std::ostringstream err;
281  err<<" cannot get GSFTracks: "
282  <<tag<<std::endl;
283  edm::LogError("PFElectronTranslator")<<err.str();
284  throw cms::Exception( "MissingProduct", err.str());
285  }
286 }
287 
288 // The basic cluster is a copy of the PFCluster -> the energy is not corrected
289 // It should be possible to get the corrected energy (including the associated PS energy)
290 // from the PFCandidate daugthers ; Needs some work
292  reco::BasicClusterCollection & basicClusters,
293  std::vector<const reco::PFCluster *> & pfClusters,
294  const reco::PFCandidate & coCandidate) const
295 {
296  reco::PFClusterRef myPFClusterRef= PFBE.clusterRef();
297  if(myPFClusterRef.isNull()) return;
298 
299  const reco::PFCluster & myPFCluster (*myPFClusterRef);
300  pfClusters.push_back(&myPFCluster);
301 // std::cout << " Creating BC " << myPFCluster.energy() << " " << coCandidate.ecalEnergy() <<" "<< coCandidate.rawEcalEnergy() <<std::endl;
302 // std::cout << " # hits " << myPFCluster.hitsAndFractions().size() << std::endl;
303 
304 // basicClusters.push_back(reco::CaloCluster(myPFCluster.energy(),
305  basicClusters.push_back(reco::CaloCluster(
306  // myPFCluster.energy(),
307  coCandidate.rawEcalEnergy(),
308  myPFCluster.position(),
309  myPFCluster.caloID(),
310  myPFCluster.hitsAndFractions(),
311  myPFCluster.algo(),
312  myPFCluster.seed()));
313 }
314 
315 
317 {
318  reco::PFClusterRef myPFClusterRef= PFBE.clusterRef();
319  preshowerClusters.push_back(reco::PreshowerCluster(myPFClusterRef->energy(),myPFClusterRef->position(),
320  myPFClusterRef->hitsAndFractions(),plane));
321 }
322 
324 {
325  unsigned size=GsfTrackRef_.size();
326  unsigned basicClusterCounter=0;
327  basicClusterPtr_.resize(size);
328 
329  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
330  {
331  unsigned nbc=basicClusters_[iGSF].size();
332  for(unsigned ibc=0;ibc<nbc;++ibc) // loop on basic clusters
333  {
334  // std::cout << "Track "<< iGSF << " ref " << basicClusterCounter << std::endl;
335  reco::CaloClusterPtr bcPtr(basicClustersHandle,basicClusterCounter);
336  basicClusterPtr_[iGSF].push_back(bcPtr);
337  ++basicClusterCounter;
338  }
339  }
340 }
341 
343 {
344  unsigned size=GsfTrackRef_.size();
345  unsigned psClusterCounter=0;
346  preshowerClusterPtr_.resize(size);
347 
348  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
349  {
350  unsigned nbc=preshowerClusters_[iGSF].size();
351  for(unsigned ibc=0;ibc<nbc;++ibc) // loop on basic clusters
352  {
353  // std::cout << "Track "<< iGSF << " ref " << basicClusterCounter << std::endl;
354  reco::CaloClusterPtr psPtr(preshowerClustersHandle,psClusterCounter);
355  preshowerClusterPtr_[iGSF].push_back(psPtr);
356  ++psClusterCounter;
357  }
358  }
359 }
360 
362 {
363  unsigned size=GsfTrackRef_.size();
364 
365  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
366  {
367  edm::Ref<reco::SuperClusterCollection> scRef(superClustersHandle,iGSF);
368  scMap_[GsfTrackRef_[iGSF]]=scRef;
369  }
370 }
371 
372 
374 {
375  gsfMvaMap_.clear();
377  bool status=fetchCandidateCollection(pfCandidates,
379  iEvent );
380 
381  unsigned ncand=(status)?pfCandidates->size():0;
382  for( unsigned i=0; i<ncand; ++i ) {
383 
384  const reco::PFCandidate& cand = (*pfCandidates)[i];
385  if(cand.particleId()!=reco::PFCandidate::e) continue;
386  if(cand.gsfTrackRef().isNull()) continue;
387  // Fill the MVA map
388  gsfMvaMap_[cand.gsfTrackRef()]=cand.mva_e_pi();
389  }
390 
392  fetchGsfCollection(gsfTracks,
394  iEvent);
395  unsigned ngsf=gsfTracks->size();
396  std::vector<float> values;
397  for(unsigned igsf=0;igsf<ngsf;++igsf)
398  {
399  reco::GsfTrackRef theTrackRef(gsfTracks, igsf);
400  std::map<reco::GsfTrackRef,float>::const_iterator itcheck=gsfMvaMap_.find(theTrackRef);
401  if(itcheck==gsfMvaMap_.end())
402  {
403  // edm::LogWarning("PFElectronTranslator") << "MVA Map, missing GSF track ref " << std::endl;
404  values.push_back(-99.);
405  // std::cout << " Push_back -99. " << std::endl;
406  }
407  else
408  {
409  // std::cout << " Value " << itcheck->second << std::endl;
410  values.push_back(itcheck->second);
411  }
412  }
413  filler.insert(gsfTracks,values.begin(),values.end());
414 }
415 
416 
419 {
421  fetchGsfCollection(gsfTracks,
423  iEvent);
424  unsigned ngsf=gsfTracks->size();
425  std::vector<reco::SuperClusterRef> values;
426  for(unsigned igsf=0;igsf<ngsf;++igsf)
427  {
428  reco::GsfTrackRef theTrackRef(gsfTracks, igsf);
429  std::map<reco::GsfTrackRef,reco::SuperClusterRef>::const_iterator itcheck=scMap_.find(theTrackRef);
430  if(itcheck==scMap_.end())
431  {
432  // edm::LogWarning("PFElectronTranslator") << "SCRef Map, missing GSF track ref" << std::endl;
433  values.push_back(reco::SuperClusterRef());
434  }
435  else
436  {
437  values.push_back(itcheck->second);
438  }
439  }
440  filler.insert(gsfTracks,values.begin(),values.end());
441 }
442 
443 
445  reco::SuperClusterCollection &superClusters) const
446 {
447  unsigned nGSF=GsfTrackRef_.size();
448  for(unsigned iGSF=0;iGSF<nGSF;++iGSF)
449  {
450 
451  // Computes energy position a la e/gamma
452  double sclusterE=0;
453  double posX=0.;
454  double posY=0.;
455  double posZ=0.;
456 
457  unsigned nbasics=basicClusters_[iGSF].size();
458  for(unsigned ibc=0;ibc<nbasics;++ibc)
459  {
460  double e = basicClusters_[iGSF][ibc].energy();
461  sclusterE += e;
462  posX += e * basicClusters_[iGSF][ibc].position().X();
463  posY += e * basicClusters_[iGSF][ibc].position().Y();
464  posZ += e * basicClusters_[iGSF][ibc].position().Z();
465  }
466  posX /=sclusterE;
467  posY /=sclusterE;
468  posZ /=sclusterE;
469 
470  if(pfCand[gsfPFCandidateIndex_[iGSF]].gsfTrackRef()!=GsfTrackRef_[iGSF])
471  {
472  edm::LogError("PFElectronTranslator") << " Major problem in PFElectron Translator" << std::endl;
473  }
474 
475  // compute the width
476  PFClusterWidthAlgo pfwidth(pfClusters_[iGSF]);
477 
478  double correctedEnergy=pfCand[gsfPFCandidateIndex_[iGSF]].ecalEnergy();
479  reco::SuperCluster mySuperCluster(correctedEnergy,math::XYZPoint(posX,posY,posZ));
480  // protection against empty basic cluster collection ; the value is -2 in this case
481  if(nbasics)
482  {
483 // std::cout << "SuperCluster creation; energy " << pfCand[gsfPFCandidateIndex_[iGSF]].ecalEnergy();
484 // std::cout << " " << pfCand[gsfPFCandidateIndex_[iGSF]].rawEcalEnergy() << std::endl;
485 // std::cout << "Seed energy from basic " << basicClusters_[iGSF][0].energy() << std::endl;
486  mySuperCluster.setSeed(basicClusterPtr_[iGSF][0]);
487  }
488  else
489  {
490  // std::cout << "SuperCluster creation ; seed energy " << 0 << std::endl;
491 // std::cout << "SuperCluster creation ; energy " << pfCand[gsfPFCandidateIndex_[iGSF]].ecalEnergy();
492 // std::cout << " " << pfCand[gsfPFCandidateIndex_[iGSF]].rawEcalEnergy() << std::endl;
493 // std::cout << " No seed found " << 0 << std::endl;
494 // std::cout << " MVA " << pfCand[gsfPFCandidateIndex_[iGSF]].mva_e_pi() << std::endl;
495  mySuperCluster.setSeed(reco::CaloClusterPtr());
496  }
497  // the seed should be the first basic cluster
498 
499  for(unsigned ibc=0;ibc<nbasics;++ibc)
500  {
501  mySuperCluster.addCluster(basicClusterPtr_[iGSF][ibc]);
502  // std::cout <<"Adding Ref to SC " << basicClusterPtr_[iGSF][ibc].index() << std::endl;
503  const std::vector< std::pair<DetId, float> > & v1 = basicClusters_[iGSF][ibc].hitsAndFractions();
504  // std::cout << " Number of cells " << v1.size() << std::endl;
505  for( std::vector< std::pair<DetId, float> >::const_iterator diIt = v1.begin();
506  diIt != v1.end();
507  ++diIt ) {
508  // std::cout << " Adding DetId " << (diIt->first).rawId() << " " << diIt->second << std::endl;
509  mySuperCluster.addHitAndFraction(diIt->first,diIt->second);
510  } // loop over rechits
511  }
512 
513  unsigned nps=preshowerClusterPtr_[iGSF].size();
514  for(unsigned ips=0;ips<nps;++ips)
515  {
516  mySuperCluster.addPreshowerCluster(preshowerClusterPtr_[iGSF][ips]);
517  }
518 
519 
520  // Set the preshower energy
521  mySuperCluster.setPreshowerEnergy(pfCand[gsfPFCandidateIndex_[iGSF]].pS1Energy()+
522  pfCand[gsfPFCandidateIndex_[iGSF]].pS2Energy());
523 
524  // Set the cluster width
525  mySuperCluster.setEtaWidth(pfwidth.pflowEtaWidth());
526  mySuperCluster.setPhiWidth(pfwidth.pflowPhiWidth());
527  // Force the computation of rawEnergy_ of the reco::SuperCluster
528  mySuperCluster.rawEnergy();
529  superClusters.push_back(mySuperCluster);
530  }
531 }
532 
533 
535 {
536  unsigned refindex=pfbe.index();
537  // std::cout << " N daughters " << cand.numberOfDaughters() << std::endl;
538  reco::PFCandidate::const_iterator myDaughterCandidate=cand.begin();
540 
541  for(;myDaughterCandidate!=itend;++myDaughterCandidate)
542  {
543  const reco::PFCandidate * myPFCandidate = (const reco::PFCandidate*)&*myDaughterCandidate;
544  if(myPFCandidate->elementsInBlocks().size()!=1)
545  {
546  // std::cout << " Daughter with " << myPFCandidate.elementsInBlocks().size()<< " element in block " << std::endl;
547  return cand;
548  }
549  if(myPFCandidate->elementsInBlocks()[0].second==refindex)
550  {
551  // std::cout << " Found it " << cand << std::endl;
552  return *myPFCandidate;
553  }
554  }
555  return cand;
556 }
557 
559  unsigned nGSF=GsfTrackRef_.size();
560  for(unsigned iGSF=0;iGSF<nGSF;++iGSF)
561  {
562  reco::GsfElectronCore myElectronCore(GsfTrackRef_[iGSF]);
563  myElectronCore.setCtfTrack(kfTrackRef_[iGSF],-1.);
564  std::map<reco::GsfTrackRef,reco::SuperClusterRef>::const_iterator
565  itcheck=scMap_.find(GsfTrackRef_[iGSF]);
566  if(itcheck!=scMap_.end())
567  myElectronCore.setParentSuperCluster(itcheck->second);
568  gsfElectronCores.push_back(myElectronCore);
569  }
570 }
571 
573  unsigned size=GsfTrackRef_.size();
574 
575  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
576  {
577  edm::Ref<reco::GsfElectronCoreCollection> elecCoreRef(gsfElectronCoreHandle,iGSF);
578  gsfElectronCoreRefs_.push_back(elecCoreRef);
579  }
580 }
581 
582 void PFElectronTranslator::getAmbiguousGsfTracks(const reco::PFBlockElement & PFBE, std::vector<reco::GsfTrackRef>& tracks) const {
583  const reco::PFBlockElementGsfTrack * GsfEl = dynamic_cast<const reco::PFBlockElementGsfTrack*>(&PFBE);
584  if(GsfEl==0) return;
585  const std::vector<reco::GsfPFRecTrackRef>& ambPFRecTracks(GsfEl->GsftrackRefPF()->convBremGsfPFRecTrackRef());
586  unsigned ntracks=ambPFRecTracks.size();
587  for(unsigned it=0;it<ntracks;++it) {
588  tracks.push_back(ambPFRecTracks[it]->gsfTrackRef());
589  }
590 }
591 
592 
594  const IsolationValueMaps& isolationValues,
595  reco::GsfElectronCollection &gsfelectrons) {
596  unsigned size=GsfTrackRef_.size();
597 
598  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
599  {
600  const reco::PFCandidate& pfCandidate(pfcand[gsfPFCandidateIndex_[iGSF]]);
601  // Electron
602  reco::GsfElectron myElectron(gsfElectronCoreRefs_[iGSF]);
603  // Warning set p4 error !
604  myElectron.setP4(reco::GsfElectron::P4_PFLOW_COMBINATION, pfCandidate.p4(),pfCandidate.deltaP(), true);
605 
606  // MVA inputs
607  reco::GsfElectron::MvaInput myMvaInput;
608  myMvaInput.earlyBrem = pfCandidate.electronExtraRef()->mvaVariable(reco::PFCandidateElectronExtra::MVA_FirstBrem);
609  myMvaInput.lateBrem = pfCandidate.electronExtraRef()->mvaVariable(reco::PFCandidateElectronExtra::MVA_LateBrem);
611  myMvaInput.sigmaEtaEta = pfCandidate.electronExtraRef()->sigmaEtaEta();
612  myMvaInput.hadEnergy = pfCandidate.electronExtraRef()->hadEnergy();
613 
614  // Mustache
615  reco::Mustache myMustache;
616  myMustache.MustacheID(*(myElectron. parentSuperCluster()), myMvaInput.nClusterOutsideMustache, myMvaInput.etOutsideMustache );
617 
618  myElectron.setMvaInput(myMvaInput);
619 
620  // MVA output
621  reco::GsfElectron::MvaOutput myMvaOutput;
622  myMvaOutput.status = pfCandidate.electronExtraRef()->electronStatus();
623  myMvaOutput.mva_e_pi = pfCandidate.mva_e_pi();
624  myElectron.setMvaOutput(myMvaOutput);
625 
626  // ambiguous tracks
627  unsigned ntracks=ambiguousGsfTracks_[iGSF].size();
628  for(unsigned it=0;it<ntracks;++it) {
629  myElectron.addAmbiguousGsfTrack(ambiguousGsfTracks_[iGSF][it]);
630  }
631 
632  // isolation
633  if( isolationValues.size() != 0 ) {
635  myPFIso.sumChargedHadronPt=(*isolationValues[0])[CandidatePtr_[iGSF]];
636  myPFIso.sumPhotonEt=(*isolationValues[1])[CandidatePtr_[iGSF]];
637  myPFIso.sumNeutralHadronEt=(*isolationValues[2])[CandidatePtr_[iGSF]];
638  myPFIso.sumPUPt=(*isolationValues[3])[CandidatePtr_[iGSF]];
639  myElectron.setPfIsolationVariables(myPFIso);
640  }
641 
642  gsfelectrons.push_back(myElectron);
643  }
644 
645 }
646 
647 
std::vector< std::vector< const reco::PFCluster * > > pfClusters_
T getParameter(std::string const &) const
std::string PFPreshowerClusterCollection_
Abstract base class for a PFBlock element (track, cluster...)
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
void setCtfTrack(const TrackRef &closestCtfTrack, float ctfGsfOverlap)
int i
Definition: DBlmapReader.cc:9
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:197
void MustacheID(const CaloClusterPtrVector &clusters, int &nclusters, float &EoutsideMustache)
Definition: Mustache.cc:162
bool fetchCandidateCollection(edm::Handle< reco::PFCandidateCollection > &c, const edm::InputTag &tag, const edm::Event &iEvent) const
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:224
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:185
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
virtual void produce(edm::Event &, const edm::EventSetup &) override
void createGsfElectronCoreRefs(const edm::OrphanHandle< reco::GsfElectronCoreCollection > &gsfElectronCoreHandle)
virtual const PFClusterRef & clusterRef() const
std::map< reco::GsfTrackRef, float > gsfMvaMap_
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
Type type() const
std::vector< reco::CaloClusterPtrVector > basicClusterPtr_
std::vector< reco::GsfElectronCoreRef > gsfElectronCoreRefs_
double pflowPhiWidth() const
void setMvaInput(const MvaInput &mi)
Definition: GsfElectron.h:610
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
void createBasicClusterPtrs(const edm::OrphanHandle< reco::BasicClusterCollection > &basicClustersHandle)
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:566
bool exists(std::string const &parameterName) const
checks if a parameter exists
list elements
Definition: asciidump.py:414
const GsfPFRecTrackRef & GsftrackRefPF() const
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:192
void setSeed(const CaloClusterPtr &r)
list of used xtals by DetId // now inherited by CaloCluster
Definition: SuperCluster.h:96
std::string GsfElectronCollection_
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:609
void setPhiWidth(double pw)
Definition: SuperCluster.h:62
void setMvaOutput(const MvaOutput &mo)
Definition: GsfElectron.h:611
double pflowEtaWidth() const
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
void fillSCRefValueMap(edm::Event &iEvent, edm::ValueMap< reco::SuperClusterRef >::Filler &filler) const
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:172
void setEtaWidth(double ew)
Definition: SuperCluster.h:63
std::vector< reco::GsfTrackRef > GsfTrackRef_
int iEvent
Definition: GenABIO.cc:230
void fillMVAValueMap(edm::Event &iEvent, edm::ValueMap< float >::Filler &filler)
void setParentSuperCluster(const SuperClusterRef &scl)
const CaloID & caloID() const
Definition: CaloCluster.h:183
const reco::PFCandidate & correspondingDaughterCandidate(const reco::PFCandidate &cand, const reco::PFBlockElement &pfbe) const
unsigned index() const
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:561
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
std::vector< GsfElectronCore > GsfElectronCoreCollection
std::vector< reco::PreshowerClusterCollection > preshowerClusters_
void createSuperClusterGsfMapRefs(const edm::OrphanHandle< reco::SuperClusterCollection > &superClustersHandle)
int j
Definition: DBlmapReader.cc:9
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:560
std::vector< int > gsfPFCandidateIndex_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
edm::InputTag inputTagPFCandidateElectrons_
bool isNull() const
Checks for null.
Definition: Ref.h:247
std::vector< reco::CandidatePtr > CandidatePtr_
edm::InputTag inputTagPFCandidates_
std::vector< std::vector< reco::GsfTrackRef > > ambiguousGsfTracks_
std::map< reco::GsfTrackRef, reco::SuperClusterRef > scMap_
edm::InputTag inputTagGSFTracks_
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:313
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
reco::PFCandidateElectronExtraRef electronExtraRef() const
return a reference to the electron extra
Definition: PFCandidate.cc:584
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:202
void fetchGsfCollection(edm::Handle< reco::GsfTrackCollection > &c, const edm::InputTag &tag, const edm::Event &iEvent) const
std::string PFBasicClusterCollection_
void createBasicCluster(const reco::PFBlockElement &, reco::BasicClusterCollection &basicClusters, std::vector< const reco::PFCluster * > &, const reco::PFCandidate &coCandidate) const
std::vector< reco::SuperClusterCollection > superClusters_
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< reco::CaloClusterPtrVector > preshowerClusterPtr_
void createSuperClusters(const reco::PFCandidateCollection &, reco::SuperClusterCollection &superClusters) const
void addPreshowerCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
Definition: SuperCluster.h:117
void getAmbiguousGsfTracks(const reco::PFBlockElement &PFBE, std::vector< reco::GsfTrackRef > &) const
std::string GsfElectronCoreCollection_
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
std::vector< edm::InputTag > inputTagIsoVals_
void addCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
Definition: SuperCluster.h:111
std::vector< reco::BasicClusterCollection > basicClusters_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::vector< reco::TrackRef > kfTrackRef_
void createPreshowerCluster(const reco::PFBlockElement &PFBE, reco::PreshowerClusterCollection &preshowerClusters, unsigned plane) const
PFElectronTranslator(const edm::ParameterSet &)
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:471
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
std::string PFSuperClusterCollection_
void createGsfElectronCores(reco::GsfElectronCoreCollection &) const
tuple status
Definition: ntuplemaker.py:245
virtual ParticleType particleId() const
Definition: PFCandidate.h:373
void createGsfElectrons(const reco::PFCandidateCollection &, const IsolationValueMaps &isolationValues, reco::GsfElectronCollection &)
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:682
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:559
void addAmbiguousGsfTrack(const reco::GsfTrackRef &t)
Definition: GsfElectron.h:644
void createPreshowerClusterPtrs(const edm::OrphanHandle< reco::PreshowerClusterCollection > &preshowerClustersHandle)
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
tuple size
Write out results.
double deltaP() const
uncertainty on 3-momentum
Definition: PFCandidate.h:297
void setPreshowerEnergy(double preshowerEnergy)
Definition: SuperCluster.h:59