32 calibHF_eta_step = iConfig.
getParameter<std::vector<double> >(
"calibHF_eta_step");
33 calibHF_a_EMonly = iConfig.
getParameter<std::vector<double> >(
"calibHF_a_EMonly");
34 calibHF_b_HADonly = iConfig.
getParameter<std::vector<double> >(
"calibHF_b_HADonly");
35 calibHF_a_EMHAD = iConfig.
getParameter<std::vector<double> >(
"calibHF_a_EMHAD");
36 calibHF_b_EMHAD = iConfig.
getParameter<std::vector<double> >(
"calibHF_b_EMHAD");
37 std::shared_ptr<PFEnergyCalibrationHF>
38 thepfEnergyCalibrationHF (
new PFEnergyCalibrationHF(calibHF_use,calibHF_eta_step,calibHF_a_EMonly,calibHF_b_HADonly,calibHF_a_EMHAD,calibHF_b_EMHAD) ) ;
48 if( iConfig.
existsAs<
bool>(
"useEGammaFilters") ) {
49 use_EGammaFilters_ = iConfig.
getParameter<
bool>(
"useEGammaFilters");
51 use_EGammaFilters_ =
false;
65 if(use_EGammaFilters_) {
66 usePFElectrons_ =
false;
67 usePFPhotons_ =
false;
75 = (usePFPhotons_) ? iConfig.
getParameter<
bool>(
"useRegressionFromDB") :
false;
80 if( useEGammaElectrons_) {
92 usePFSCEleCalib = iConfig.
getParameter<
bool>(
"usePFSCEleCalib");
93 calibPFSCEle_Fbrem_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_barrel");
94 calibPFSCEle_Fbrem_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_endcap");
95 calibPFSCEle_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_barrel");
96 calibPFSCEle_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_endcap");
97 std::shared_ptr<PFSCEnergyCalibration>
98 thePFSCEnergyCalibration (
new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
99 calibPFSCEle_barrel,calibPFSCEle_endcap ));
112 produces<reco::PFCandidateCollection>();
113 produces<reco::PFCandidateCollection>(
"CleanedHF");
114 produces<reco::PFCandidateCollection>(
"CleanedCosmicsMuons");
115 produces<reco::PFCandidateCollection>(
"CleanedTrackerAndGlobalMuons");
116 produces<reco::PFCandidateCollection>(
"CleanedFakeMuons");
117 produces<reco::PFCandidateCollection>(
"CleanedPunchThroughMuons");
118 produces<reco::PFCandidateCollection>(
"CleanedPunchThroughNeutralHadrons");
119 produces<reco::PFCandidateCollection>(
"AddedMuonsAndHadrons");
122 if (usePFElectrons_) {
123 produces<reco::PFCandidateCollection>(electronOutputCol_);
124 produces<reco::PFCandidateElectronExtraCollection>(electronExtraOutputCol_);
128 produces<reco::PFCandidatePhotonExtraCollection>(photonExtraOutputCol_);
142 string mvaWeightFileEleID
143 = iConfig.
getParameter<
string>(
"pf_electronID_mvaWeightFile");
145 bool applyCrackCorrectionsForElectrons
146 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
148 string path_mvaWeightFileEleID;
151 path_mvaWeightFileEleID =
edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath();
156 string path_mvaWeightFileConvID;
157 string mvaWeightFileConvID;
158 string path_mvaWeightFileGCorr;
159 string path_mvaWeightFileLCorr;
161 string path_mvaWeightFileRes;
162 double mvaConvCut=-99.;
168 mvaWeightFileConvID =iConfig.
getParameter<
string>(
"pf_convID_mvaWeightFile");
169 mvaConvCut = iConfig.
getParameter<
double>(
"pf_conv_mvaCut");
170 path_mvaWeightFileConvID =
edm::FileInPath ( mvaWeightFileConvID.c_str() ).fullPath();
171 sumPtTrackIsoForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoForPhoton");
172 sumPtTrackIsoSlopeForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
177 if(!useRegressionFromDB_) {
178 string mvaWeightFileLCorr=iConfig.
getParameter<
string>(
"pf_locC_mvaWeightFile");
179 path_mvaWeightFileLCorr =
edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
180 string mvaWeightFileGCorr=iConfig.
getParameter<
string>(
"pf_GlobC_mvaWeightFile");
181 path_mvaWeightFileGCorr =
edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
182 string mvaWeightFileRes=iConfig.
getParameter<
string>(
"pf_Res_mvaWeightFile");
183 path_mvaWeightFileRes=
edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
185 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
186 ReaderGC_ =(
const GBRForest*)fgbr->Get(
"GBRForest");
187 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
188 ReaderLC_ = (
const GBRForest*)fgbr2->Get(
"GBRForest");
189 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
190 ReaderRes_ = (
const GBRForest*)fgbr3->Get(
"GBRForest");
191 LogDebug(
"PFProducer")<<
"Will set regressions from binary files " <<endl;
199 double ele_iso_pt(0.0), ele_iso_mva_barrel(0.0), ele_iso_mva_endcap(0.0),
200 ele_iso_combIso_barrel(0.0), ele_iso_combIso_endcap(0.0),
202 unsigned int ele_missinghits(0);
203 double ph_MinEt(0.0), ph_combIso(0.0), ph_HoE(0.0),
204 ph_sietaieta_eb(0.0),ph_sietaieta_ee(0.0);
205 string ele_iso_mvaWeightFile(
""), ele_iso_path_mvaWeightFile(
"");
206 edm::ParameterSet ele_protectionsForJetMET,ele_protectionsForBadHcal,ph_protectionsForJetMET,ph_protectionsForBadHcal;
208 if(use_EGammaFilters_) {
209 ele_iso_mvaWeightFile = iConfig.
getParameter<
string>(
"isolatedElectronID_mvaWeightFile");
210 ele_iso_path_mvaWeightFile =
edm::FileInPath ( ele_iso_mvaWeightFile.c_str() ).fullPath();
211 inputTagPFEGammaCandidates_ = consumes<edm::View<reco::PFCandidate> >((iConfig.
getParameter<
edm::InputTag>(
"PFEGammaCandidates")));
212 inputTagValueMapGedElectrons_ = consumes<edm::ValueMap<reco::GsfElectronRef>>(iConfig.
getParameter<
edm::InputTag>(
"GedElectronValueMap"));
213 inputTagValueMapGedPhotons_ = consumes<edm::ValueMap<reco::PhotonRef> >(iConfig.
getParameter<
edm::InputTag>(
"GedPhotonValueMap"));
214 ele_iso_pt = iConfig.
getParameter<
double>(
"electron_iso_pt");
215 ele_iso_mva_barrel = iConfig.
getParameter<
double>(
"electron_iso_mva_barrel");
216 ele_iso_mva_endcap = iConfig.
getParameter<
double>(
"electron_iso_mva_endcap");
217 ele_iso_combIso_barrel = iConfig.
getParameter<
double>(
"electron_iso_combIso_barrel");
218 ele_iso_combIso_endcap = iConfig.
getParameter<
double>(
"electron_iso_combIso_endcap");
219 ele_noniso_mva = iConfig.
getParameter<
double>(
"electron_noniso_mvaCut");
220 ele_missinghits = iConfig.
getParameter<
unsigned int>(
"electron_missinghits");
221 ph_MinEt = iConfig.
getParameter<
double>(
"photon_MinEt");
222 ph_combIso = iConfig.
getParameter<
double>(
"photon_combIso");
224 ph_sietaieta_eb = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_barrel");
225 ph_sietaieta_ee = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_endcap");
226 useProtectionsForJetMET =
228 ele_protectionsForJetMET =
230 ele_protectionsForBadHcal =
232 ph_protectionsForJetMET =
234 ph_protectionsForBadHcal =
247 = iConfig.
getParameter<
bool>(
"usePFNuclearInteractions");
264 useCalibrationsFromDB_
267 if (useCalibrationsFromDB_)
270 auto calibration = std::make_shared<PFEnergyCalibration>();
277 pfAlgo_.reset(
new PFAlgo);
283 pfAlgo_->setParameters( nSigmaECAL,
286 thepfEnergyCalibrationHF);
289 pfAlgo_->setPFEleParameters(mvaEleCut,
290 path_mvaWeightFileEleID,
292 thePFSCEnergyCalibration,
294 sumEtEcalIsoForEgammaSC_barrel,
295 sumEtEcalIsoForEgammaSC_endcap,
296 coneEcalIsoForEgammaSC,
297 sumPtTrackIsoForEgammaSC_barrel,
298 sumPtTrackIsoForEgammaSC_endcap,
299 nTrackIsoForEgammaSC,
300 coneTrackIsoForEgammaSC,
301 applyCrackCorrectionsForElectrons,
304 useEGammaSupercluster);
309 pfAlgo_->setPFPhotonParameters(usePFPhotons_,
310 path_mvaWeightFileConvID,
315 sumPtTrackIsoForPhoton,
316 sumPtTrackIsoSlopeForPhoton);
320 pfAlgo_->setEGammaParameters(use_EGammaFilters_,
321 ele_iso_path_mvaWeightFile,
325 ele_iso_combIso_barrel,
326 ele_iso_combIso_endcap,
329 useProtectionsForJetMET,
330 ele_protectionsForJetMET,
331 ele_protectionsForBadHcal,
337 ph_protectionsForJetMET,
338 ph_protectionsForBadHcal);
342 pfAlgo_->setDisplacedVerticesParameters(rejectTracks_Bad,
344 usePFNuclearInteractions,
349 if (usePFNuclearInteractions)
350 pfAlgo_->setCandConnectorParameters( iCfgCandConnector );
355 pfAlgo_->setPFMuonAndFakeParameters(iConfig);
356 pfAlgo_->setBadHcalTrackParams(iConfig);
368 = iConfig.
getParameter<
double>(
"minSignificanceReduction");
375 pfAlgo_->setPostHFCleaningParameters(postHFCleaning_,
379 minSignificanceReduction,
384 std::vector<edm::InputTag> tags =iConfig.
getParameter< std::vector<edm::InputTag> >(
"cleanedHF");
385 for (
unsigned int i=0;
i<tags.size();++
i)
386 inputTagCleanedHF_.push_back(consumes<reco::PFRecHitCollection>(tags[
i]));
389 useVerticesForNeutral_ = iConfig.
getParameter<
bool>(
"useVerticesForNeutral");
393 pfAlgo_->setHOTag(useHO_);
401 pfAlgo_->setDebug( debug_ );
430 if ( useCalibrationsFromDB_ ) {
437 pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
461 if(usePFPhotons_ && useRegressionFromDB_) {
469 ReaderLCEB_=readerPFLCEB.
product();
471 ReaderLCEE_=readerPFLCEE.
product();
473 ReaderGCBarrel_=readerPFGCEB.
product();
475 ReaderGCEndCapHighr9_=readerPFGCEEHR9.
product();
477 ReaderGCEndCapLowr9_=readerPFGCEELR9.
product();
479 ReaderEcalRes_=readerPFRes.
product();
488 pfAlgo_->setPFPhotonRegWeights(ReaderLCEB_,ReaderLCEE_,ReaderGCBarrel_,ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderEcalRes_ );
497 LogDebug(
"PFProducer")<<
"START event: " 499 <<
" in run "<<iEvent.
id().
run()<<endl;
505 bool gotVertices = iEvent.
getByToken(vertices_,vertices);
508 err<<
"Cannot find vertices for this event.Continuing Without them ";
509 LogError(
"PFProducer")<<err.str()<<endl;
513 pfAlgo_->setPFVertexParameters(useVerticesForNeutral_,vertices.
product());
525 if ( postMuonCleaning_ ) {
528 pfAlgo_->setMuonHandle(muons);
531 if (useEGammaElectrons_) {
533 iEvent.
getByToken( inputTagEgammaElectrons_, egelectrons );
534 pfAlgo_->setEGElectronCollection(*egelectrons);
537 if(use_EGammaFilters_) {
542 iEvent.
getByToken(inputTagPFEGammaCandidates_,pfEgammaCandidates);
547 iEvent.
getByToken(inputTagValueMapGedElectrons_,valueMapGedElectrons);
550 iEvent.
getByToken(inputTagValueMapGedPhotons_,valueMapGedPhotons);
552 pfAlgo_->setEGammaCollections(*pfEgammaCandidates,
553 *valueMapGedElectrons,
554 *valueMapGedPhotons);
559 LogDebug(
"PFProducer")<<
"particle flow is starting"<<endl;
563 pfAlgo_->reconstructParticles( blocks );
567 str<<(*pfAlgo_)<<endl;
569 LogInfo(
"PFProducer") <<str.str()<<endl;
575 if(usePFElectrons_) {
576 std::unique_ptr<reco::PFCandidateElectronExtraCollection> pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
579 iEvent.
put(
std::move(pOutputElectronCandidateExtraCollection),electronExtraOutputCol_);
580 pfAlgo_->setElectronExtraRef(electronExtraProd);
586 std::unique_ptr<reco::PFCandidatePhotonExtraCollection> pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
589 iEvent.
put(
std::move(pOutputPhotonCandidateExtraCollection),photonExtraOutputCol_);
590 pfAlgo_->setPhotonExtraRef(photonExtraProd);
594 std::unique_ptr<reco::PFCandidateCollection>
595 pCosmicsMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedCosmicCandidates() );
597 std::unique_ptr<reco::PFCandidateCollection>
598 pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedTrackerAndGlobalCandidates() );
600 std::unique_ptr<reco::PFCandidateCollection>
601 pFakeCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedFakeCandidates() );
603 std::unique_ptr<reco::PFCandidateCollection>
604 pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedMuonCandidates() );
606 std::unique_ptr<reco::PFCandidateCollection>
607 pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedHadronCandidates() );
609 std::unique_ptr<reco::PFCandidateCollection>
610 pAddedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferAddedMuonCandidates() );
614 for (
unsigned ihf=0;
ihf<inputTagCleanedHF_.size(); ++
ihf ) {
616 bool foundHF = iEvent.
getByToken( inputTagCleanedHF_[
ihf], hfCleaned );
617 if (!foundHF)
continue;
618 for (
unsigned jhf=0; jhf<(*hfCleaned).size(); ++jhf ) {
619 hfCopy.push_back( (*hfCleaned)[jhf] );
624 pfAlgo_->checkCleaning( hfCopy );
627 std::unique_ptr<reco::PFCandidateCollection> pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
631 std::unique_ptr<reco::PFCandidateCollection> pOutputCandidateCollection( pfAlgo_->transferCandidates() );
635 LogDebug(
"PFProducer")<<
"particle flow: putting products in the event"<<endl;
636 if ( verbose_ )
std::cout <<
"particle flow: putting products in the event. Here the full list"<<endl;
638 for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
640 if (verbose_ )
std::cout << nC <<
")" << (*itCand).particleId() << std::endl;
648 iEvent.
put(
std::move(pCleanedCandidateCollection),
"CleanedHF");
650 if ( postMuonCleaning_ ) {
651 iEvent.
put(
std::move(pCosmicsMuonCleanedCandidateCollection),
"CleanedCosmicsMuons");
652 iEvent.
put(
std::move(pTrackerAndGlobalCleanedMuonCandidateCollection),
"CleanedTrackerAndGlobalMuons");
653 iEvent.
put(
std::move(pFakeCleanedMuonCandidateCollection),
"CleanedFakeMuons");
654 iEvent.
put(
std::move(pPunchThroughMuonCleanedCandidateCollection),
"CleanedPunchThroughMuons");
655 iEvent.
put(
std::move(pPunchThroughHadronCleanedCandidateCollection),
"CleanedPunchThroughNeutralHadrons");
656 iEvent.
put(
std::move(pAddedMuonCandidateCollection),
"AddedMuonsAndHadrons");
661 std::unique_ptr<reco::PFCandidateCollection>
662 pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
663 iEvent.
put(
std::move(pOutputElectronCandidateCollection),electronOutputCol_);
sumPtTrackIsoForEgammaSC_barrel
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
sumPtTrackIsoForEgammaSC_endcap
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
sumEtEcalIsoForEgammaSC_endcap
void produce(edm::Event &, const edm::EventSetup &) override
PFProducer(const edm::ParameterSet &)
calibPFSCEle_Fbrem_endcap
sumEtEcalIsoForEgammaSC_barrel
void beginRun(const edm::Run &, const edm::EventSetup &) override
T const * product() const
sumPtTrackIsoSlopeForPhoton
calibPFSCEle_Fbrem_barrel
T const * product() const