20 using namespace boost;
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) ) ;
52 if( iConfig.
existsAs<
bool>(
"useEGammaFilters") ) {
53 use_EGammaFilters_ = iConfig.
getParameter<
bool>(
"useEGammaFilters");
55 use_EGammaFilters_ =
false;
69 if(use_EGammaFilters_) {
70 usePFElectrons_ =
false;
71 usePFPhotons_ =
false;
79 = (usePFPhotons_) ? iConfig.
getParameter<
bool>(
"useRegressionFromDB") :
false;
84 if( useEGammaElectrons_) {
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 ));
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");
126 if (usePFElectrons_) {
127 produces<reco::PFCandidateCollection>(electronOutputCol_);
128 produces<reco::PFCandidateElectronExtraCollection>(electronExtraOutputCol_);
132 produces<reco::PFCandidatePhotonExtraCollection>(photonExtraOutputCol_);
146 string mvaWeightFileEleID
147 = iConfig.
getParameter<
string>(
"pf_electronID_mvaWeightFile");
149 bool applyCrackCorrectionsForElectrons
150 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
152 string path_mvaWeightFileEleID;
155 path_mvaWeightFileEleID =
edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath();
160 string path_mvaWeightFileConvID;
161 string mvaWeightFileConvID;
162 string path_mvaWeightFileGCorr;
163 string path_mvaWeightFileLCorr;
165 string path_mvaWeightFileRes;
166 double mvaConvCut=-99.;
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");
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();
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;
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),
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,ele_protectionsForBadHcal,ph_protectionsForJetMET,ph_protectionsForBadHcal;
212 if(use_EGammaFilters_) {
213 ele_iso_mvaWeightFile = iConfig.
getParameter<
string>(
"isolatedElectronID_mvaWeightFile");
214 ele_iso_path_mvaWeightFile =
edm::FileInPath ( ele_iso_mvaWeightFile.c_str() ).fullPath();
215 inputTagPFEGammaCandidates_ = consumes<edm::View<reco::PFCandidate> >((iConfig.
getParameter<
edm::InputTag>(
"PFEGammaCandidates")));
216 inputTagValueMapGedElectrons_ = consumes<edm::ValueMap<reco::GsfElectronRef>>(iConfig.
getParameter<
edm::InputTag>(
"GedElectronValueMap"));
217 inputTagValueMapGedPhotons_ = consumes<edm::ValueMap<reco::PhotonRef> >(iConfig.
getParameter<
edm::InputTag>(
"GedPhotonValueMap"));
218 ele_iso_pt = iConfig.
getParameter<
double>(
"electron_iso_pt");
219 ele_iso_mva_barrel = iConfig.
getParameter<
double>(
"electron_iso_mva_barrel");
220 ele_iso_mva_endcap = iConfig.
getParameter<
double>(
"electron_iso_mva_endcap");
221 ele_iso_combIso_barrel = iConfig.
getParameter<
double>(
"electron_iso_combIso_barrel");
222 ele_iso_combIso_endcap = iConfig.
getParameter<
double>(
"electron_iso_combIso_endcap");
223 ele_noniso_mva = iConfig.
getParameter<
double>(
"electron_noniso_mvaCut");
224 ele_missinghits = iConfig.
getParameter<
unsigned int>(
"electron_missinghits");
225 ph_MinEt = iConfig.
getParameter<
double>(
"photon_MinEt");
226 ph_combIso = iConfig.
getParameter<
double>(
"photon_combIso");
228 ph_sietaieta_eb = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_barrel");
229 ph_sietaieta_ee = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_endcap");
230 useProtectionsForJetMET =
232 ele_protectionsForJetMET =
234 ele_protectionsForBadHcal =
236 ph_protectionsForJetMET =
238 ph_protectionsForBadHcal =
251 = iConfig.
getParameter<
bool>(
"usePFNuclearInteractions");
268 useCalibrationsFromDB_
271 if (useCalibrationsFromDB_)
274 boost::shared_ptr<PFEnergyCalibration>
282 pfAlgo_.reset(
new PFAlgo);
288 pfAlgo_->setParameters( nSigmaECAL,
291 thepfEnergyCalibrationHF);
294 pfAlgo_->setPFEleParameters(mvaEleCut,
295 path_mvaWeightFileEleID,
297 thePFSCEnergyCalibration,
299 sumEtEcalIsoForEgammaSC_barrel,
300 sumEtEcalIsoForEgammaSC_endcap,
301 coneEcalIsoForEgammaSC,
302 sumPtTrackIsoForEgammaSC_barrel,
303 sumPtTrackIsoForEgammaSC_endcap,
304 nTrackIsoForEgammaSC,
305 coneTrackIsoForEgammaSC,
306 applyCrackCorrectionsForElectrons,
309 useEGammaSupercluster);
314 pfAlgo_->setPFPhotonParameters(usePFPhotons_,
315 path_mvaWeightFileConvID,
320 sumPtTrackIsoForPhoton,
321 sumPtTrackIsoSlopeForPhoton);
325 pfAlgo_->setEGammaParameters(use_EGammaFilters_,
326 ele_iso_path_mvaWeightFile,
330 ele_iso_combIso_barrel,
331 ele_iso_combIso_endcap,
334 useProtectionsForJetMET,
335 ele_protectionsForJetMET,
336 ele_protectionsForBadHcal,
342 ph_protectionsForJetMET,
343 ph_protectionsForBadHcal);
347 pfAlgo_->setDisplacedVerticesParameters(rejectTracks_Bad,
349 usePFNuclearInteractions,
354 if (usePFNuclearInteractions)
355 pfAlgo_->setCandConnectorParameters( iCfgCandConnector );
360 pfAlgo_->setPFMuonAndFakeParameters(iConfig);
361 pfAlgo_->setBadHcalTrackParams(iConfig);
373 = iConfig.
getParameter<
double>(
"minSignificanceReduction");
380 pfAlgo_->setPostHFCleaningParameters(postHFCleaning_,
384 minSignificanceReduction,
389 std::vector<edm::InputTag> tags =iConfig.
getParameter< std::vector<edm::InputTag> >(
"cleanedHF");
390 for (
unsigned int i=0;
i<tags.size();++
i)
391 inputTagCleanedHF_.push_back(consumes<reco::PFRecHitCollection>(tags[
i]));
394 useVerticesForNeutral_ = iConfig.
getParameter<
bool>(
"useVerticesForNeutral");
398 pfAlgo_->setHOTag(useHO_);
406 pfAlgo_->setDebug( debug_ );
435 if ( useCalibrationsFromDB_ ) {
442 pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
466 if(usePFPhotons_ && useRegressionFromDB_) {
474 ReaderLCEB_=readerPFLCEB.
product();
476 ReaderLCEE_=readerPFLCEE.
product();
478 ReaderGCBarrel_=readerPFGCEB.
product();
480 ReaderGCEndCapHighr9_=readerPFGCEEHR9.
product();
482 ReaderGCEndCapLowr9_=readerPFGCEELR9.
product();
484 ReaderEcalRes_=readerPFRes.
product();
493 pfAlgo_->setPFPhotonRegWeights(ReaderLCEB_,ReaderLCEE_,ReaderGCBarrel_,ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderEcalRes_ );
502 LogDebug(
"PFProducer")<<
"START event: " 504 <<
" in run "<<iEvent.
id().
run()<<endl;
510 bool gotVertices = iEvent.
getByToken(vertices_,vertices);
513 err<<
"Cannot find vertices for this event.Continuing Without them ";
514 LogError(
"PFProducer")<<err.str()<<endl;
518 pfAlgo_->setPFVertexParameters(useVerticesForNeutral_,vertices.
product());
530 if ( postMuonCleaning_ ) {
533 pfAlgo_->setMuonHandle(muons);
536 if (useEGammaElectrons_) {
538 iEvent.
getByToken( inputTagEgammaElectrons_, egelectrons );
539 pfAlgo_->setEGElectronCollection(*egelectrons);
542 if(use_EGammaFilters_) {
547 iEvent.
getByToken(inputTagPFEGammaCandidates_,pfEgammaCandidates);
552 iEvent.
getByToken(inputTagValueMapGedElectrons_,valueMapGedElectrons);
555 iEvent.
getByToken(inputTagValueMapGedPhotons_,valueMapGedPhotons);
557 pfAlgo_->setEGammaCollections(*pfEgammaCandidates,
558 *valueMapGedElectrons,
559 *valueMapGedPhotons);
564 LogDebug(
"PFProducer")<<
"particle flow is starting"<<endl;
568 pfAlgo_->reconstructParticles( blocks );
572 str<<(*pfAlgo_)<<endl;
574 LogInfo(
"PFProducer") <<str.str()<<endl;
580 if(usePFElectrons_) {
581 std::unique_ptr<reco::PFCandidateElectronExtraCollection> pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
584 iEvent.
put(
std::move(pOutputElectronCandidateExtraCollection),electronExtraOutputCol_);
585 pfAlgo_->setElectronExtraRef(electronExtraProd);
591 std::unique_ptr<reco::PFCandidatePhotonExtraCollection> pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
594 iEvent.
put(
std::move(pOutputPhotonCandidateExtraCollection),photonExtraOutputCol_);
595 pfAlgo_->setPhotonExtraRef(photonExtraProd);
599 std::unique_ptr<reco::PFCandidateCollection>
600 pCosmicsMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedCosmicCandidates() );
602 std::unique_ptr<reco::PFCandidateCollection>
603 pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedTrackerAndGlobalCandidates() );
605 std::unique_ptr<reco::PFCandidateCollection>
606 pFakeCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedFakeCandidates() );
608 std::unique_ptr<reco::PFCandidateCollection>
609 pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedMuonCandidates() );
611 std::unique_ptr<reco::PFCandidateCollection>
612 pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedHadronCandidates() );
614 std::unique_ptr<reco::PFCandidateCollection>
615 pAddedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferAddedMuonCandidates() );
619 for (
unsigned ihf=0;
ihf<inputTagCleanedHF_.size(); ++
ihf ) {
621 bool foundHF = iEvent.
getByToken( inputTagCleanedHF_[
ihf], hfCleaned );
622 if (!foundHF)
continue;
623 for (
unsigned jhf=0; jhf<(*hfCleaned).size(); ++jhf ) {
624 hfCopy.push_back( (*hfCleaned)[jhf] );
629 pfAlgo_->checkCleaning( hfCopy );
632 std::unique_ptr<reco::PFCandidateCollection> pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
636 std::unique_ptr<reco::PFCandidateCollection> pOutputCandidateCollection( pfAlgo_->transferCandidates() );
640 LogDebug(
"PFProducer")<<
"particle flow: putting products in the event"<<endl;
641 if ( verbose_ )
std::cout <<
"particle flow: putting products in the event. Here the full list"<<endl;
643 for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
645 if (verbose_ )
std::cout << nC <<
")" << (*itCand).particleId() << std::endl;
653 iEvent.
put(
std::move(pCleanedCandidateCollection),
"CleanedHF");
655 if ( postMuonCleaning_ ) {
656 iEvent.
put(
std::move(pCosmicsMuonCleanedCandidateCollection),
"CleanedCosmicsMuons");
657 iEvent.
put(
std::move(pTrackerAndGlobalCleanedMuonCandidateCollection),
"CleanedTrackerAndGlobalMuons");
658 iEvent.
put(
std::move(pFakeCleanedMuonCandidateCollection),
"CleanedFakeMuons");
659 iEvent.
put(
std::move(pPunchThroughMuonCleanedCandidateCollection),
"CleanedPunchThroughMuons");
660 iEvent.
put(
std::move(pPunchThroughHadronCleanedCandidateCollection),
"CleanedPunchThroughNeutralHadrons");
661 iEvent.
put(
std::move(pAddedMuonCandidateCollection),
"AddedMuonsAndHadrons");
666 std::unique_ptr<reco::PFCandidateCollection>
667 pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
668 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