CMS 3D CMS Logo

PFEGammaProducer.cc
Go to the documentation of this file.
2 
3 
19 
24 
26 #include <sstream>
27 
28 #include "TFile.h"
29 
30 //#define PFLOW_DEBUG
31 
32 #ifdef PFLOW_DEBUG
33 #define docast(x,y) dynamic_cast<x>(y)
34 #define LOGVERB(x) edm::LogVerbatim(x)
35 #define LOGWARN(x) edm::LogWarning(x)
36 #define LOGERR(x) edm::LogError(x)
37 #define LOGDRESSED(x) edm::LogInfo(x)
38 #else
39 #define docast(x,y) reinterpret_cast<x>(y)
40 #define LOGVERB(x) LogTrace(x)
41 #define LOGWARN(x) edm::LogWarning(x)
42 #define LOGERR(x) edm::LogError(x)
43 #define LOGDRESSED(x) LogDebug(x)
44 #endif
45 
46 namespace {
47  typedef std::list< reco::PFBlockRef >::iterator IBR;
48 }
49 
52  primaryVertex_(reco::Vertex()),
53  ebeeClustersCollection_("EBEEClusters"),
54  esClustersCollection_("ESClusters") {
55 
56  PFEGammaAlgo::PFEGConfigInfo algo_config;
57 
59  = consumes<reco::PFBlockCollection>(iConfig.getParameter<edm::InputTag>("blocks"));
60 
61  eetopsSrc_ = consumes<reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<edm::InputTag>("EEtoPS_source"));
62 
63  algo_config.useReg
64  = iConfig.getParameter<bool>("usePhotonReg");
65 
67  = iConfig.getParameter<bool>("useVerticesForNeutral");
68 
70  = iConfig.getParameter<bool>("useRegressionFromDB");
71 
72 
73  std::vector<double> calibPFSCEle_Fbrem_barrel;
74  std::vector<double> calibPFSCEle_Fbrem_endcap;
75  std::vector<double> calibPFSCEle_barrel;
76  std::vector<double> calibPFSCEle_endcap;
77  algo_config.usePFSCEleCalib = iConfig.getParameter<bool>("usePFSCEleCalib");
78  calibPFSCEle_Fbrem_barrel = iConfig.getParameter<std::vector<double> >("calibPFSCEle_Fbrem_barrel");
79  calibPFSCEle_Fbrem_endcap = iConfig.getParameter<std::vector<double> >("calibPFSCEle_Fbrem_endcap");
80  calibPFSCEle_barrel = iConfig.getParameter<std::vector<double> >("calibPFSCEle_barrel");
81  calibPFSCEle_endcap = iConfig.getParameter<std::vector<double> >("calibPFSCEle_endcap");
82  algo_config.thePFSCEnergyCalibration.reset( new PFSCEnergyCalibration( calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
83  calibPFSCEle_barrel,calibPFSCEle_endcap ) );
84 
85  algo_config.useEGammaSupercluster =
86  iConfig.getParameter<bool>("useEGammaSupercluster");
88  iConfig.getParameter<bool>("produceEGCandsWithNoSuperCluster");
89  algo_config.sumEtEcalIsoForEgammaSC_barrel =
90  iConfig.getParameter<double>("sumEtEcalIsoForEgammaSC_barrel");
91  algo_config.sumEtEcalIsoForEgammaSC_endcap =
92  iConfig.getParameter<double>("sumEtEcalIsoForEgammaSC_endcap");
93  algo_config.coneEcalIsoForEgammaSC =
94  iConfig.getParameter<double>("coneEcalIsoForEgammaSC");
95  algo_config.sumPtTrackIsoForEgammaSC_barrel =
96  iConfig.getParameter<double>("sumPtTrackIsoForEgammaSC_barrel");
97  algo_config.sumPtTrackIsoForEgammaSC_endcap =
98  iConfig.getParameter<double>("sumPtTrackIsoForEgammaSC_endcap");
99  algo_config.coneTrackIsoForEgammaSC =
100  iConfig.getParameter<double>("coneTrackIsoForEgammaSC");
101  algo_config.nTrackIsoForEgammaSC =
102  iConfig.getParameter<unsigned int>("nTrackIsoForEgammaSC");
103 
104 
105  // register products
106  produces<reco::PFCandidateCollection>();
107  produces<reco::PFCandidateEGammaExtraCollection>();
108  produces<reco::SuperClusterCollection>();
109  produces<reco::CaloClusterCollection>(ebeeClustersCollection_);
110  produces<reco::CaloClusterCollection>(esClustersCollection_);
111  produces<reco::ConversionCollection>();
112 
113  //PFElectrons Configuration
114  algo_config.mvaEleCut
115  = iConfig.getParameter<double>("pf_electron_mvaCut");
116 
117 
118  algo_config. mvaWeightFileEleID
119  = iConfig.getParameter<edm::FileInPath>("pf_electronID_mvaWeightFile").fullPath();
120 
121  algo_config.applyCrackCorrections
122  = iConfig.getParameter<bool>("pf_electronID_crackCorrection");
123 
124  //PFPhoton Configuration
125 
126  std::string path_mvaWeightFileConvID;
127  std::string mvaWeightFileConvID;
128  std::string path_mvaWeightFileGCorr;
129  std::string path_mvaWeightFileLCorr;
130  std::string path_X0_Map;
131  std::string path_mvaWeightFileRes;
132 
133  algo_config.mvaweightfile =
134  iConfig.getParameter<edm::FileInPath>("pf_convID_mvaWeightFile").fullPath();
135  algo_config.mvaConvCut = iConfig.getParameter<double>("pf_conv_mvaCut");
136  algo_config.sumPtTrackIsoForPhoton =
137  iConfig.getParameter<double>("sumPtTrackIsoForPhoton");
138  algo_config.sumPtTrackIsoSlopeForPhoton =
139  iConfig.getParameter<double>("sumPtTrackIsoSlopeForPhoton");
140 
141  algo_config.X0_Map = iConfig.getParameter<std::string>("X0_Map");
142  algo_config.X0_Map =
143  edm::FileInPath( algo_config.X0_Map.c_str() ).fullPath();
144 
145  if(!useRegressionFromDB_) {
146  std::string mvaWeightFileLCorr=iConfig.getParameter<std::string>("pf_locC_mvaWeightFile");
147  path_mvaWeightFileLCorr = edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
148  std::string mvaWeightFileGCorr=iConfig.getParameter<std::string>("pf_GlobC_mvaWeightFile");
149  path_mvaWeightFileGCorr = edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
150  std::string mvaWeightFileRes=iConfig.getParameter<std::string>("pf_Res_mvaWeightFile");
151  path_mvaWeightFileRes=edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
152 
153  TFile *fgbr = new TFile(path_mvaWeightFileGCorr.c_str(),"READ");
154  ReaderGC_ =(const GBRForest*)fgbr->Get("GBRForest");
155  TFile *fgbr2 = new TFile(path_mvaWeightFileLCorr.c_str(),"READ");
156  ReaderLC_ = (const GBRForest*)fgbr2->Get("GBRForest");
157  TFile *fgbr3 = new TFile(path_mvaWeightFileRes.c_str(),"READ");
158  ReaderRes_ = (const GBRForest*)fgbr3->Get("GBRForest");
159  LogDebug("PFEGammaProducer")<<"Will set regressions from binary files " <<std::endl;
160  }
161 
163  = iConfig.getParameter<edm::ParameterSet>("iCfgCandConnector");
164 
165 
166  // fToRead = iConfig.getUntrackedParameter<std::vector<std::string> >("toRead");
167 
169  = iConfig.getParameter<bool>("useCalibrationsFromDB");
170 
171  algo_config.thePFEnergyCalibration.reset(new PFEnergyCalibration());
172 
173  int algoType
174  = iConfig.getParameter<unsigned>("algoType");
175 
176  switch(algoType) {
177  case 0:
178  //pfAlgo_.reset( new PFAlgo);
179  break;
180  default:
181  assert(0);
182  }
183 
184  //PFEGamma
185  setPFEGParameters(algo_config);
186 
187  //MIKE: Vertex Parameters
188  vertices_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"));
189 
190  verbose_ =
191  iConfig.getUntrackedParameter<bool>("verbose",false);
192 
193 // bool debug_ =
194 // iConfig.getUntrackedParameter<bool>("debug",false);
195 
196 }
197 
198 
199 
201 
202 void
204  const edm::EventSetup & es)
205 {
206 
207  /* // kept for historical reasons
208  if(useRegressionFromDB_) {
209 
210  edm::ESHandle<GBRForest> readerPFLCEB;
211  edm::ESHandle<GBRForest> readerPFLCEE;
212  edm::ESHandle<GBRForest> readerPFGCEB;
213  edm::ESHandle<GBRForest> readerPFGCEEHR9;
214  edm::ESHandle<GBRForest> readerPFGCEELR9;
215  edm::ESHandle<GBRForest> readerPFRes;
216  es.get<GBRWrapperRcd>().get("PFLCorrectionBar",readerPFLCEB);
217  ReaderLCEB_=readerPFLCEB.product();
218  es.get<GBRWrapperRcd>().get("PFLCorrectionEnd",readerPFLCEE);
219  ReaderLCEE_=readerPFLCEE.product();
220  es.get<GBRWrapperRcd>().get("PFGCorrectionBar",readerPFGCEB);
221  ReaderGCBarrel_=readerPFGCEB.product();
222  es.get<GBRWrapperRcd>().get("PFGCorrectionEndHighR9",readerPFGCEEHR9);
223  ReaderGCEndCapHighr9_=readerPFGCEEHR9.product();
224  es.get<GBRWrapperRcd>().get("PFGCorrectionEndLowR9",readerPFGCEELR9);
225  ReaderGCEndCapLowr9_=readerPFGCEELR9.product();
226  es.get<GBRWrapperRcd>().get("PFEcalResolution",readerPFRes);
227  ReaderEcalRes_=readerPFRes.product();
228 
229 
230  LogDebug("PFEGammaProducer")<<"setting regressions from DB "<<std::endl;
231 
232  }
233  */
234 
235  //pfAlgo_->setPFPhotonRegWeights(ReaderLC_, ReaderGC_, ReaderRes_);
236 
237 }
238 
239 
240 void
242  const edm::EventSetup& iSetup) {
243 
244  LOGDRESSED("PFEGammaProducer")
245  <<"START event: "
246  <<iEvent.id().event()
247  <<" in run "<<iEvent.id().run()<<std::endl;
248 
249 
250  // reset output collection
251  egCandidates_ = std::make_unique<reco::PFCandidateCollection>();
252  egExtra_ = std::make_unique<reco::PFCandidateEGammaExtraCollection>();
253  sClusters_ = std::make_unique<reco::SuperClusterCollection>();
254 
255  // Get the EE-PS associations
257  iEvent.getByToken(eetopsSrc_,eetops);
258  pfeg_->setEEtoPSAssociation(eetops);
259 
260  // preshower conditions
261  edm::ESHandle<ESEEIntercalibConstants> esEEInterCalibHandle_;
262  iSetup.get<ESEEIntercalibConstantsRcd>().get(esEEInterCalibHandle_);
263  pfeg_->setAlphaGamma_ESplanes_fromDB(esEEInterCalibHandle_.product());
264 
265  edm::ESHandle<ESChannelStatus> esChannelStatusHandle_;
266  iSetup.get<ESChannelStatusRcd>().get(esChannelStatusHandle_);
267  pfeg_->setESChannelStatus(esChannelStatusHandle_.product());
268 
269  // Get The vertices from the event
270  // and assign dynamic vertex parameters
272  bool gotVertices = iEvent.getByToken(vertices_,vertices);
273  if(!gotVertices) {
274  std::ostringstream err;
275  err<<"Cannot find vertices for this event.Continuing Without them ";
276  edm::LogError("PFEGammaProducer")<<err.str()<<std::endl;
277  }
278 
279  //Assign the PFAlgo Parameters
281 
282  // get the collection of blocks
283 
285 
286  LOGDRESSED("PFEGammaProducer")<<"getting blocks"<<std::endl;
287  bool found = iEvent.getByToken( inputTagBlocks_, blocks );
288 
289  if(!found ) {
290 
291  std::ostringstream err;
292  err<<"cannot find blocks: (tag index)"
293  << std::hex<< inputTagBlocks_.index() << std::dec;
294  edm::LogError("PFEGammaProducer")<<err.str()<<std::endl;
295 
296  throw cms::Exception( "MissingProduct", err.str());
297  }
298 
299  LOGDRESSED("PFEGammaProducer")
300  <<"EGPFlow is starting..."<<std::endl;
301 
302 #ifdef PFLOW_DEBUG
303  assert( blocks.isValid() && "edm::Handle to blocks was null!");
304  std::ostringstream str;
305  //str<<(*pfAlgo_)<<std::endl;
306  // cout << (*pfAlgo_) << std::endl;
307  LOGDRESSED("PFEGammaProducer") <<str.str()<<std::endl;
308 #endif
309 
310  // sort elements in three lists:
311  std::list< reco::PFBlockRef > hcalBlockRefs;
312  std::list< reco::PFBlockRef > ecalBlockRefs;
313  std::list< reco::PFBlockRef > hoBlockRefs;
314  std::list< reco::PFBlockRef > otherBlockRefs;
315 
316  for( unsigned i=0; i<blocks->size(); ++i ) {
317  // reco::PFBlockRef blockref( blockh,i );
318  //reco::PFBlockRef blockref = createBlockRef( *blocks, i);
319  reco::PFBlockRef blockref(blocks, i);
320 
322  elements = blockref->elements();
323 
324  LOGDRESSED("PFEGammaProducer")
325  << "Found " << elements.size()
326  << " PFBlockElements in block: " << i << std::endl;
327 
328  bool singleEcalOrHcal = false;
329  if( elements.size() == 1 ){
330  switch( elements[0].type() ) {
332  edm::LogError("PFEGammaProducer")
333  << "PFBLOCKALGO BUG!!!! Found a SuperCluster in a block by itself!";
337  ecalBlockRefs.push_back( blockref );
338  singleEcalOrHcal = true;
339  break;
343  if (elements[0].clusterRef()->flags() & reco::CaloCluster::badHcalMarker) continue;
344  hcalBlockRefs.push_back( blockref );
345  singleEcalOrHcal = true;
346  break;
348  // Single HO elements are likely to be noise. Not considered for now.
349  hoBlockRefs.push_back( blockref );
350  singleEcalOrHcal = true;
351  break;
352  default:
353  break;
354  }
355  }
356 
357  if(!singleEcalOrHcal) {
358  otherBlockRefs.push_back( blockref );
359  }
360  }//loop blocks
361 
362  // loop on blocks that are not single ecal, single ps1, single ps2 , or
363  // single hcal and produce unbiased collection of EGamma Candidates
364 
365  //printf("loop over blocks\n");
366  unsigned nblcks = 0;
367 
368  // this auto is a const reco::PFBlockRef&
369  for( const auto& blockref : otherBlockRefs ) {
370  ++nblcks;
371  // this auto is a: const edm::OwnVector< reco::PFBlockElement >&
372  const auto& elements = blockref->elements();
373  // make a copy of the link data, which will be edited.
374  //PFBlock::LinkData linkData = block.linkData();
375 
376  // keep track of the elements which are still active.
377  std::vector<bool> active( elements.size(), true );
378 
379  pfeg_->RunPFEG(globalCache(),blockref,active);
380 
381  if( !pfeg_->getCandidates().empty() ) {
382  LOGDRESSED("PFEGammaProducer")
383  << "Block with " << elements.size()
384  << " elements produced "
385  << pfeg_->getCandidates().size()
386  << " e-g candidates!" << std::endl;
387  }
388 
389  const size_t egsize = egCandidates_->size();
390  egCandidates_->resize(egsize + pfeg_->getCandidates().size());
391  reco::PFCandidateCollection::iterator eginsertfrom =
392  egCandidates_->begin() + egsize;
393  std::move(pfeg_->getCandidates().begin(),
394  pfeg_->getCandidates().end(),
395  eginsertfrom);
396 
397  const size_t egxsize = egExtra_->size();
398  egExtra_->resize(egxsize + pfeg_->getEGExtra().size());
399  reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
400  egExtra_->begin() + egxsize;
401  std::move(pfeg_->getEGExtra().begin(),
402  pfeg_->getEGExtra().end(),
403  egxinsertfrom);
404 
405  const size_t rscsize = sClusters_->size();
406  sClusters_->resize(rscsize + pfeg_->getRefinedSCs().size());
407  reco::SuperClusterCollection::iterator rscinsertfrom =
408  sClusters_->begin() + rscsize;
409  std::move(pfeg_->getRefinedSCs().begin(),
410  pfeg_->getRefinedSCs().end(),
411  rscinsertfrom);
412  }
413 
414  LOGDRESSED("PFEGammaProducer")
415  << "Running PFEGammaAlgo on all blocks produced = "
416  << egCandidates_->size() << " e-g candidates!"
417  << std::endl;
418 
421 
424 
425  //set the correct references to refined SC and EG extra using the refprods
426  for (unsigned int i=0; i < egCandidates_->size(); ++i) {
428  reco::PFCandidateEGammaExtra &xtra = egExtra_->at(i);
429 
430  reco::PFCandidateEGammaExtraRef extraref(egXtraProd,i);
431  reco::SuperClusterRef refinedSCRef(sClusterProd,i);
432 
433  xtra.setSuperClusterRef(refinedSCRef);
434  cand.setSuperClusterRef(refinedSCRef);
435  cand.setPFEGammaExtraRef(extraref);
436  }
437 
438  //build collections of output CaloClusters from the used PFClusters
439  auto caloClustersEBEE = std::make_unique<reco::CaloClusterCollection>();
440  auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();
441 
442  std::map<edm::Ptr<reco::CaloCluster>, unsigned int> pfClusterMapEBEE; //maps of pfclusters to caloclusters
443  std::map<edm::Ptr<reco::CaloCluster>, unsigned int> pfClusterMapES;
444 
445  for( const auto& sc : *sClusters_ ) {
446  for (reco::CaloCluster_iterator pfclus = sc.clustersBegin(); pfclus!=sc.clustersEnd(); ++pfclus) {
447  if (!pfClusterMapEBEE.count(*pfclus)) {
448  reco::CaloCluster caloclus(**pfclus);
449  caloClustersEBEE->push_back(caloclus);
450  pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
451  }
452  else {
453  throw cms::Exception("PFEgammaProducer::produce")
454  << "Found an EB/EE pfcluster matched to more than one supercluster!"
455  << std::dec << std::endl;
456  }
457  }
458  for (reco::CaloCluster_iterator pfclus = sc.preshowerClustersBegin(); pfclus!=sc.preshowerClustersEnd(); ++pfclus) {
459  if (!pfClusterMapES.count(*pfclus)) {
460  reco::CaloCluster caloclus(**pfclus);
461  caloClustersES->push_back(caloclus);
462  pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
463  }
464  else {
465  throw cms::Exception("PFEgammaProducer::produce")
466  << "Found an ES pfcluster matched to more than one supercluster!"
467  << std::dec << std::endl;
468  }
469  }
470  }
471 
472  //put calocluster output collections in event and get orphan handles to create ptrs
473  const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEBEE = iEvent.put(std::move(caloClustersEBEE),ebeeClustersCollection_);
474  const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleES = iEvent.put(std::move(caloClustersES),esClustersCollection_);
475 
476  //relink superclusters to output caloclusters
477  for( auto& sc : *sClusters_ ) {
478  edm::Ptr<reco::CaloCluster> seedptr(caloClusHandleEBEE,pfClusterMapEBEE[sc.seed()]);
479  sc.setSeed(seedptr);
480 
482  for (reco::CaloCluster_iterator pfclus = sc.clustersBegin(); pfclus!=sc.clustersEnd(); ++pfclus) {
483  edm::Ptr<reco::CaloCluster> clusptr(caloClusHandleEBEE,pfClusterMapEBEE[*pfclus]);
484  clusters.push_back(clusptr);
485  }
486  sc.setClusters(clusters);
487 
488  reco::CaloClusterPtrVector psclusters;
489  for (reco::CaloCluster_iterator pfclus = sc.preshowerClustersBegin(); pfclus!=sc.preshowerClustersEnd(); ++pfclus) {
490  edm::Ptr<reco::CaloCluster> clusptr(caloClusHandleES,pfClusterMapES[*pfclus]);
491  psclusters.push_back(clusptr);
492  }
493  sc.setPreshowerClusters(psclusters);
494  }
495 
496  //create and fill references to single leg conversions
498  singleLegConv_ = std::make_unique<reco::ConversionCollection>();
499  createSingleLegConversions(*egExtra_, *singleLegConv_, convProd);
500 
501  // release our demonspawn into the wild to cause havoc
502  iEvent.put(std::move(sClusters_));
503  iEvent.put(std::move(egExtra_));
504  iEvent.put(std::move(singleLegConv_));
505  iEvent.put(std::move(egCandidates_));
506 }
507 
508 //PFEGammaAlgo: a new method added to set the parameters for electron and photon reconstruction.
509 void
511 
512  FILE * fileEleID = fopen(cfg.mvaWeightFileEleID.c_str(), "r");
513  if (fileEleID) {
514  fclose(fileEleID);
515  }
516  else {
517  std::string err = "PFAlgo: cannot open weight file '";
518  err += cfg.mvaWeightFileEleID;
519  err += "'";
520  throw std::invalid_argument( err );
521  }
522 
523  //for MVA pass PV if there is one in the collection otherwise pass a dummy
524  if(!useVerticesForNeutral_) { // create a dummy PV
526  e(0, 0) = 0.0015 * 0.0015;
527  e(1, 1) = 0.0015 * 0.0015;
528  e(2, 2) = 15. * 15.;
529  reco::Vertex::Point p(0, 0, 0);
530  primaryVertex_ = reco::Vertex(p, e, 0, 0, 0);
531  }
532  // pv=&dummy;
533  //if(! usePFPhotons_) return;
534  FILE * filePhotonConvID = fopen(cfg.mvaweightfile.c_str(), "r");
535  if (filePhotonConvID) {
536  fclose(filePhotonConvID);
537  }
538  else {
539  std::string err = "PFAlgo: cannot open weight file '";
540  err += cfg.mvaweightfile;
541  err += "'";
542  throw std::invalid_argument( err );
543  }
544  cfg.primaryVtx = &primaryVertex_;
545  pfeg_.reset(new PFEGammaAlgo(cfg));
546 }
547 
548 /*
549 void PFAlgo::setPFPhotonRegWeights(
550  const GBRForest *LCorrForest,
551  const GBRForest *GCorrForest,
552  const GBRForest *ResForest
553  ) {
554  if(usePFPhotons_)
555  pfpho_->setGBRForest(LCorrForest, GCorrForest, ResForest);
556 }
557 */
558 
559 void
563 
564  //Set the vertices for muon cleaning
565 // pfmu_->setInputsForCleaning(primaryVertices);
566 
567 
568  //Now find the primary vertex!
569  //bool primaryVertexFound = false;
570  int nVtx=primaryVertices->size();
571  pfeg_->setnPU(nVtx);
572 // if(usePFPhotons_){
573 // pfpho_->setnPU(nVtx);
574 // }
575  primaryVertex_ = primaryVertices->front();
576  for (unsigned short i=0 ;i<primaryVertices->size();++i)
577  {
578  if(primaryVertices->at(i).isValid()&&(!primaryVertices->at(i).isFake()))
579  {
580  primaryVertex_ = primaryVertices->at(i);
581  //primaryVertexFound = true;
582  break;
583  }
584  }
585 
586  pfeg_->setPhotonPrimaryVtx(primaryVertex_ );
587 
588 }
589 
591 
593  for (auto &extra : extras){
594  for (const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
595  const reco::Track &trk = *tkrefmva.first;
596 
597  const reco::Vertex convVtx(trk.innerPosition(), error);
598  std::vector<reco::TrackRef> OneLegConvVector;
599  OneLegConvVector.push_back(tkrefmva.first);
600  std::vector< float > OneLegMvaVector;
601  OneLegMvaVector.push_back(tkrefmva.second);
602  std::vector<reco::CaloClusterPtr> dummymatchingBC;
604  scPtrVec.push_back(edm::refToPtr(extra.superClusterRef()));
605 
606  std::vector<math::XYZPointF>trackPositionAtEcalVec;
607  std::vector<math::XYZPointF>innPointVec;
608  std::vector<math::XYZVectorF>trackPinVec;
609  std::vector<math::XYZVectorF>trackPoutVec;
610  math::XYZPointF trackPositionAtEcal(trk.outerPosition().X(), trk.outerPosition().Y(), trk.outerPosition().Z());
611  trackPositionAtEcalVec.push_back(trackPositionAtEcal);
612 
613  math::XYZPointF innPoint(trk.innerPosition().X(), trk.innerPosition().Y(), trk.innerPosition().Z());
614  innPointVec.push_back(innPoint);
615 
616  math::XYZVectorF trackPin(trk.innerMomentum().X(), trk.innerMomentum().Y(), trk.innerMomentum().Z());
617  trackPinVec.push_back(trackPin);
618 
619  math::XYZVectorF trackPout(trk.outerMomentum().X(), trk.outerMomentum().Y(), trk.outerMomentum().Z());
620  trackPoutVec.push_back( trackPout );
621 
622  float DCA = trk.d0() ;
623  float mvaval = tkrefmva.second;
624  reco::Conversion singleLegConvCandidate(scPtrVec,
625  OneLegConvVector,
626  trackPositionAtEcalVec,
627  convVtx,
628  dummymatchingBC,
629  DCA,
630  innPointVec,
631  trackPinVec,
632  trackPoutVec,
633  mvaval,
635  singleLegConvCandidate.setOneLegMVA(OneLegMvaVector);
636  oneLegConversions.push_back(singleLegConvCandidate);
637 
638  reco::ConversionRef convref(convProd,oneLegConversions.size()-1);
639  extra.addSingleLegConversionRef(convref);
640 
641  }
642 
643  }
644 
645 }
646 
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
void createSingleLegConversions(reco::PFCandidateEGammaExtraCollection &extras, reco::ConversionCollection &oneLegConversions, const edm::RefProd< reco::ConversionCollection > &convProd)
const GBRForest * ReaderRes_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void setSuperClusterRef(reco::SuperClusterRef sc)
set reference to the corresponding supercluster
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:597
std::unique_ptr< reco::PFCandidateEGammaExtraCollection > egExtra_
edm::EDGetTokenT< reco::VertexCollection > vertices_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
Definition: PFEGammaAlgo.h:114
unsigned int index() const
Definition: EDGetToken.h:72
size_type size() const
Definition: OwnVector.h:264
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
ErrorD< N >::type type
Definition: Error.h:33
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
const reco::Vertex * primaryVtx
Definition: PFEGammaAlgo.h:131
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
int iEvent
Definition: GenABIO.cc:230
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
~PFEGammaProducer() override
void setPFVertexParameters(bool useVertex, const reco::VertexCollection *primaryVertices)
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
reco::Vertex primaryVertex_
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
std::string ebeeClustersCollection_
std::unique_ptr< reco::PFCandidateCollection > egCandidates_
std::unique_ptr< reco::ConversionCollection > singleLegConv_
std::string esClustersCollection_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:17
void setPFEGParameters(PFEGammaAlgo::PFEGConfigInfo &)
void beginRun(const edm::Run &, const edm::EventSetup &) override
bool verbose_
verbose ?
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eetopsSrc_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:167
const GBRForest * ReaderLC_
std::list< reco::PFBlockRef >::iterator IBR
Definition: PFAlgo.cc:55
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
T const * product() const
Definition: Handle.h:81
primaryVertices
Definition: jets_cff.py:27
std::unique_ptr< PFEGammaAlgo > pfeg_
the unfiltered electron collection
const GBRForest * ReaderGC_
std::shared_ptr< PFSCEnergyCalibration > thePFSCEnergyCalibration
Definition: PFEGammaAlgo.h:113
edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
edm::EventID id() const
Definition: EventBase.h:60
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
void setOneLegMVA(const std::vector< float > &mva)
set the MVS output from PF for one leg conversions
Definition: Conversion.h:172
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
#define LOGDRESSED(x)
T get() const
Definition: EventSetup.h:63
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
Definition: PFCandidate.cc:650
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:629
PFEGammaProducer(const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
#define str(s)
void produce(edm::Event &, const edm::EventSetup &) override
std::unique_ptr< reco::SuperClusterCollection > sClusters_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:44