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::PATPhotonSlimmer Class Reference

slimmer of PAT Taus More...

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

Public Member Functions

 PATPhotonSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PATPhotonSlimmer ()
 
- 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

StringCutObjectSelector
< pat::Photon
dropBasicClusters_
 
StringCutObjectSelector
< pat::Photon
dropPreshowerClusters_
 
StringCutObjectSelector
< pat::Photon
dropRecHits_
 
StringCutObjectSelector
< pat::Photon
dropSeedCluster_
 
StringCutObjectSelector
< pat::Photon
dropSuperClusters_
 
bool linkToPackedPF_
 
edm::EDGetTokenT
< pat::PackedCandidateCollection
pc_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
edm::EDGetTokenT
< edm::ValueMap< std::vector
< reco::PFCandidateRef > > > 
reco2pf_
 
edm::EDGetTokenT< edm::View
< pat::Photon > > 
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 24 of file PATPhotonSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 44 of file PATPhotonSlimmer.cc.

References edm::ParameterSet::getParameter(), linkToPackedPF_, pc_, pf2pc_, and reco2pf_.

44  :
46  dropSuperClusters_(iConfig.getParameter<std::string>("dropSuperCluster")),
47  dropBasicClusters_(iConfig.getParameter<std::string>("dropBasicClusters")),
48  dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
49  dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
50  dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
51  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates"))
52 {
53  produces<std::vector<pat::Photon> >();
54  if (linkToPackedPF_) {
55  reco2pf_ = consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("recoToPFMap"));
56  pf2pc_ = consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
57  pc_ = consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
58  }
59 }
T getParameter(std::string const &) const
StringCutObjectSelector< pat::Photon > dropSeedCluster_
StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
edm::EDGetTokenT< edm::View< pat::Photon > > src_
StringCutObjectSelector< pat::Photon > dropSuperClusters_
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
StringCutObjectSelector< pat::Photon > dropRecHits_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
StringCutObjectSelector< pat::Photon > dropBasicClusters_
virtual pat::PATPhotonSlimmer::~PATPhotonSlimmer ( )
inlinevirtual

Definition at line 27 of file PATPhotonSlimmer.cc.

27 { }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 62 of file PATPhotonSlimmer.cc.

References pat::Photon::basicClusters_, pat::Photon::embeddedRecHits_, pat::Photon::embeddedSeedCluster_, pat::Photon::embeddedSuperCluster_, edm::Event::getByToken(), dbtoconf::out, pat::Photon::preshowerClusters_, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), pat::Photon::recHits_, pat::PATObject< ObjectType >::refToOrig_, edm::refToPtr(), pat::Photon::seedCluster_, pat::Photon::setAssociatedPackedPFCandidates(), pat::Photon::setPackedPFCandidateCollection(), edm::RefVector< C, T, F >::size(), alcazmumu_cfi::src, and pat::Photon::superCluster_.

62  {
63  using namespace edm;
64  using namespace std;
65 
67  iEvent.getByToken(src_, src);
68 
72  if (linkToPackedPF_) {
73  iEvent.getByToken(reco2pf_, reco2pf);
74  iEvent.getByToken(pf2pc_, pf2pc);
75  iEvent.getByToken(pc_, pc);
76  }
77 
78  auto_ptr<vector<pat::Photon> > out(new vector<pat::Photon>());
79  out->reserve(src->size());
80 
81  for (View<pat::Photon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
82  out->push_back(*it);
83  pat::Photon & photon = out->back();
84 
85  if (dropSuperClusters_(photon)) { photon.superCluster_.clear(); photon.embeddedSuperCluster_ = false; }
86  if (dropBasicClusters_(photon)) { photon.basicClusters_.clear(); }
87  if (dropPreshowerClusters_(photon)) { photon.preshowerClusters_.clear(); }
88  if (dropSeedCluster_(photon)) { photon.seedCluster_.clear(); photon.embeddedSeedCluster_ = false; }
89  if (dropRecHits_(photon)) { photon.recHits_ = EcalRecHitCollection(); photon.embeddedRecHits_ = false; }
90 
91  if (linkToPackedPF_) {
93  //std::cout << " PAT photon in " << src.id() << " comes from " << photon.refToOrig_.id() << ", " << photon.refToOrig_.key() << std::endl;
95  for (const reco::PFCandidateRef & pf : (*reco2pf)[photon.refToOrig_]) {
96  if (pf2pc->contains(pf.id())) {
97  origs.push_back((*pf2pc)[pf]);
98  } //else std::cerr << " Photon linked to a PFCand in " << pf.id() << " while we expect them in " << pf2pc->ids().front().first << "\n";
99  }
100  //std::cout << "Photon with pt " << photon.pt() << " associated to " << origs.size() << " PF Candidates\n";
101  photon.setAssociatedPackedPFCandidates(origs);
102  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
103  if (origs.size() == 1) {
104  photon.refToOrig_ = refToPtr(origs[0]);
105  } else {
106  photon.refToOrig_ = reco::CandidatePtr(pc.id());
107  }
108  }
109  }
110 
111  iEvent.put(out);
112 }
void setAssociatedPackedPFCandidates(const edm::RefVector< pat::PackedCandidateCollection > &refvector)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Photon.cc:198
StringCutObjectSelector< pat::Photon > dropSeedCluster_
Analysis-level Photon class.
Definition: Photon.h:47
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
StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
edm::EDGetTokenT< edm::View< pat::Photon > > src_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
StringCutObjectSelector< pat::Photon > dropSuperClusters_
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:245
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:251
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:255
StringCutObjectSelector< pat::Photon > dropRecHits_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool embeddedSuperCluster_
Definition: Photon.h:244
tuple out
Definition: dbtoconf.py:99
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:259
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:257
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:253
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
void setPackedPFCandidateCollection(const edm::RefProd< pat::PackedCandidateCollection > &refprod)
References to PFCandidates (e.g. to recompute isolation)
Definition: Photon.cc:185
StringCutObjectSelector< pat::Photon > dropBasicClusters_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:407
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:249
edm::SortedCollection< EcalRecHit > EcalRecHitCollection

Member Data Documentation

StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::dropBasicClusters_
private

Definition at line 34 of file PATPhotonSlimmer.cc.

StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::dropPreshowerClusters_
private

Definition at line 34 of file PATPhotonSlimmer.cc.

StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::dropRecHits_
private

Definition at line 34 of file PATPhotonSlimmer.cc.

StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::dropSeedCluster_
private

Definition at line 34 of file PATPhotonSlimmer.cc.

StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::dropSuperClusters_
private

Definition at line 34 of file PATPhotonSlimmer.cc.

bool pat::PATPhotonSlimmer::linkToPackedPF_
private

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer().

edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PATPhotonSlimmer::pc_
private

Definition at line 38 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer().

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

Definition at line 37 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer().

edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef> > > pat::PATPhotonSlimmer::reco2pf_
private

Definition at line 36 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer().

edm::EDGetTokenT<edm::View<pat::Photon> > pat::PATPhotonSlimmer::src_
private

Definition at line 32 of file PATPhotonSlimmer.cc.