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_) {
79 = iConfig.
getParameter<std::string>(
"pf_electron_output_col");
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 );
283 std::vector<double> muonHCAL
284 = iConfig.
getParameter<std::vector<double> >(
"muon_HCAL");
285 std::vector<double> muonECAL
286 = iConfig.
getParameter<std::vector<double> >(
"muon_ECAL");
287 std::vector<double> muonHO
288 = iConfig.
getParameter<std::vector<double> >(
"muon_HO");
290 assert ( muonHCAL.size() == 2 && muonECAL.size() == 2 && muonHO.size() == 2);
299 std::vector<double> factors45
300 = iConfig.
getParameter<std::vector<double> >(
"factors_45");
301 assert ( factors45.size() == 2 );
303 bool usePFMuonMomAssign
306 bool useBestMuonTrack
310 pfAlgo_->setPFMuonAndFakeParameters(muonHCAL,
323 double minHFCleaningPt
325 double minSignificance
327 double maxSignificance
329 double minSignificanceReduction
330 = iConfig.
getParameter<
double>(
"minSignificanceReduction");
337 pfAlgo_->setPostHFCleaningParameters(postHFCleaning,
341 minSignificanceReduction,
347 = iConfig.
getParameter< std::vector<edm::InputTag> >(
"cleanedHF");
351 useVerticesForNeutral_ = iConfig.
getParameter<
bool>(
"useVerticesForNeutral");
355 pfAlgo_->setHOTag(useHO_);
363 pfAlgo_->setDebug( debug_ );
396 if ( useCalibrationsFromDB_ ) {
403 pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations);
427 if(useRegressionFromDB_) {
435 ReaderLCEB_=readerPFLCEB.
product();
437 ReaderLCEE_=readerPFLCEE.
product();
439 ReaderGCBarrel_=readerPFGCEB.
product();
441 ReaderGCEndCapHighr9_=readerPFGCEEHR9.
product();
443 ReaderGCEndCapLowr9_=readerPFGCEELR9.
product();
445 ReaderEcalRes_=readerPFRes.
product();
454 pfAlgo_->setPFPhotonRegWeights(ReaderLCEB_,ReaderLCEE_,ReaderGCBarrel_,ReaderGCEndCapHighr9_, ReaderGCEndCapLowr9_, ReaderEcalRes_ );
463 LogDebug(
"PFProducer")<<
"START event: "
465 <<
" in run "<<iEvent.
id().
run()<<endl;
471 bool gotVertices = iEvent.
getByLabel(vertices_,vertices);
474 err<<
"Cannot find vertices for this event.Continuing Without them ";
475 LogError(
"PFProducer")<<err.str()<<endl;
479 pfAlgo_->setPFVertexParameters(useVerticesForNeutral_,*vertices);
485 LogDebug(
"PFProducer")<<
"getting blocks"<<endl;
491 err<<
"cannot find blocks: "<<inputTagBlocks_;
492 LogError(
"PFProducer")<<err.str()<<endl;
501 if ( postMuonCleaning_ ) {
503 LogDebug(
"PFProducer")<<
"getting muons"<<endl;
504 found = iEvent.
getByLabel( inputTagMuons_, muons );
508 err<<
"cannot find muons: "<<inputTagMuons_;
509 LogError(
"PFProducer")<<err.str()<<endl;
516 if (useEGammaElectrons_) {
519 LogDebug(
"PFProducer")<<
" Reading e/gamma electrons activated "<<endl;
520 found = iEvent.
getByLabel( inputTagEgammaElectrons_, egelectrons );
524 err<<
"cannot find electrons: "<<inputTagEgammaElectrons_;
525 LogError(
"PFProducer")<<err.str()<<endl;
530 pfAlgo_->setEGElectronCollection(*egelectrons);
534 LogDebug(
"PFProducer")<<
"particle flow is starting"<<endl;
538 pfAlgo_->reconstructParticles( blocks );
542 str<<(*pfAlgo_)<<endl;
544 LogInfo(
"PFProducer") <<str.str()<<endl;
548 if ( postMuonCleaning_ )
549 pfAlgo_->postMuonCleaning( muons, *vertices );
553 if(usePFElectrons_) {
554 auto_ptr< reco::PFCandidateElectronExtraCollection >
555 pOutputElectronCandidateExtraCollection( pfAlgo_->transferElectronExtra() );
558 iEvent.
put(pOutputElectronCandidateExtraCollection,electronExtraOutputCol_);
559 pfAlgo_->setElectronExtraRef(electronExtraProd);
565 auto_ptr< reco::PFCandidatePhotonExtraCollection >
566 pOutputPhotonCandidateExtraCollection( pfAlgo_->transferPhotonExtra() );
569 iEvent.
put(pOutputPhotonCandidateExtraCollection,photonExtraOutputCol_);
570 pfAlgo_->setPhotonExtraRef(photonExtraProd);
575 auto_ptr< reco::PFCandidateCollection >
576 pCosmicsMuonCleanedCandidateCollection( pfAlgo_->transferCosmicsMuonCleanedCandidates() );
578 auto_ptr< reco::PFCandidateCollection >
579 pTrackerAndGlobalCleanedMuonCandidateCollection( pfAlgo_->transferCleanedTrackerAndGlobalMuonCandidates() );
581 auto_ptr< reco::PFCandidateCollection >
582 pFakeCleanedMuonCandidateCollection( pfAlgo_->transferFakeMuonCleanedCandidates() );
584 auto_ptr< reco::PFCandidateCollection >
585 pPunchThroughMuonCleanedCandidateCollection( pfAlgo_->transferPunchThroughMuonCleanedCandidates() );
587 auto_ptr< reco::PFCandidateCollection >
588 pPunchThroughHadronCleanedCandidateCollection( pfAlgo_->transferPunchThroughHadronCleanedCandidates() );
590 auto_ptr< reco::PFCandidateCollection >
591 pAddedMuonCandidateCollection( pfAlgo_->transferAddedMuonCandidates() );
595 for (
unsigned ihf=0;
ihf<inputTagCleanedHF_.size(); ++
ihf ) {
597 bool foundHF = iEvent.
getByLabel( inputTagCleanedHF_[
ihf], hfCleaned );
598 if (!foundHF)
continue;
599 for (
unsigned jhf=0; jhf<(*hfCleaned).size(); ++jhf ) {
600 hfCopy.push_back( (*hfCleaned)[jhf] );
603 pfAlgo_->checkCleaning( hfCopy );
606 auto_ptr< reco::PFCandidateCollection >
607 pCleanedCandidateCollection( pfAlgo_->transferCleanedCandidates() );
611 auto_ptr< reco::PFCandidateCollection >
612 pOutputCandidateCollection( pfAlgo_->transferCandidates() );
616 LogDebug(
"PFProducer")<<
"particle flow: putting products in the event"<<endl;
617 if ( verbose_ )
std::cout <<
"particle flow: putting products in the event. Here the full list"<<endl;
619 for( reco::PFCandidateCollection::const_iterator itCand = (*pOutputCandidateCollection).begin(); itCand != (*pOutputCandidateCollection).end(); itCand++) {
621 if (verbose_ )
std::cout << nC <<
")" << (*itCand).particleId() << std::endl;
626 iEvent.
put(pOutputCandidateCollection);
627 iEvent.
put(pCleanedCandidateCollection,
"CleanedHF");
629 if ( postMuonCleaning_ ) {
630 iEvent.
put(pCosmicsMuonCleanedCandidateCollection,
"CleanedCosmicsMuons");
631 iEvent.
put(pTrackerAndGlobalCleanedMuonCandidateCollection,
"CleanedTrackerAndGlobalMuons");
632 iEvent.
put(pFakeCleanedMuonCandidateCollection,
"CleanedFakeMuons");
633 iEvent.
put(pPunchThroughMuonCleanedCandidateCollection,
"CleanedPunchThroughMuons");
634 iEvent.
put(pPunchThroughHadronCleanedCandidateCollection,
"CleanedPunchThroughNeutralHadrons");
635 iEvent.
put(pAddedMuonCandidateCollection,
"AddedMuonsAndHadrons");
640 auto_ptr< reco::PFCandidateCollection >
641 pOutputElectronCandidateCollection( pfAlgo_->transferElectronCandidates() );
642 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
PFProducer(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void beginRun(edm::Run &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
virtual void produce(edm::Event &, const edm::EventSetup &)