CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFProducer.cc
Go to the documentation of this file.
3 
13 
14 #include <sstream>
15 
16 #include "TFile.h"
17 
18 using namespace std;
19 
20 using namespace boost;
21 
22 using namespace edm;
23 
24 
25 
27 
28  //--ab: get calibration factors for HF:
29  bool calibHF_use;
30  std::vector<double> calibHF_eta_step;
31  std::vector<double> calibHF_a_EMonly;
32  std::vector<double> calibHF_b_HADonly;
33  std::vector<double> calibHF_a_EMHAD;
34  std::vector<double> calibHF_b_EMHAD;
35  calibHF_use = iConfig.getParameter<bool>("calibHF_use");
36  calibHF_eta_step = iConfig.getParameter<std::vector<double> >("calibHF_eta_step");
37  calibHF_a_EMonly = iConfig.getParameter<std::vector<double> >("calibHF_a_EMonly");
38  calibHF_b_HADonly = iConfig.getParameter<std::vector<double> >("calibHF_b_HADonly");
39  calibHF_a_EMHAD = iConfig.getParameter<std::vector<double> >("calibHF_a_EMHAD");
40  calibHF_b_EMHAD = iConfig.getParameter<std::vector<double> >("calibHF_b_EMHAD");
41  boost::shared_ptr<PFEnergyCalibrationHF>
42  thepfEnergyCalibrationHF ( new PFEnergyCalibrationHF(calibHF_use,calibHF_eta_step,calibHF_a_EMonly,calibHF_b_HADonly,calibHF_a_EMHAD,calibHF_b_EMHAD) ) ;
43  //-----------------
44 
45  inputTagBlocks_ = consumes<reco::PFBlockCollection>(iConfig.getParameter<InputTag>("blocks"));
46 
47  //Post cleaning of the muons
48  inputTagMuons_ = consumes<reco::MuonCollection>(iConfig.getParameter<InputTag>("muons"));
49  postMuonCleaning_
50  = iConfig.getParameter<bool>("postMuonCleaning");
51 
52  if( iConfig.existsAs<bool>("useEGammaFilters") ) {
53  use_EGammaFilters_ = iConfig.getParameter<bool>("useEGammaFilters");
54  } else {
55  use_EGammaFilters_ = false;
56  }
57 
58  usePFElectrons_
59  = iConfig.getParameter<bool>("usePFElectrons");
60 
61  usePFPhotons_
62  = iConfig.getParameter<bool>("usePFPhotons");
63 
64  // **************************** !! IMPORTANT !! ************************************
65  // When you code is swithed on, automatically turn off the old PFElectrons/PFPhotons.
66  // The two algorithms can not run at the same time
67  // *********************************************************************************
68 
69  if(use_EGammaFilters_) {
70  usePFElectrons_ = false;
71  usePFPhotons_ = false;
72  }
73 
74 
75  usePhotonReg_
76  = (usePFPhotons_) ? iConfig.getParameter<bool>("usePhotonReg") : false ;
77 
78  useRegressionFromDB_
79  = (usePFPhotons_) ? iConfig.getParameter<bool>("useRegressionFromDB") : false;
80 
81  useEGammaElectrons_
82  = iConfig.getParameter<bool>("useEGammaElectrons");
83 
84  if( useEGammaElectrons_) {
85  inputTagEgammaElectrons_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("egammaElectrons"));
86  }
87 
88  electronOutputCol_
89  = iConfig.getParameter<std::string>("pf_electron_output_col");
90 
91  bool usePFSCEleCalib;
92  std::vector<double> calibPFSCEle_Fbrem_barrel;
93  std::vector<double> calibPFSCEle_Fbrem_endcap;
94  std::vector<double> calibPFSCEle_barrel;
95  std::vector<double> calibPFSCEle_endcap;
96  usePFSCEleCalib = iConfig.getParameter<bool>("usePFSCEleCalib");
97  calibPFSCEle_Fbrem_barrel = iConfig.getParameter<std::vector<double> >("calibPFSCEle_Fbrem_barrel");
98  calibPFSCEle_Fbrem_endcap = iConfig.getParameter<std::vector<double> >("calibPFSCEle_Fbrem_endcap");
99  calibPFSCEle_barrel = iConfig.getParameter<std::vector<double> >("calibPFSCEle_barrel");
100  calibPFSCEle_endcap = iConfig.getParameter<std::vector<double> >("calibPFSCEle_endcap");
101  boost::shared_ptr<PFSCEnergyCalibration>
102  thePFSCEnergyCalibration ( new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
103  calibPFSCEle_barrel,calibPFSCEle_endcap ));
104 
105  bool useEGammaSupercluster = iConfig.getParameter<bool>("useEGammaSupercluster");
106  double sumEtEcalIsoForEgammaSC_barrel = iConfig.getParameter<double>("sumEtEcalIsoForEgammaSC_barrel");
107  double sumEtEcalIsoForEgammaSC_endcap = iConfig.getParameter<double>("sumEtEcalIsoForEgammaSC_endcap");
108  double coneEcalIsoForEgammaSC = iConfig.getParameter<double>("coneEcalIsoForEgammaSC");
109  double sumPtTrackIsoForEgammaSC_barrel = iConfig.getParameter<double>("sumPtTrackIsoForEgammaSC_barrel");
110  double sumPtTrackIsoForEgammaSC_endcap = iConfig.getParameter<double>("sumPtTrackIsoForEgammaSC_endcap");
111  double coneTrackIsoForEgammaSC = iConfig.getParameter<double>("coneTrackIsoForEgammaSC");
112  unsigned int nTrackIsoForEgammaSC = iConfig.getParameter<unsigned int>("nTrackIsoForEgammaSC");
113 
114 
115  // register products
116  produces<reco::PFCandidateCollection>();
117  produces<reco::PFCandidateCollection>("CleanedHF");
118  produces<reco::PFCandidateCollection>("CleanedCosmicsMuons");
119  produces<reco::PFCandidateCollection>("CleanedTrackerAndGlobalMuons");
120  produces<reco::PFCandidateCollection>("CleanedFakeMuons");
121  produces<reco::PFCandidateCollection>("CleanedPunchThroughMuons");
122  produces<reco::PFCandidateCollection>("CleanedPunchThroughNeutralHadrons");
123  produces<reco::PFCandidateCollection>("AddedMuonsAndHadrons");
124 
125 
126  if (usePFElectrons_) {
127  produces<reco::PFCandidateCollection>(electronOutputCol_);
128  produces<reco::PFCandidateElectronExtraCollection>(electronExtraOutputCol_);
129  }
130 
131  if (usePFPhotons_) {
132  produces<reco::PFCandidatePhotonExtraCollection>(photonExtraOutputCol_);
133  }
134 
135 
136  double nSigmaECAL
137  = iConfig.getParameter<double>("pf_nsigma_ECAL");
138  double nSigmaHCAL
139  = iConfig.getParameter<double>("pf_nsigma_HCAL");
140 
141  //PFElectrons Configuration
142  double mvaEleCut
143  = iConfig.getParameter<double>("pf_electron_mvaCut");
144 
145 
146  string mvaWeightFileEleID
147  = iConfig.getParameter<string>("pf_electronID_mvaWeightFile");
148 
149  bool applyCrackCorrectionsForElectrons
150  = iConfig.getParameter<bool>("pf_electronID_crackCorrection");
151 
152  string path_mvaWeightFileEleID;
153  if(usePFElectrons_)
154  {
155  path_mvaWeightFileEleID = edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath();
156  }
157 
158  //PFPhoton Configuration
159 
160  string path_mvaWeightFileConvID;
161  string mvaWeightFileConvID;
162  string path_mvaWeightFileGCorr;
163  string path_mvaWeightFileLCorr;
164  string path_X0_Map;
165  string path_mvaWeightFileRes;
166  double mvaConvCut=-99.;
167  double sumPtTrackIsoForPhoton = 99.;
168  double sumPtTrackIsoSlopeForPhoton = 99.;
169 
170  if(usePFPhotons_ )
171  {
172  mvaWeightFileConvID =iConfig.getParameter<string>("pf_convID_mvaWeightFile");
173  mvaConvCut = iConfig.getParameter<double>("pf_conv_mvaCut");
174  path_mvaWeightFileConvID = edm::FileInPath ( mvaWeightFileConvID.c_str() ).fullPath();
175  sumPtTrackIsoForPhoton = iConfig.getParameter<double>("sumPtTrackIsoForPhoton");
176  sumPtTrackIsoSlopeForPhoton = iConfig.getParameter<double>("sumPtTrackIsoSlopeForPhoton");
177 
178  string X0_Map=iConfig.getParameter<string>("X0_Map");
179  path_X0_Map = edm::FileInPath( X0_Map.c_str() ).fullPath();
180 
181  if(!useRegressionFromDB_) {
182  string mvaWeightFileLCorr=iConfig.getParameter<string>("pf_locC_mvaWeightFile");
183  path_mvaWeightFileLCorr = edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
184  string mvaWeightFileGCorr=iConfig.getParameter<string>("pf_GlobC_mvaWeightFile");
185  path_mvaWeightFileGCorr = edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
186  string mvaWeightFileRes=iConfig.getParameter<string>("pf_Res_mvaWeightFile");
187  path_mvaWeightFileRes=edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
188 
189  TFile *fgbr = new TFile(path_mvaWeightFileGCorr.c_str(),"READ");
190  ReaderGC_ =(const GBRForest*)fgbr->Get("GBRForest");
191  TFile *fgbr2 = new TFile(path_mvaWeightFileLCorr.c_str(),"READ");
192  ReaderLC_ = (const GBRForest*)fgbr2->Get("GBRForest");
193  TFile *fgbr3 = new TFile(path_mvaWeightFileRes.c_str(),"READ");
194  ReaderRes_ = (const GBRForest*)fgbr3->Get("GBRForest");
195  LogDebug("PFProducer")<<"Will set regressions from binary files " <<endl;
196  }
197 
198  }
199 
200 
201  // Reading new EGamma selection cuts
202  bool useProtectionsForJetMET(false);
203  double ele_iso_pt(0.0), ele_iso_mva_barrel(0.0), ele_iso_mva_endcap(0.0),
204  ele_iso_combIso_barrel(0.0), ele_iso_combIso_endcap(0.0),
205  ele_noniso_mva(0.0);
206  unsigned int ele_missinghits(0);
207  double ph_MinEt(0.0), ph_combIso(0.0), ph_HoE(0.0),
208  ph_sietaieta_eb(0.0),ph_sietaieta_ee(0.0);
209  string ele_iso_mvaWeightFile(""), ele_iso_path_mvaWeightFile("");
210  edm::ParameterSet ele_protectionsForJetMET,ph_protectionsForJetMET;
211 
212  // Reading new EGamma ubiased collections and value maps
213  if(use_EGammaFilters_) {
214  ele_iso_mvaWeightFile = iConfig.getParameter<string>("isolatedElectronID_mvaWeightFile");
215  ele_iso_path_mvaWeightFile = edm::FileInPath ( ele_iso_mvaWeightFile.c_str() ).fullPath();
216  inputTagPFEGammaCandidates_ = consumes<edm::View<reco::PFCandidate> >((iConfig.getParameter<edm::InputTag>("PFEGammaCandidates")));
217  inputTagValueMapGedElectrons_ = consumes<edm::ValueMap<reco::GsfElectronRef>>(iConfig.getParameter<edm::InputTag>("GedElectronValueMap"));
218  inputTagValueMapGedPhotons_ = consumes<edm::ValueMap<reco::PhotonRef> >(iConfig.getParameter<edm::InputTag>("GedPhotonValueMap"));
219  ele_iso_pt = iConfig.getParameter<double>("electron_iso_pt");
220  ele_iso_mva_barrel = iConfig.getParameter<double>("electron_iso_mva_barrel");
221  ele_iso_mva_endcap = iConfig.getParameter<double>("electron_iso_mva_endcap");
222  ele_iso_combIso_barrel = iConfig.getParameter<double>("electron_iso_combIso_barrel");
223  ele_iso_combIso_endcap = iConfig.getParameter<double>("electron_iso_combIso_endcap");
224  ele_noniso_mva = iConfig.getParameter<double>("electron_noniso_mvaCut");
225  ele_missinghits = iConfig.getParameter<unsigned int>("electron_missinghits");
226  ph_MinEt = iConfig.getParameter<double>("photon_MinEt");
227  ph_combIso = iConfig.getParameter<double>("photon_combIso");
228  ph_HoE = iConfig.getParameter<double>("photon_HoE");
229  ph_sietaieta_eb = iConfig.getParameter<double>("photon_SigmaiEtaiEta_barrel");
230  ph_sietaieta_ee = iConfig.getParameter<double>("photon_SigmaiEtaiEta_endcap");
231  useProtectionsForJetMET =
232  iConfig.getParameter<bool>("useProtectionsForJetMET");
233  ele_protectionsForJetMET =
234  iConfig.getParameter<edm::ParameterSet>("electron_protectionsForJetMET");
235  ph_protectionsForJetMET =
236  iConfig.getParameter<edm::ParameterSet>("photon_protectionsForJetMET");
237  }
238 
239  //Secondary tracks and displaced vertices parameters
240 
241  bool rejectTracks_Bad
242  = iConfig.getParameter<bool>("rejectTracks_Bad");
243 
245  = iConfig.getParameter<bool>("rejectTracks_Step45");
246 
248  = iConfig.getParameter<bool>("usePFNuclearInteractions");
249 
250  bool usePFConversions
251  = iConfig.getParameter<bool>("usePFConversions");
252 
253  bool usePFDecays
254  = iConfig.getParameter<bool>("usePFDecays");
255 
256  double dptRel_DispVtx
257  = iConfig.getParameter<double>("dptRel_DispVtx");
258 
260  = iConfig.getParameter<edm::ParameterSet>("iCfgCandConnector");
261 
262 
263  // fToRead = iConfig.getUntrackedParameter<vector<string> >("toRead");
264 
265  useCalibrationsFromDB_
266  = iConfig.getParameter<bool>("useCalibrationsFromDB");
267 
268  if (useCalibrationsFromDB_)
269  calibrationsLabel_ = iConfig.getParameter<std::string>("calibrationsLabel");
270 
271  boost::shared_ptr<PFEnergyCalibration>
272  calibration( new PFEnergyCalibration() );
273 
274  int algoType
275  = iConfig.getParameter<unsigned>("algoType");
276 
277  switch(algoType) {
278  case 0:
279  pfAlgo_.reset( new PFAlgo);
280  break;
281  default:
282  assert(0);
283  }
284 
285  pfAlgo_->setParameters( nSigmaECAL,
286  nSigmaHCAL,
287  calibration,
288  thepfEnergyCalibrationHF);
289 
290  //PFElectrons: call the method setpfeleparameters
291  pfAlgo_->setPFEleParameters(mvaEleCut,
292  path_mvaWeightFileEleID,
293  usePFElectrons_,
294  thePFSCEnergyCalibration,
295  calibration,
296  sumEtEcalIsoForEgammaSC_barrel,
297  sumEtEcalIsoForEgammaSC_endcap,
298  coneEcalIsoForEgammaSC,
299  sumPtTrackIsoForEgammaSC_barrel,
300  sumPtTrackIsoForEgammaSC_endcap,
301  nTrackIsoForEgammaSC,
302  coneTrackIsoForEgammaSC,
303  applyCrackCorrectionsForElectrons,
304  usePFSCEleCalib,
305  useEGammaElectrons_,
306  useEGammaSupercluster);
307 
308  // pfAlgo_->setPFConversionParameters(usePFConversions);
309 
310  // PFPhotons:
311  pfAlgo_->setPFPhotonParameters(usePFPhotons_,
312  path_mvaWeightFileConvID,
313  mvaConvCut,
314  usePhotonReg_,
315  path_X0_Map,
316  calibration,
317  sumPtTrackIsoForPhoton,
318  sumPtTrackIsoSlopeForPhoton);
319 
320 
321  // NEW EGamma Filters
322  pfAlgo_->setEGammaParameters(use_EGammaFilters_,
323  ele_iso_path_mvaWeightFile,
324  ele_iso_pt,
325  ele_iso_mva_barrel,
326  ele_iso_mva_endcap,
327  ele_iso_combIso_barrel,
328  ele_iso_combIso_endcap,
329  ele_noniso_mva,
330  ele_missinghits,
331  useProtectionsForJetMET,
332  ele_protectionsForJetMET,
333  ph_MinEt,
334  ph_combIso,
335  ph_HoE,
336  ph_sietaieta_eb,
337  ph_sietaieta_ee,
338  ph_protectionsForJetMET);
339 
340  //Secondary tracks and displaced vertices parameters
341 
342  pfAlgo_->setDisplacedVerticesParameters(rejectTracks_Bad,
343  rejectTracks_Step45,
344  usePFNuclearInteractions,
345  usePFConversions,
346  usePFDecays,
347  dptRel_DispVtx);
348 
349  if (usePFNuclearInteractions)
350  pfAlgo_->setCandConnectorParameters( iCfgCandConnector );
351 
352 
353 
354  // Set muon and fake track parameters
355  pfAlgo_->setPFMuonAndFakeParameters(iConfig);
356 
357  //Post cleaning of the HF
358  postHFCleaning_
359  = iConfig.getParameter<bool>("postHFCleaning");
360  double minHFCleaningPt
361  = iConfig.getParameter<double>("minHFCleaningPt");
362  double minSignificance
363  = iConfig.getParameter<double>("minSignificance");
364  double maxSignificance
365  = iConfig.getParameter<double>("maxSignificance");
367  = iConfig.getParameter<double>("minSignificanceReduction");
368  double maxDeltaPhiPt
369  = iConfig.getParameter<double>("maxDeltaPhiPt");
370  double minDeltaMet
371  = iConfig.getParameter<double>("minDeltaMet");
372 
373  // Set post HF cleaning muon parameters
374  pfAlgo_->setPostHFCleaningParameters(postHFCleaning_,
375  minHFCleaningPt,
376  minSignificance,
377  maxSignificance,
378  minSignificanceReduction,
379  maxDeltaPhiPt,
380  minDeltaMet);
381 
382  // Input tags for HF cleaned rechits
383  std::vector<edm::InputTag> tags =iConfig.getParameter< std::vector<edm::InputTag> >("cleanedHF");
384  for (unsigned int i=0;i<tags.size();++i)
385  inputTagCleanedHF_.push_back(consumes<reco::PFRecHitCollection>(tags[i]));
386  //MIKE: Vertex Parameters
387  vertices_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"));
388  useVerticesForNeutral_ = iConfig.getParameter<bool>("useVerticesForNeutral");
389 
390  // Use HO clusters and links in the PF reconstruction
391  useHO_= iConfig.getParameter<bool>("useHO");
392  pfAlgo_->setHOTag(useHO_);
393 
394  verbose_ =
395  iConfig.getUntrackedParameter<bool>("verbose",false);
396 
397  bool debug_ =
398  iConfig.getUntrackedParameter<bool>("debug",false);
399 
400  pfAlgo_->setDebug( debug_ );
401 
402 }
403 
404 
405 
407 
408 void
410  const edm::EventSetup & es)
411 {
412 
413 
414  /*
415  static map<string, PerformanceResult::ResultType> functType;
416 
417  functType["PFfa_BARREL"] = PerformanceResult::PFfa_BARREL;
418  functType["PFfa_ENDCAP"] = PerformanceResult::PFfa_ENDCAP;
419  functType["PFfb_BARREL"] = PerformanceResult::PFfb_BARREL;
420  functType["PFfb_ENDCAP"] = PerformanceResult::PFfb_ENDCAP;
421  functType["PFfc_BARREL"] = PerformanceResult::PFfc_BARREL;
422  functType["PFfc_ENDCAP"] = PerformanceResult::PFfc_ENDCAP;
423  functType["PFfaEta_BARREL"] = PerformanceResult::PFfaEta_BARREL;
424  functType["PFfaEta_ENDCAP"] = PerformanceResult::PFfaEta_ENDCAP;
425  functType["PFfbEta_BARREL"] = PerformanceResult::PFfbEta_BARREL;
426  functType["PFfbEta_ENDCAP"] = PerformanceResult::PFfbEta_ENDCAP;
427  */
428 
429  if ( useCalibrationsFromDB_ ) {
430  // read the PFCalibration functions from the global tags
432  es.get<PFCalibrationRcd>().get(calibrationsLabel_, perfH);
433 
434  PerformancePayloadFromTFormula const * pfCalibrations = static_cast< const PerformancePayloadFromTFormula *>(perfH.product());
435 
436  pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
437  }
438 
439  /*
440  for(vector<string>::const_iterator name = fToRead.begin(); name != fToRead.end(); ++name) {
441 
442  cout << "Function: " << *name << endl;
443  PerformanceResult::ResultType fType = functType[*name];
444  pfCalibrations->printFormula(fType);
445 
446  // evaluate it @ 10 GeV
447  float energy = 10.;
448 
449  BinningPointByMap point;
450  point.insert(BinningVariables::JetEt, energy);
451 
452  if(pfCalibrations->isInPayload(fType, point)) {
453  float value = pfCalibrations->getResult(fType, point);
454  cout << " Energy before:: " << energy << " after: " << value << endl;
455  } else cout << "outside limits!" << endl;
456 
457  }
458  */
459 
460  if(usePFPhotons_ && useRegressionFromDB_) {
461  edm::ESHandle<GBRForest> readerPFLCEB;
462  edm::ESHandle<GBRForest> readerPFLCEE;
463  edm::ESHandle<GBRForest> readerPFGCEB;
464  edm::ESHandle<GBRForest> readerPFGCEEHR9;
465  edm::ESHandle<GBRForest> readerPFGCEELR9;
466  edm::ESHandle<GBRForest> readerPFRes;
467  es.get<GBRWrapperRcd>().get("PFLCorrectionBar",readerPFLCEB);
468  ReaderLCEB_=readerPFLCEB.product();
469  es.get<GBRWrapperRcd>().get("PFLCorrectionEnd",readerPFLCEE);
470  ReaderLCEE_=readerPFLCEE.product();
471  es.get<GBRWrapperRcd>().get("PFGCorrectionBar",readerPFGCEB);
472  ReaderGCBarrel_=readerPFGCEB.product();
473  es.get<GBRWrapperRcd>().get("PFGCorrectionEndHighR9",readerPFGCEEHR9);
474  ReaderGCEndCapHighr9_=readerPFGCEEHR9.product();
475  es.get<GBRWrapperRcd>().get("PFGCorrectionEndLowR9",readerPFGCEELR9);
476  ReaderGCEndCapLowr9_=readerPFGCEELR9.product();
477  es.get<GBRWrapperRcd>().get("PFEcalResolution",readerPFRes);
478  ReaderEcalRes_=readerPFRes.product();
479 
480  /*
481  LogDebug("PFProducer")<<"setting regressions from DB "<<endl;
482  */
483  }
484 
485  if(usePFPhotons_){
486  //pfAlgo_->setPFPhotonRegWeights(ReaderLC_, ReaderGC_, ReaderRes_);
487  pfAlgo_->setPFPhotonRegWeights(ReaderLCEB_,ReaderLCEE_,ReaderGCBarrel_,ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderEcalRes_ );
488  }
489 }
490 
491 
492 void
494  const EventSetup& iSetup) {
495 
496  LogDebug("PFProducer")<<"START event: "
497  <<iEvent.id().event()
498  <<" in run "<<iEvent.id().run()<<endl;
499 
500 
501  // Get The vertices from the event
502  // and assign dynamic vertex parameters
504  bool gotVertices = iEvent.getByToken(vertices_,vertices);
505  if(!gotVertices) {
506  ostringstream err;
507  err<<"Cannot find vertices for this event.Continuing Without them ";
508  LogError("PFProducer")<<err.str()<<endl;
509  }
510 
511  //Assign the PFAlgo Parameters
512  pfAlgo_->setPFVertexParameters(useVerticesForNeutral_,vertices.product());
513 
514  // get the collection of blocks
515 
517 
518  iEvent.getByToken( inputTagBlocks_, blocks );
519 
520  // get the collection of muons
521 
523 
524  if ( postMuonCleaning_ ) {
525 
526  iEvent.getByToken( inputTagMuons_, muons );
527  pfAlgo_->setMuonHandle(muons);
528  }
529 
530  if (useEGammaElectrons_) {
532  iEvent.getByToken( inputTagEgammaElectrons_, egelectrons );
533  pfAlgo_->setEGElectronCollection(*egelectrons);
534  }
535 
536  if(use_EGammaFilters_) {
537 
538  // Read PFEGammaCandidates
539 
540  edm::Handle<edm::View<reco::PFCandidate> > pfEgammaCandidates;
541  iEvent.getByToken(inputTagPFEGammaCandidates_,pfEgammaCandidates);
542 
543  // Get the value maps
544 
546  iEvent.getByToken(inputTagValueMapGedElectrons_,valueMapGedElectrons);
547 
548  edm::Handle<edm::ValueMap<reco::PhotonRef> > valueMapGedPhotons;
549  iEvent.getByToken(inputTagValueMapGedPhotons_,valueMapGedPhotons);
550 
551  pfAlgo_->setEGammaCollections(*pfEgammaCandidates,
552  *valueMapGedElectrons,
553  *valueMapGedPhotons);
554 
555  }
556 
557 
558  LogDebug("PFProducer")<<"particle flow is starting"<<endl;
559 
560  assert( blocks.isValid() );
561 
562  pfAlgo_->reconstructParticles( blocks );
563 
564  if(verbose_) {
565  ostringstream str;
566  str<<(*pfAlgo_)<<endl;
567  // cout << (*pfAlgo_) << endl;
568  LogInfo("PFProducer") <<str.str()<<endl;
569  }
570 
571 
572  // Florian 5/01/2011
573  // Save the PFElectron Extra Collection First as to be able to create valid References
574  if(usePFElectrons_) {
575  auto_ptr< reco::PFCandidateElectronExtraCollection >
576  pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
577 
579  iEvent.put(pOutputElectronCandidateExtraCollection,electronExtraOutputCol_);
580  pfAlgo_->setElectronExtraRef(electronExtraProd);
581  }
582 
583  // Daniele 18/05/2011
584  // Save the PFPhoton Extra Collection First as to be able to create valid References
585  if(usePFPhotons_) {
586  auto_ptr< reco::PFCandidatePhotonExtraCollection >
587  pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
588 
590  iEvent.put(pOutputPhotonCandidateExtraCollection,photonExtraOutputCol_);
591  pfAlgo_->setPhotonExtraRef(photonExtraProd);
592  }
593 
594  // Save cosmic cleaned muon candidates
595  auto_ptr< reco::PFCandidateCollection >
596  pCosmicsMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedCosmicCandidates() );
597  // Save tracker/global cleaned muon candidates
598  auto_ptr< reco::PFCandidateCollection >
599  pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedTrackerAndGlobalCandidates() );
600  // Save fake cleaned muon candidates
601  auto_ptr< reco::PFCandidateCollection >
602  pFakeCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedFakeCandidates() );
603  // Save punch-through cleaned muon candidates
604  auto_ptr< reco::PFCandidateCollection >
605  pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedMuonCandidates() );
606  // Save punch-through cleaned neutral hadron candidates
607  auto_ptr< reco::PFCandidateCollection >
608  pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedHadronCandidates() );
609  // Save added muon candidates
610  auto_ptr< reco::PFCandidateCollection >
611  pAddedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferAddedMuonCandidates() );
612 
613  // Check HF overcleaning
615  for ( unsigned ihf=0; ihf<inputTagCleanedHF_.size(); ++ihf ) {
617  bool foundHF = iEvent.getByToken( inputTagCleanedHF_[ihf], hfCleaned );
618  if (!foundHF) continue;
619  for ( unsigned jhf=0; jhf<(*hfCleaned).size(); ++jhf ) {
620  hfCopy.push_back( (*hfCleaned)[jhf] );
621  }
622  }
623 
624  if (postHFCleaning_)
625  pfAlgo_->checkCleaning( hfCopy );
626 
627  // Save recovered HF candidates
628  auto_ptr< reco::PFCandidateCollection >
629  pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
630 
631 
632  // Save the final PFCandidate collection
633  auto_ptr< reco::PFCandidateCollection >
634  pOutputCandidateCollection( pfAlgo_->transferCandidates() );
635 
636 
637 
638  LogDebug("PFProducer")<<"particle flow: putting products in the event"<<endl;
639  if ( verbose_ ) std::cout <<"particle flow: putting products in the event. Here the full list"<<endl;
640  int nC=0;
641  for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
642  nC++;
643  if (verbose_ ) std::cout << nC << ")" << (*itCand).particleId() << std::endl;
644 
645  }
646 
647 
648 
649  // Write in the event
650  iEvent.put(pOutputCandidateCollection);
651  iEvent.put(pCleanedCandidateCollection,"CleanedHF");
652 
653  if ( postMuonCleaning_ ) {
654  iEvent.put(pCosmicsMuonCleanedCandidateCollection,"CleanedCosmicsMuons");
655  iEvent.put(pTrackerAndGlobalCleanedMuonCandidateCollection,"CleanedTrackerAndGlobalMuons");
656  iEvent.put(pFakeCleanedMuonCandidateCollection,"CleanedFakeMuons");
657  iEvent.put(pPunchThroughMuonCleanedCandidateCollection,"CleanedPunchThroughMuons");
658  iEvent.put(pPunchThroughHadronCleanedCandidateCollection,"CleanedPunchThroughNeutralHadrons");
659  iEvent.put(pAddedMuonCandidateCollection,"AddedMuonsAndHadrons");
660  }
661 
662  if(usePFElectrons_)
663  {
664  auto_ptr< reco::PFCandidateCollection >
665  pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
666  iEvent.put(pOutputElectronCandidateCollection,electronOutputCol_);
667 
668  }
669 }
670 
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
tuple calibHF_b_EMHAD
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
tuple usePFConversions
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
int ihf
tuple coneTrackIsoForEgammaSC
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
tuple calibHF_eta_step
tuple useProtectionsForJetMET
tuple sumPtTrackIsoForEgammaSC_endcap
assert(m_qm.get())
tuple calibHF_b_HADonly
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
tuple sumPtTrackIsoSlopeForPhoton
tuple maxDeltaPhiPt
tuple minHFCleaningPt
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition: PFProducer.cc:493
tuple calibPFSCEle_Fbrem_barrel
tuple minSignificance
PFProducer(const edm::ParameterSet &)
Definition: PFProducer.cc:26
tuple coneEcalIsoForEgammaSC
int iEvent
Definition: GenABIO.cc:230
tuple sumPtTrackIsoForEgammaSC_barrel
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
tuple calibPFSCEle_Fbrem_endcap
tuple sumEtEcalIsoForEgammaSC_barrel
tuple calibPFSCEle_endcap
tuple calibPFSCEle_barrel
tuple rejectTracks_Bad
tuple sumEtEcalIsoForEgammaSC_endcap
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: PFProducer.cc:409
bool isValid() const
Definition: HandleBase.h:75
tuple usePFSCEleCalib
tuple calibHF_a_EMonly
tuple tags
Definition: o2o.py:248
tuple rejectTracks_Step45
tuple maxSignificance
T const * product() const
Definition: Handle.h:81
tuple dptRel_DispVtx
tuple useEGammaSupercluster
const T & get() const
Definition: EventSetup.h:56
list blocks
Definition: gather_cfg.py:90
T const * product() const
Definition: ESHandle.h:86
tuple minSignificanceReduction
tuple calibHF_a_EMHAD
tuple usePFNuclearInteractions
edm::EventID id() const
Definition: EventBase.h:59
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:145
tuple sumPtTrackIsoForPhoton
tuple iCfgCandConnector
volatile std::atomic< bool > shutdown_flag false
Definition: PFAlgo.h:52
tuple nTrackIsoForEgammaSC
Definition: Run.h:43