2 #include <boost/foreach.hpp>
31 qualityCutsPSet_(pset.getParameter<edm::
ParameterSet>(
"qualityCuts"))
34 "ApplyDiscriminationByTrackerIsolation");
36 "ApplyDiscriminationByECALIsolation");
38 applyOccupancyCut_ = pset.
getParameter<
bool>(
"applyOccupancyCut");
39 maximumOccupancy_ = pset.
getParameter<uint32_t>(
"maximumOccupancy");
41 applySumPtCut_ = pset.
getParameter<
bool>(
"applySumPtCut");
42 maximumSumPt_ = pset.
getParameter<
double>(
"maximumSumPtCut");
45 "applyRelativeSumPtCut");
49 storeRawOccupancy_ = pset.
exists(
"storeRawOccupancy") ?
51 storeRawSumPt_ = pset.
exists(
"storeRawSumPt") ?
53 storeRawPUsumPt_ = pset.
exists(
"storeRawPUsumPt") ?
58 if ( applySumPtCut_ || applyOccupancyCut_ || applyRelativeSumPtCut_ ) {
59 if ( storeRawSumPt_ || storeRawOccupancy_ || storeRawPUsumPt_ ) {
61 <<
"A 'store raw' and a 'apply cut' option have been set to true "
62 <<
"simultaneously. These options are mutually exclusive.";
67 int numStoreOptions = 0;
68 if ( storeRawSumPt_ ) ++numStoreOptions;
69 if ( storeRawOccupancy_ ) ++numStoreOptions;
70 if ( storeRawPUsumPt_ ) ++numStoreOptions;
71 if ( numStoreOptions > 1 ) {
73 <<
"Both 'store sum pt' and 'store occupancy' options are set."
74 <<
" These options are mutually exclusive.";
77 if ( pset.
exists(
"customOuterCone") ) {
78 customIsoCone_ = pset.
getParameter<
double>(
"customOuterCone");
85 "isolationQualityCuts");
89 vertexAssociator_.reset(
92 applyDeltaBeta_ = pset.
exists(
"applyDeltaBetaCorrection") ?
93 pset.
getParameter<
bool>(
"applyDeltaBetaCorrection") :
false;
95 if ( applyDeltaBeta_ ) {
98 std::pair<edm::ParameterSet, edm::ParameterSet> puFactorizedIsoQCuts =
103 if ( pset.
exists(
"deltaBetaPUTrackPtCutOverride") ) {
104 puFactorizedIsoQCuts.second.addParameter<
double>(
106 pset.
getParameter<
double>(
"deltaBetaPUTrackPtCutOverride"));
109 puFactorizedIsoQCuts.second.addParameter<
double>(
115 puFactorizedIsoQCuts.first));
118 puFactorizedIsoQCuts.second));
121 pfCand_token=consumes<reco::PFCandidateCollection>(pfCandSrc_);
123 vertex_token=consumes<reco::VertexCollection>(vertexSrc_);
125 "isoConeSizeForDeltaBeta");
128 deltaBetaFormula_.reset(
129 new TFormula(
"DB_corr", deltaBetaFactorFormula.c_str()));
132 applyRhoCorrection_ = pset.
exists(
"applyRhoCorrection") ?
134 if ( applyRhoCorrection_ ) {
136 rho_token=consumes<double>(rhoProducer_);
137 rhoConeSize_ = pset.
getParameter<
double>(
"rhoConeSize");
138 rhoUEOffsetCorrection_ =
142 verbosity_ = ( pset.
exists(
"verbosity") ) ?
149 double discriminate(
const PFTauRef& pfTau)
override;
155 std::auto_ptr<tau::RecoTauQualityCuts>
qcuts_;
217 vertexAssociator_->setEvent(event);
221 if ( applyDeltaBeta_ ) {
224 event.getByToken(pfCand_token, pfCandidates);
225 chargedPFCandidatesInEvent_.clear();
226 chargedPFCandidatesInEvent_.reserve(pfCandidates->size());
227 size_t numPFCandidates = pfCandidates->size();
228 for (
size_t i = 0;
i < numPFCandidates; ++
i ) {
230 if ( pfCandidate->charge() != 0 ) {
231 chargedPFCandidatesInEvent_.push_back(pfCandidate);
237 event.getByToken(vertex_token, vertices);
238 size_t nVtxThisEvent = vertices->size();
239 deltaBetaFactorThisEvent_ = deltaBetaFormula_->Eval(nVtxThisEvent);
242 if ( applyRhoCorrection_ ) {
244 event.getByToken(rho_token, rhoHandle_);
245 rhoThisEvent_ = (*rhoHandle_ - rhoUEOffsetCorrection_)*
246 (3.14159)*rhoConeSize_*rhoConeSize_;
254 std::cout <<
"<PFRecoTauDiscriminationByIsolation::discriminate (moduleLabel = " <<
moduleLabel_ <<
")>:" << std::endl;
255 std::cout <<
" tau: Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi() << std::endl;
260 isoCharged_.reserve(pfTau->isolationPFChargedHadrCands().size());
262 isoNeutral_.reserve(pfTau->isolationPFGammaCands().size());
264 isoPU_.reserve(chargedPFCandidatesInEvent_.size());
272 std::cout <<
"pv: x = " << pv->position().x() <<
", y = " << pv->position().y() <<
", z = " << pv->position().z() << std::endl;
276 if ( pfTau->leadPFChargedHadrCand().
isNonnull() ) {
278 <<
" Pt = " << pfTau->leadPFChargedHadrCand()->pt() <<
","
279 <<
" eta = " << pfTau->leadPFChargedHadrCand()->eta() <<
","
280 <<
" phi = " << pfTau->leadPFChargedHadrCand()->phi() << std::endl;
282 std::cout <<
"leadPFChargedHadron: N/A" << std::endl;
290 qcuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
292 if ( applyDeltaBeta_ ) {
293 pileupQcutsGeneralQCuts_->setPV(pv);
294 pileupQcutsGeneralQCuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
295 pileupQcutsPUTrackSelection_->setPV(pv);
296 pileupQcutsPUTrackSelection_->setLeadTrack(pfTau->leadPFChargedHadrCand());
300 if ( includeTracks_ ) {
302 if ( qcuts_->filterCandRef(cand) ) {
303 isoCharged_.push_back(cand);
307 if ( includeGammas_ ) {
309 if ( qcuts_->filterCandRef(cand) ) {
310 isoNeutral_.push_back(cand);
318 if ( applyDeltaBeta_ ) {
324 std::vector<PFCandidatePtr> allPU =
325 pileupQcutsPUTrackSelection_->filterCandRefs(
326 chargedPFCandidatesInEvent_,
true);
332 std::vector<PFCandidatePtr> cleanPU =
333 pileupQcutsGeneralQCuts_->filterCandRefs(allPU);
339 DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_);
341 if ( deltaBetaFilter(cand) ) {
342 isoPU_.push_back(cand);
351 if ( customIsoCone_ >= 0. ) {
354 DRFilter
filter(pfTau->p4(), 0, customIsoCone_);
355 std::vector<PFCandidatePtr> isoCharged_filter;
356 std::vector<PFCandidatePtr> isoNeutral_filter;
359 if (
filter(isoObject) ) isoCharged_filter.push_back(isoObject);
362 if (
filter(isoObject) ) isoNeutral_filter.push_back(isoObject);
364 isoCharged_ = isoCharged_filter;
365 isoNeutral_ = isoNeutral_filter;
368 bool failsOccupancyCut =
false;
369 bool failsSumPtCut =
false;
370 bool failsRelativeSumPtCut =
false;
373 int neutrals = isoNeutral_.size();
375 if ( applyDeltaBeta_ ) {
376 neutrals -= TMath::Nint(deltaBetaFactorThisEvent_*isoPU_.size());
378 if ( neutrals < 0 ) {
382 size_t nOccupants = isoCharged_.size() + neutrals;
384 failsOccupancyCut = ( nOccupants > maximumOccupancy_ );
386 double totalPt = 0.0;
389 if ( applySumPtCut_ || applyRelativeSumPtCut_ || storeRawSumPt_ || storeRawPUsumPt_ ) {
390 double chargedPt = 0.0;
391 double neutralPt = 0.0;
393 chargedPt += isoObject->pt();
396 neutralPt += isoObject->pt();
399 puPt += isoObject->pt();
402 std::cout <<
"chargedPt = " << chargedPt << std::endl;
403 std::cout <<
"neutralPt = " << neutralPt << std::endl;
404 std::cout <<
"puPt = " << puPt <<
" (delta-beta corr. = " << (deltaBetaFactorThisEvent_*puPt) <<
")" << std::endl;
407 if ( applyDeltaBeta_ ) {
408 neutralPt -= deltaBetaFactorThisEvent_*puPt;
411 if ( applyRhoCorrection_ ) {
412 neutralPt -= rhoThisEvent_;
415 if ( neutralPt < 0.0 ) {
419 totalPt = chargedPt + neutralPt;
421 std::cout <<
"totalPt = " << totalPt <<
" (cut = " << maximumSumPt_ <<
")" << std::endl;
424 failsSumPtCut = (totalPt > maximumSumPt_);
427 failsRelativeSumPtCut = (totalPt > (pfTau->pt()*maximumRelativeSumPt_));
430 bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
431 (applySumPtCut_ && failsSumPtCut) ||
432 (applyRelativeSumPtCut_ && failsRelativeSumPtCut);
435 if ( storeRawSumPt_ ) {
437 }
else if ( storeRawPUsumPt_ ) {
438 if ( applyDeltaBeta_ )
return puPt;
439 else if ( applyRhoCorrection_ )
return rhoThisEvent_;
441 }
else if ( storeRawOccupancy_ ) {
444 return (fails ? 0. : 1.);
PFRecoTauDiscriminationByIsolation(const edm::ParameterSet &pset)
T getParameter(std::string const &) const
edm::EDGetTokenT< double > rho_token
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
std::vector< PFCandidatePtr > isoCharged_
~PFRecoTauDiscriminationByIsolation()
void beginEvent(const edm::Event &evt, const edm::EventSetup &evtSetup) override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< PFCandidatePtr > isoNeutral_
double rhoUEOffsetCorrection_
double maximumRelativeSumPt_
bool applyRelativeSumPtCut_
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
double rhoCorrectionThisEvent_
double deltaBetaFactorThisEvent_
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< reco::PFCandidateCollection > pfCand_token
std::vector< reco::PFCandidatePtr > chargedPFCandidatesInEvent_
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< PFCandidatePtr > isoPU_
double discriminate(const PFTauRef &pfTau) override
std::auto_ptr< tau::RecoTauQualityCuts > qcuts_
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsPUTrackSelection_
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
double deltaBetaCollectionCone_
ParameterSet const & getParameterSet(std::string const &) const
uint32_t maximumOccupancy_
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
edm::InputTag rhoProducer_
std::auto_ptr< TFormula > deltaBetaFormula_
edm::ParameterSet qualityCutsPSet_
edm::EDGetTokenT< reco::VertexCollection > vertex_token