CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
pat::PATTauSlimmer Class Reference

Slimmer of PAT Taus. More...

Inheritance diagram for pat::PATTauSlimmer:
edm::stream::EDProducer<>

Public Member Functions

 PATTauSlimmer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATTauSlimmer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

const bool dropPFSpecific_
 
const bool dropPiZeroRefs_
 
const bool dropTauChargedHadronRefs_
 
const bool linkToPackedPF_
 
const bool modifyTau_
 
const edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
const edm::EDGetTokenT
< edm::View< pat::Tau > > 
src_
 
std::unique_ptr
< pat::ObjectModifier
< pat::Tau > > 
tauModifier_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Slimmer of PAT Taus.

Definition at line 19 of file PATTauSlimmer.cc.

Constructor & Destructor Documentation

pat::PATTauSlimmer::PATTauSlimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 39 of file PATTauSlimmer.cc.

References edm::ParameterSet::getParameter(), modifyTau_, and tauModifier_.

40  : src_(consumes<edm::View<pat::Tau>>(iConfig.getParameter<edm::InputTag>("src"))),
41  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
43  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
44  dropPiZeroRefs_(iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter<bool>("dropPiZeroRefs") : true),
46  iConfig.exists("dropTauChargedHadronRefs") ? iConfig.getParameter<bool>("dropTauChargedHadronRefs") : true),
47  dropPFSpecific_(iConfig.exists("dropPFSpecific") ? iConfig.getParameter<bool>("dropPFSpecific") : true),
48  modifyTau_(iConfig.getParameter<bool>("modifyTaus")) {
49  if (modifyTau_) {
50  const edm::ParameterSet &mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
51  tauModifier_ = std::make_unique<pat::ObjectModifier<pat::Tau>>(mod_config, consumesCollector());
52  }
53  produces<std::vector<pat::Tau>>();
54 }
bool exists(std::string const &parameterName) const
checks if a parameter exists
const edm::EDGetTokenT< edm::View< pat::Tau > > src_
const bool dropPFSpecific_
const bool dropPiZeroRefs_
const bool modifyTau_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
pat::PATTauSlimmer::~PATTauSlimmer ( )
inlineoverride

Definition at line 22 of file PATTauSlimmer.cc.

22 {}

Member Function Documentation

void pat::PATTauSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 56 of file PATTauSlimmer.cc.

References edm::Event::getByToken(), pat::Lepton< LeptonType >::isoDeposits_, pat::Tau::isolationPFChargedHadrCands(), pat::Tau::isolationPFGammaCands(), pat::Tau::isolationPFNeutrHadrCands(), pat::Lepton< LeptonType >::isolations_, eostools::move(), submitPVResolutionJobs::out, AlCaHLTBitMon_ParallelJobs::p, pat::Tau::pfSpecific_, edm::PtrVector< T >::push_back(), edm::Event::put(), edm::refToPtr(), pat::Tau::setIsolationChargedHadrCands(), pat::Tau::setIsolationGammaCands(), pat::Tau::setIsolationNeutralHadrCands(), pat::Tau::setSignalChargedHadrCands(), pat::Tau::setSignalGammaCands(), pat::Tau::setSignalNeutralHadrCands(), pat::Tau::signalPFChargedHadrCands(), pat::Tau::signalPFGammaCands(), pat::Tau::signalPFNeutrHadrCands(), alcazmumu_cfi::src, and metsig::tau.

56  {
57  using namespace edm;
58  using namespace std;
59 
60  if (modifyTau_)
61  tauModifier_->setEventContent(iSetup);
62 
64  iEvent.getByToken(src_, src);
65 
67  if (linkToPackedPF_)
68  iEvent.getByToken(pf2pc_, pf2pc);
69 
70  auto out = std::make_unique<std::vector<pat::Tau>>();
71  out->reserve(src->size());
72 
73  if (modifyTau_) {
74  tauModifier_->setEvent(iEvent);
75  }
76 
77  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
78  out->push_back(*it);
79  pat::Tau &tau = out->back();
80 
81  if (modifyTau_) {
82  tauModifier_->modify(tau);
83  }
84 
85  // clearing the pat isolation which is not used by taus
86  tau.isolations_.clear();
87  tau.isoDeposits_.clear();
88 
89  if (linkToPackedPF_) {
90  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs,
91  isolationGammaPtrs;
92 
93  for (const reco::PFCandidatePtr &p : tau.signalPFChargedHadrCands()) {
94  signalChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
95  }
96  tau.setSignalChargedHadrCands(signalChHPtrs);
97 
98  for (const reco::PFCandidatePtr &p : tau.signalPFNeutrHadrCands()) {
99  signalNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
100  }
101  tau.setSignalNeutralHadrCands(signalNHPtrs);
102 
103  for (const reco::PFCandidatePtr &p : tau.signalPFGammaCands()) {
104  signalGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
105  }
106  tau.setSignalGammaCands(signalGammaPtrs);
107 
108  for (const reco::PFCandidatePtr &p : tau.isolationPFChargedHadrCands()) {
109  isolationChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
110  }
111  tau.setIsolationChargedHadrCands(isolationChHPtrs);
112 
113  for (const reco::PFCandidatePtr &p : tau.isolationPFNeutrHadrCands()) {
114  isolationNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
115  }
116  tau.setIsolationNeutralHadrCands(isolationNHPtrs);
117 
118  for (const reco::PFCandidatePtr &p : tau.isolationPFGammaCands()) {
119  isolationGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
120  }
121  tau.setIsolationGammaCands(isolationGammaPtrs);
122  }
123  if (dropPiZeroRefs_) {
124  tau.pfSpecific_[0].signalPiZeroCandidates_.clear();
125  tau.pfSpecific_[0].isolationPiZeroCandidates_.clear();
126  }
128  tau.pfSpecific_[0].signalTauChargedHadronCandidates_.clear();
129  tau.pfSpecific_[0].isolationTauChargedHadronCandidates_.clear();
130  }
131  if (dropPFSpecific_) {
132  tau.pfSpecific_.clear();
133  }
134  }
135 
136  iEvent.put(std::move(out));
137 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
const std::vector< reco::PFCandidatePtr > & isolationPFChargedHadrCands() const
const edm::EDGetTokenT< edm::View< pat::Tau > > src_
const bool dropPFSpecific_
const bool dropPiZeroRefs_
void setIsolationGammaCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:265
void setIsolationNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:264
void setIsolationChargedHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:263
def move
Definition: eostools.py:511
void setSignalChargedHadrCands(const reco::CandidatePtrVector &ptrs)
setters for the PtrVectors (for miniAOD)
Definition: Tau.h:260
Analysis-level tau class.
Definition: Tau.h:53
IsoDepositPairs isoDeposits_
Definition: Lepton.h:222
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
const bool modifyTau_
void setSignalGammaCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:262
const std::vector< reco::PFCandidatePtr > & signalPFNeutrHadrCands() const
const std::vector< reco::PFCandidatePtr > & isolationPFGammaCands() const
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
std::vector< float > isolations_
Definition: Lepton.h:223
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
std::vector< pat::tau::TauPFSpecific > pfSpecific_
holder for PFTau info, or empty vector if CaloTau
Definition: Tau.h:469
const std::vector< reco::PFCandidatePtr > & isolationPFNeutrHadrCands() const
void setSignalNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:261
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_

Member Data Documentation

const bool pat::PATTauSlimmer::dropPFSpecific_
private

Definition at line 32 of file PATTauSlimmer.cc.

const bool pat::PATTauSlimmer::dropPiZeroRefs_
private

Definition at line 30 of file PATTauSlimmer.cc.

const bool pat::PATTauSlimmer::dropTauChargedHadronRefs_
private

Definition at line 31 of file PATTauSlimmer.cc.

const bool pat::PATTauSlimmer::linkToPackedPF_
private

Definition at line 28 of file PATTauSlimmer.cc.

const bool pat::PATTauSlimmer::modifyTau_
private

Definition at line 33 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATTauSlimmer::pf2pc_
private

Definition at line 29 of file PATTauSlimmer.cc.

const edm::EDGetTokenT<edm::View<pat::Tau> > pat::PATTauSlimmer::src_
private

Definition at line 27 of file PATTauSlimmer.cc.

std::unique_ptr<pat::ObjectModifier<pat::Tau> > pat::PATTauSlimmer::tauModifier_
private

Definition at line 34 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().