CMS 3D CMS Logo

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

void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) final
 
 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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Slimmer of PAT Taus.

Definition at line 19 of file PATTauSlimmer.cc.

Constructor & Destructor Documentation

◆ PATTauSlimmer()

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

Definition at line 40 of file PATTauSlimmer.cc.

41  : src_(consumes<edm::View<pat::Tau>>(iConfig.getParameter<edm::InputTag>("src"))),
42  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
44  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
45  dropPiZeroRefs_(iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter<bool>("dropPiZeroRefs") : true),
47  iConfig.exists("dropTauChargedHadronRefs") ? iConfig.getParameter<bool>("dropTauChargedHadronRefs") : true),
48  dropPFSpecific_(iConfig.exists("dropPFSpecific") ? iConfig.getParameter<bool>("dropPFSpecific") : true),
49  modifyTau_(iConfig.getParameter<bool>("modifyTaus")) {
50  if (modifyTau_) {
51  const edm::ParameterSet &mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
52  tauModifier_ = std::make_unique<pat::ObjectModifier<pat::Tau>>(mod_config, consumesCollector());
53  }
54  produces<std::vector<pat::Tau>>();
55 }

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

◆ ~PATTauSlimmer()

pat::PATTauSlimmer::~PATTauSlimmer ( )
inlineoverride

Definition at line 22 of file PATTauSlimmer.cc.

22 {}

Member Function Documentation

◆ beginLuminosityBlock()

void pat::PATTauSlimmer::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup iSetup 
)
final

Definition at line 57 of file PATTauSlimmer.cc.

57  {
58  if (modifyTau_)
59  tauModifier_->setEventContent(iSetup);
60 }

◆ produce()

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

Definition at line 62 of file PATTauSlimmer.cc.

62  {
63  using namespace edm;
64  using namespace std;
65 
67  iEvent.getByToken(src_, src);
68 
70  if (linkToPackedPF_)
71  iEvent.getByToken(pf2pc_, pf2pc);
72 
73  auto out = std::make_unique<std::vector<pat::Tau>>();
74  out->reserve(src->size());
75 
76  if (modifyTau_) {
77  tauModifier_->setEvent(iEvent);
78  }
79 
80  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
81  out->push_back(*it);
82  pat::Tau &tau = out->back();
83 
84  if (modifyTau_) {
85  tauModifier_->modify(tau);
86  }
87 
88  // clearing the pat isolation which is not used by taus
89  tau.isolations_.clear();
90  tau.isoDeposits_.clear();
91 
92  if (linkToPackedPF_) {
93  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs,
94  isolationGammaPtrs;
95 
96  for (const reco::PFCandidatePtr &p : tau.signalPFChargedHadrCands()) {
97  signalChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
98  }
99  tau.setSignalChargedHadrCands(signalChHPtrs);
100 
101  for (const reco::PFCandidatePtr &p : tau.signalPFNeutrHadrCands()) {
102  signalNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
103  }
104  tau.setSignalNeutralHadrCands(signalNHPtrs);
105 
106  for (const reco::PFCandidatePtr &p : tau.signalPFGammaCands()) {
107  signalGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
108  }
109  tau.setSignalGammaCands(signalGammaPtrs);
110 
111  for (const reco::PFCandidatePtr &p : tau.isolationPFChargedHadrCands()) {
112  isolationChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
113  }
114  tau.setIsolationChargedHadrCands(isolationChHPtrs);
115 
116  for (const reco::PFCandidatePtr &p : tau.isolationPFNeutrHadrCands()) {
117  isolationNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
118  }
119  tau.setIsolationNeutralHadrCands(isolationNHPtrs);
120 
121  for (const reco::PFCandidatePtr &p : tau.isolationPFGammaCands()) {
122  isolationGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
123  }
124  tau.setIsolationGammaCands(isolationGammaPtrs);
125  }
126  if (dropPiZeroRefs_) {
127  tau.pfSpecific_[0].signalPiZeroCandidates_.clear();
128  tau.pfSpecific_[0].isolationPiZeroCandidates_.clear();
129  }
131  tau.pfSpecific_[0].signalTauChargedHadronCandidates_.clear();
132  tau.pfSpecific_[0].isolationTauChargedHadronCandidates_.clear();
133  }
134  if (dropPFSpecific_) {
135  tau.pfSpecific_.clear();
136  }
137  }
138 
139  iEvent.put(std::move(out));
140 }

References iEvent, eostools::move(), MillePedeFileConverter_cfg::out, AlCaHLTBitMon_ParallelJobs::p, edm::PtrVector< T >::push_back(), edm::refToPtr(), TrackRefitter_38T_cff::src, and metsig::tau.

Member Data Documentation

◆ dropPFSpecific_

const bool pat::PATTauSlimmer::dropPFSpecific_
private

Definition at line 33 of file PATTauSlimmer.cc.

◆ dropPiZeroRefs_

const bool pat::PATTauSlimmer::dropPiZeroRefs_
private

Definition at line 31 of file PATTauSlimmer.cc.

◆ dropTauChargedHadronRefs_

const bool pat::PATTauSlimmer::dropTauChargedHadronRefs_
private

Definition at line 32 of file PATTauSlimmer.cc.

◆ linkToPackedPF_

const bool pat::PATTauSlimmer::linkToPackedPF_
private

Definition at line 29 of file PATTauSlimmer.cc.

◆ modifyTau_

const bool pat::PATTauSlimmer::modifyTau_
private

Definition at line 34 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

◆ pf2pc_

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

Definition at line 30 of file PATTauSlimmer.cc.

◆ src_

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

Definition at line 28 of file PATTauSlimmer.cc.

◆ tauModifier_

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

Definition at line 35 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

metsig::tau
Definition: SignAlgoResolutions.h:49
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pat::Tau
Analysis-level tau class.
Definition: Tau.h:53
pat::PATTauSlimmer::modifyTau_
const bool modifyTau_
Definition: PATTauSlimmer.cc:34
pat::PATTauSlimmer::pf2pc_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
Definition: PATTauSlimmer.cc:30
edm::Handle
Definition: AssociativeIterator.h:50
pat::PATTauSlimmer::tauModifier_
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
Definition: PATTauSlimmer.cc:35
pat::PATTauSlimmer::src_
const edm::EDGetTokenT< edm::View< pat::Tau > > src_
Definition: PATTauSlimmer.cc:28
edm::refToPtr
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
edm::PtrVector< Candidate >
pat::PATTauSlimmer::linkToPackedPF_
const bool linkToPackedPF_
Definition: PATTauSlimmer.cc:29
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
pat::PATTauSlimmer::dropPiZeroRefs_
const bool dropPiZeroRefs_
Definition: PATTauSlimmer.cc:31
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::Association
Definition: Association.h:18
edm::Ptr< PFCandidate >
pat::PATTauSlimmer::dropPFSpecific_
const bool dropPFSpecific_
Definition: PATTauSlimmer.cc:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
pat::PATTauSlimmer::dropTauChargedHadronRefs_
const bool dropTauChargedHadronRefs_
Definition: PATTauSlimmer.cc:32
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::InputTag
Definition: InputTag.h:15