CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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::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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

const StringCutObjectSelector
< pat::Photon
dropBasicClusters_
 
const StringCutObjectSelector
< pat::Photon
dropPreshowerClusters_
 
const StringCutObjectSelector
< pat::Photon
dropRecHits_
 
const StringCutObjectSelector
< pat::Photon
dropRegressionData_
 
const StringCutObjectSelector
< pat::Photon
dropSaturation_
 
const StringCutObjectSelector
< pat::Photon
dropSeedCluster_
 
const StringCutObjectSelector
< pat::Photon
dropSuperClusters_
 
const
EcalClusterLazyTools::ESGetTokens 
ecalClusterToolsESGetTokens_
 
const bool linkToPackedPF_
 
const bool modifyPhoton_
 
const edm::EDGetTokenT
< pat::PackedCandidateCollection
pc_
 
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
< EcalRecHitCollection
reducedBarrelRecHitCollectionToken_
 
const edm::EDGetTokenT
< EcalRecHitCollection
reducedEndcapRecHitCollectionToken_
 
const StringCutObjectSelector
< pat::Photon
saveNonZSClusterShapes_
 
const edm::EDGetTokenT
< edm::View< pat::Photon > > 
src_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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 56 of file PATPhotonSlimmer.cc.

57  : src_(consumes<edm::View<pat::Photon>>(iConfig.getParameter<edm::InputTag>("src"))),
58  dropSuperClusters_(iConfig.getParameter<std::string>("dropSuperCluster")),
59  dropBasicClusters_(iConfig.getParameter<std::string>("dropBasicClusters")),
60  dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
61  dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
62  dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
63  dropSaturation_(iConfig.getParameter<std::string>("dropSaturation")),
64  dropRegressionData_(iConfig.getParameter<std::string>("dropRegressionData")),
65  reco2pf_(mayConsume<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
66  iConfig.getParameter<edm::InputTag>("recoToPFMap"))),
68  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
69  pc_(mayConsume<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
70  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
71  saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
73  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
75  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
76  modifyPhoton_(iConfig.getParameter<bool>("modifyPhotons")),
77  ecalClusterToolsESGetTokens_{consumesCollector()} {
78  if (modifyPhoton_) {
79  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
80  photonModifier_ = std::make_unique<pat::ObjectModifier<pat::Photon>>(mod_config, consumesCollector());
81  }
82 
83  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
84  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
85 
86  produces<std::vector<pat::Photon>>();
87 }
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
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_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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.

31 {}

Member Function Documentation

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

Definition at line 89 of file PATPhotonSlimmer.cc.

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

Definition at line 91 of file PATPhotonSlimmer.cc.

References pat::PATObject< ObjectType >::addUserFloat(), pat::Photon::basicClusters_, dropBasicClusters_, dropPreshowerClusters_, dropRecHits_, dropRegressionData_, dropSaturation_, dropSeedCluster_, dropSuperClusters_, ecalClusterToolsESGetTokens_, pat::Photon::embeddedRecHits_, pat::Photon::embeddedSeedCluster_, pat::Photon::embeddedSuperCluster_, EcalClusterLazyToolsBase::ESGetTokens::get(), edm::Event::getByToken(), edm::isNotFinite(), submitPVResolutionJobs::key, relativeConstraints::keys, linkToPackedPF_, modifyPhoton_, eostools::move(), submitPVResolutionJobs::out, pc_, pf2pc_, photonModifier_, pat::Photon::preshowerClusters_, edm::Event::put(), 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(), alcazmumu_cfi::src, src_, pat::Photon::superCluster(), and pat::Photon::superCluster_.

91  {
92  using namespace edm;
93  using namespace std;
94 
96  iEvent.getByToken(src_, src);
97 
101  if (linkToPackedPF_) {
102  iEvent.getByToken(reco2pf_, reco2pf);
103  iEvent.getByToken(pf2pc_, pf2pc);
104  iEvent.getByToken(pc_, pc);
105  }
106  noZS::EcalClusterLazyTools lazyToolsNoZS(iEvent,
110 
111  auto out = std::make_unique<std::vector<pat::Photon>>();
112  out->reserve(src->size());
113 
114  if (modifyPhoton_) {
115  photonModifier_->setEvent(iEvent);
116  }
117  if (modifyPhoton_)
118  photonModifier_->setEventContent(iSetup);
119 
120  std::vector<unsigned int> keys;
121  for (View<pat::Photon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
122  out->push_back(*it);
123  pat::Photon& photon = out->back();
124 
125  if (modifyPhoton_) {
126  photonModifier_->modify(photon);
127  }
128 
129  if (dropSuperClusters_(photon)) {
130  photon.superCluster_.clear();
131  photon.embeddedSuperCluster_ = false;
132  }
133  if (dropBasicClusters_(photon)) {
134  photon.basicClusters_.clear();
135  }
136  if (dropPreshowerClusters_(photon)) {
137  photon.preshowerClusters_.clear();
138  }
139  if (dropSeedCluster_(photon)) {
140  photon.seedCluster_.clear();
141  photon.embeddedSeedCluster_ = false;
142  }
143  if (dropRecHits_(photon)) {
144  photon.recHits_ = EcalRecHitCollection();
145  photon.embeddedRecHits_ = false;
146  }
147  if (dropSaturation_(photon)) {
149  }
150  if (dropRegressionData_(photon)) {
151  photon.setEMax(0);
152  photon.setE2nd(0);
153  photon.setE3x3(0);
154  photon.setETop(0);
155  photon.setEBottom(0);
156  photon.setELeft(0);
157  photon.setERight(0);
158  photon.setSee(0);
159  photon.setSep(0);
160  photon.setSpp(0);
161  photon.setMaxDR(0);
162  photon.setMaxDRDPhi(0);
163  photon.setMaxDRDEta(0);
164  photon.setMaxDRRawEnergy(0);
165  photon.setSubClusRawE1(0);
166  photon.setSubClusRawE2(0);
167  photon.setSubClusRawE3(0);
168  photon.setSubClusDPhi1(0);
169  photon.setSubClusDPhi2(0);
170  photon.setSubClusDPhi3(0);
171  photon.setSubClusDEta1(0);
172  photon.setSubClusDEta2(0);
173  photon.setSubClusDEta3(0);
174  photon.setCryPhi(0);
175  photon.setCryEta(0);
176  photon.setIEta(0);
177  photon.setIPhi(0);
178  }
179 
180  if (linkToPackedPF_) {
181  //std::cout << " PAT photon in " << src.id() << " comes from " << photon.refToOrig_.id() << ", " << photon.refToOrig_.key() << std::endl;
182  keys.clear();
183  for (auto const& pf : (*reco2pf)[photon.refToOrig_]) {
184  if (pf2pc->contains(pf.id())) {
185  keys.push_back((*pf2pc)[pf].key());
186  }
187  }
190  //std::cout << "Photon with pt " << photon.pt() << " associated to " << photon.associatedPackedFCandidateIndices_.size() << " PF Candidates\n";
191  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
192  if (keys.size() == 1) {
193  photon.refToOrig_ = photon.sourceCandidatePtr(0);
194  } else {
195  photon.refToOrig_ = reco::CandidatePtr(pc.id());
196  }
197  }
198  if (saveNonZSClusterShapes_(photon)) {
199  const auto& vCov = lazyToolsNoZS.localCovariances(*(photon.superCluster()->seed()));
200  float r9 = lazyToolsNoZS.e3x3(*(photon.superCluster()->seed())) / photon.superCluster()->rawEnergy();
201  float sigmaIetaIeta = (!edm::isNotFinite(vCov[0])) ? sqrt(vCov[0]) : 0;
202  float sigmaIetaIphi = vCov[1];
203  float sigmaIphiIphi = (!edm::isNotFinite(vCov[2])) ? sqrt(vCov[2]) : 0;
204  float e15o55 =
205  lazyToolsNoZS.e1x5(*(photon.superCluster()->seed())) / lazyToolsNoZS.e5x5(*(photon.superCluster()->seed()));
206  photon.addUserFloat("sigmaIetaIeta_NoZS", sigmaIetaIeta);
207  photon.addUserFloat("sigmaIetaIphi_NoZS", sigmaIetaIphi);
208  photon.addUserFloat("sigmaIphiIphi_NoZS", sigmaIphiIphi);
209  photon.addUserFloat("r9_NoZS", r9);
210  photon.addUserFloat("e1x5_over_e5x5_NoZS", e15o55);
211  }
212  }
213 
214  iEvent.put(std::move(out));
215 }
void setSpp(float s)
Definition: Photon.h:266
Analysis-level Photon class.
Definition: Photon.h:46
void setIEta(float i)
Definition: Photon.h:308
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
void setSubClusDPhi3(float s)
Definition: Photon.h:291
void setE2nd(float e)
Definition: Photon.h:251
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void setSee(float s)
Definition: Photon.h:264
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void setMaxDRRawEnergy(float m)
Definition: Photon.h:277
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:317
void setSubClusDPhi2(float s)
Definition: Photon.h:289
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:312
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:335
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:892
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:341
void setIPhi(float i)
Definition: Photon.h:306
reco::CandidatePtr sourceCandidatePtr(size_type i) const override
get the source candidate pointer with index i
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:345
void setELeft(float e)
Definition: Photon.h:259
void setEMax(float e)
Definition: Photon.h:249
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
void setERight(float e)
Definition: Photon.h:261
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
void setMaxDRDEta(float m)
Definition: Photon.h:275
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
tuple key
prepare the HTCondor submission files and eventually submit them
void setETop(float e)
Definition: Photon.h:255
void setSubClusDPhi1(float s)
Definition: Photon.h:287
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
void setSubClusDEta1(float s)
Definition: Photon.h:294
bool embeddedSuperCluster_
Definition: Photon.h:334
void setCryEta(float c)
Definition: Photon.h:303
const StringCutObjectSelector< pat::Photon > dropRegressionData_
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:349
ESData get(edm::EventSetup const &eventSetup) const
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:347
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:301
void setSubClusDEta2(float s)
Definition: Photon.h:296
void setMaxDR(float m)
Definition: Photon.h:271
void setSubClusRawE2(float s)
Definition: Photon.h:282
reco::SuperClusterRef superCluster() const override
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
void setEBottom(float e)
Definition: Photon.h:257
void setMaxDRDPhi(float m)
Definition: Photon.h:273
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void setSubClusDEta3(float s)
Definition: Photon.h:298
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:343
void setSubClusRawE1(float s)
Definition: Photon.h:280
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:284
const StringCutObjectSelector< pat::Photon > dropSaturation_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:458
const StringCutObjectSelector< pat::Photon > dropBasicClusters_
void setE3x3(float e)
Definition: Photon.h:253
const StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:339
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
void setSep(float s)
Definition: Photon.h:268
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 EcalClusterLazyTools::ESGetTokens pat::PATPhotonSlimmer::ecalClusterToolsESGetTokens_
private

Definition at line 51 of file PATPhotonSlimmer.cc.

Referenced by produce().

const bool pat::PATPhotonSlimmer::linkToPackedPF_
private

Definition at line 45 of file PATPhotonSlimmer.cc.

Referenced by produce().

const bool pat::PATPhotonSlimmer::modifyPhoton_
private

Definition at line 49 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 44 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 43 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 50 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 42 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 47 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 47 of file PATPhotonSlimmer.cc.

Referenced by produce().

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

Definition at line 46 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().