2 #include <boost/foreach.hpp>
30 qualityCutsPSet_(pset.getParameter<edm::
ParameterSet>(
"qualityCuts")) {
33 "ApplyDiscriminationByTrackerIsolation");
35 "ApplyDiscriminationByECALIsolation");
37 applyOccupancyCut_ = pset.
getParameter<
bool>(
"applyOccupancyCut");
38 maximumOccupancy_ = pset.
getParameter<uint32_t>(
"maximumOccupancy");
40 applySumPtCut_ = pset.
getParameter<
bool>(
"applySumPtCut");
41 maximumSumPt_ = pset.
getParameter<
double>(
"maximumSumPtCut");
44 "applyRelativeSumPtCut");
48 storeRawOccupancy_ = pset.
exists(
"storeRawOccupancy") ?
50 storeRawSumPt_ = pset.
exists(
"storeRawSumPt") ?
55 if (applySumPtCut_ || applyOccupancyCut_ || applyRelativeSumPtCut_) {
56 if (storeRawSumPt_ || storeRawOccupancy_) {
58 "A 'store raw' and a 'apply cut' option have been set to true "
59 <<
"simultaneously. These options are mutually exclusive.";
64 if (storeRawSumPt_ && storeRawOccupancy_) {
66 "Both 'store sum pt' and 'store occupancy' options are set."
67 <<
" These options are mutually exclusive.";
70 if (pset.
exists(
"customOuterCone")) {
71 customIsoCone_ = pset.
getParameter<
double>(
"customOuterCone");
78 "isolationQualityCuts");
82 vertexAssociator_.reset(
85 applyDeltaBeta_ = pset.
exists(
"applyDeltaBetaCorrection") ?
86 pset.
getParameter<
bool>(
"applyDeltaBetaCorrection") :
false;
88 if (applyDeltaBeta_) {
91 std::pair<edm::ParameterSet, edm::ParameterSet> puFactorizedIsoQCuts =
96 if (pset.
exists(
"deltaBetaPUTrackPtCutOverride")) {
97 puFactorizedIsoQCuts.second.addParameter<
double>(
99 pset.
getParameter<
double>(
"deltaBetaPUTrackPtCutOverride"));
102 puFactorizedIsoQCuts.second.addParameter<
double>(
108 puFactorizedIsoQCuts.first));
111 puFactorizedIsoQCuts.second));
116 "isoConeSizeForDeltaBeta");
119 deltaBetaFormula_.reset(
120 new TFormula(
"DB_corr", deltaBetaFactorFormula.c_str()));
123 applyRhoCorrection_ = pset.
exists(
"applyRhoCorrection") ?
125 if (applyRhoCorrection_) {
127 rhoConeSize_ = pset.
getParameter<
double>(
"rhoConeSize");
128 rhoUEOffsetCorrection_ =
136 double discriminate(
const PFTauRef& pfTau);
140 std::auto_ptr<tau::RecoTauQualityCuts>
qcuts_;
194 vertexAssociator_->setEvent(event);
198 chargedPFCandidatesInEvent_.clear();
199 if (applyDeltaBeta_) {
202 event.getByLabel(pfCandSrc_, pfCandHandle_);
203 chargedPFCandidatesInEvent_.reserve(pfCandHandle_->size());
204 for (
size_t i = 0;
i < pfCandHandle_->size(); ++
i) {
206 if (pfCand->charge() != 0)
207 chargedPFCandidatesInEvent_.push_back(pfCand);
212 event.getByLabel(vertexSrc_, vertices);
213 size_t nVtxThisEvent = vertices->size();
214 deltaBetaFactorThisEvent_ = deltaBetaFormula_->Eval(nVtxThisEvent);
217 if (applyRhoCorrection_) {
219 event.getByLabel(rhoProducer_, rhoHandle_);
220 rhoThisEvent_ = (*rhoHandle_ - rhoUEOffsetCorrection_)*
221 (3.14159)*rhoConeSize_*rhoConeSize_;
228 std::vector<PFCandidateRef> isoCharged;
229 std::vector<PFCandidateRef> isoNeutral;
230 std::vector<PFCandidateRef> isoPU;
237 qcuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
238 if (applyDeltaBeta_) {
239 pileupQcutsGeneralQCuts_->setPV(pv);
240 pileupQcutsGeneralQCuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
241 pileupQcutsPUTrackSelection_->setPV(pv);
242 pileupQcutsPUTrackSelection_->setLeadTrack(pfTau->leadPFChargedHadrCand());
245 if (includeTracks_) {
247 pfTau->isolationPFChargedHadrCands()) {
248 if (qcuts_->filterRef(cand))
249 isoCharged.push_back(cand);
253 if (includeGammas_) {
255 pfTau->isolationPFGammaCands()) {
256 if (qcuts_->filterRef(cand))
257 isoNeutral.push_back(cand);
263 if (applyDeltaBeta_) {
268 std::vector<PFCandidateRef> allPU =
269 pileupQcutsPUTrackSelection_->filterRefs(
270 chargedPFCandidatesInEvent_,
true);
275 std::vector<PFCandidateRef> cleanPU =
276 pileupQcutsGeneralQCuts_->filterRefs(allPU);
281 DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_);
283 if (deltaBetaFilter(cand)) {
284 isoPU.push_back(cand);
291 if (customIsoCone_ >= 0.) {
292 DRFilter
filter(pfTau->p4(), 0, customIsoCone_);
293 std::vector<PFCandidateRef> isoCharged_filter;
294 std::vector<PFCandidateRef> isoNeutral_filter;
297 if(
filter(isoObject)) isoCharged_filter.push_back(isoObject);
300 if(
filter(isoObject)) isoNeutral_filter.push_back(isoObject);
303 isoCharged=isoCharged_filter;
305 isoNeutral=isoNeutral_filter;
309 bool failsOccupancyCut =
false;
310 bool failsSumPtCut =
false;
311 bool failsRelativeSumPtCut =
false;
314 int neutrals = isoNeutral.size();
316 if (applyDeltaBeta_) {
317 neutrals -= TMath::Nint(deltaBetaFactorThisEvent_*isoPU.size());
323 size_t nOccupants = isoCharged.size() + neutrals;
325 failsOccupancyCut = ( nOccupants > maximumOccupancy_ );
329 if( applySumPtCut_ || applyRelativeSumPtCut_ || storeRawSumPt_) {
330 double chargedPt=0.0;
332 double neutralPt=0.0;
334 chargedPt += isoObject->pt();
337 neutralPt += isoObject->pt();
340 puPt += isoObject->pt();
343 if (applyDeltaBeta_) {
344 neutralPt -= deltaBetaFactorThisEvent_*puPt;
347 if (applyRhoCorrection_) {
348 neutralPt -= rhoThisEvent_;
351 if (neutralPt < 0.0) {
355 totalPt = chargedPt+neutralPt;
357 failsSumPtCut = (totalPt > maximumSumPt_);
360 failsRelativeSumPtCut = (
361 (pfTau->pt() > 0 ? totalPt/pfTau->pt() : 0 ) > maximumRelativeSumPt_ );
364 bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
365 (applySumPtCut_ && failsSumPtCut) ||
366 (applyRelativeSumPtCut_ && failsRelativeSumPtCut);
371 else if (storeRawOccupancy_)
374 return (fails ? 0. : 1.);
PFRecoTauDiscriminationByIsolation(const edm::ParameterSet &pset)
std::vector< reco::PFCandidateRef > chargedPFCandidatesInEvent_
T getParameter(std::string const &) const
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
~PFRecoTauDiscriminationByIsolation()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
double rhoUEOffsetCorrection_
double maximumRelativeSumPt_
bool applyRelativeSumPtCut_
double rhoCorrectionThisEvent_
double deltaBetaFactorThisEvent_
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
void beginEvent(const edm::Event &evt, const edm::EventSetup &evtSetup)
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_
double discriminate(const PFTauRef &pfTau)
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
edm::InputTag rhoProducer_
std::auto_ptr< TFormula > deltaBetaFormula_
edm::ParameterSet qualityCutsPSet_