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;
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");
175 sumPtTrackIsoForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoForPhoton");
176 sumPtTrackIsoSlopeForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
181 if(!useRegressionFromDB_) {
182 string mvaWeightFileLCorr=iConfig.
getParameter<
string>(
"pf_locC_mvaWeightFile");
184 string mvaWeightFileGCorr=iConfig.
getParameter<
string>(
"pf_GlobC_mvaWeightFile");
186 string mvaWeightFileRes=iConfig.
getParameter<
string>(
"pf_Res_mvaWeightFile");
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(
"");
213 if(use_EGammaFilters_) {
214 ele_iso_mvaWeightFile = iConfig.
getParameter<
string>(
"isolatedElectronID_mvaWeightFile");
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");
229 ph_sietaieta_eb = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_barrel");
230 ph_sietaieta_ee = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_endcap");
231 useProtectionsForJetMET =
233 ele_protectionsForJetMET =
235 ph_protectionsForJetMET =
248 = iConfig.
getParameter<
bool>(
"usePFNuclearInteractions");
265 useCalibrationsFromDB_
268 if (useCalibrationsFromDB_)
271 boost::shared_ptr<PFEnergyCalibration>
279 pfAlgo_.reset(
new PFAlgo);
285 pfAlgo_->setParameters( nSigmaECAL,
288 thepfEnergyCalibrationHF);
291 pfAlgo_->setPFEleParameters(mvaEleCut,
292 path_mvaWeightFileEleID,
294 thePFSCEnergyCalibration,
296 sumEtEcalIsoForEgammaSC_barrel,
297 sumEtEcalIsoForEgammaSC_endcap,
298 coneEcalIsoForEgammaSC,
299 sumPtTrackIsoForEgammaSC_barrel,
300 sumPtTrackIsoForEgammaSC_endcap,
301 nTrackIsoForEgammaSC,
302 coneTrackIsoForEgammaSC,
303 applyCrackCorrectionsForElectrons,
306 useEGammaSupercluster);
311 pfAlgo_->setPFPhotonParameters(usePFPhotons_,
312 path_mvaWeightFileConvID,
317 sumPtTrackIsoForPhoton,
318 sumPtTrackIsoSlopeForPhoton);
322 pfAlgo_->setEGammaParameters(use_EGammaFilters_,
323 ele_iso_path_mvaWeightFile,
327 ele_iso_combIso_barrel,
328 ele_iso_combIso_endcap,
331 useProtectionsForJetMET,
332 ele_protectionsForJetMET,
338 ph_protectionsForJetMET);
342 pfAlgo_->setDisplacedVerticesParameters(rejectTracks_Bad,
344 usePFNuclearInteractions,
349 if (usePFNuclearInteractions)
350 pfAlgo_->setCandConnectorParameters( iCfgCandConnector );
355 pfAlgo_->setPFMuonAndFakeParameters(iConfig);
367 = iConfig.
getParameter<
double>(
"minSignificanceReduction");
374 pfAlgo_->setPostHFCleaningParameters(postHFCleaning_,
378 minSignificanceReduction,
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]));
388 useVerticesForNeutral_ = iConfig.
getParameter<
bool>(
"useVerticesForNeutral");
392 pfAlgo_->setHOTag(useHO_);
400 pfAlgo_->setDebug( debug_ );
429 if ( useCalibrationsFromDB_ ) {
436 pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
460 if(usePFPhotons_ && useRegressionFromDB_) {
468 ReaderLCEB_=readerPFLCEB.
product();
470 ReaderLCEE_=readerPFLCEE.
product();
472 ReaderGCBarrel_=readerPFGCEB.
product();
474 ReaderGCEndCapHighr9_=readerPFGCEEHR9.
product();
476 ReaderGCEndCapLowr9_=readerPFGCEELR9.
product();
478 ReaderEcalRes_=readerPFRes.
product();
487 pfAlgo_->setPFPhotonRegWeights(ReaderLCEB_,ReaderLCEE_,ReaderGCBarrel_,ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderEcalRes_ );
496 LogDebug(
"PFProducer")<<
"START event: "
498 <<
" in run "<<iEvent.
id().
run()<<endl;
504 bool gotVertices = iEvent.
getByToken(vertices_,vertices);
507 err<<
"Cannot find vertices for this event.Continuing Without them ";
508 LogError(
"PFProducer")<<err.str()<<endl;
512 pfAlgo_->setPFVertexParameters(useVerticesForNeutral_,vertices.
product());
524 if ( postMuonCleaning_ ) {
527 pfAlgo_->setMuonHandle(muons);
530 if (useEGammaElectrons_) {
532 iEvent.
getByToken( inputTagEgammaElectrons_, egelectrons );
533 pfAlgo_->setEGElectronCollection(*egelectrons);
536 if(use_EGammaFilters_) {
541 iEvent.
getByToken(inputTagPFEGammaCandidates_,pfEgammaCandidates);
546 iEvent.
getByToken(inputTagValueMapGedElectrons_,valueMapGedElectrons);
549 iEvent.
getByToken(inputTagValueMapGedPhotons_,valueMapGedPhotons);
551 pfAlgo_->setEGammaCollections(*pfEgammaCandidates,
552 *valueMapGedElectrons,
553 *valueMapGedPhotons);
558 LogDebug(
"PFProducer")<<
"particle flow is starting"<<endl;
562 pfAlgo_->reconstructParticles( blocks );
566 str<<(*pfAlgo_)<<endl;
568 LogInfo(
"PFProducer") <<str.str()<<endl;
574 if(usePFElectrons_) {
575 auto_ptr< reco::PFCandidateElectronExtraCollection >
576 pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
579 iEvent.
put(pOutputElectronCandidateExtraCollection,electronExtraOutputCol_);
580 pfAlgo_->setElectronExtraRef(electronExtraProd);
586 auto_ptr< reco::PFCandidatePhotonExtraCollection >
587 pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
590 iEvent.
put(pOutputPhotonCandidateExtraCollection,photonExtraOutputCol_);
591 pfAlgo_->setPhotonExtraRef(photonExtraProd);
595 auto_ptr< reco::PFCandidateCollection >
596 pCosmicsMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedCosmicCandidates() );
598 auto_ptr< reco::PFCandidateCollection >
599 pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedTrackerAndGlobalCandidates() );
601 auto_ptr< reco::PFCandidateCollection >
602 pFakeCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedFakeCandidates() );
604 auto_ptr< reco::PFCandidateCollection >
605 pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedMuonCandidates() );
607 auto_ptr< reco::PFCandidateCollection >
608 pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedHadronCandidates() );
610 auto_ptr< reco::PFCandidateCollection >
611 pAddedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferAddedMuonCandidates() );
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] );
625 pfAlgo_->checkCleaning( hfCopy );
628 auto_ptr< reco::PFCandidateCollection >
629 pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
633 auto_ptr< reco::PFCandidateCollection >
634 pOutputCandidateCollection( pfAlgo_->transferCandidates() );
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;
641 for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
643 if (verbose_ )
std::cout << nC <<
")" << (*itCand).particleId() << std::endl;
650 iEvent.
put(pOutputCandidateCollection);
651 iEvent.
put(pCleanedCandidateCollection,
"CleanedHF");
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");
664 auto_ptr< reco::PFCandidateCollection >
665 pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
666 iEvent.
put(pOutputElectronCandidateCollection,electronOutputCol_);
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
tuple coneTrackIsoForEgammaSC
bool getByToken(EDGetToken token, Handle< PROD > &result) const
tuple useProtectionsForJetMET
tuple sumPtTrackIsoForEgammaSC_endcap
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
tuple sumPtTrackIsoSlopeForPhoton
virtual void produce(edm::Event &, const edm::EventSetup &) override
tuple calibPFSCEle_Fbrem_barrel
PFProducer(const edm::ParameterSet &)
tuple coneEcalIsoForEgammaSC
tuple sumPtTrackIsoForEgammaSC_barrel
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
tuple calibPFSCEle_Fbrem_endcap
tuple sumEtEcalIsoForEgammaSC_barrel
tuple calibPFSCEle_endcap
tuple calibPFSCEle_barrel
tuple sumEtEcalIsoForEgammaSC_endcap
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
tuple rejectTracks_Step45
T const * product() const
tuple useEGammaSupercluster
T const * product() const
tuple minSignificanceReduction
tuple usePFNuclearInteractions
tuple sumPtTrackIsoForPhoton
volatile std::atomic< bool > shutdown_flag false
tuple nTrackIsoForEgammaSC