CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATPhotonSlimmer Class Reference

slimmer of PAT Taus More...

Inheritance diagram for pat::PATPhotonSlimmer:
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
 
 PATPhotonSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~PATPhotonSlimmer ()
 
- 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
 
 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 StringCutObjectSelector< pat::PhotondropBasicClusters_
 
const StringCutObjectSelector< pat::PhotondropPreshowerClusters_
 
const StringCutObjectSelector< pat::PhotondropRecHits_
 
const StringCutObjectSelector< pat::PhotondropSaturation_
 
const StringCutObjectSelector< pat::PhotondropSeedCluster_
 
const StringCutObjectSelector< pat::PhotondropSuperClusters_
 
const bool linkToPackedPF_
 
const bool modifyPhoton_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionpc_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
 
std::unique_ptr< pat::ObjectModifier< pat::Photon > > photonModifier_
 
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
 
const edm::EDGetTokenT< EcalRecHitCollectionreducedBarrelRecHitCollectionToken_
 
const edm::EDGetTokenT< EcalRecHitCollectionreducedEndcapRecHitCollectionToken_
 
const StringCutObjectSelector< pat::PhotonsaveNonZSClusterShapes_
 
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
 

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 28 of file PATPhotonSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 53 of file PATPhotonSlimmer.cc.

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

53  :
55  dropSuperClusters_(iConfig.getParameter<std::string>("dropSuperCluster")),
56  dropBasicClusters_(iConfig.getParameter<std::string>("dropBasicClusters")),
57  dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
58  dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
59  dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
60  dropSaturation_(iConfig.getParameter<std::string>("dropSaturation")),
61  reco2pf_(mayConsume<edm::ValueMap<std::vector<reco::PFCandidateRef> > >(iConfig.getParameter<edm::InputTag>("recoToPFMap"))),
63  pc_(mayConsume<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
64  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
65  saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
66  reducedBarrelRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
67  reducedEndcapRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
68  modifyPhoton_(iConfig.getParameter<bool>("modifyPhotons"))
69 {
71  if( modifyPhoton_ ) {
72  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
73  photonModifier_.reset(new pat::ObjectModifier<pat::Photon>(mod_config) );
74  photonModifier_->setConsumes(sumes);
75  } else {
76  photonModifier_.reset(nullptr);
77  }
78 
79  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
80  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
81 
82  produces<std::vector<pat::Photon> >();
83 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
const StringCutObjectSelector< pat::Photon > dropSeedCluster_
const StringCutObjectSelector< pat::Photon > dropRecHits_
std::unique_ptr< pat::ObjectModifier< pat::Photon > > photonModifier_
const StringCutObjectSelector< pat::Photon > dropSaturation_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
const StringCutObjectSelector< pat::Photon > dropBasicClusters_
const StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
virtual pat::PATPhotonSlimmer::~PATPhotonSlimmer ( )
inlinevirtual

Definition at line 31 of file PATPhotonSlimmer.cc.

References beginLuminosityBlock(), iEvent, and produce().

31 { }

Member Function Documentation

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

Definition at line 86 of file PATPhotonSlimmer.cc.

Referenced by ~PATPhotonSlimmer().

86  {
87 }
void pat::PATPhotonSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 90 of file PATPhotonSlimmer.cc.

References pat::PATObject< ObjectType >::addUserFloat(), pat::Photon::basicClusters_, DEFINE_FWK_MODULE, dropBasicClusters_, dropPreshowerClusters_, dropRecHits_, dropSaturation_, dropSeedCluster_, dropSuperClusters_, EcalClusterLazyToolsT< EcalClusterToolsImpl >::e1x5(), EcalClusterLazyToolsT< EcalClusterToolsImpl >::e3x3(), EcalClusterLazyToolsT< EcalClusterToolsImpl >::e5x5(), pat::Photon::embeddedRecHits_, pat::Photon::embeddedSeedCluster_, pat::Photon::embeddedSuperCluster_, edm::Event::getByToken(), edm::HandleBase::id(), edm::isNotFinite(), crabWrapper::key, relativeConstraints::keys, linkToPackedPF_, EcalClusterLazyToolsT< EcalClusterToolsImpl >::localCovariances(), modifyPhoton_, eostools::move(), MillePedeFileConverter_cfg::out, pc_, packedPFCandidateRefMixer_cfi::pf, pf2pc_, muons2muons_cfi::photon, photonModifier_, pat::Photon::preshowerClusters_, edm::Event::put(), pat::Photon::recHits_, reco2pf_, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_, pat::PATObject< ObjectType >::refToOrig_, saveNonZSClusterShapes_, pat::Photon::seedCluster_, pat::Photon::setAssociatedPackedPFCandidates(), reco::Photon::setSaturationInfo(), pat::Photon::sourceCandidatePtr(), mathSSE::sqrt(), TrackRefitter_38T_cff::src, src_, pat::Photon::superCluster(), and pat::Photon::superCluster_.

Referenced by ~PATPhotonSlimmer().

90  {
91  using namespace edm;
92  using namespace std;
93 
95  iEvent.getByToken(src_, src);
96 
100  if (linkToPackedPF_) {
101  iEvent.getByToken(reco2pf_, reco2pf);
102  iEvent.getByToken(pf2pc_, pf2pc);
103  iEvent.getByToken(pc_, pc);
104  }
106 
107  auto out = std::make_unique<std::vector<pat::Photon>>();
108  out->reserve(src->size());
109 
110  if( modifyPhoton_ ) { photonModifier_->setEvent(iEvent); }
111  if( modifyPhoton_ ) photonModifier_->setEventContent(iSetup);
112 
113 
114  std::vector<unsigned int> keys;
115  for (View<pat::Photon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
116  out->push_back(*it);
117  pat::Photon & photon = out->back();
118 
119  if( modifyPhoton_ ) { photonModifier_->modify(photon); }
120 
121  if (dropSuperClusters_(photon)) { photon.superCluster_.clear(); photon.embeddedSuperCluster_ = false; }
122  if (dropBasicClusters_(photon)) { photon.basicClusters_.clear(); }
123  if (dropPreshowerClusters_(photon)) { photon.preshowerClusters_.clear(); }
124  if (dropSeedCluster_(photon)) { photon.seedCluster_.clear(); photon.embeddedSeedCluster_ = false; }
125  if (dropRecHits_(photon)) { photon.recHits_ = EcalRecHitCollection(); photon.embeddedRecHits_ = false; }
127 
128  if (linkToPackedPF_) {
129  //std::cout << " PAT photon in " << src.id() << " comes from " << photon.refToOrig_.id() << ", " << photon.refToOrig_.key() << std::endl;
130  keys.clear();
131  for(auto const& pf: (*reco2pf)[photon.refToOrig_]) {
132  if( pf2pc->contains(pf.id()) ) {
133  keys.push_back( (*pf2pc)[pf].key());
134  }
135  }
137  keys.begin(), keys.end());
138  //std::cout << "Photon with pt " << photon.pt() << " associated to " << photon.associatedPackedFCandidateIndices_.size() << " PF Candidates\n";
139  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
140  if (keys.size() == 1) {
141  photon.refToOrig_ = photon.sourceCandidatePtr(0);
142  } else {
143  photon.refToOrig_ = reco::CandidatePtr(pc.id());
144  }
145  }
146  if (saveNonZSClusterShapes_(photon)) {
147  std::vector<float> vCov = lazyToolsNoZS.localCovariances(*( photon.superCluster()->seed()));
148  float r9 = lazyToolsNoZS.e3x3( *( photon.superCluster()->seed())) / photon.superCluster()->rawEnergy() ;
149  float sigmaIetaIeta = ( !edm::isNotFinite(vCov[0]) ) ? sqrt(vCov[0]) : 0;
150  float sigmaIetaIphi = vCov[1];
151  float sigmaIphiIphi = ( !edm::isNotFinite(vCov[2]) ) ? sqrt(vCov[2]) : 0;
152  float e15o55 = lazyToolsNoZS.e1x5( *( photon.superCluster()->seed()) ) / lazyToolsNoZS.e5x5( *( photon.superCluster()->seed()) );
153  photon.addUserFloat("sigmaIetaIeta_NoZS", sigmaIetaIeta);
154  photon.addUserFloat("sigmaIetaIphi_NoZS", sigmaIetaIphi);
155  photon.addUserFloat("sigmaIphiIphi_NoZS", sigmaIphiIphi);
156  photon.addUserFloat("r9_NoZS", r9);
157  photon.addUserFloat("e1x5_over_e5x5_NoZS", e15o55);
158  }
159 
160  }
161 
162  iEvent.put(std::move(out));
163 }
Analysis-level Photon class.
Definition: Photon.h:47
reco::SuperClusterRef superCluster() const
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
void setAssociatedPackedPFCandidates(const edm::RefProd< pat::PackedCandidateCollection > &refprod, T beginIndexItr, T endIndexItr)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Photon.h:322
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:257
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:343
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:813
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:349
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:353
bool isNotFinite(T x)
Definition: isFinite.h:10
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the source candidate pointer with index i
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
T sqrt(T t)
Definition: SSEVec.h:18
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
bool embeddedSuperCluster_
Definition: Photon.h:342
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:357
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:355
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:351
const StringCutObjectSelector< pat::Photon > dropSeedCluster_
const StringCutObjectSelector< pat::Photon > dropRecHits_
std::unique_ptr< pat::ObjectModifier< pat::Photon > > photonModifier_
const StringCutObjectSelector< pat::Photon > dropSaturation_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:421
def move(src, dest)
Definition: eostools.py:510
const StringCutObjectSelector< pat::Photon > dropBasicClusters_
const StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:347
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_

Member Data Documentation

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

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::dropSaturation_
private

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 39 of file PATPhotonSlimmer.cc.

Referenced by produce().

const bool pat::PATPhotonSlimmer::linkToPackedPF_
private

Definition at line 44 of file PATPhotonSlimmer.cc.

Referenced by produce().

const bool pat::PATPhotonSlimmer::modifyPhoton_
private

Definition at line 47 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer(), and produce().

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

Definition at line 43 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 42 of file PATPhotonSlimmer.cc.

Referenced by produce().

std::unique_ptr<pat::ObjectModifier<pat::Photon> > pat::PATPhotonSlimmer::photonModifier_
private

Definition at line 48 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer(), and produce().

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

Definition at line 41 of file PATPhotonSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<EcalRecHitCollection> pat::PATPhotonSlimmer::reducedBarrelRecHitCollectionToken_
private

Definition at line 46 of file PATPhotonSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<EcalRecHitCollection> pat::PATPhotonSlimmer::reducedEndcapRecHitCollectionToken_
private

Definition at line 46 of file PATPhotonSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<pat::Photon> pat::PATPhotonSlimmer::saveNonZSClusterShapes_
private

Definition at line 45 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 37 of file PATPhotonSlimmer.cc.

Referenced by produce().