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

 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
 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
 
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_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
edm::EDGetTokenT< edm::View
< pat::Tau > > 
src_
 

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 19 of file PATTauSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 39 of file PATTauSlimmer.cc.

References dropPFSpecific_, dropPiZeroRefs_, dropTauChargedHadronRefs_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), linkToPackedPF_, and pf2pc_.

39  :
41  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates"))
42 {
43  produces<std::vector<pat::Tau> >();
44  if (linkToPackedPF_) pf2pc_ = consumes<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 
49 }
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)
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
virtual pat::PATTauSlimmer::~PATTauSlimmer ( )
inlinevirtual

Definition at line 22 of file PATTauSlimmer.cc.

22 { }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 52 of file PATTauSlimmer.cc.

References edm::Event::getByToken(), pat::Lepton< LeptonType >::isoDeposits_, pat::Tau::isolationPFChargedHadrCands(), pat::Tau::isolationPFGammaCands(), pat::Tau::isolationPFNeutrHadrCands(), pat::Lepton< LeptonType >::isolations_, dbtoconf::out, AlCaHLTBitMon_ParallelJobs::p, 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, and metsig::tau.

52  {
53  using namespace edm;
54  using namespace std;
55 
57  iEvent.getByToken(src_, src);
58 
60  if (linkToPackedPF_) iEvent.getByToken(pf2pc_, pf2pc);
61 
62  auto_ptr<vector<pat::Tau> > out(new vector<pat::Tau>());
63  out->reserve(src->size());
64 
65  for (View<pat::Tau>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
66  out->push_back(*it);
67  pat::Tau & tau = out->back();
68  // clearing the pat isolation which is not used by taus
69  tau.isolations_.clear();
70  tau.isoDeposits_.clear();
71 
72  if (linkToPackedPF_) {
73 
74  reco::CandidatePtrVector signalChHPtrs, signalNHPtrs, signalGammaPtrs, isolationChHPtrs, isolationNHPtrs, isolationGammaPtrs;
75 
76  for (const reco::PFCandidatePtr &p : tau.signalPFChargedHadrCands()) {
77  signalChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
78  }
79  tau.setSignalChargedHadrCands(signalChHPtrs);
80 
81  for (const reco::PFCandidatePtr &p : tau.signalPFNeutrHadrCands()) {
82  signalNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
83  }
84  tau.setSignalNeutralHadrCands(signalNHPtrs);
85 
86  for (const reco::PFCandidatePtr &p : tau.signalPFGammaCands()) {
87  signalGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
88  }
89  tau.setSignalGammaCands(signalGammaPtrs);
90 
92  isolationChHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
93  }
94  tau.setIsolationChargedHadrCands(isolationChHPtrs);
95 
96  for (const reco::PFCandidatePtr &p : tau.isolationPFNeutrHadrCands()) {
97  isolationNHPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
98  }
99  tau.setIsolationNeutralHadrCands(isolationNHPtrs);
100 
101  for (const reco::PFCandidatePtr &p : tau.isolationPFGammaCands()) {
102  isolationGammaPtrs.push_back(edm::refToPtr((*pf2pc)[p]));
103  }
104  tau.setIsolationGammaCands(isolationGammaPtrs);
105 
106  }
107  if(dropPiZeroRefs_){
108  tau.pfSpecific_[0].signalPiZeroCandidates_.clear();
109  tau.pfSpecific_[0].isolationPiZeroCandidates_.clear();
110  }
112  tau.pfSpecific_[0].signalTauChargedHadronCandidates_.clear();
113  tau.pfSpecific_[0].isolationTauChargedHadronCandidates_.clear();
114  }
115  if(dropPFSpecific_){ tau.pfSpecific_.clear();}
116 
117  }
118 
119  iEvent.put(out);
120 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
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:434
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:138
edm::EDGetTokenT< edm::View< pat::Tau > > src_
const std::vector< reco::PFCandidatePtr > & isolationPFChargedHadrCands() const
Definition: Tau.cc:586
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:116
void setIsolationNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:301
void setIsolationChargedHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:300
const std::vector< reco::PFCandidatePtr > & isolationPFNeutrHadrCands() const
Definition: Tau.cc:608
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
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Definition: Tau.cc:488
tuple out
Definition: dbtoconf.py:99
void setSignalGammaCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:299
const std::vector< reco::PFCandidatePtr > & isolationPFGammaCands() const
Definition: Tau.cc:630
std::vector< float > isolations_
Definition: Lepton.h:200
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Definition: Tau.cc:532
const std::vector< reco::PFCandidatePtr > & signalPFNeutrHadrCands() const
Definition: Tau.cc:510
std::vector< pat::tau::TauPFSpecific > pfSpecific_
holder for PFTau info, or empty vector if CaloTau
Definition: Tau.h:477
void setSignalNeutralHadrCands(const reco::CandidatePtrVector &ptrs)
Definition: Tau.h:298

Member Data Documentation

bool pat::PATTauSlimmer::dropPFSpecific_
private

Definition at line 32 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

bool pat::PATTauSlimmer::dropPiZeroRefs_
private

Definition at line 30 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

bool pat::PATTauSlimmer::dropTauChargedHadronRefs_
private

Definition at line 31 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

bool pat::PATTauSlimmer::linkToPackedPF_
private

Definition at line 28 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

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

Definition at line 29 of file PATTauSlimmer.cc.

Referenced by PATTauSlimmer().

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

Definition at line 27 of file PATTauSlimmer.cc.