27 using namespace boost;
37 std::vector<double> calibHF_eta_step;
38 std::vector<double> calibHF_a_EMonly;
39 std::vector<double> calibHF_b_HADonly;
40 std::vector<double> calibHF_a_EMHAD;
41 std::vector<double> calibHF_b_EMHAD;
43 calibHF_eta_step = iConfig.
getParameter<std::vector<double> >(
"calibHF_eta_step");
44 calibHF_a_EMonly = iConfig.
getParameter<std::vector<double> >(
"calibHF_a_EMonly");
45 calibHF_b_HADonly = iConfig.
getParameter<std::vector<double> >(
"calibHF_b_HADonly");
46 calibHF_a_EMHAD = iConfig.
getParameter<std::vector<double> >(
"calibHF_a_EMHAD");
47 calibHF_b_EMHAD = iConfig.
getParameter<std::vector<double> >(
"calibHF_b_EMHAD");
48 boost::shared_ptr<PFEnergyCalibrationHF>
49 thepfEnergyCalibrationHF (
new PFEnergyCalibrationHF(calibHF_use,calibHF_eta_step,calibHF_a_EMonly,calibHF_b_HADonly,calibHF_a_EMHAD,calibHF_b_EMHAD) ) ;
61 if( iConfig.
existsAs<
bool>(
"useEGammaFilters") ) {
62 use_EGammaFilters_ = iConfig.
getParameter<
bool>(
"useEGammaFilters");
64 use_EGammaFilters_ =
false;
78 if(use_EGammaFilters_) {
79 usePFElectrons_ =
false;
80 usePFPhotons_ =
false;
88 = (usePFPhotons_) ? iConfig.
getParameter<
bool>(
"useRegressionFromDB") :
false;
93 if( useEGammaElectrons_) {
100 bool usePFSCEleCalib;
101 std::vector<double> calibPFSCEle_Fbrem_barrel;
102 std::vector<double> calibPFSCEle_Fbrem_endcap;
103 std::vector<double> calibPFSCEle_barrel;
104 std::vector<double> calibPFSCEle_endcap;
105 usePFSCEleCalib = iConfig.
getParameter<
bool>(
"usePFSCEleCalib");
106 calibPFSCEle_Fbrem_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_barrel");
107 calibPFSCEle_Fbrem_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_endcap");
108 calibPFSCEle_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_barrel");
109 calibPFSCEle_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_endcap");
110 boost::shared_ptr<PFSCEnergyCalibration>
111 thePFSCEnergyCalibration (
new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
112 calibPFSCEle_barrel,calibPFSCEle_endcap ));
114 bool useEGammaSupercluster = iConfig.
getParameter<
bool>(
"useEGammaSupercluster");
115 double sumEtEcalIsoForEgammaSC_barrel = iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_barrel");
116 double sumEtEcalIsoForEgammaSC_endcap = iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_endcap");
117 double coneEcalIsoForEgammaSC = iConfig.
getParameter<
double>(
"coneEcalIsoForEgammaSC");
118 double sumPtTrackIsoForEgammaSC_barrel = iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_barrel");
119 double sumPtTrackIsoForEgammaSC_endcap = iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_endcap");
120 double coneTrackIsoForEgammaSC = iConfig.
getParameter<
double>(
"coneTrackIsoForEgammaSC");
121 unsigned int nTrackIsoForEgammaSC = iConfig.
getParameter<
unsigned int>(
"nTrackIsoForEgammaSC");
125 produces<reco::PFCandidateCollection>();
126 produces<reco::PFCandidateCollection>(
"CleanedHF");
127 produces<reco::PFCandidateCollection>(
"CleanedCosmicsMuons");
128 produces<reco::PFCandidateCollection>(
"CleanedTrackerAndGlobalMuons");
129 produces<reco::PFCandidateCollection>(
"CleanedFakeMuons");
130 produces<reco::PFCandidateCollection>(
"CleanedPunchThroughMuons");
131 produces<reco::PFCandidateCollection>(
"CleanedPunchThroughNeutralHadrons");
132 produces<reco::PFCandidateCollection>(
"AddedMuonsAndHadrons");
135 if (usePFElectrons_) {
136 produces<reco::PFCandidateCollection>(electronOutputCol_);
137 produces<reco::PFCandidateElectronExtraCollection>(electronExtraOutputCol_);
141 produces<reco::PFCandidatePhotonExtraCollection>(photonExtraOutputCol_);
155 string mvaWeightFileEleID
156 = iConfig.
getParameter<
string>(
"pf_electronID_mvaWeightFile");
158 bool applyCrackCorrectionsForElectrons
159 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
161 string path_mvaWeightFileEleID;
164 path_mvaWeightFileEleID =
edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath();
169 string path_mvaWeightFileConvID;
170 string mvaWeightFileConvID;
171 string path_mvaWeightFileGCorr;
172 string path_mvaWeightFileLCorr;
174 string path_mvaWeightFileRes;
175 double mvaConvCut=-99.;
176 double sumPtTrackIsoForPhoton = 99.;
177 double sumPtTrackIsoSlopeForPhoton = 99.;
181 mvaWeightFileConvID =iConfig.
getParameter<
string>(
"pf_convID_mvaWeightFile");
182 mvaConvCut = iConfig.
getParameter<
double>(
"pf_conv_mvaCut");
183 path_mvaWeightFileConvID =
edm::FileInPath ( mvaWeightFileConvID.c_str() ).fullPath();
184 sumPtTrackIsoForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoForPhoton");
185 sumPtTrackIsoSlopeForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
190 if(!useRegressionFromDB_) {
191 string mvaWeightFileLCorr=iConfig.
getParameter<
string>(
"pf_locC_mvaWeightFile");
192 path_mvaWeightFileLCorr =
edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
193 string mvaWeightFileGCorr=iConfig.
getParameter<
string>(
"pf_GlobC_mvaWeightFile");
194 path_mvaWeightFileGCorr =
edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
195 string mvaWeightFileRes=iConfig.
getParameter<
string>(
"pf_Res_mvaWeightFile");
196 path_mvaWeightFileRes=
edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
198 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
199 ReaderGC_ =(
const GBRForest*)fgbr->Get(
"GBRForest");
200 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
201 ReaderLC_ = (
const GBRForest*)fgbr2->Get(
"GBRForest");
202 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
203 ReaderRes_ = (
const GBRForest*)fgbr3->Get(
"GBRForest");
204 LogDebug(
"PFProducer")<<
"Will set regressions from binary files " <<endl;
211 bool useProtectionsForJetMET(
false);
212 double ele_iso_pt(0.0), ele_iso_mva_barrel(0.0), ele_iso_mva_endcap(0.0),
213 ele_iso_combIso_barrel(0.0), ele_iso_combIso_endcap(0.0),
215 unsigned int ele_missinghits(0);
216 double ph_MinEt(0.0), ph_combIso(0.0), ph_HoE(0.0),
217 ph_sietaieta_eb(0.0),ph_sietaieta_ee(0.0);
218 string ele_iso_mvaWeightFile(
""), ele_iso_path_mvaWeightFile(
"");
222 if(use_EGammaFilters_) {
223 ele_iso_mvaWeightFile = iConfig.
getParameter<
string>(
"isolatedElectronID_mvaWeightFile");
224 ele_iso_path_mvaWeightFile =
edm::FileInPath ( ele_iso_mvaWeightFile.c_str() ).fullPath();
228 ele_iso_pt = iConfig.
getParameter<
double>(
"electron_iso_pt");
229 ele_iso_mva_barrel = iConfig.
getParameter<
double>(
"electron_iso_mva_barrel");
230 ele_iso_mva_endcap = iConfig.
getParameter<
double>(
"electron_iso_mva_endcap");
231 ele_iso_combIso_barrel = iConfig.
getParameter<
double>(
"electron_iso_combIso_barrel");
232 ele_iso_combIso_endcap = iConfig.
getParameter<
double>(
"electron_iso_combIso_endcap");
233 ele_noniso_mva = iConfig.
getParameter<
double>(
"electron_noniso_mvaCut");
234 ele_missinghits = iConfig.
getParameter<
unsigned int>(
"electron_missinghits");
235 ph_MinEt = iConfig.
getParameter<
double>(
"photon_MinEt");
236 ph_combIso = iConfig.
getParameter<
double>(
"photon_combIso");
238 ph_sietaieta_eb = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_barrel");
239 ph_sietaieta_ee = iConfig.
getParameter<
double>(
"photon_SigmaiEtaiEta_endcap");
240 useProtectionsForJetMET =
242 ele_protectionsForJetMET =
244 ph_protectionsForJetMET =
250 bool rejectTracks_Bad
253 bool rejectTracks_Step45
256 bool usePFNuclearInteractions
257 = iConfig.
getParameter<
bool>(
"usePFNuclearInteractions");
259 bool usePFConversions
265 double dptRel_DispVtx
274 useCalibrationsFromDB_
277 boost::shared_ptr<PFEnergyCalibration>
285 pfAlgo_.reset(
new PFAlgo);
291 pfAlgo_->setParameters( nSigmaECAL,
294 thepfEnergyCalibrationHF);
297 pfAlgo_->setPFEleParameters(mvaEleCut,
298 path_mvaWeightFileEleID,
300 thePFSCEnergyCalibration,
302 sumEtEcalIsoForEgammaSC_barrel,
303 sumEtEcalIsoForEgammaSC_endcap,
304 coneEcalIsoForEgammaSC,
305 sumPtTrackIsoForEgammaSC_barrel,
306 sumPtTrackIsoForEgammaSC_endcap,
307 nTrackIsoForEgammaSC,
308 coneTrackIsoForEgammaSC,
309 applyCrackCorrectionsForElectrons,
312 useEGammaSupercluster);
317 pfAlgo_->setPFPhotonParameters(usePFPhotons_,
318 path_mvaWeightFileConvID,
323 sumPtTrackIsoForPhoton,
324 sumPtTrackIsoSlopeForPhoton);
328 pfAlgo_->setEGammaParameters(use_EGammaFilters_,
329 ele_iso_path_mvaWeightFile,
333 ele_iso_combIso_barrel,
334 ele_iso_combIso_endcap,
337 useProtectionsForJetMET,
338 ele_protectionsForJetMET,
344 ph_protectionsForJetMET);
348 pfAlgo_->setDisplacedVerticesParameters(rejectTracks_Bad,
350 usePFNuclearInteractions,
355 if (usePFNuclearInteractions)
356 pfAlgo_->setCandConnectorParameters( iCfgCandConnector );
361 pfAlgo_->setPFMuonAndFakeParameters(iConfig);
366 double minHFCleaningPt
368 double minSignificance
370 double maxSignificance
372 double minSignificanceReduction
373 = iConfig.
getParameter<
double>(
"minSignificanceReduction");
380 pfAlgo_->setPostHFCleaningParameters(postHFCleaning,
384 minSignificanceReduction,
390 = iConfig.
getParameter< std::vector<edm::InputTag> >(
"cleanedHF");
394 useVerticesForNeutral_ = iConfig.
getParameter<
bool>(
"useVerticesForNeutral");
398 pfAlgo_->setHOTag(useHO_);
406 pfAlgo_->setDebug( debug_ );
435 if ( useCalibrationsFromDB_ ) {
442 pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
466 if(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.
getByLabel(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());
524 LogDebug(
"PFProducer")<<
"getting blocks"<<endl;
530 err<<
"cannot find blocks: "<<inputTagBlocks_;
531 LogError(
"PFProducer")<<err.str()<<endl;
540 if ( postMuonCleaning_ ) {
542 LogDebug(
"PFProducer")<<
"getting muons"<<endl;
543 found = iEvent.
getByLabel( inputTagMuons_, muons );
544 pfAlgo_->setMuonHandle(muons);
547 err<<
"cannot find muons: "<<inputTagMuons_;
548 LogError(
"PFProducer")<<err.str()<<endl;
556 if (useEGammaElectrons_) {
559 LogDebug(
"PFProducer")<<
" Reading e/gamma electrons activated "<<endl;
560 found = iEvent.
getByLabel( inputTagEgammaElectrons_, egelectrons );
564 err<<
"cannot find electrons: "<<inputTagEgammaElectrons_;
565 LogError(
"PFProducer")<<err.str()<<endl;
570 pfAlgo_->setEGElectronCollection(*egelectrons);
573 if(use_EGammaFilters_) {
579 found=iEvent.
getByLabel(inputTagPFEGammaCandidates_,pfEgammaCandidates);
582 std::ostringstream err;
583 err<<
" cannot get PFEGammaCandidates: "
584 << inputTagPFEGammaCandidates_ <<std::endl;
592 found = iEvent.
getByLabel(inputTagValueMapGedElectrons_,valueMapGedElectrons);
595 std::ostringstream err;
596 err<<
" cannot get valueMapGedElectrons: "
597 << inputTagValueMapGedElectrons_ <<std::endl;
604 found = iEvent.
getByLabel(inputTagValueMapGedPhotons_,valueMapGedPhotons);
607 std::ostringstream err;
608 err<<
" cannot get valueMapGedPhotons: "
609 << inputTagValueMapGedPhotons_ <<std::endl;
614 pfAlgo_->setEGammaCollections(*pfEgammaCandidates,
615 *valueMapGedElectrons,
616 *valueMapGedPhotons);
622 LogDebug(
"PFProducer")<<
"particle flow is starting"<<endl;
626 pfAlgo_->reconstructParticles( blocks );
630 str<<(*pfAlgo_)<<endl;
632 LogInfo(
"PFProducer") <<str.str()<<endl;
638 if(usePFElectrons_) {
639 auto_ptr< reco::PFCandidateElectronExtraCollection >
640 pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
643 iEvent.
put(pOutputElectronCandidateExtraCollection,electronExtraOutputCol_);
644 pfAlgo_->setElectronExtraRef(electronExtraProd);
650 auto_ptr< reco::PFCandidatePhotonExtraCollection >
651 pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
654 iEvent.
put(pOutputPhotonCandidateExtraCollection,photonExtraOutputCol_);
655 pfAlgo_->setPhotonExtraRef(photonExtraProd);
659 auto_ptr< reco::PFCandidateCollection >
660 pCosmicsMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedCosmicCandidates() );
662 auto_ptr< reco::PFCandidateCollection >
663 pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedTrackerAndGlobalCandidates() );
665 auto_ptr< reco::PFCandidateCollection >
666 pFakeCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedFakeCandidates() );
668 auto_ptr< reco::PFCandidateCollection >
669 pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedMuonCandidates() );
671 auto_ptr< reco::PFCandidateCollection >
672 pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedHadronCandidates() );
674 auto_ptr< reco::PFCandidateCollection >
675 pAddedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferAddedMuonCandidates() );
679 for (
unsigned ihf=0;
ihf<inputTagCleanedHF_.size(); ++
ihf ) {
681 bool foundHF = iEvent.
getByLabel( inputTagCleanedHF_[
ihf], hfCleaned );
682 if (!foundHF)
continue;
683 for (
unsigned jhf=0; jhf<(*hfCleaned).size(); ++jhf ) {
684 hfCopy.push_back( (*hfCleaned)[jhf] );
687 pfAlgo_->checkCleaning( hfCopy );
690 auto_ptr< reco::PFCandidateCollection >
691 pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
695 auto_ptr< reco::PFCandidateCollection >
696 pOutputCandidateCollection( pfAlgo_->transferCandidates() );
700 LogDebug(
"PFProducer")<<
"particle flow: putting products in the event"<<endl;
701 if ( verbose_ )
std::cout <<
"particle flow: putting products in the event. Here the full list"<<endl;
703 for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
705 if (verbose_ )
std::cout << nC <<
")" << (*itCand).particleId() << std::endl;
712 iEvent.
put(pOutputCandidateCollection);
713 iEvent.
put(pCleanedCandidateCollection,
"CleanedHF");
715 if ( postMuonCleaning_ ) {
716 iEvent.
put(pCosmicsMuonCleanedCandidateCollection,
"CleanedCosmicsMuons");
717 iEvent.
put(pTrackerAndGlobalCleanedMuonCandidateCollection,
"CleanedTrackerAndGlobalMuons");
718 iEvent.
put(pFakeCleanedMuonCandidateCollection,
"CleanedFakeMuons");
719 iEvent.
put(pPunchThroughMuonCleanedCandidateCollection,
"CleanedPunchThroughMuons");
720 iEvent.
put(pPunchThroughHadronCleanedCandidateCollection,
"CleanedPunchThroughNeutralHadrons");
721 iEvent.
put(pAddedMuonCandidateCollection,
"AddedMuonsAndHadrons");
726 auto_ptr< reco::PFCandidateCollection >
727 pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
728 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
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
virtual void produce(edm::Event &, const edm::EventSetup &) override
PFProducer(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
T const * product() const
volatile std::atomic< bool > shutdown_flag false