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  edm::ConsumesCollector sumes(consumesCollector());
51  if( modifyTau_ ) {
52  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
53  tauModifier_.reset(new pat::ObjectModifier<pat::Tau>(mod_config) );
54  tauModifier_->setConsumes(sumes);
55  } else {
56  tauModifier_.reset(nullptr);
57  }
58  produces<std::vector<pat::Tau> >();
59 }
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 62 of file PATTauSlimmer.cc.

References modifyTau_, and tauModifier_.

Referenced by ~PATTauSlimmer().

62  {
63  if( modifyTau_ ) tauModifier_->setEventContent(iSetup);
64 }
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 67 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().

67  {
68  using namespace edm;
69  using namespace std;
70 
72  iEvent.getByToken(src_, src);
73 
75  if (linkToPackedPF_) iEvent.getByToken(pf2pc_, pf2pc);
76 
77  auto out = std::make_unique<std::vector<pat::Tau>>();
78  out->reserve(src->size());
79 
80  if( modifyTau_ ) { tauModifier_->setEvent(iEvent); }
81 
82  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
83  out->push_back(*it);
84  pat::Tau & tau = out->back();
85 
86  if( modifyTau_ ) { tauModifier_->modify(tau); }
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 
94  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs, 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  }
127  if(dropPiZeroRefs_){
128  tau.pfSpecific_[0].signalPiZeroCandidates_.clear();
129  tau.pfSpecific_[0].isolationPiZeroCandidates_.clear();
130  }
132  tau.pfSpecific_[0].signalTauChargedHadronCandidates_.clear();
133  tau.pfSpecific_[0].isolationTauChargedHadronCandidates_.clear();
134  }
135  if(dropPFSpecific_){ tau.pfSpecific_.clear();}
136 
137  }
138 
139  iEvent.put(std::move(out));
140 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
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:579
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:301
void setIsolationNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:300
void setIsolationChargedHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:299
void setSignalChargedHadrCands(const reco::CandidatePtrVector &ptrs)
setters for the PtrVectors (for miniAOD)
Definition: Tau.h:296
Analysis-level tau class.
Definition: Tau.h:55
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:298
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:510
std::vector< pat::tau::TauPFSpecific > pfSpecific_
holder for PFTau info, or empty vector if CaloTau
Definition: Tau.h:505
const std::vector< reco::PFCandidatePtr > & isolationPFNeutrHadrCands() const
void setSignalNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:297
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().