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

Public Member Functions

void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) final
 
 PATPhotonSlimmer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATPhotonSlimmer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

const StringCutObjectSelector< pat::PhotondropBasicClusters_
 
const StringCutObjectSelector< pat::PhotondropPreshowerClusters_
 
const StringCutObjectSelector< pat::PhotondropRecHits_
 
const StringCutObjectSelector< pat::PhotondropRegressionData_
 
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
 

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::ParameterSet::getParameter(), modifyPhoton_, and photonModifier_.

53  :
54  src_(consumes<edm::View<pat::Photon> >(iConfig.getParameter<edm::InputTag>("src"))),
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  dropRegressionData_(iConfig.getParameter<std::string>("dropRegressionData")),
62  reco2pf_(mayConsume<edm::ValueMap<std::vector<reco::PFCandidateRef> > >(iConfig.getParameter<edm::InputTag>("recoToPFMap"))),
63  pf2pc_(mayConsume<edm::Association<pat::PackedCandidateCollection>>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
64  pc_(mayConsume<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
65  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
66  saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
67  reducedBarrelRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
68  reducedEndcapRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
69  modifyPhoton_(iConfig.getParameter<bool>("modifyPhotons"))
70 {
71  if( modifyPhoton_ ) {
72  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
73  photonModifier_ = std::make_unique<pat::ObjectModifier<pat::Photon>>(mod_config, consumesCollector());
74  }
75 
76  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
77  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
78 
79  produces<std::vector<pat::Photon> >();
80 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
const StringCutObjectSelector< pat::Photon > dropRegressionData_
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_
const StringCutObjectSelector< pat::Photon > dropBasicClusters_
const StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
pat::PATPhotonSlimmer::~PATPhotonSlimmer ( )
inlineoverride

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

Definition at line 83 of file PATPhotonSlimmer.cc.

Referenced by ~PATPhotonSlimmer().

83  {
84 }
void pat::PATPhotonSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 87 of file PATPhotonSlimmer.cc.

References pat::PATObject< ObjectType >::addUserFloat(), pat::Photon::basicClusters_, DEFINE_FWK_MODULE, dropBasicClusters_, dropPreshowerClusters_, dropRecHits_, dropRegressionData_, dropSaturation_, dropSeedCluster_, dropSuperClusters_, EcalClusterLazyToolsT< ClusterTools >::e1x5(), EcalClusterLazyToolsT< ClusterTools >::e3x3(), EcalClusterLazyToolsT< ClusterTools >::e5x5(), pat::Photon::embeddedRecHits_, pat::Photon::embeddedSeedCluster_, pat::Photon::embeddedSuperCluster_, edm::Event::getByToken(), edm::HandleBase::id(), edm::isNotFinite(), crabWrapper::key, relativeConstraints::keys, linkToPackedPF_, EcalClusterLazyToolsT< ClusterTools >::localCovariances(), modifyPhoton_, eostools::move(), MillePedeFileConverter_cfg::out, pc_, packedPFCandidateRefMixer_cfi::pf, pf2pc_, muons2muons_cfi::photon, photonModifier_, pat::Photon::preshowerClusters_, edm::Event::put(), electrons_cff::r9, pat::Photon::recHits_, reco2pf_, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_, pat::PATObject< ObjectType >::refToOrig_, saveNonZSClusterShapes_, pat::Photon::seedCluster_, pat::Photon::setAssociatedPackedPFCandidates(), pat::Photon::setCryEta(), pat::Photon::setCryPhi(), pat::Photon::setE2nd(), pat::Photon::setE3x3(), pat::Photon::setEBottom(), pat::Photon::setELeft(), pat::Photon::setEMax(), pat::Photon::setERight(), pat::Photon::setETop(), pat::Photon::setIEta(), pat::Photon::setIPhi(), pat::Photon::setMaxDR(), pat::Photon::setMaxDRDEta(), pat::Photon::setMaxDRDPhi(), pat::Photon::setMaxDRRawEnergy(), reco::Photon::setSaturationInfo(), pat::Photon::setSee(), pat::Photon::setSep(), pat::Photon::setSpp(), pat::Photon::setSubClusDEta1(), pat::Photon::setSubClusDEta2(), pat::Photon::setSubClusDEta3(), pat::Photon::setSubClusDPhi1(), pat::Photon::setSubClusDPhi2(), pat::Photon::setSubClusDPhi3(), pat::Photon::setSubClusRawE1(), pat::Photon::setSubClusRawE2(), pat::Photon::setSubClusRawE3(), pat::Photon::sourceCandidatePtr(), mathSSE::sqrt(), TrackRefitter_38T_cff::src, src_, pat::Photon::superCluster(), and pat::Photon::superCluster_.

Referenced by ~PATPhotonSlimmer().

87  {
88  using namespace edm;
89  using namespace std;
90 
92  iEvent.getByToken(src_, src);
93 
97  if (linkToPackedPF_) {
98  iEvent.getByToken(reco2pf_, reco2pf);
99  iEvent.getByToken(pf2pc_, pf2pc);
100  iEvent.getByToken(pc_, pc);
101  }
103 
104  auto out = std::make_unique<std::vector<pat::Photon>>();
105  out->reserve(src->size());
106 
107  if( modifyPhoton_ ) { photonModifier_->setEvent(iEvent); }
108  if( modifyPhoton_ ) photonModifier_->setEventContent(iSetup);
109 
110 
111  std::vector<unsigned int> keys;
112  for (View<pat::Photon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
113  out->push_back(*it);
114  pat::Photon & photon = out->back();
115 
116  if( modifyPhoton_ ) { photonModifier_->modify(photon); }
117 
118  if (dropSuperClusters_(photon)) { photon.superCluster_.clear(); photon.embeddedSuperCluster_ = false; }
119  if (dropBasicClusters_(photon)) { photon.basicClusters_.clear(); }
120  if (dropPreshowerClusters_(photon)) { photon.preshowerClusters_.clear(); }
121  if (dropSeedCluster_(photon)) { photon.seedCluster_.clear(); photon.embeddedSeedCluster_ = false; }
122  if (dropRecHits_(photon)) { photon.recHits_ = EcalRecHitCollection(); photon.embeddedRecHits_ = false; }
124  if (dropRegressionData_(photon)) {
125  photon.setEMax(0); photon.setE2nd(0); photon.setE3x3(0);
126  photon.setETop(0); photon.setEBottom(0); photon.setELeft(0); photon.setERight(0);
127  photon.setSee(0); photon.setSep(0); photon.setSpp(0);
128  photon.setMaxDR(0); photon.setMaxDRDPhi(0); photon.setMaxDRDEta(0); photon.setMaxDRRawEnergy(0);
129  photon.setSubClusRawE1(0); photon.setSubClusRawE2(0); photon.setSubClusRawE3(0);
130  photon.setSubClusDPhi1(0); photon.setSubClusDPhi2(0); photon.setSubClusDPhi3(0);
131  photon.setSubClusDEta1(0); photon.setSubClusDEta2(0); photon.setSubClusDEta3(0);
132  photon.setCryPhi(0); photon.setCryEta(0); photon.setIEta(0); photon.setIPhi(0);
133  }
134 
135  if (linkToPackedPF_) {
136  //std::cout << " PAT photon in " << src.id() << " comes from " << photon.refToOrig_.id() << ", " << photon.refToOrig_.key() << std::endl;
137  keys.clear();
138  for(auto const& pf: (*reco2pf)[photon.refToOrig_]) {
139  if( pf2pc->contains(pf.id()) ) {
140  keys.push_back( (*pf2pc)[pf].key());
141  }
142  }
144  keys.begin(), keys.end());
145  //std::cout << "Photon with pt " << photon.pt() << " associated to " << photon.associatedPackedFCandidateIndices_.size() << " PF Candidates\n";
146  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
147  if (keys.size() == 1) {
148  photon.refToOrig_ = photon.sourceCandidatePtr(0);
149  } else {
150  photon.refToOrig_ = reco::CandidatePtr(pc.id());
151  }
152  }
153  if (saveNonZSClusterShapes_(photon)) {
154  std::vector<float> vCov = lazyToolsNoZS.localCovariances(*( photon.superCluster()->seed()));
155  float r9 = lazyToolsNoZS.e3x3( *( photon.superCluster()->seed())) / photon.superCluster()->rawEnergy() ;
156  float sigmaIetaIeta = ( !edm::isNotFinite(vCov[0]) ) ? sqrt(vCov[0]) : 0;
157  float sigmaIetaIphi = vCov[1];
158  float sigmaIphiIphi = ( !edm::isNotFinite(vCov[2]) ) ? sqrt(vCov[2]) : 0;
159  float e15o55 = lazyToolsNoZS.e1x5( *( photon.superCluster()->seed()) ) / lazyToolsNoZS.e5x5( *( photon.superCluster()->seed()) );
160  photon.addUserFloat("sigmaIetaIeta_NoZS", sigmaIetaIeta);
161  photon.addUserFloat("sigmaIetaIphi_NoZS", sigmaIetaIphi);
162  photon.addUserFloat("sigmaIphiIphi_NoZS", sigmaIphiIphi);
163  photon.addUserFloat("r9_NoZS", r9);
164  photon.addUserFloat("e1x5_over_e5x5_NoZS", e15o55);
165  }
166 
167  }
168 
169  iEvent.put(std::move(out));
170 }
void setSpp(float s)
Definition: Photon.h:265
Analysis-level Photon class.
Definition: Photon.h:47
void setIEta(float i)
Definition: Photon.h:307
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
void setSubClusDPhi3(float s)
Definition: Photon.h:290
ProductID id() const
Definition: HandleBase.cc:15
void setE2nd(float e)
Definition: Photon.h:250
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void setSee(float s)
Definition: Photon.h:263
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void setMaxDRRawEnergy(float m)
Definition: Photon.h:276
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:316
void setSubClusDPhi2(float s)
Definition: Photon.h:288
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:269
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:337
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:343
void setIPhi(float i)
Definition: Photon.h:305
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
reco::SuperClusterRef superCluster() const override
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:347
void setELeft(float e)
Definition: Photon.h:258
void setEMax(float e)
Definition: Photon.h:248
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
void setERight(float e)
Definition: Photon.h:260
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
void setMaxDRDEta(float m)
Definition: Photon.h:274
T sqrt(T t)
Definition: SSEVec.h:18
void setETop(float e)
Definition: Photon.h:254
void setSubClusDPhi1(float s)
Definition: Photon.h:286
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
void setSubClusDEta1(float s)
Definition: Photon.h:293
bool embeddedSuperCluster_
Definition: Photon.h:336
void setCryEta(float c)
Definition: Photon.h:302
const StringCutObjectSelector< pat::Photon > dropRegressionData_
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:351
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:349
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
void setCryPhi(float c)
Definition: Photon.h:300
void setSubClusDEta2(float s)
Definition: Photon.h:295
void setMaxDR(float m)
Definition: Photon.h:270
void setSubClusRawE2(float s)
Definition: Photon.h:281
void setEBottom(float e)
Definition: Photon.h:256
void setMaxDRDPhi(float m)
Definition: Photon.h:272
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void setSubClusDEta3(float s)
Definition: Photon.h:297
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:345
void setSubClusRawE1(float s)
Definition: Photon.h:279
const StringCutObjectSelector< pat::Photon > dropSeedCluster_
const StringCutObjectSelector< pat::Photon > dropRecHits_
std::unique_ptr< pat::ObjectModifier< pat::Photon > > photonModifier_
void setSubClusRawE3(float s)
Definition: Photon.h:283
reco::CandidatePtr sourceCandidatePtr(size_type i) const override
get the source candidate pointer with index i
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:511
const StringCutObjectSelector< pat::Photon > dropBasicClusters_
void setE3x3(float e)
Definition: Photon.h:252
const StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:341
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
void setSep(float s)
Definition: Photon.h:267
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::dropRegressionData_
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().