25 using namespace boost;
35 std::vector<double> calibHF_eta_step;
36 std::vector<double> calibHF_a_EMonly;
37 std::vector<double> calibHF_b_HADonly;
38 std::vector<double> calibHF_a_EMHAD;
39 std::vector<double> calibHF_b_EMHAD;
41 calibHF_eta_step = iConfig.
getParameter<std::vector<double> >(
"calibHF_eta_step");
42 calibHF_a_EMonly = iConfig.
getParameter<std::vector<double> >(
"calibHF_a_EMonly");
43 calibHF_b_HADonly = iConfig.
getParameter<std::vector<double> >(
"calibHF_b_HADonly");
44 calibHF_a_EMHAD = iConfig.
getParameter<std::vector<double> >(
"calibHF_a_EMHAD");
45 calibHF_b_EMHAD = iConfig.
getParameter<std::vector<double> >(
"calibHF_b_EMHAD");
46 boost::shared_ptr<PFEnergyCalibrationHF>
47 thepfEnergyCalibrationHF (
new PFEnergyCalibrationHF(calibHF_use,calibHF_eta_step,calibHF_a_EMonly,calibHF_b_HADonly,calibHF_a_EMHAD,calibHF_b_EMHAD) ) ;
69 = (usePFPhotons_) ? iConfig.
getParameter<
bool>(
"useRegressionFromDB") :
false;
74 if( useEGammaElectrons_) {
82 std::vector<double> calibPFSCEle_Fbrem_barrel;
83 std::vector<double> calibPFSCEle_Fbrem_endcap;
84 std::vector<double> calibPFSCEle_barrel;
85 std::vector<double> calibPFSCEle_endcap;
86 usePFSCEleCalib = iConfig.
getParameter<
bool>(
"usePFSCEleCalib");
87 calibPFSCEle_Fbrem_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_barrel");
88 calibPFSCEle_Fbrem_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_Fbrem_endcap");
89 calibPFSCEle_barrel = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_barrel");
90 calibPFSCEle_endcap = iConfig.
getParameter<std::vector<double> >(
"calibPFSCEle_endcap");
91 boost::shared_ptr<PFSCEnergyCalibration>
92 thePFSCEnergyCalibration (
new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
93 calibPFSCEle_barrel,calibPFSCEle_endcap ));
95 bool useEGammaSupercluster = iConfig.
getParameter<
bool>(
"useEGammaSupercluster");
96 double sumEtEcalIsoForEgammaSC_barrel = iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_barrel");
97 double sumEtEcalIsoForEgammaSC_endcap = iConfig.
getParameter<
double>(
"sumEtEcalIsoForEgammaSC_endcap");
98 double coneEcalIsoForEgammaSC = iConfig.
getParameter<
double>(
"coneEcalIsoForEgammaSC");
99 double sumPtTrackIsoForEgammaSC_barrel = iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_barrel");
100 double sumPtTrackIsoForEgammaSC_endcap = iConfig.
getParameter<
double>(
"sumPtTrackIsoForEgammaSC_endcap");
101 double coneTrackIsoForEgammaSC = iConfig.
getParameter<
double>(
"coneTrackIsoForEgammaSC");
102 unsigned int nTrackIsoForEgammaSC = iConfig.
getParameter<
unsigned int>(
"nTrackIsoForEgammaSC");
106 produces<reco::PFCandidateCollection>();
107 produces<reco::PFCandidateCollection>(
"CleanedHF");
108 produces<reco::PFCandidateCollection>(
"CleanedCosmicsMuons");
109 produces<reco::PFCandidateCollection>(
"CleanedTrackerAndGlobalMuons");
110 produces<reco::PFCandidateCollection>(
"CleanedFakeMuons");
111 produces<reco::PFCandidateCollection>(
"CleanedPunchThroughMuons");
112 produces<reco::PFCandidateCollection>(
"CleanedPunchThroughNeutralHadrons");
113 produces<reco::PFCandidateCollection>(
"AddedMuonsAndHadrons");
116 if (usePFElectrons_) {
117 produces<reco::PFCandidateCollection>(electronOutputCol_);
118 produces<reco::PFCandidateElectronExtraCollection>(electronExtraOutputCol_);
122 produces<reco::PFCandidatePhotonExtraCollection>(photonExtraOutputCol_);
136 string mvaWeightFileEleID
137 = iConfig.
getParameter<
string>(
"pf_electronID_mvaWeightFile");
139 bool applyCrackCorrectionsForElectrons
140 = iConfig.
getParameter<
bool>(
"pf_electronID_crackCorrection");
142 string path_mvaWeightFileEleID;
145 path_mvaWeightFileEleID =
edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath();
150 string path_mvaWeightFileConvID;
151 string mvaWeightFileConvID;
152 string path_mvaWeightFileGCorr;
153 string path_mvaWeightFileLCorr;
155 string path_mvaWeightFileRes;
156 double mvaConvCut=-99.;
157 double sumPtTrackIsoForPhoton = 99.;
158 double sumPtTrackIsoSlopeForPhoton = 99.;
162 mvaWeightFileConvID =iConfig.
getParameter<
string>(
"pf_convID_mvaWeightFile");
163 mvaConvCut = iConfig.
getParameter<
double>(
"pf_conv_mvaCut");
164 path_mvaWeightFileConvID =
edm::FileInPath ( mvaWeightFileConvID.c_str() ).fullPath();
165 sumPtTrackIsoForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoForPhoton");
166 sumPtTrackIsoSlopeForPhoton = iConfig.
getParameter<
double>(
"sumPtTrackIsoSlopeForPhoton");
171 if(!useRegressionFromDB_) {
172 string mvaWeightFileLCorr=iConfig.
getParameter<
string>(
"pf_locC_mvaWeightFile");
173 path_mvaWeightFileLCorr =
edm::FileInPath( mvaWeightFileLCorr.c_str() ).fullPath();
174 string mvaWeightFileGCorr=iConfig.
getParameter<
string>(
"pf_GlobC_mvaWeightFile");
175 path_mvaWeightFileGCorr =
edm::FileInPath( mvaWeightFileGCorr.c_str() ).fullPath();
176 string mvaWeightFileRes=iConfig.
getParameter<
string>(
"pf_Res_mvaWeightFile");
177 path_mvaWeightFileRes=
edm::FileInPath(mvaWeightFileRes.c_str()).fullPath();
179 TFile *fgbr =
new TFile(path_mvaWeightFileGCorr.c_str(),
"READ");
180 ReaderGC_ =(
const GBRForest*)fgbr->Get(
"GBRForest");
181 TFile *fgbr2 =
new TFile(path_mvaWeightFileLCorr.c_str(),
"READ");
182 ReaderLC_ = (
const GBRForest*)fgbr2->Get(
"GBRForest");
183 TFile *fgbr3 =
new TFile(path_mvaWeightFileRes.c_str(),
"READ");
184 ReaderRes_ = (
const GBRForest*)fgbr3->Get(
"GBRForest");
185 LogDebug(
"PFProducer")<<
"Will set regressions from binary files " <<endl;
193 bool rejectTracks_Bad
196 bool rejectTracks_Step45
199 bool usePFNuclearInteractions
200 = iConfig.
getParameter<
bool>(
"usePFNuclearInteractions");
202 bool usePFConversions
208 double dptRel_DispVtx
217 useCalibrationsFromDB_
220 boost::shared_ptr<PFEnergyCalibration>
228 pfAlgo_.reset(
new PFAlgo);
234 pfAlgo_->setParameters( nSigmaECAL,
237 thepfEnergyCalibrationHF);
240 pfAlgo_->setPFEleParameters(mvaEleCut,
241 path_mvaWeightFileEleID,
243 thePFSCEnergyCalibration,
245 sumEtEcalIsoForEgammaSC_barrel,
246 sumEtEcalIsoForEgammaSC_endcap,
247 coneEcalIsoForEgammaSC,
248 sumPtTrackIsoForEgammaSC_barrel,
249 sumPtTrackIsoForEgammaSC_endcap,
250 nTrackIsoForEgammaSC,
251 coneTrackIsoForEgammaSC,
252 applyCrackCorrectionsForElectrons,
255 useEGammaSupercluster);
260 pfAlgo_->setPFPhotonParameters(usePFPhotons_,
261 path_mvaWeightFileConvID,
266 sumPtTrackIsoForPhoton,
267 sumPtTrackIsoSlopeForPhoton);
272 pfAlgo_->setDisplacedVerticesParameters(rejectTracks_Bad,
274 usePFNuclearInteractions,
279 if (usePFNuclearInteractions)
280 pfAlgo_->setCandConnectorParameters( iCfgCandConnector );
285 pfAlgo_->setPFMuonAndFakeParameters(iConfig);
290 double minHFCleaningPt
292 double minSignificance
294 double maxSignificance
296 double minSignificanceReduction
297 = iConfig.
getParameter<
double>(
"minSignificanceReduction");
304 pfAlgo_->setPostHFCleaningParameters(postHFCleaning,
308 minSignificanceReduction,
314 = iConfig.
getParameter< std::vector<edm::InputTag> >(
"cleanedHF");
318 useVerticesForNeutral_ = iConfig.
getParameter<
bool>(
"useVerticesForNeutral");
322 pfAlgo_->setHOTag(useHO_);
330 pfAlgo_->setDebug( debug_ );
359 if ( useCalibrationsFromDB_ ) {
366 pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
390 if(useRegressionFromDB_) {
398 ReaderLCEB_=readerPFLCEB.
product();
400 ReaderLCEE_=readerPFLCEE.
product();
402 ReaderGCBarrel_=readerPFGCEB.
product();
404 ReaderGCEndCapHighr9_=readerPFGCEEHR9.
product();
406 ReaderGCEndCapLowr9_=readerPFGCEELR9.
product();
408 ReaderEcalRes_=readerPFRes.
product();
417 pfAlgo_->setPFPhotonRegWeights(ReaderLCEB_,ReaderLCEE_,ReaderGCBarrel_,ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderEcalRes_ );
426 LogDebug(
"PFProducer")<<
"START event: "
428 <<
" in run "<<iEvent.
id().
run()<<endl;
434 bool gotVertices = iEvent.
getByLabel(vertices_,vertices);
437 err<<
"Cannot find vertices for this event.Continuing Without them ";
438 LogError(
"PFProducer")<<err.str()<<endl;
442 pfAlgo_->setPFVertexParameters(useVerticesForNeutral_,vertices.
product());
448 LogDebug(
"PFProducer")<<
"getting blocks"<<endl;
454 err<<
"cannot find blocks: "<<inputTagBlocks_;
455 LogError(
"PFProducer")<<err.str()<<endl;
464 if ( postMuonCleaning_ ) {
466 LogDebug(
"PFProducer")<<
"getting muons"<<endl;
467 found = iEvent.
getByLabel( inputTagMuons_, muons );
468 pfAlgo_->setMuonHandle(muons);
471 err<<
"cannot find muons: "<<inputTagMuons_;
472 LogError(
"PFProducer")<<err.str()<<endl;
480 if (useEGammaElectrons_) {
483 LogDebug(
"PFProducer")<<
" Reading e/gamma electrons activated "<<endl;
484 found = iEvent.
getByLabel( inputTagEgammaElectrons_, egelectrons );
488 err<<
"cannot find electrons: "<<inputTagEgammaElectrons_;
489 LogError(
"PFProducer")<<err.str()<<endl;
494 pfAlgo_->setEGElectronCollection(*egelectrons);
498 LogDebug(
"PFProducer")<<
"particle flow is starting"<<endl;
502 pfAlgo_->reconstructParticles( blocks );
506 str<<(*pfAlgo_)<<endl;
508 LogInfo(
"PFProducer") <<str.str()<<endl;
514 if(usePFElectrons_) {
515 auto_ptr< reco::PFCandidateElectronExtraCollection >
516 pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
519 iEvent.
put(pOutputElectronCandidateExtraCollection,electronExtraOutputCol_);
520 pfAlgo_->setElectronExtraRef(electronExtraProd);
526 auto_ptr< reco::PFCandidatePhotonExtraCollection >
527 pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
530 iEvent.
put(pOutputPhotonCandidateExtraCollection,photonExtraOutputCol_);
531 pfAlgo_->setPhotonExtraRef(photonExtraProd);
536 auto_ptr< reco::PFCandidateCollection >
537 pCosmicsMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedCosmicCandidates() );
539 auto_ptr< reco::PFCandidateCollection >
540 pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedTrackerAndGlobalCandidates() );
542 auto_ptr< reco::PFCandidateCollection >
543 pFakeCleanedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferCleanedFakeCandidates() );
545 auto_ptr< reco::PFCandidateCollection >
546 pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedMuonCandidates() );
548 auto_ptr< reco::PFCandidateCollection >
549 pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferPunchThroughCleanedHadronCandidates() );
551 auto_ptr< reco::PFCandidateCollection >
552 pAddedMuonCandidateCollection( pfAlgo_->getPFMuonAlgo()->transferAddedMuonCandidates() );
556 for (
unsigned ihf=0;
ihf<inputTagCleanedHF_.size(); ++
ihf ) {
558 bool foundHF = iEvent.
getByLabel( inputTagCleanedHF_[
ihf], hfCleaned );
559 if (!foundHF)
continue;
560 for (
unsigned jhf=0; jhf<(*hfCleaned).size(); ++jhf ) {
561 hfCopy.push_back( (*hfCleaned)[jhf] );
564 pfAlgo_->checkCleaning( hfCopy );
567 auto_ptr< reco::PFCandidateCollection >
568 pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
572 auto_ptr< reco::PFCandidateCollection >
573 pOutputCandidateCollection( pfAlgo_->transferCandidates() );
577 LogDebug(
"PFProducer")<<
"particle flow: putting products in the event"<<endl;
578 if ( verbose_ )
std::cout <<
"particle flow: putting products in the event. Here the full list"<<endl;
580 for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
582 if (verbose_ )
std::cout << nC <<
")" << (*itCand).particleId() << std::endl;
589 iEvent.
put(pOutputCandidateCollection);
590 iEvent.
put(pCleanedCandidateCollection,
"CleanedHF");
592 if ( postMuonCleaning_ ) {
593 iEvent.
put(pCosmicsMuonCleanedCandidateCollection,
"CleanedCosmicsMuons");
594 iEvent.
put(pTrackerAndGlobalCleanedMuonCandidateCollection,
"CleanedTrackerAndGlobalMuons");
595 iEvent.
put(pFakeCleanedMuonCandidateCollection,
"CleanedFakeMuons");
596 iEvent.
put(pPunchThroughMuonCleanedCandidateCollection,
"CleanedPunchThroughMuons");
597 iEvent.
put(pPunchThroughHadronCleanedCandidateCollection,
"CleanedPunchThroughNeutralHadrons");
598 iEvent.
put(pAddedMuonCandidateCollection,
"AddedMuonsAndHadrons");
603 auto_ptr< reco::PFCandidateCollection >
604 pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
605 iEvent.
put(pOutputElectronCandidateCollection,electronOutputCol_);
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
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