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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override final
 
 PATTauSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~PATTauSlimmer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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::EDConsumerBase::consumesCollector(), edm::ParameterSet::getParameter(), modifyTau_, and tauModifier_.

41  :
43  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
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 {
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_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const bool modifyTau_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const bool dropTauChargedHadronRefs_
const bool linkToPackedPF_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
virtual pat::PATTauSlimmer::~PATTauSlimmer ( )
inlinevirtual

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 
)
finaloverridevirtual

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 
)
overridevirtual

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:122
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:460
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
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().