CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pat::PATTauSlimmer Class Reference

Slimmer of PAT Taus. More...

Inheritance diagram for pat::PATTauSlimmer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
 
 PATTauSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PATTauSlimmer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool dropPFSpecific_
 
bool dropPiZeroRefs_
 
bool dropTauChargedHadronRefs_
 
bool linkToPackedPF_
 
bool modifyTau_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
edm::EDGetTokenT< edm::View
< pat::Tau > > 
src_
 
std::unique_ptr
< pat::ObjectModifier
< pat::Tau > > 
tauModifier_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 42 of file PATTauSlimmer.cc.

References edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

42  :
44  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
45  modifyTau_(iConfig.getParameter<bool>("modifyTaus"))
46 {
48  if( modifyTau_ ) {
49  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
50  tauModifier_.reset(new pat::ObjectModifier<pat::Tau>(mod_config) );
51  tauModifier_->setConsumes(sumes);
52  } else {
53  tauModifier_.reset(nullptr);
54  }
55  produces<std::vector<pat::Tau> >();
56  if (linkToPackedPF_) pf2pc_ = consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
57  dropPiZeroRefs_ = iConfig.exists("dropPiZeroRefs") ? iConfig.getParameter<bool>("dropPiZeroRefs") : true;
58  dropTauChargedHadronRefs_ = iConfig.exists("dropTauChargedHadronRefs") ? iConfig.getParameter<bool>("dropTauChargedHadronRefs") : true;
59  dropPFSpecific_ = iConfig.exists("dropPFSpecific") ? iConfig.getParameter<bool>("dropPFSpecific"): true;
60 
61 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::View< pat::Tau > > src_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
virtual pat::PATTauSlimmer::~PATTauSlimmer ( )
inlinevirtual

Definition at line 23 of file PATTauSlimmer.cc.

23 { }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 64 of file PATTauSlimmer.cc.

References modifyTau_, and tauModifier_.

64  {
65  if( modifyTau_ ) tauModifier_->setEventContent(iSetup);
66 }
std::unique_ptr< pat::ObjectModifier< pat::Tau > > tauModifier_
void pat::PATTauSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 69 of file PATTauSlimmer.cc.

References 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_, dbtoconf::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(), alcazmumu_cfi::src, src_, metsig::tau, and tauModifier_.

69  {
70  using namespace edm;
71  using namespace std;
72 
74  iEvent.getByToken(src_, src);
75 
77  if (linkToPackedPF_) iEvent.getByToken(pf2pc_, pf2pc);
78 
79  auto_ptr<vector<pat::Tau> > out(new vector<pat::Tau>());
80  out->reserve(src->size());
81 
82  if( modifyTau_ ) { tauModifier_->setEvent(iEvent); }
83 
84  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
85  out->push_back(*it);
86  pat::Tau & tau = out->back();
87 
88  if( modifyTau_ ) { tauModifier_->modify(tau); }
89 
90  // clearing the pat isolation which is not used by taus
91  tau.isolations_.clear();
92  tau.isoDeposits_.clear();
93 
94  if (linkToPackedPF_) {
95 
96  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs, isolationGammaPtrs;
97 
98  for (const reco::PFCandidatePtr &p : tau.signalPFChargedHadrCands()) {
99  signalChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
100  }
101  tau.setSignalChargedHadrCands(signalChHPtrs);
102 
103  for (const reco::PFCandidatePtr &p : tau.signalPFNeutrHadrCands()) {
104  signalNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
105  }
106  tau.setSignalNeutralHadrCands(signalNHPtrs);
107 
108  for (const reco::PFCandidatePtr &p : tau.signalPFGammaCands()) {
109  signalGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
110  }
111  tau.setSignalGammaCands(signalGammaPtrs);
112 
113  for (const reco::PFCandidatePtr &p : tau.isolationPFChargedHadrCands()) {
114  isolationChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
115  }
116  tau.setIsolationChargedHadrCands(isolationChHPtrs);
117 
118  for (const reco::PFCandidatePtr &p : tau.isolationPFNeutrHadrCands()) {
119  isolationNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
120  }
121  tau.setIsolationNeutralHadrCands(isolationNHPtrs);
122 
123  for (const reco::PFCandidatePtr &p : tau.isolationPFGammaCands()) {
124  isolationGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
125  }
126  tau.setIsolationGammaCands(isolationGammaPtrs);
127 
128  }
129  if(dropPiZeroRefs_){
130  tau.pfSpecific_[0].signalPiZeroCandidates_.clear();
131  tau.pfSpecific_[0].isolationPiZeroCandidates_.clear();
132  }
134  tau.pfSpecific_[0].signalTauChargedHadronCandidates_.clear();
135  tau.pfSpecific_[0].isolationTauChargedHadronCandidates_.clear();
136  }
137  if(dropPFSpecific_){ tau.pfSpecific_.clear();}
138 
139  }
140 
141  iEvent.put(out);
142 }
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:449
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
const std::vector< reco::PFCandidatePtr > & isolationPFChargedHadrCands() const
edm::EDGetTokenT< edm::View< pat::Tau > > src_
void setIsolationGammaCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:302
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
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:199
tuple out
Definition: dbtoconf.py:99
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
void setSignalGammaCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:299
const std::vector< reco::PFCandidatePtr > & signalPFNeutrHadrCands() const
const std::vector< reco::PFCandidatePtr > & isolationPFGammaCands() const
std::vector< float > isolations_
Definition: Lepton.h:200
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
std::vector< pat::tau::TauPFSpecific > pfSpecific_
holder for PFTau info, or empty vector if CaloTau
Definition: Tau.h:477
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

bool pat::PATTauSlimmer::dropPFSpecific_
private

Definition at line 34 of file PATTauSlimmer.cc.

Referenced by produce().

bool pat::PATTauSlimmer::dropPiZeroRefs_
private

Definition at line 32 of file PATTauSlimmer.cc.

Referenced by produce().

bool pat::PATTauSlimmer::dropTauChargedHadronRefs_
private

Definition at line 33 of file PATTauSlimmer.cc.

Referenced by produce().

bool pat::PATTauSlimmer::linkToPackedPF_
private

Definition at line 30 of file PATTauSlimmer.cc.

Referenced by produce().

bool pat::PATTauSlimmer::modifyTau_
private

Definition at line 35 of file PATTauSlimmer.cc.

Referenced by beginLuminosityBlock(), and produce().

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

Definition at line 31 of file PATTauSlimmer.cc.

Referenced by produce().

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(), and produce().