test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
PFRecoTauDiscriminationByIsolation Class Reference
Inheritance diagram for PFRecoTauDiscriminationByIsolation:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  FootprintCorrection
 

Public Member Functions

void beginEvent (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
double discriminate (const PFTauRef &pfTau) const override
 
 PFRecoTauDiscriminationByIsolation (const edm::ParameterSet &pset)
 
double weightedSum (const std::vector< PFCandidatePtr > &inColl_, double eta, double phi) const
 
 ~PFRecoTauDiscriminationByIsolation ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &evt)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool applyDeltaBeta_
 
bool applyFootprintCorrection_
 
bool applyOccupancyCut_
 
bool applyPhotonPtSumOutsideSignalConeCut_
 
bool applyRelativeSumPtCut_
 
bool applyRhoCorrection_
 
bool applySumPtCut_
 
bool calculateWeights_
 
std::vector< reco::PFCandidatePtrchargedPFCandidatesInEvent_
 
double customIsoCone_
 
double deltaBetaCollectionCone_
 
double deltaBetaFactorThisEvent_
 
std::auto_ptr< TFormula > deltaBetaFormula_
 
std::vector< std::unique_ptr
< FootprintCorrection > > 
footprintCorrections_
 
bool includeGammas_
 
bool includeTracks_
 
double maxAbsPhotonSumPt_outsideSignalCone_
 
uint32_t maximumOccupancy_
 
double maximumRelativeSumPt_
 
double maximumSumPt_
 
double maxRelPhotonSumPt_outsideSignalCone_
 
double minPtForNoIso_
 
std::string moduleLabel_
 
double offsetRelativeSumPt_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfCand_token
 
edm::InputTag pfCandSrc_
 
std::auto_ptr
< tau::RecoTauQualityCuts
pileupQcutsGeneralQCuts_
 
std::auto_ptr
< tau::RecoTauQualityCuts
pileupQcutsPUTrackSelection_
 
std::auto_ptr
< tau::RecoTauQualityCuts
qcuts_
 
edm::ParameterSet qualityCutsPSet_
 
edm::EDGetTokenT< double > rho_token
 
double rhoConeSize_
 
double rhoCorrectionThisEvent_
 
edm::InputTag rhoProducer_
 
double rhoThisEvent_
 
double rhoUEOffsetCorrection_
 
bool storeRawFootprintCorrection_
 
bool storeRawOccupancy_
 
bool storeRawPhotonSumPt_outsideSignalCone_
 
bool storeRawPUsumPt_
 
bool storeRawSumPt_
 
bool useAllPFCands_
 
int verbosity_
 
edm::EDGetTokenT
< reco::VertexCollection
vertex_token
 
std::auto_ptr
< tau::RecoTauVertexAssociator
vertexAssociator_
 
edm::InputTag vertexSrc_
 
double weightGammas_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd
< TauCollection
TauRefProd
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 26 of file PFRecoTauDiscriminationByIsolation.cc.

Constructor & Destructor Documentation

PFRecoTauDiscriminationByIsolation::PFRecoTauDiscriminationByIsolation ( const edm::ParameterSet pset)
inlineexplicit

Definition at line 29 of file PFRecoTauDiscriminationByIsolation.cc.

References Exception, edm::ParameterSet::exists(), reco::tau::factorizePUQCuts(), PFRecoTauDiscriminationByMVAIsolationRun2_cff::footprintCorrection, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), eostools::move(), hltrates_dqm_sourceclient-live_cfg::offset, corrVsCorr::selection, and AlCaHLTBitMon_QueryRunRegistry::string.

31  moduleLabel_(pset.getParameter<std::string>("@module_label")),
32  qualityCutsPSet_(pset.getParameter<edm::ParameterSet>("qualityCuts"))
33  {
34  includeTracks_ = pset.getParameter<bool>(
35  "ApplyDiscriminationByTrackerIsolation");
36  includeGammas_ = pset.getParameter<bool>(
37  "ApplyDiscriminationByECALIsolation");
38 
39  calculateWeights_ = pset.exists("ApplyDiscriminationByWeightedECALIsolation") ?
40  pset.getParameter<bool>("ApplyDiscriminationByWeightedECALIsolation") : false;
41 
42  // RIC: multiply neutral isolation by a flat factor.
43  // Useful, for instance, to combine charged and neutral isolations
44  // with different relative weights
45  weightGammas_ = pset.exists("WeightECALIsolation") ?
46  pset.getParameter<double>("WeightECALIsolation") : 1.0;
47 
48  // RIC: allow to relax the isolation completely beyond a given tau pt
49  minPtForNoIso_ = pset.exists("minTauPtForNoIso") ?
50  pset.getParameter<double>("minTauPtForNoIso") : -99.;
51 
52  applyOccupancyCut_ = pset.getParameter<bool>("applyOccupancyCut");
53  maximumOccupancy_ = pset.getParameter<uint32_t>("maximumOccupancy");
54 
55  applySumPtCut_ = pset.getParameter<bool>("applySumPtCut");
56  maximumSumPt_ = pset.getParameter<double>("maximumSumPtCut");
57 
59  "applyRelativeSumPtCut");
60  maximumRelativeSumPt_ = pset.getParameter<double>(
61  "relativeSumPtCut");
62  offsetRelativeSumPt_ = pset.exists("relativeSumPtOffset") ?
63  pset.getParameter<double>("relativeSumPtOffset") : 0.0;
64 
65  storeRawOccupancy_ = pset.exists("storeRawOccupancy") ?
66  pset.getParameter<bool>("storeRawOccupancy") : false;
67  storeRawSumPt_ = pset.exists("storeRawSumPt") ?
68  pset.getParameter<bool>("storeRawSumPt") : false;
69  storeRawPUsumPt_ = pset.exists("storeRawPUsumPt") ?
70  pset.getParameter<bool>("storeRawPUsumPt") : false;
71  storeRawFootprintCorrection_ = pset.exists("storeRawFootprintCorrection") ?
72  pset.getParameter<bool>("storeRawFootprintCorrection") : false;
73  storeRawPhotonSumPt_outsideSignalCone_ = pset.exists("storeRawPhotonSumPt_outsideSignalCone") ?
74  pset.getParameter<bool>("storeRawPhotonSumPt_outsideSignalCone") : false;
75 
76  // Sanity check on requested options. We can't apply cuts and store the
77  // raw output at the same time
78  if ( applySumPtCut_ || applyOccupancyCut_ || applyRelativeSumPtCut_ ) {
79  if ( storeRawSumPt_ || storeRawOccupancy_ || storeRawPUsumPt_ ) {
80  throw cms::Exception("BadIsoConfig")
81  << "A 'store raw' and a 'apply cut' option have been set to true "
82  << "simultaneously. These options are mutually exclusive.";
83  }
84  }
85 
86  // sanity check2 - can't use weighted and unweighted iso at the same time
87  if ( includeGammas_ && calculateWeights_ ) {
88  throw cms::Exception("BasIsoConfig")
89  << "Both 'ApplyDiscriminationByECALIsolation' and 'ApplyDiscriminationByWeightedECALIsolation' "
90  << "have been set to true. These options are mutually exclusive.";
91  }
92 
93  // Can only store one type
94  int numStoreOptions = 0;
95  if ( storeRawSumPt_ ) ++numStoreOptions;
96  if ( storeRawOccupancy_ ) ++numStoreOptions;
97  if ( storeRawPUsumPt_ ) ++numStoreOptions;
98  if ( storeRawFootprintCorrection_ ) ++numStoreOptions;
99  if ( storeRawPhotonSumPt_outsideSignalCone_ ) ++numStoreOptions;
100  if ( numStoreOptions > 1 ) {
101  throw cms::Exception("BadIsoConfig")
102  << "Multiple 'store sum pt' and/or 'store occupancy' options are set."
103  << " These options are mutually exclusive.";
104  }
105 
106  if ( pset.exists("customOuterCone") ) {
107  customIsoCone_ = pset.getParameter<double>("customOuterCone");
108  } else {
109  customIsoCone_ = -1;
110  }
111 
112  applyPhotonPtSumOutsideSignalConeCut_ = ( pset.exists("applyPhotonPtSumOutsideSignalConeCut") ) ?
113  pset.getParameter<bool>("applyPhotonPtSumOutsideSignalConeCut") : false;
115  maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter<double>("maxAbsPhotonSumPt_outsideSignalCone");
116  maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter<double>("maxRelPhotonSumPt_outsideSignalCone");
117  }
118 
119  applyFootprintCorrection_ = ( pset.exists("applyFootprintCorrection") ) ?
120  pset.getParameter<bool>("applyFootprintCorrection") : false;
121  if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) {
122  edm::VParameterSet cfgFootprintCorrections = pset.getParameter<edm::VParameterSet>("footprintCorrections");
123  for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin();
124  cfgFootprintCorrection != cfgFootprintCorrections.end(); ++cfgFootprintCorrection ) {
125  std::string selection = cfgFootprintCorrection->getParameter<std::string>("selection");
126  std::string offset = cfgFootprintCorrection->getParameter<std::string>("offset");
127  std::unique_ptr<FootprintCorrection> footprintCorrection(new FootprintCorrection(selection, offset));
129  }
130  }
131 
132  // Get the quality cuts specific to the isolation region
134  "isolationQualityCuts");
135 
136  qcuts_.reset(new tau::RecoTauQualityCuts(isolationQCuts));
137 
138  vertexAssociator_.reset(
140 
141  applyDeltaBeta_ = pset.exists("applyDeltaBetaCorrection") ?
142  pset.getParameter<bool>("applyDeltaBetaCorrection") : false;
143 
144  if ( applyDeltaBeta_ || calculateWeights_ ) {
145  // Factorize the isolation QCuts into those that are used to
146  // select PU and those that are not.
147  std::pair<edm::ParameterSet, edm::ParameterSet> puFactorizedIsoQCuts =
148  reco::tau::factorizePUQCuts(isolationQCuts);
149 
150  // Determine the pt threshold for the PU tracks
151  // First check if the user specifies explicitly the cut.
152  if ( pset.exists("deltaBetaPUTrackPtCutOverride") ) {
153  puFactorizedIsoQCuts.second.addParameter<double>(
154  "minTrackPt",
155  pset.getParameter<double>("deltaBetaPUTrackPtCutOverride"));
156  } else {
157  // Secondly take it from the minGammaEt
158  puFactorizedIsoQCuts.second.addParameter<double>(
159  "minTrackPt",
160  isolationQCuts.getParameter<double>("minGammaEt"));
161  }
162 
164  puFactorizedIsoQCuts.first));
165 
167  puFactorizedIsoQCuts.second));
168 
169  pfCandSrc_ = pset.getParameter<edm::InputTag>("particleFlowSrc");
170  pfCand_token = consumes<reco::PFCandidateCollection>(pfCandSrc_);
171  vertexSrc_ = pset.getParameter<edm::InputTag>("vertexSrc");
172  vertex_token = consumes<reco::VertexCollection>(vertexSrc_);
173  deltaBetaCollectionCone_ = pset.getParameter<double>(
174  "isoConeSizeForDeltaBeta");
175  std::string deltaBetaFactorFormula =
176  pset.getParameter<string>("deltaBetaFactor");
177  deltaBetaFormula_.reset(
178  new TFormula("DB_corr", deltaBetaFactorFormula.c_str()));
179  }
180 
181  applyRhoCorrection_ = pset.exists("applyRhoCorrection") ?
182  pset.getParameter<bool>("applyRhoCorrection") : false;
183  if ( applyRhoCorrection_ ) {
184  rhoProducer_ = pset.getParameter<edm::InputTag>("rhoProducer");
185  rho_token=consumes<double>(rhoProducer_);
186  rhoConeSize_ = pset.getParameter<double>("rhoConeSize");
188  pset.getParameter<double>("rhoUEOffsetCorrection");
189  }
190  useAllPFCands_ = pset.exists("UseAllPFCandsForWeights") ?
191  pset.getParameter<bool>("UseAllPFCandsForWeights") : false;
192 
193  verbosity_ = ( pset.exists("verbosity") ) ?
194  pset.getParameter<int>("verbosity") : 0;
195  }
T getParameter(std::string const &) const
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
selection
main part
Definition: corrVsCorr.py:98
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< std::unique_ptr< FootprintCorrection > > footprintCorrections_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCand_token
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
def move
Definition: eostools.py:510
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
std::auto_ptr< tau::RecoTauQualityCuts > qcuts_
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsPUTrackSelection_
ParameterSet const & getParameterSet(std::string const &) const
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
edm::EDGetTokenT< reco::VertexCollection > vertex_token
PFRecoTauDiscriminationByIsolation::~PFRecoTauDiscriminationByIsolation ( )
inline

Definition at line 197 of file PFRecoTauDiscriminationByIsolation.cc.

198  {
199  }

Member Function Documentation

void PFRecoTauDiscriminationByIsolation::beginEvent ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 295 of file PFRecoTauDiscriminationByIsolation.cc.

References i, reco::tau::pfCandidates(), and HLT_25ns10e33_v2_cff::vertices.

296 {
297  // NB: The use of the PV in this context is necessitated by its use in
298  // applying quality cuts to the different objects in the isolation cone
299  // The vertex associator contains the logic to select the appropriate vertex
300  // We need to pass it the event so it can load the vertices.
301  vertexAssociator_->setEvent(event);
302 
303  // If we are applying the delta beta correction, we need to get the PF
304  // candidates from the event so we can find the PU tracks.
306  // Collect all the PF pile up tracks
308  event.getByToken(pfCand_token, pfCandidates);
310  chargedPFCandidatesInEvent_.reserve(pfCandidates->size());
311  size_t numPFCandidates = pfCandidates->size();
312  for ( size_t i = 0; i < numPFCandidates; ++i ) {
313  reco::PFCandidatePtr pfCandidate(pfCandidates, i);
314  if ( pfCandidate->charge() != 0 ) {
315  chargedPFCandidatesInEvent_.push_back(pfCandidate);
316  }
317  }
318  // Count all the vertices in the event, to parameterize the DB
319  // correction factor
321  event.getByToken(vertex_token, vertices);
322  size_t nVtxThisEvent = vertices->size();
323  deltaBetaFactorThisEvent_ = deltaBetaFormula_->Eval(nVtxThisEvent);
324  }
325 
326  if ( applyRhoCorrection_ ) {
327  edm::Handle<double> rhoHandle_;
328  event.getByToken(rho_token, rhoHandle_);
329  rhoThisEvent_ = (*rhoHandle_ - rhoUEOffsetCorrection_)*
330  (3.14159)*rhoConeSize_*rhoConeSize_;
331  }
332 }
int i
Definition: DBlmapReader.cc:9
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
edm::EDGetTokenT< reco::PFCandidateCollection > pfCand_token
std::vector< reco::PFCandidatePtr > chargedPFCandidatesInEvent_
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::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
edm::EDGetTokenT< reco::VertexCollection > vertex_token
double PFRecoTauDiscriminationByIsolation::discriminate ( const PFTauRef pfTau) const
override

Definition at line 335 of file PFRecoTauDiscriminationByIsolation.cc.

References gather_cfg::cout, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, eta, alcazmumu_cfi::filter, PFRecoTauDiscriminationByMVAIsolationRun2_cff::footprintCorrection, edm::Ref< C, T, F >::isNonnull(), dqm-mbProfile::log, LogDebug, LogTrace, min(), eostools::move(), reco::LeafCandidate::p4(), phi(), MetAnalyzer::pv(), and reco::LeafCandidate::setP4().

336 {
337  LogDebug("discriminate") << " tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi();
338  LogDebug("discriminate") << *pfTau ;
339 
340  // collect the objects we are working with (ie tracks, tracks+gammas, etc)
341  std::vector<PFCandidatePtr> isoCharged_;
342  std::vector<PFCandidatePtr> isoNeutral_;
343  std::vector<PFCandidatePtr> isoPU_;
344  PFCandidateCollection isoNeutralWeight_;
345  std::vector<PFCandidatePtr> chPV_;
346  isoCharged_.reserve(pfTau->isolationPFChargedHadrCands().size());
347  isoNeutral_.reserve(pfTau->isolationPFGammaCands().size());
348  isoPU_.reserve(std::min(100UL, chargedPFCandidatesInEvent_.size()));
349  isoNeutralWeight_.reserve(pfTau->isolationPFGammaCands().size());
350 
351  chPV_.reserve(std::min(50UL, chargedPFCandidatesInEvent_.size()));
352 
353  // Get the primary vertex associated to this tau
354  reco::VertexRef pv = vertexAssociator_->associatedVertex(*pfTau);
355  // Let the quality cuts know which the vertex to use when applying selections
356  // on dz, etc.
357  if ( verbosity_ ) {
358  if ( pv.isNonnull() ) {
359  LogTrace("discriminate") << "pv: x = " << pv->position().x() << ", y = " << pv->position().y() << ", z = " << pv->position().z() ;
360  } else {
361  LogTrace("discriminate") << "pv: N/A" ;
362  }
363  if ( pfTau->leadPFChargedHadrCand().isNonnull() ) {
364  LogTrace("discriminate") << "leadPFChargedHadron:"
365  << " Pt = " << pfTau->leadPFChargedHadrCand()->pt() << ","
366  << " eta = " << pfTau->leadPFChargedHadrCand()->eta() << ","
367  << " phi = " << pfTau->leadPFChargedHadrCand()->phi() ;
368  } else {
369  LogTrace("discriminate") << "leadPFChargedHadron: N/A" ;
370  }
371  }
372 
373  // CV: isolation is not well defined in case primary vertex or leading charged hadron do not exist
374  if ( !(pv.isNonnull() && pfTau->leadPFChargedHadrCand().isNonnull()) ) return 0.;
375 
376  qcuts_->setPV(pv);
377  qcuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
378 
380  pileupQcutsGeneralQCuts_->setPV(pv);
381  pileupQcutsGeneralQCuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
382  pileupQcutsPUTrackSelection_->setPV(pv);
383  pileupQcutsPUTrackSelection_->setLeadTrack(pfTau->leadPFChargedHadrCand());
384  }
385 
386  // Load the tracks if they are being used.
387  if ( includeTracks_ ) {
388  for( auto const & cand : pfTau->isolationPFChargedHadrCands() ) {
389  if ( qcuts_->filterCandRef(cand) ) {
390  LogTrace("discriminate") << "adding charged iso cand with pt " << cand->pt() ;
391  isoCharged_.push_back(cand);
392  }
393  }
394  }
396  for( auto const & cand : pfTau->isolationPFGammaCands() ) {
397  if ( qcuts_->filterCandRef(cand) ) {
398  LogTrace("discriminate") << "adding neutral iso cand with pt " << cand->pt() ;
399  isoNeutral_.push_back(cand);
400  }
401  }
402  }
403 
406 
407  // If desired, get PU tracks.
409  // First select by inverted the DZ/track weight cuts. True = invert
410  if ( verbosity_ ) {
411  std::cout << "Initial PFCands: " << chargedPFCandidatesInEvent_.size() << std::endl;
412  }
413 
414  std::vector<PFCandidatePtr> allPU =
415  pileupQcutsPUTrackSelection_->filterCandRefs(
417 
418  std::vector<PFCandidatePtr> allNPU =
419  pileupQcutsPUTrackSelection_->filterCandRefs(
421  LogTrace("discriminate") << "After track cuts: " << allPU.size() ;
422 
423  // Now apply the rest of the cuts, like pt, and TIP, tracker hits, etc
424  if ( !useAllPFCands_ ) {
425  std::vector<PFCandidatePtr> cleanPU =
426  pileupQcutsGeneralQCuts_->filterCandRefs(allPU);
427 
428  std::vector<PFCandidatePtr> cleanNPU =
429  pileupQcutsGeneralQCuts_->filterCandRefs(allNPU);
430 
431  LogTrace("discriminate") << "After cleaning cuts: " << cleanPU.size() ;
432 
433  // Only select PU tracks inside the isolation cone.
434  DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_);
435  for ( auto const & cand : cleanPU ) {
436  if ( deltaBetaFilter(cand) ) isoPU_.push_back(cand);
437  }
438 
439  for ( auto const & cand : cleanNPU ) {
440  if ( deltaBetaFilter(cand) ) chPV_.push_back(cand);
441  }
442  LogTrace("discriminate") << "After cone cuts: " << isoPU_.size() << " " << chPV_.size() ;
443  } else {
444  isoPU_ = std::move(allPU);
445  chPV_ = std::move(allNPU);
446  }
447  }
448 
449  if ( calculateWeights_ ) {
450  for ( auto const & isoObject : isoNeutral_ ) {
451  if ( isoObject->charge() != 0 ) {
452  // weight only neutral objects
453  isoNeutralWeight_.push_back(*isoObject);
454  continue;
455  }
456 
457  double eta = isoObject->eta();
458  double phi = isoObject->phi();
459  double sumNPU = 0.5*log(weightedSum(chPV_, eta, phi));
460 
461  double sumPU = 0.5*log(weightedSum(isoPU_, eta, phi));
462  PFCandidate neutral = (*isoObject);
463  if ( (sumNPU + sumPU) > 0 ) neutral.setP4(((sumNPU)/(sumNPU + sumPU))*neutral.p4());
464 
465  isoNeutralWeight_.push_back(neutral);
466  }
467  }
468 
469  // Check if we want a custom iso cone
470  if ( customIsoCone_ >= 0. ) {
471  DRFilter filter(pfTau->p4(), 0, customIsoCone_);
472  DRFilter2 filter2(pfTau->p4(), 0, customIsoCone_);
473  std::vector<PFCandidatePtr> isoCharged_filter;
474  std::vector<PFCandidatePtr> isoNeutral_filter;
475  PFCandidateCollection isoNeutralWeight_filter;
476  // Remove all the objects not in our iso cone
477  for( auto const & isoObject : isoCharged_ ) {
478  if ( filter(isoObject) ) isoCharged_filter.push_back(isoObject);
479  }
480  if(!calculateWeights_){
481  for( auto const & isoObject : isoNeutral_ ) {
482  if ( filter(isoObject) ) isoNeutral_filter.push_back(isoObject);
483  }
484  isoNeutral_ = isoNeutral_filter;
485  }else{
486  for( auto const & isoObject : isoNeutralWeight_){
487  if ( filter2(isoObject) ) isoNeutralWeight_filter.push_back(isoObject);
488  }
489  isoNeutralWeight_ = isoNeutralWeight_filter;
490  }
491  isoCharged_ = isoCharged_filter;
492  }
493 
494  bool failsOccupancyCut = false;
495  bool failsSumPtCut = false;
496  bool failsRelativeSumPtCut = false;
497 
498 //--- nObjects requirement
499  int neutrals = isoNeutral_.size();
500 
501  if ( applyDeltaBeta_ ) {
502  neutrals -= TMath::Nint(deltaBetaFactorThisEvent_*isoPU_.size());
503  }
504  if ( neutrals < 0 ) {
505  neutrals = 0;
506  }
507 
508  size_t nOccupants = isoCharged_.size() + neutrals;
509 
510  failsOccupancyCut = ( nOccupants > maximumOccupancy_ );
511 
512  double footprintCorrection_value = 0.;
514  for ( std::vector<std::unique_ptr<FootprintCorrection> >::const_iterator footprintCorrection = footprintCorrections_.begin();
516  if ( (*footprintCorrection)->selection_(*pfTau) ) {
517  footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau);
518  }
519  }
520  }
521 
522  double totalPt = 0.;
523  double puPt = 0.;
524 //--- Sum PT requirement
526  double chargedPt = 0.;
527  double neutralPt = 0.;
528  double weightedNeutralPt = 0.;
529  for ( auto const & isoObject : isoCharged_ ) {
530  chargedPt += isoObject->pt();
531  }
532  if ( !calculateWeights_ ) {
533  for ( auto const & isoObject : isoNeutral_ ) {
534  neutralPt += isoObject->pt();
535  }
536  } else {
537  for ( auto const & isoObject : isoNeutralWeight_ ) {
538  weightedNeutralPt += isoObject.pt();
539  }
540  }
541  for ( auto const & isoObject : isoPU_ ) {
542  puPt += isoObject->pt();
543  }
544  LogTrace("discriminate") << "chargedPt = " << chargedPt ;
545  LogTrace("discriminate") << "neutralPt = " << neutralPt ;
546  LogTrace("discriminate") << "weighted neutral Pt = " << weightedNeutralPt ;
547  LogTrace("discriminate") << "puPt = " << puPt << " (delta-beta corr. = " << (deltaBetaFactorThisEvent_*puPt) << ")" ;
548 
549  if ( calculateWeights_ ) {
550  neutralPt = weightedNeutralPt;
551  }
552 
553  if ( applyDeltaBeta_ ) {
554  neutralPt -= (deltaBetaFactorThisEvent_*puPt);
555  }
556 
558  neutralPt -= footprintCorrection_value;
559  }
560 
561  if ( applyRhoCorrection_ ) {
562  neutralPt -= rhoThisEvent_;
563  }
564 
565  if ( neutralPt < 0. ) {
566  neutralPt = 0.;
567  }
568 
569  totalPt = chargedPt + weightGammas_ * neutralPt;
570  LogTrace("discriminate") << "totalPt = " << totalPt << " (cut = " << maximumSumPt_ << ")" ;
571 
572  failsSumPtCut = (totalPt > maximumSumPt_);
573 
574 //--- Relative Sum PT requirement
575  failsRelativeSumPtCut = (totalPt > ((pfTau->pt() - offsetRelativeSumPt_)*maximumRelativeSumPt_));
576  }
577 
578  bool failsPhotonPtSumOutsideSignalConeCut = false;
579  double photonSumPt_outsideSignalCone = 0.;
581  const std::vector<reco::PFCandidatePtr>& signalPFGammas = pfTau->signalPFGammaCands();
582  for ( std::vector<reco::PFCandidatePtr>::const_iterator signalPFGamma = signalPFGammas.begin();
583  signalPFGamma != signalPFGammas.end(); ++signalPFGamma ) {
584  double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalPFGamma)->eta(), (*signalPFGamma)->phi());
585  if ( dR > pfTau->signalConeSize() ) photonSumPt_outsideSignalCone += (*signalPFGamma)->pt();
586  }
587  if ( photonSumPt_outsideSignalCone > maxAbsPhotonSumPt_outsideSignalCone_ || photonSumPt_outsideSignalCone > (maxRelPhotonSumPt_outsideSignalCone_*pfTau->pt()) ) {
588  failsPhotonPtSumOutsideSignalConeCut = true;
589  }
590  }
591 
592  bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
593  (applySumPtCut_ && failsSumPtCut) ||
594  (applyRelativeSumPtCut_ && failsRelativeSumPtCut) ||
595  (applyPhotonPtSumOutsideSignalConeCut_ && failsPhotonPtSumOutsideSignalConeCut);
596 
597 
598  if (pfTau->pt() > minPtForNoIso_ && minPtForNoIso_ > 0.){
599  return 1.;
600  LogDebug("discriminate") << "tau pt = " << pfTau->pt() << "\t min cutoff pt = " << minPtForNoIso_ ;
601  }
602 
603  // We did error checking in the constructor, so this is safe.
604  if ( storeRawSumPt_ ) {
605  return totalPt;
606  } else if ( storeRawPUsumPt_ ) {
607  if ( applyDeltaBeta_ ) return puPt;
608  else if ( applyRhoCorrection_ ) return rhoThisEvent_;
609  else return 0.;
610  } else if ( storeRawOccupancy_ ) {
611  return nOccupants;
612  } else if ( storeRawFootprintCorrection_ ) {
613  return footprintCorrection_value;
615  return photonSumPt_outsideSignalCone;
616  } else {
617  return (fails ? 0. : 1.);
618  }
619 }
#define LogDebug(id)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
double weightedSum(const std::vector< PFCandidatePtr > &inColl_, double eta, double phi) const
std::vector< std::unique_ptr< FootprintCorrection > > footprintCorrections_
def move
Definition: eostools.py:510
std::vector< reco::PFCandidatePtr > chargedPFCandidatesInEvent_
T min(T a, T b)
Definition: MathUtil.h:58
#define LogTrace(id)
std::auto_ptr< tau::RecoTauQualityCuts > qcuts_
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsPUTrackSelection_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
tuple cout
Definition: gather_cfg.py:145
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
double PFRecoTauDiscriminationByIsolation::weightedSum ( const std::vector< PFCandidatePtr > &  inColl_,
double  eta,
double  phi 
) const
inline

Definition at line 204 of file PFRecoTauDiscriminationByIsolation.cc.

References reco::deltaR2(), and GenerateHcalLaserBadRunList::out.

204  {
205  double out = 1.0;
206  for (auto const & inObj_ : inColl_){
207  double sum = (inObj_->pt()*inObj_->pt())/(deltaR2(eta,phi,inObj_->eta(),inObj_->phi()));
208  if(sum > 1.0) out *= sum;
209  }
210  return out;
211  }
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36

Member Data Documentation

bool PFRecoTauDiscriminationByIsolation::applyDeltaBeta_
private

Definition at line 269 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyFootprintCorrection_
private

Definition at line 244 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyOccupancyCut_
private

Definition at line 229 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyPhotonPtSumOutsideSignalConeCut_
private

Definition at line 240 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyRelativeSumPtCut_
private

Definition at line 233 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyRhoCorrection_
private

Definition at line 282 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applySumPtCut_
private

Definition at line 231 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::calculateWeights_
private

Definition at line 227 of file PFRecoTauDiscriminationByIsolation.cc.

std::vector<reco::PFCandidatePtr> PFRecoTauDiscriminationByIsolation::chargedPFCandidatesInEvent_
private

Definition at line 275 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::customIsoCone_
private

Definition at line 236 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::deltaBetaCollectionCone_
private

Definition at line 277 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::deltaBetaFactorThisEvent_
private

Definition at line 279 of file PFRecoTauDiscriminationByIsolation.cc.

std::auto_ptr<TFormula> PFRecoTauDiscriminationByIsolation::deltaBetaFormula_
private

Definition at line 278 of file PFRecoTauDiscriminationByIsolation.cc.

std::vector<std::unique_ptr<FootprintCorrection> > PFRecoTauDiscriminationByIsolation::footprintCorrections_
private

Definition at line 255 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::includeGammas_
private

Definition at line 226 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::includeTracks_
private

Definition at line 225 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::maxAbsPhotonSumPt_outsideSignalCone_
private

Definition at line 241 of file PFRecoTauDiscriminationByIsolation.cc.

uint32_t PFRecoTauDiscriminationByIsolation::maximumOccupancy_
private

Definition at line 230 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::maximumRelativeSumPt_
private

Definition at line 234 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::maximumSumPt_
private

Definition at line 232 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::maxRelPhotonSumPt_outsideSignalCone_
private

Definition at line 242 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::minPtForNoIso_
private

Definition at line 238 of file PFRecoTauDiscriminationByIsolation.cc.

std::string PFRecoTauDiscriminationByIsolation::moduleLabel_
private
double PFRecoTauDiscriminationByIsolation::offsetRelativeSumPt_
private

Definition at line 235 of file PFRecoTauDiscriminationByIsolation.cc.

edm::EDGetTokenT<reco::PFCandidateCollection> PFRecoTauDiscriminationByIsolation::pfCand_token
private

Definition at line 271 of file PFRecoTauDiscriminationByIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByIsolation::pfCandSrc_
private

Definition at line 270 of file PFRecoTauDiscriminationByIsolation.cc.

std::auto_ptr<tau::RecoTauQualityCuts> PFRecoTauDiscriminationByIsolation::pileupQcutsGeneralQCuts_
private

Definition at line 221 of file PFRecoTauDiscriminationByIsolation.cc.

std::auto_ptr<tau::RecoTauQualityCuts> PFRecoTauDiscriminationByIsolation::pileupQcutsPUTrackSelection_
private

Definition at line 220 of file PFRecoTauDiscriminationByIsolation.cc.

std::auto_ptr<tau::RecoTauQualityCuts> PFRecoTauDiscriminationByIsolation::qcuts_
private

Definition at line 217 of file PFRecoTauDiscriminationByIsolation.cc.

edm::ParameterSet PFRecoTauDiscriminationByIsolation::qualityCutsPSet_
private

Definition at line 216 of file PFRecoTauDiscriminationByIsolation.cc.

edm::EDGetTokenT<double> PFRecoTauDiscriminationByIsolation::rho_token
private

Definition at line 285 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoConeSize_
private

Definition at line 286 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoCorrectionThisEvent_
private

Definition at line 288 of file PFRecoTauDiscriminationByIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByIsolation::rhoProducer_
private

Definition at line 284 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoThisEvent_
private

Definition at line 289 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoUEOffsetCorrection_
private

Definition at line 287 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawFootprintCorrection_
private

Definition at line 261 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawOccupancy_
private

Definition at line 258 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawPhotonSumPt_outsideSignalCone_
private

Definition at line 262 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawPUsumPt_
private

Definition at line 260 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawSumPt_
private

Definition at line 259 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::useAllPFCands_
private

Definition at line 283 of file PFRecoTauDiscriminationByIsolation.cc.

int PFRecoTauDiscriminationByIsolation::verbosity_
private

Definition at line 292 of file PFRecoTauDiscriminationByIsolation.cc.

edm::EDGetTokenT<reco::VertexCollection> PFRecoTauDiscriminationByIsolation::vertex_token
private

Definition at line 274 of file PFRecoTauDiscriminationByIsolation.cc.

std::auto_ptr<tau::RecoTauVertexAssociator> PFRecoTauDiscriminationByIsolation::vertexAssociator_
private

Definition at line 223 of file PFRecoTauDiscriminationByIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByIsolation::vertexSrc_
private

Definition at line 273 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::weightGammas_
private

Definition at line 228 of file PFRecoTauDiscriminationByIsolation.cc.