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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 20 of file PATTauSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 41 of file PATTauSlimmer.cc.

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

41  :
42  src_(consumes<edm::View<pat::Tau> >(iConfig.getParameter<edm::InputTag>("src"))),
43  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
44  pf2pc_(mayConsume<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
45  dropPiZeroRefs_(iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter<bool>("dropPiZeroRefs") : true ),
46  dropTauChargedHadronRefs_(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 {
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 }
T getParameter(std::string const &) const
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_
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
pat::PATTauSlimmer::~PATTauSlimmer ( )
inlineoverride

Definition at line 23 of file PATTauSlimmer.cc.

References beginLuminosityBlock(), iEvent, and produce().

23 { }

Member Function Documentation

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

Definition at line 58 of file PATTauSlimmer.cc.

References modifyTau_, and tauModifier_.

Referenced by ~PATTauSlimmer().

58  {
59  if( modifyTau_ ) tauModifier_->setEventContent(iSetup);
60 }
const bool modifyTau_
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
void pat::PATTauSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 63 of file PATTauSlimmer.cc.

References DEFINE_FWK_MODULE, dropPFSpecific_, dropPiZeroRefs_, dropTauChargedHadronRefs_, edm::Event::getByToken(), pat::Lepton< LeptonType >::isoDeposits_, pat::Tau::isolationPFChargedHadrCands(), pat::Tau::isolationPFGammaCands(), pat::Tau::isolationPFNeutrHadrCands(), pat::Lepton< LeptonType >::isolations_, linkToPackedPF_, modifyTau_, eostools::move(), MillePedeFileConverter_cfg::out, AlCaHLTBitMon_ParallelJobs::p, pf2pc_, 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(), TrackRefitter_38T_cff::src, src_, metsig::tau, and tauModifier_.

Referenced by ~PATTauSlimmer().

63  {
64  using namespace edm;
65  using namespace std;
66 
68  iEvent.getByToken(src_, src);
69 
71  if (linkToPackedPF_) iEvent.getByToken(pf2pc_, pf2pc);
72 
73  auto out = std::make_unique<std::vector<pat::Tau>>();
74  out->reserve(src->size());
75 
76  if( modifyTau_ ) { tauModifier_->setEvent(iEvent); }
77 
78  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
79  out->push_back(*it);
80  pat::Tau & tau = out->back();
81 
82  if( modifyTau_ ) { tauModifier_->modify(tau); }
83 
84  // clearing the pat isolation which is not used by taus
85  tau.isolations_.clear();
86  tau.isoDeposits_.clear();
87 
88  if (linkToPackedPF_) {
89 
90  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs, isolationGammaPtrs;
91 
92  for (const reco::PFCandidatePtr &p : tau.signalPFChargedHadrCands()) {
93  signalChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
94  }
95  tau.setSignalChargedHadrCands(signalChHPtrs);
96 
97  for (const reco::PFCandidatePtr &p : tau.signalPFNeutrHadrCands()) {
98  signalNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
99  }
100  tau.setSignalNeutralHadrCands(signalNHPtrs);
101 
102  for (const reco::PFCandidatePtr &p : tau.signalPFGammaCands()) {
103  signalGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
104  }
105  tau.setSignalGammaCands(signalGammaPtrs);
106 
107  for (const reco::PFCandidatePtr &p : tau.isolationPFChargedHadrCands()) {
108  isolationChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
109  }
110  tau.setIsolationChargedHadrCands(isolationChHPtrs);
111 
112  for (const reco::PFCandidatePtr &p : tau.isolationPFNeutrHadrCands()) {
113  isolationNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
114  }
115  tau.setIsolationNeutralHadrCands(isolationNHPtrs);
116 
117  for (const reco::PFCandidatePtr &p : tau.isolationPFGammaCands()) {
118  isolationGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
119  }
120  tau.setIsolationGammaCands(isolationGammaPtrs);
121 
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_){ tau.pfSpecific_.clear();}
132 
133  }
134 
135  iEvent.put(std::move(out));
136 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
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:517
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
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:302
void setIsolationNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:301
void setIsolationChargedHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:300
void setSignalChargedHadrCands(const reco::CandidatePtrVector &ptrs)
setters for the PtrVectors (for miniAOD)
Definition: Tau.h:297
Analysis-level tau class.
Definition: Tau.h:56
IsoDepositPairs isoDeposits_
Definition: Lepton.h:202
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
const bool modifyTau_
void setSignalGammaCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:299
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:203
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
def move(src, dest)
Definition: eostools.py:511
std::vector< pat::tau::TauPFSpecific > pfSpecific_
holder for PFTau info, or empty vector if CaloTau
Definition: Tau.h:508
const std::vector< reco::PFCandidatePtr > & isolationPFNeutrHadrCands() const
void setSignalNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:298
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_

Member Data Documentation

const bool pat::PATTauSlimmer::dropPFSpecific_
private

Definition at line 34 of file PATTauSlimmer.cc.

Referenced by produce().

const bool pat::PATTauSlimmer::dropPiZeroRefs_
private

Definition at line 32 of file PATTauSlimmer.cc.

Referenced by produce().

const bool pat::PATTauSlimmer::dropTauChargedHadronRefs_
private

Definition at line 33 of file PATTauSlimmer.cc.

Referenced by produce().

const bool pat::PATTauSlimmer::linkToPackedPF_
private

Definition at line 30 of file PATTauSlimmer.cc.

Referenced by produce().

const bool pat::PATTauSlimmer::modifyTau_
private

Definition at line 35 of file PATTauSlimmer.cc.

Referenced by beginLuminosityBlock(), PATTauSlimmer(), and produce().

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

Definition at line 31 of file PATTauSlimmer.cc.

Referenced by produce().

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

Definition at line 29 of file PATTauSlimmer.cc.

Referenced by produce().

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

Definition at line 36 of file PATTauSlimmer.cc.

Referenced by beginLuminosityBlock(), PATTauSlimmer(), and produce().