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

 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 linkToLostTracks_
 
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_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trk2lost_
 

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

◆ PATTauSlimmer()

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

Definition at line 41 of file PATTauSlimmer.cc.

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

42  : src_(consumes<edm::View<pat::Tau>>(iConfig.getParameter<edm::InputTag>("src"))),
43  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
45  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
46  linkToLostTracks_(iConfig.getParameter<bool>("linkToLostTracks")),
48  iConfig.getParameter<edm::InputTag>("lostTracks"))),
49  dropPiZeroRefs_(iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter<bool>("dropPiZeroRefs") : true),
51  iConfig.exists("dropTauChargedHadronRefs") ? iConfig.getParameter<bool>("dropTauChargedHadronRefs") : true),
52  dropPFSpecific_(iConfig.exists("dropPFSpecific") ? iConfig.getParameter<bool>("dropPFSpecific") : true),
53  modifyTau_(iConfig.getParameter<bool>("modifyTaus")) {
54  if (modifyTau_) {
55  const edm::ParameterSet &mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
56  tauModifier_ = std::make_unique<pat::ObjectModifier<pat::Tau>>(mod_config, consumesCollector());
57  }
58  produces<std::vector<pat::Tau>>();
59 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const bool linkToLostTracks_
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 edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trk2lost_
const bool modifyTau_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_

◆ ~PATTauSlimmer()

pat::PATTauSlimmer::~PATTauSlimmer ( )
inlineoverride

Definition at line 22 of file PATTauSlimmer.cc.

22 {}

Member Function Documentation

◆ produce()

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

Definition at line 61 of file PATTauSlimmer.cc.

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

61  {
62  using namespace edm;
63  using namespace std;
64 
65  if (modifyTau_)
66  tauModifier_->setEventContent(iSetup);
67 
69  iEvent.getByToken(src_, src);
70 
72  if (linkToPackedPF_)
73  iEvent.getByToken(pf2pc_, pf2pc);
74 
77  iEvent.getByToken(trk2lost_, trk2lost);
78 
79  auto out = std::make_unique<std::vector<pat::Tau>>();
80  out->reserve(src->size());
81 
82  if (modifyTau_) {
83  tauModifier_->setEvent(iEvent);
84  }
85 
86  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
87  out->push_back(*it);
88  pat::Tau &tau = out->back();
89 
90  if (modifyTau_) {
91  tauModifier_->modify(tau);
92  }
93 
94  // clearing the pat isolation which is not used by taus
95  tau.isolations_.clear();
96  tau.isoDeposits_.clear();
97 
98  if (linkToPackedPF_) {
99  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs,
100  isolationGammaPtrs;
101 
102  for (const reco::PFCandidatePtr &p : tau.signalPFChargedHadrCands()) {
103  signalChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
104  }
105  tau.setSignalChargedHadrCands(signalChHPtrs);
106 
107  for (const reco::PFCandidatePtr &p : tau.signalPFNeutrHadrCands()) {
108  signalNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
109  }
110  tau.setSignalNeutralHadrCands(signalNHPtrs);
111 
112  for (const reco::PFCandidatePtr &p : tau.signalPFGammaCands()) {
113  signalGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
114  }
115  tau.setSignalGammaCands(signalGammaPtrs);
116 
117  for (const reco::PFCandidatePtr &p : tau.isolationPFChargedHadrCands()) {
118  isolationChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
119  }
120  tau.setIsolationChargedHadrCands(isolationChHPtrs);
121 
122  for (const reco::PFCandidatePtr &p : tau.isolationPFNeutrHadrCands()) {
123  isolationNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
124  }
125  tau.setIsolationNeutralHadrCands(isolationNHPtrs);
126 
127  for (const reco::PFCandidatePtr &p : tau.isolationPFGammaCands()) {
128  isolationGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
129  }
130  tau.setIsolationGammaCands(isolationGammaPtrs);
131  }
132  if (linkToLostTracks_ && !tau.signalTracks().empty()) {
133  std::vector<reco::CandidatePtr> signalLostTracks;
134  for (const auto &trkRef : tau.signalTracks()) {
135  const auto &lostCandRef = (*trk2lost)[edm::refToPtr(trkRef)];
136  if (lostCandRef.isNonnull())
137  signalLostTracks.push_back(edm::refToPtr(lostCandRef));
138  }
139  tau.setSignalLostTracks(signalLostTracks);
140  }
141 
142  if (dropPiZeroRefs_) {
143  tau.pfSpecific_[0].signalPiZeroCandidates_.clear();
144  tau.pfSpecific_[0].isolationPiZeroCandidates_.clear();
145  }
147  tau.pfSpecific_[0].signalTauChargedHadronCandidates_.clear();
148  tau.pfSpecific_[0].isolationTauChargedHadronCandidates_.clear();
149  }
150  if (dropPFSpecific_) {
151  tau.pfSpecific_.clear();
152  }
153  }
154 
155  iEvent.put(std::move(out));
156 }
const bool linkToLostTracks_
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
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:152
const edm::EDGetTokenT< edm::View< pat::Tau > > src_
const bool dropPFSpecific_
const bool dropPiZeroRefs_
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trk2lost_
Analysis-level tau class.
Definition: Tau.h:53
const bool modifyTau_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_

Member Data Documentation

◆ dropPFSpecific_

const bool pat::PATTauSlimmer::dropPFSpecific_
private

Definition at line 34 of file PATTauSlimmer.cc.

◆ dropPiZeroRefs_

const bool pat::PATTauSlimmer::dropPiZeroRefs_
private

Definition at line 32 of file PATTauSlimmer.cc.

◆ dropTauChargedHadronRefs_

const bool pat::PATTauSlimmer::dropTauChargedHadronRefs_
private

Definition at line 33 of file PATTauSlimmer.cc.

◆ linkToLostTracks_

const bool pat::PATTauSlimmer::linkToLostTracks_
private

Definition at line 30 of file PATTauSlimmer.cc.

◆ linkToPackedPF_

const bool pat::PATTauSlimmer::linkToPackedPF_
private

Definition at line 28 of file PATTauSlimmer.cc.

◆ modifyTau_

const bool pat::PATTauSlimmer::modifyTau_
private

Definition at line 35 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

◆ pf2pc_

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

Definition at line 29 of file PATTauSlimmer.cc.

◆ src_

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

Definition at line 27 of file PATTauSlimmer.cc.

◆ tauModifier_

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

Definition at line 36 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

◆ trk2lost_

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

Definition at line 31 of file PATTauSlimmer.cc.