CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

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 (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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool applyDeltaBeta_
 
bool applyOccupancyCut_
 
bool applyRelativeSumPtCut_
 
bool applyRhoCorrection_
 
bool applySumPtCut_
 
bool calculateWeights_
 
std::vector< reco::PFCandidatePtrchargedPFCandidatesInEvent_
 
double customIsoCone_
 
double deltaBetaCollectionCone_
 
double deltaBetaFactorThisEvent_
 
std::auto_ptr< TFormula > deltaBetaFormula_
 
bool includeGammas_
 
bool includeTracks_
 
uint32_t maximumOccupancy_
 
double maximumRelativeSumPt_
 
double maximumSumPt_
 
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 storeRawOccupancy_
 
bool storeRawPUsumPt_
 
bool storeRawSumPt_
 
bool useAllPFCands_
 
int verbosity_
 
edm::EDGetTokenT
< reco::VertexCollection
vertex_token
 
std::auto_ptr
< tau::RecoTauVertexAssociator
vertexAssociator_
 
edm::InputTag vertexSrc_
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 24 of file PFRecoTauDiscriminationByIsolation.cc.

Constructor & Destructor Documentation

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

Definition at line 27 of file PFRecoTauDiscriminationByIsolation.cc.

References edm::hlt::Exception, edm::ParameterSet::exists(), reco::tau::factorizePUQCuts(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), and AlCaHLTBitMon_QueryRunRegistry::string.

29  moduleLabel_(pset.getParameter<std::string>("@module_label")),
30  qualityCutsPSet_(pset.getParameter<edm::ParameterSet>("qualityCuts"))
31  {
32  includeTracks_ = pset.getParameter<bool>(
33  "ApplyDiscriminationByTrackerIsolation");
34  includeGammas_ = pset.getParameter<bool>(
35  "ApplyDiscriminationByECALIsolation");
36 
37  calculateWeights_ = pset.exists("ApplyDiscriminationByWeightedECALIsolation") ?
38  pset.getParameter<bool>("ApplyDiscriminationByWeightedECALIsolation") : false;
39 
40  applyOccupancyCut_ = pset.getParameter<bool>("applyOccupancyCut");
41  maximumOccupancy_ = pset.getParameter<uint32_t>("maximumOccupancy");
42 
43  applySumPtCut_ = pset.getParameter<bool>("applySumPtCut");
44  maximumSumPt_ = pset.getParameter<double>("maximumSumPtCut");
45 
47  "applyRelativeSumPtCut");
48  maximumRelativeSumPt_ = pset.getParameter<double>(
49  "relativeSumPtCut");
50  offsetRelativeSumPt_ = pset.exists("relativeSumPtOffset") ?
51  pset.getParameter<double>("relativeSumPtOffset") : 0.0;
52 
53  storeRawOccupancy_ = pset.exists("storeRawOccupancy") ?
54  pset.getParameter<bool>("storeRawOccupancy") : false;
55  storeRawSumPt_ = pset.exists("storeRawSumPt") ?
56  pset.getParameter<bool>("storeRawSumPt") : false;
57  storeRawPUsumPt_ = pset.exists("storeRawPUsumPt") ?
58  pset.getParameter<bool>("storeRawPUsumPt") : false;
59 
60  // Sanity check on requested options. We can't apply cuts and store the
61  // raw output at the same time
62  if ( applySumPtCut_ || applyOccupancyCut_ || applyRelativeSumPtCut_ ) {
63  if ( storeRawSumPt_ || storeRawOccupancy_ || storeRawPUsumPt_ ) {
64  throw cms::Exception("BadIsoConfig")
65  << "A 'store raw' and a 'apply cut' option have been set to true "
66  << "simultaneously. These options are mutually exclusive.";
67  }
68  }
69 
70  // sanity check2 - can't use weighted and unweighted iso at the same time
71  if(includeGammas_ && calculateWeights_)
72  {
73  throw cms::Exception("BasIsoConfig")
74  << "Both 'ApplyDiscriminationByECALIsolation' and 'ApplyDiscriminationByWeightedECALIsolation' "
75  << "have been set to true. These options are mutually exclusive.";
76  }
77 
78  // Can only store one type
79  int numStoreOptions = 0;
80  if ( storeRawSumPt_ ) ++numStoreOptions;
81  if ( storeRawOccupancy_ ) ++numStoreOptions;
82  if ( storeRawPUsumPt_ ) ++numStoreOptions;
83  if ( numStoreOptions > 1 ) {
84  throw cms::Exception("BadIsoConfig")
85  << "Both 'store sum pt' and 'store occupancy' options are set."
86  << " These options are mutually exclusive.";
87  }
88 
89  if ( pset.exists("customOuterCone") ) {
90  customIsoCone_ = pset.getParameter<double>("customOuterCone");
91  } else {
92  customIsoCone_ = -1;
93  }
94 
95  // Get the quality cuts specific to the isolation region
97  "isolationQualityCuts");
98 
99  qcuts_.reset(new tau::RecoTauQualityCuts(isolationQCuts));
100 
101  vertexAssociator_.reset(
103 
104  applyDeltaBeta_ = pset.exists("applyDeltaBetaCorrection") ?
105  pset.getParameter<bool>("applyDeltaBetaCorrection") : false;
106 
107  if ( applyDeltaBeta_ || calculateWeights_ ) {
108  // Factorize the isolation QCuts into those that are used to
109  // select PU and those that are not.
110  std::pair<edm::ParameterSet, edm::ParameterSet> puFactorizedIsoQCuts =
111  reco::tau::factorizePUQCuts(isolationQCuts);
112 
113  // Determine the pt threshold for the PU tracks
114  // First check if the user specifies explicitly the cut.
115  if ( pset.exists("deltaBetaPUTrackPtCutOverride") ) {
116  puFactorizedIsoQCuts.second.addParameter<double>(
117  "minTrackPt",
118  pset.getParameter<double>("deltaBetaPUTrackPtCutOverride"));
119  } else {
120  // Secondly take it from the minGammaEt
121  puFactorizedIsoQCuts.second.addParameter<double>(
122  "minTrackPt",
123  isolationQCuts.getParameter<double>("minGammaEt"));
124  }
125 
127  puFactorizedIsoQCuts.first));
128 
130  puFactorizedIsoQCuts.second));
131 
132  pfCandSrc_ = pset.getParameter<edm::InputTag>("particleFlowSrc");
133  pfCand_token=consumes<reco::PFCandidateCollection>(pfCandSrc_);
134  vertexSrc_ = pset.getParameter<edm::InputTag>("vertexSrc");
135  vertex_token=consumes<reco::VertexCollection>(vertexSrc_);
136  deltaBetaCollectionCone_ = pset.getParameter<double>(
137  "isoConeSizeForDeltaBeta");
138  std::string deltaBetaFactorFormula =
139  pset.getParameter<string>("deltaBetaFactor");
140  deltaBetaFormula_.reset(
141  new TFormula("DB_corr", deltaBetaFactorFormula.c_str()));
142  }
143 
144  applyRhoCorrection_ = pset.exists("applyRhoCorrection") ?
145  pset.getParameter<bool>("applyRhoCorrection") : false;
146  if ( applyRhoCorrection_ ) {
147  rhoProducer_ = pset.getParameter<edm::InputTag>("rhoProducer");
148  rho_token=consumes<double>(rhoProducer_);
149  rhoConeSize_ = pset.getParameter<double>("rhoConeSize");
151  pset.getParameter<double>("rhoUEOffsetCorrection");
152  }
153  useAllPFCands_ = pset.exists("UseAllPFCandsForWeights") ?
154  pset.getParameter<bool>("UseAllPFCandsForWeights") : false;
155 
156  verbosity_ = ( pset.exists("verbosity") ) ?
157  pset.getParameter<int>("verbosity") : 0;
158  }
T getParameter(std::string const &) const
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::PFCandidateCollection > pfCand_token
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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 160 of file PFRecoTauDiscriminationByIsolation.cc.

160 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 234 of file PFRecoTauDiscriminationByIsolation.cc.

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

235 {
236  // NB: The use of the PV in this context is necessitated by its use in
237  // applying quality cuts to the different objects in the isolation cone
238  // The vertex associator contains the logic to select the appropriate vertex
239  // We need to pass it the event so it can load the vertices.
240  vertexAssociator_->setEvent(event);
241 
242  // If we are applying the delta beta correction, we need to get the PF
243  // candidates from the event so we can find the PU tracks.
245  // Collect all the PF pile up tracks
247  event.getByToken(pfCand_token, pfCandidates);
249  chargedPFCandidatesInEvent_.reserve(pfCandidates->size());
250  size_t numPFCandidates = pfCandidates->size();
251  for ( size_t i = 0; i < numPFCandidates; ++i ) {
252  reco::PFCandidatePtr pfCandidate(pfCandidates, i);
253  if ( pfCandidate->charge() != 0 ) {
254  chargedPFCandidatesInEvent_.push_back(pfCandidate);
255  }
256  }
257  // Count all the vertices in the event, to parameterize the DB
258  // correction factor
260  event.getByToken(vertex_token, vertices);
261  size_t nVtxThisEvent = vertices->size();
262  deltaBetaFactorThisEvent_ = deltaBetaFormula_->Eval(nVtxThisEvent);
263  }
264 
265  if ( applyRhoCorrection_ ) {
266  edm::Handle<double> rhoHandle_;
267  event.getByToken(rho_token, rhoHandle_);
268  rhoThisEvent_ = (*rhoHandle_ - rhoUEOffsetCorrection_)*
269  (3.14159)*rhoConeSize_*rhoConeSize_;
270  }
271 }
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 274 of file PFRecoTauDiscriminationByIsolation.cc.

References gather_cfg::cout, eta(), alcazmumu_cfi::filter, edm::Ref< C, T, F >::isNonnull(), cmsBatch::log, LogDebug, LogTrace, reco::LeafCandidate::p4(), phi, MetAnalyzer::pv(), and reco::LeafCandidate::setP4().

275 {
276  LogDebug("discriminate") << " tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi();
277  LogDebug("discriminate") << *pfTau ;
278 
279  // collect the objects we are working with (ie tracks, tracks+gammas, etc)
280  std::vector<PFCandidatePtr> isoCharged_;
281  std::vector<PFCandidatePtr> isoNeutral_;
282  std::vector<PFCandidatePtr> isoPU_;
283  PFCandidateCollection isoNeutralWeight_;
284  std::vector<PFCandidatePtr> chPV_;
285  isoCharged_.reserve(pfTau->isolationPFChargedHadrCands().size());
286  isoNeutral_.reserve(pfTau->isolationPFGammaCands().size());
287  isoPU_.reserve(chargedPFCandidatesInEvent_.size());
288  isoNeutralWeight_.reserve(pfTau->isolationPFGammaCands().size());
289 
290  chPV_.reserve(chargedPFCandidatesInEvent_.size());
291 
292  // Get the primary vertex associated to this tau
293  reco::VertexRef pv = vertexAssociator_->associatedVertex(*pfTau);
294  // Let the quality cuts know which the vertex to use when applying selections
295  // on dz, etc.
296  if ( verbosity_ ) {
297  if ( pv.isNonnull() ) {
298  LogTrace("discriminate") << "pv: x = " << pv->position().x() << ", y = " << pv->position().y() << ", z = " << pv->position().z() ;
299  } else {
300  LogTrace("discriminate") << "pv: N/A" ;
301  }
302  if ( pfTau->leadPFChargedHadrCand().isNonnull() ) {
303  LogTrace("discriminate") << "leadPFChargedHadron:"
304  << " Pt = " << pfTau->leadPFChargedHadrCand()->pt() << ","
305  << " eta = " << pfTau->leadPFChargedHadrCand()->eta() << ","
306  << " phi = " << pfTau->leadPFChargedHadrCand()->phi() ;
307  } else {
308  LogTrace("discriminate") << "leadPFChargedHadron: N/A" ;
309  }
310  }
311 
312  // CV: isolation is not well defined in case primary vertex or leading charged hadron do not exist
313  if ( !(pv.isNonnull() && pfTau->leadPFChargedHadrCand().isNonnull()) ) return 0.;
314 
315  qcuts_->setPV(pv);
316  qcuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
317 
319  pileupQcutsGeneralQCuts_->setPV(pv);
320  pileupQcutsGeneralQCuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
321  pileupQcutsPUTrackSelection_->setPV(pv);
322  pileupQcutsPUTrackSelection_->setLeadTrack(pfTau->leadPFChargedHadrCand());
323  }
324 
325  // Load the tracks if they are being used.
326  if ( includeTracks_ ) {
327  for( auto const & cand : pfTau->isolationPFChargedHadrCands() ) {
328  if ( qcuts_->filterCandRef(cand) ) {
329  LogTrace("discriminate") << "adding charged iso cand with pt " << cand->pt() ;
330  isoCharged_.push_back(cand);
331  }
332  }
333  }
335  for( auto const & cand : pfTau->isolationPFGammaCands() ) {
336  if ( qcuts_->filterCandRef(cand) ) {
337  LogTrace("discriminate") << "adding neutral iso cand with pt " << cand->pt() ;
338  isoNeutral_.push_back(cand);
339  }
340  }
341  }
342 
345 
346  // If desired, get PU tracks.
348  // First select by inverted the DZ/track weight cuts. True = invert
349  if ( verbosity_ ) {
350  std::cout << "Initial PFCands: " << chargedPFCandidatesInEvent_.size() << std::endl;
351  }
352 
353  std::vector<PFCandidatePtr> allPU =
354  pileupQcutsPUTrackSelection_->filterCandRefs(
356 
357  std::vector<PFCandidatePtr> allNPU =
358  pileupQcutsPUTrackSelection_->filterCandRefs(
360  LogTrace("discriminate") << "After track cuts: " << allPU.size() ;
361 
362  // Now apply the rest of the cuts, like pt, and TIP, tracker hits, etc
363  if(!useAllPFCands_){
364  std::vector<PFCandidatePtr> cleanPU =
365  pileupQcutsGeneralQCuts_->filterCandRefs(allPU);
366 
367  std::vector<PFCandidatePtr> cleanNPU =
368  pileupQcutsGeneralQCuts_->filterCandRefs(allNPU);
369 
370 
371  LogTrace("discriminate") << "After cleaning cuts: " << cleanPU.size() ;
372 
373 
374  // Only select PU tracks inside the isolation cone.
375  DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_);
376  for(auto const & cand : cleanPU) {
377  if ( deltaBetaFilter(cand) ) isoPU_.push_back(cand);
378  }
379 
380  for(auto const & cand : cleanNPU) {
381  if ( deltaBetaFilter(cand) ) chPV_.push_back(cand);
382  }
383  LogTrace("discriminate") << "After cone cuts: " << isoPU_.size() << " " << chPV_.size() ;
384  }else{
385  isoPU_=allPU;
386  chPV_= allNPU;
387  }
388  }
389 
390  if (calculateWeights_)
391  {
392  for( auto const & isoObject : isoNeutral_ ) {
393  if(isoObject->charge() !=0){
394  // weight only neutral objects
395  isoNeutralWeight_.push_back(*isoObject);
396  continue;
397  }
398 
399  double eta=isoObject->eta();
400  double phi=isoObject->phi();
401  double sumNPU = 0.5*log(weightedSum(chPV_,eta,phi));
402 
403  double sumPU = 0.5*log(weightedSum(isoPU_,eta,phi));
404  PFCandidate neutral = *isoObject;
405  if (sumNPU+sumPU>0) neutral.setP4(((sumNPU)/(sumNPU+sumPU))*neutral.p4());
406 
407  isoNeutralWeight_.push_back(neutral);
408  }
409  }
410 
411  // Check if we want a custom iso cone
412  if ( customIsoCone_ >= 0. ) {
413  DRFilter filter(pfTau->p4(), 0, customIsoCone_);
414  DRFilter2 filter2(pfTau->p4(), 0, customIsoCone_);
415  std::vector<PFCandidatePtr> isoCharged_filter;
416  std::vector<PFCandidatePtr> isoNeutral_filter;
417  PFCandidateCollection isoNeutralWeight_filter;
418  // Remove all the objects not in our iso cone
419  for( auto const & isoObject : isoCharged_ ) {
420  if ( filter(isoObject) ) isoCharged_filter.push_back(isoObject);
421  }
422  if(!calculateWeights_){
423  for( auto const & isoObject : isoNeutral_ ) {
424  if ( filter(isoObject) ) isoNeutral_filter.push_back(isoObject);
425  }
426  isoNeutral_ = isoNeutral_filter;
427  }else{
428  for( auto const & isoObject : isoNeutralWeight_){
429  if ( filter2(isoObject) ) isoNeutralWeight_filter.push_back(isoObject);
430  }
431  isoNeutralWeight_ = isoNeutralWeight_filter;
432  }
433  isoCharged_ = isoCharged_filter;
434  }
435 
436  bool failsOccupancyCut = false;
437  bool failsSumPtCut = false;
438  bool failsRelativeSumPtCut = false;
439 
440 //--- nObjects requirement
441  int neutrals = isoNeutral_.size();
442 
443  if ( applyDeltaBeta_ ) {
444  neutrals -= TMath::Nint(deltaBetaFactorThisEvent_*isoPU_.size());
445  }
446  if ( neutrals < 0 ) {
447  neutrals = 0;
448  }
449 
450  size_t nOccupants = isoCharged_.size() + neutrals;
451 
452  failsOccupancyCut = ( nOccupants > maximumOccupancy_ );
453 
454  double totalPt = 0.0;
455  double puPt = 0.0;
456 //--- Sum PT requirement
458  double chargedPt = 0.0;
459  double neutralPt = 0.0;
460  double weightedNeutralPt = 0.0;
461  for( auto const & isoObject : isoCharged_ ) {
462  chargedPt += isoObject->pt();
463  }
464  if(!calculateWeights_){
465  for( auto const & isoObject : isoNeutral_ ) {
466  neutralPt += isoObject->pt();
467  }
468  }else{
469  for( auto const & isoObject : isoNeutralWeight_){
470  weightedNeutralPt+=isoObject.pt();
471  }
472  }
473  for( auto const & isoObject : isoPU_ ) {
474  puPt += isoObject->pt();
475  }
476  LogTrace("discriminate") << "chargedPt = " << chargedPt ;
477  LogTrace("discriminate") << "neutralPt = " << neutralPt ;
478  LogTrace("discriminate") << "weighted neutral Pt = " << weightedNeutralPt ;
479  LogTrace("discriminate") << "puPt = " << puPt << " (delta-beta corr. = " << (deltaBetaFactorThisEvent_*puPt) << ")" ;
480  if( calculateWeights_) {
481  neutralPt = weightedNeutralPt;
482  }
483 
484  if ( applyDeltaBeta_ ) {
485  neutralPt -= deltaBetaFactorThisEvent_*puPt;
486  }
487 
488  if ( applyRhoCorrection_ ) {
489  neutralPt -= rhoThisEvent_;
490  }
491 
492  if ( neutralPt < 0.0 ) {
493  neutralPt = 0.0;
494  }
495 
496  totalPt = chargedPt + neutralPt;
497  LogTrace("discriminate") << "totalPt = " << totalPt << " (cut = " << maximumSumPt_ << ")" ;
498 
499  failsSumPtCut = (totalPt > maximumSumPt_);
500 
501 //--- Relative Sum PT requirement
502  failsRelativeSumPtCut = (totalPt > ((pfTau->pt() - offsetRelativeSumPt_)*maximumRelativeSumPt_));
503  }
504 
505  bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
506  (applySumPtCut_ && failsSumPtCut) ||
507  (applyRelativeSumPtCut_ && failsRelativeSumPtCut);
508 
509  // We did error checking in the constructor, so this is safe.
510  if ( storeRawSumPt_ ) {
511  return totalPt;
512  } else if ( storeRawPUsumPt_ ) {
513  if ( applyDeltaBeta_ ) return puPt;
514  else if ( applyRhoCorrection_ ) return rhoThisEvent_;
515  else return 0.;
516  } else if ( storeRawOccupancy_ ) {
517  return nOccupants;
518  } else {
519  return (fails ? 0. : 1.);
520  }
521 }
#define LogDebug(id)
double weightedSum(std::vector< PFCandidatePtr > inColl_, double eta, double phi) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
virtual void setP4(const LorentzVector &p4)
set 4-momentum
T eta() const
std::vector< reco::PFCandidatePtr > chargedPFCandidatesInEvent_
#define LogTrace(id)
std::auto_ptr< tau::RecoTauQualityCuts > qcuts_
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsPUTrackSelection_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
tuple cout
Definition: gather_cfg.py:121
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
tuple log
Definition: cmsBatch.py:347
Definition: DDAxes.h:10
double PFRecoTauDiscriminationByIsolation::weightedSum ( std::vector< PFCandidatePtr inColl_,
double  eta,
double  phi 
) const
inline

Definition at line 165 of file PFRecoTauDiscriminationByIsolation.cc.

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

165  {
166  double out = 1.0;
167  for (auto const & inObj_ : inColl_){
168  double sum = (inObj_->pt()*inObj_->pt())/(deltaR2(eta,phi,inObj_->eta(),inObj_->phi()));
169  if(sum > 1.0) out *= sum;
170  }
171  return out;
172  }
T eta() const
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
tuple out
Definition: dbtoconf.py:99
Definition: DDAxes.h:10

Member Data Documentation

bool PFRecoTauDiscriminationByIsolation::applyDeltaBeta_
private

Definition at line 208 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyOccupancyCut_
private

Definition at line 189 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyRelativeSumPtCut_
private

Definition at line 193 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applyRhoCorrection_
private

Definition at line 221 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::applySumPtCut_
private

Definition at line 191 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::calculateWeights_
private

Definition at line 188 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 214 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::customIsoCone_
private

Definition at line 196 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::deltaBetaCollectionCone_
private

Definition at line 216 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::deltaBetaFactorThisEvent_
private

Definition at line 218 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 217 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::includeGammas_
private

Definition at line 187 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::includeTracks_
private

Definition at line 186 of file PFRecoTauDiscriminationByIsolation.cc.

uint32_t PFRecoTauDiscriminationByIsolation::maximumOccupancy_
private

Definition at line 190 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::maximumRelativeSumPt_
private

Definition at line 194 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::maximumSumPt_
private

Definition at line 192 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 195 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 210 of file PFRecoTauDiscriminationByIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByIsolation::pfCandSrc_
private

Definition at line 209 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 182 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 181 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 178 of file PFRecoTauDiscriminationByIsolation.cc.

edm::ParameterSet PFRecoTauDiscriminationByIsolation::qualityCutsPSet_
private

Definition at line 177 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 224 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoConeSize_
private

Definition at line 225 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoCorrectionThisEvent_
private

Definition at line 227 of file PFRecoTauDiscriminationByIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByIsolation::rhoProducer_
private

Definition at line 223 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoThisEvent_
private

Definition at line 228 of file PFRecoTauDiscriminationByIsolation.cc.

double PFRecoTauDiscriminationByIsolation::rhoUEOffsetCorrection_
private

Definition at line 226 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawOccupancy_
private

Definition at line 199 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawPUsumPt_
private

Definition at line 201 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::storeRawSumPt_
private

Definition at line 200 of file PFRecoTauDiscriminationByIsolation.cc.

bool PFRecoTauDiscriminationByIsolation::useAllPFCands_
private

Definition at line 222 of file PFRecoTauDiscriminationByIsolation.cc.

int PFRecoTauDiscriminationByIsolation::verbosity_
private

Definition at line 231 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 213 of file PFRecoTauDiscriminationByIsolation.cc.

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

Definition at line 184 of file PFRecoTauDiscriminationByIsolation.cc.

edm::InputTag PFRecoTauDiscriminationByIsolation::vertexSrc_
private

Definition at line 212 of file PFRecoTauDiscriminationByIsolation.cc.