CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  hcalBlockRefs.push_back( blockref );
344  singleEcalOrHcal = true;
345  break;
347  // Single HO elements are likely to be noise. Not considered for now.
348  hoBlockRefs.push_back( blockref );
349  singleEcalOrHcal = true;
350  break;
351  default:
352  break;
353  }
354  }
355 
356  if(!singleEcalOrHcal) {
357  otherBlockRefs.push_back( blockref );
358  }
359  }//loop blocks
360 
361  // loop on blocks that are not single ecal, single ps1, single ps2 , or
362  // single hcal and produce unbiased collection of EGamma Candidates
363 
364  //printf("loop over blocks\n");
365  unsigned nblcks = 0;
366 
367  // this auto is a const reco::PFBlockRef&
368  for( const auto& blockref : otherBlockRefs ) {
369  ++nblcks;
370  // this auto is a: const edm::OwnVector< reco::PFBlockElement >&
371  const auto& elements = blockref->elements();
372  // make a copy of the link data, which will be edited.
373  //PFBlock::LinkData linkData = block.linkData();
374 
375  // keep track of the elements which are still active.
376  std::vector<bool> active( elements.size(), true );
377 
378  pfeg_->RunPFEG(globalCache(),blockref,active);
379 
380  if( pfeg_->getCandidates().size() ) {
381  LOGDRESSED("PFEGammaProducer")
382  << "Block with " << elements.size()
383  << " elements produced "
384  << pfeg_->getCandidates().size()
385  << " e-g candidates!" << std::endl;
386  }
387 
388  const size_t egsize = egCandidates_->size();
389  egCandidates_->resize(egsize + pfeg_->getCandidates().size());
390  reco::PFCandidateCollection::iterator eginsertfrom =
391  egCandidates_->begin() + egsize;
392  std::move(pfeg_->getCandidates().begin(),
393  pfeg_->getCandidates().end(),
394  eginsertfrom);
395 
396  const size_t egxsize = egExtra_->size();
397  egExtra_->resize(egxsize + pfeg_->getEGExtra().size());
398  reco::PFCandidateEGammaExtraCollection::iterator egxinsertfrom =
399  egExtra_->begin() + egxsize;
400  std::move(pfeg_->getEGExtra().begin(),
401  pfeg_->getEGExtra().end(),
402  egxinsertfrom);
403 
404  const size_t rscsize = sClusters_->size();
405  sClusters_->resize(rscsize + pfeg_->getRefinedSCs().size());
406  reco::SuperClusterCollection::iterator rscinsertfrom =
407  sClusters_->begin() + rscsize;
408  std::move(pfeg_->getRefinedSCs().begin(),
409  pfeg_->getRefinedSCs().end(),
410  rscinsertfrom);
411  }
412 
413  LOGDRESSED("PFEGammaProducer")
414  << "Running PFEGammaAlgo on all blocks produced = "
415  << egCandidates_->size() << " e-g candidates!"
416  << std::endl;
417 
420 
423 
424  //set the correct references to refined SC and EG extra using the refprods
425  for (unsigned int i=0; i < egCandidates_->size(); ++i) {
426  reco::PFCandidate &cand = egCandidates_->at(i);
427  reco::PFCandidateEGammaExtra &xtra = egExtra_->at(i);
428 
429  reco::PFCandidateEGammaExtraRef extraref(egXtraProd,i);
430  reco::SuperClusterRef refinedSCRef(sClusterProd,i);
431 
432  xtra.setSuperClusterRef(refinedSCRef);
433  cand.setSuperClusterRef(refinedSCRef);
434  cand.setPFEGammaExtraRef(extraref);
435  }
436 
437  //build collections of output CaloClusters from the used PFClusters
438  auto caloClustersEBEE = std::make_unique<reco::CaloClusterCollection>();
439  auto caloClustersES = std::make_unique<reco::CaloClusterCollection>();
440 
441  std::map<edm::Ptr<reco::CaloCluster>, unsigned int> pfClusterMapEBEE; //maps of pfclusters to caloclusters
442  std::map<edm::Ptr<reco::CaloCluster>, unsigned int> pfClusterMapES;
443 
444  for( const auto& sc : *sClusters_ ) {
445  for (reco::CaloCluster_iterator pfclus = sc.clustersBegin(); pfclus!=sc.clustersEnd(); ++pfclus) {
446  if (!pfClusterMapEBEE.count(*pfclus)) {
447  reco::CaloCluster caloclus(**pfclus);
448  caloClustersEBEE->push_back(caloclus);
449  pfClusterMapEBEE[*pfclus] = caloClustersEBEE->size() - 1;
450  }
451  else {
452  throw cms::Exception("PFEgammaProducer::produce")
453  << "Found an EB/EE pfcluster matched to more than one supercluster!"
454  << std::dec << std::endl;
455  }
456  }
457  for (reco::CaloCluster_iterator pfclus = sc.preshowerClustersBegin(); pfclus!=sc.preshowerClustersEnd(); ++pfclus) {
458  if (!pfClusterMapES.count(*pfclus)) {
459  reco::CaloCluster caloclus(**pfclus);
460  caloClustersES->push_back(caloclus);
461  pfClusterMapES[*pfclus] = caloClustersES->size() - 1;
462  }
463  else {
464  throw cms::Exception("PFEgammaProducer::produce")
465  << "Found an ES pfcluster matched to more than one supercluster!"
466  << std::dec << std::endl;
467  }
468  }
469  }
470 
471  //put calocluster output collections in event and get orphan handles to create ptrs
472  const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleEBEE = iEvent.put(std::move(caloClustersEBEE),ebeeClustersCollection_);
473  const edm::OrphanHandle<reco::CaloClusterCollection> &caloClusHandleES = iEvent.put(std::move(caloClustersES),esClustersCollection_);
474 
475  //relink superclusters to output caloclusters
476  for( auto& sc : *sClusters_ ) {
477  edm::Ptr<reco::CaloCluster> seedptr(caloClusHandleEBEE,pfClusterMapEBEE[sc.seed()]);
478  sc.setSeed(seedptr);
479 
481  for (reco::CaloCluster_iterator pfclus = sc.clustersBegin(); pfclus!=sc.clustersEnd(); ++pfclus) {
482  edm::Ptr<reco::CaloCluster> clusptr(caloClusHandleEBEE,pfClusterMapEBEE[*pfclus]);
483  clusters.push_back(clusptr);
484  }
485  sc.setClusters(clusters);
486 
487  reco::CaloClusterPtrVector psclusters;
488  for (reco::CaloCluster_iterator pfclus = sc.preshowerClustersBegin(); pfclus!=sc.preshowerClustersEnd(); ++pfclus) {
489  edm::Ptr<reco::CaloCluster> clusptr(caloClusHandleES,pfClusterMapES[*pfclus]);
490  psclusters.push_back(clusptr);
491  }
492  sc.setPreshowerClusters(psclusters);
493  }
494 
495  //create and fill references to single leg conversions
497  singleLegConv_ = std::make_unique<reco::ConversionCollection>();
498  createSingleLegConversions(*egExtra_, *singleLegConv_, convProd);
499 
500  // release our demonspawn into the wild to cause havoc
501  iEvent.put(std::move(sClusters_));
502  iEvent.put(std::move(egExtra_));
503  iEvent.put(std::move(singleLegConv_));
504  iEvent.put(std::move(egCandidates_));
505 }
506 
507 //PFEGammaAlgo: a new method added to set the parameters for electron and photon reconstruction.
508 void
510 
511  FILE * fileEleID = fopen(cfg.mvaWeightFileEleID.c_str(), "r");
512  if (fileEleID) {
513  fclose(fileEleID);
514  }
515  else {
516  std::string err = "PFAlgo: cannot open weight file '";
517  err += cfg.mvaWeightFileEleID;
518  err += "'";
519  throw std::invalid_argument( err );
520  }
521 
522  //for MVA pass PV if there is one in the collection otherwise pass a dummy
523  if(!useVerticesForNeutral_) { // create a dummy PV
525  e(0, 0) = 0.0015 * 0.0015;
526  e(1, 1) = 0.0015 * 0.0015;
527  e(2, 2) = 15. * 15.;
528  reco::Vertex::Point p(0, 0, 0);
529  primaryVertex_ = reco::Vertex(p, e, 0, 0, 0);
530  }
531  // pv=&dummy;
532  //if(! usePFPhotons_) return;
533  FILE * filePhotonConvID = fopen(cfg.mvaweightfile.c_str(), "r");
534  if (filePhotonConvID) {
535  fclose(filePhotonConvID);
536  }
537  else {
538  std::string err = "PFAlgo: cannot open weight file '";
539  err += cfg.mvaweightfile;
540  err += "'";
541  throw std::invalid_argument( err );
542  }
543  cfg.primaryVtx = &primaryVertex_;
544  pfeg_.reset(new PFEGammaAlgo(cfg));
545 }
546 
547 /*
548 void PFAlgo::setPFPhotonRegWeights(
549  const GBRForest *LCorrForest,
550  const GBRForest *GCorrForest,
551  const GBRForest *ResForest
552  ) {
553  if(usePFPhotons_)
554  pfpho_->setGBRForest(LCorrForest, GCorrForest, ResForest);
555 }
556 */
557 
558 void
562 
563  //Set the vertices for muon cleaning
564 // pfmu_->setInputsForCleaning(primaryVertices);
565 
566 
567  //Now find the primary vertex!
568  //bool primaryVertexFound = false;
569  int nVtx=primaryVertices->size();
570  pfeg_->setnPU(nVtx);
571 // if(usePFPhotons_){
572 // pfpho_->setnPU(nVtx);
573 // }
574  primaryVertex_ = primaryVertices->front();
575  for (unsigned short i=0 ;i<primaryVertices->size();++i)
576  {
577  if(primaryVertices->at(i).isValid()&&(!primaryVertices->at(i).isFake()))
578  {
579  primaryVertex_ = primaryVertices->at(i);
580  //primaryVertexFound = true;
581  break;
582  }
583  }
584 
585  pfeg_->setPhotonPrimaryVtx(primaryVertex_ );
586 
587 }
588 
590 
592  for (auto &extra : extras){
593  for (const auto &tkrefmva : extra.singleLegConvTrackRefMva()) {
594  const reco::Track &trk = *tkrefmva.first;
595 
596  const reco::Vertex convVtx(trk.innerPosition(), error);
597  std::vector<reco::TrackRef> OneLegConvVector;
598  OneLegConvVector.push_back(tkrefmva.first);
599  std::vector< float > OneLegMvaVector;
600  OneLegMvaVector.push_back(tkrefmva.second);
601  std::vector<reco::CaloClusterPtr> dummymatchingBC;
603  scPtrVec.push_back(edm::refToPtr(extra.superClusterRef()));
604 
605  std::vector<math::XYZPointF>trackPositionAtEcalVec;
606  std::vector<math::XYZPointF>innPointVec;
607  std::vector<math::XYZVectorF>trackPinVec;
608  std::vector<math::XYZVectorF>trackPoutVec;
609  math::XYZPointF trackPositionAtEcal(trk.outerPosition().X(), trk.outerPosition().Y(), trk.outerPosition().Z());
610  trackPositionAtEcalVec.push_back(trackPositionAtEcal);
611 
612  math::XYZPointF innPoint(trk.innerPosition().X(), trk.innerPosition().Y(), trk.innerPosition().Z());
613  innPointVec.push_back(innPoint);
614 
615  math::XYZVectorF trackPin(trk.innerMomentum().X(), trk.innerMomentum().Y(), trk.innerMomentum().Z());
616  trackPinVec.push_back(trackPin);
617 
618  math::XYZVectorF trackPout(trk.outerMomentum().X(), trk.outerMomentum().Y(), trk.outerMomentum().Z());
619  trackPoutVec.push_back( trackPout );
620 
621  float DCA = trk.d0() ;
622  float mvaval = tkrefmva.second;
623  reco::Conversion singleLegConvCandidate(scPtrVec,
624  OneLegConvVector,
625  trackPositionAtEcalVec,
626  convVtx,
627  dummymatchingBC,
628  DCA,
629  innPointVec,
630  trackPinVec,
631  trackPoutVec,
632  mvaval,
634  singleLegConvCandidate.setOneLegMVA(OneLegMvaVector);
635  oneLegConversions.push_back(singleLegConvCandidate);
636 
637  reco::ConversionRef convref(convProd,oneLegConversions.size()-1);
638  extra.addSingleLegConversionRef(convref);
639 
640  }
641 
642  }
643 
644 }
645 
#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
int i
Definition: DBlmapReader.cc:9
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:122
tuple cfg
Definition: looper.py:293
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:592
std::unique_ptr< reco::PFCandidateEGammaExtraCollection > egExtra_
edm::EDGetTokenT< reco::VertexCollection > vertices_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
tuple primaryVertices
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
std::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration
Definition: PFEGammaAlgo.h:114
assert(m_qm.get())
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< 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
dictionary elements
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
tuple calibPFSCEle_Fbrem_barrel
int iEvent
Definition: GenABIO.cc:230
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void setPFVertexParameters(bool useVertex, const reco::VertexCollection *primaryVertices)
std::vector< reco::PFCandidateEGammaExtra > PFCandidateEGammaExtraCollection
collection of PFCandidateEGammaExtras
def move
Definition: eostools.py:510
tuple calibPFSCEle_Fbrem_endcap
reco::Vertex primaryVertex_
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
tuple calibPFSCEle_endcap
std::string ebeeClustersCollection_
std::unique_ptr< reco::PFCandidateCollection > egCandidates_
std::unique_ptr< reco::ConversionCollection > singleLegConv_
tuple calibPFSCEle_barrel
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 &)
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
bool verbose_
verbose ?
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eetopsSrc_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
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
const T & get() const
Definition: EventSetup.h:56
list blocks
Definition: gather_cfg.py:90
T const * product() const
Definition: ESHandle.h:86
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:58
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
void setOneLegMVA(const std::vector< float > &mva)
set the MVS output from PF for one leg conversions
Definition: Conversion.h:171
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
#define LOGDRESSED(x)
void setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef &ref)
set the PF EGamma Extra Ref
Definition: PFCandidate.cc:646
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
Definition: PFCandidate.cc:625
tuple iCfgCandConnector
PFEGammaProducer(const edm::ParameterSet &, const pfEGHelpers::HeavyObjectCache *)
virtual void produce(edm::Event &, const edm::EventSetup &) override
std::unique_ptr< reco::SuperClusterCollection > sClusters_
Definition: Run.h:42