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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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

◆ PATPhotonSlimmer()

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

Definition at line 55 of file PATPhotonSlimmer.cc.

56  : src_(consumes<edm::View<pat::Photon>>(iConfig.getParameter<edm::InputTag>("src"))),
57  dropSuperClusters_(iConfig.getParameter<std::string>("dropSuperCluster")),
58  dropBasicClusters_(iConfig.getParameter<std::string>("dropBasicClusters")),
59  dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
60  dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
61  dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
62  dropSaturation_(iConfig.getParameter<std::string>("dropSaturation")),
63  dropRegressionData_(iConfig.getParameter<std::string>("dropRegressionData")),
64  reco2pf_(mayConsume<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
65  iConfig.getParameter<edm::InputTag>("recoToPFMap"))),
67  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
68  pc_(mayConsume<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
69  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
70  saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
72  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
74  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection"))),
75  modifyPhoton_(iConfig.getParameter<bool>("modifyPhotons")) {
76  if (modifyPhoton_) {
77  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
78  photonModifier_ = std::make_unique<pat::ObjectModifier<pat::Photon>>(mod_config, consumesCollector());
79  }
80 
81  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
82  mayConsume<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
83 
84  produces<std::vector<pat::Photon>>();
85 }

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

◆ ~PATPhotonSlimmer()

pat::PATPhotonSlimmer::~PATPhotonSlimmer ( )
inlineoverride

Definition at line 31 of file PATPhotonSlimmer.cc.

31 {}

Member Function Documentation

◆ beginLuminosityBlock()

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

Definition at line 87 of file PATPhotonSlimmer.cc.

87 {}

◆ produce()

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

Definition at line 89 of file PATPhotonSlimmer.cc.

89  {
90  using namespace edm;
91  using namespace std;
92 
94  iEvent.getByToken(src_, src);
95 
99  if (linkToPackedPF_) {
100  iEvent.getByToken(reco2pf_, reco2pf);
101  iEvent.getByToken(pf2pc_, pf2pc);
102  iEvent.getByToken(pc_, pc);
103  }
104  noZS::EcalClusterLazyTools lazyToolsNoZS(
106 
107  auto out = std::make_unique<std::vector<pat::Photon>>();
108  out->reserve(src->size());
109 
110  if (modifyPhoton_) {
111  photonModifier_->setEvent(iEvent);
112  }
113  if (modifyPhoton_)
114  photonModifier_->setEventContent(iSetup);
115 
116  std::vector<unsigned int> keys;
117  for (View<pat::Photon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
118  out->push_back(*it);
119  pat::Photon& photon = out->back();
120 
121  if (modifyPhoton_) {
122  photonModifier_->modify(photon);
123  }
124 
125  if (dropSuperClusters_(photon)) {
126  photon.superCluster_.clear();
127  photon.embeddedSuperCluster_ = false;
128  }
129  if (dropBasicClusters_(photon)) {
130  photon.basicClusters_.clear();
131  }
133  photon.preshowerClusters_.clear();
134  }
135  if (dropSeedCluster_(photon)) {
136  photon.seedCluster_.clear();
137  photon.embeddedSeedCluster_ = false;
138  }
139  if (dropRecHits_(photon)) {
140  photon.recHits_ = EcalRecHitCollection();
141  photon.embeddedRecHits_ = false;
142  }
143  if (dropSaturation_(photon)) {
144  photon.setSaturationInfo(reco::Photon::SaturationInfo());
145  }
147  photon.setEMax(0);
148  photon.setE2nd(0);
149  photon.setE3x3(0);
150  photon.setETop(0);
151  photon.setEBottom(0);
152  photon.setELeft(0);
153  photon.setERight(0);
154  photon.setSee(0);
155  photon.setSep(0);
156  photon.setSpp(0);
157  photon.setMaxDR(0);
158  photon.setMaxDRDPhi(0);
159  photon.setMaxDRDEta(0);
160  photon.setMaxDRRawEnergy(0);
161  photon.setSubClusRawE1(0);
162  photon.setSubClusRawE2(0);
163  photon.setSubClusRawE3(0);
164  photon.setSubClusDPhi1(0);
165  photon.setSubClusDPhi2(0);
166  photon.setSubClusDPhi3(0);
167  photon.setSubClusDEta1(0);
168  photon.setSubClusDEta2(0);
169  photon.setSubClusDEta3(0);
170  photon.setCryPhi(0);
171  photon.setCryEta(0);
172  photon.setIEta(0);
173  photon.setIPhi(0);
174  }
175 
176  if (linkToPackedPF_) {
177  //std::cout << " PAT photon in " << src.id() << " comes from " << photon.refToOrig_.id() << ", " << photon.refToOrig_.key() << std::endl;
178  keys.clear();
179  for (auto const& pf : (*reco2pf)[photon.refToOrig_]) {
180  if (pf2pc->contains(pf.id())) {
181  keys.push_back((*pf2pc)[pf].key());
182  }
183  }
184  photon.setAssociatedPackedPFCandidates(
186  //std::cout << "Photon with pt " << photon.pt() << " associated to " << photon.associatedPackedFCandidateIndices_.size() << " PF Candidates\n";
187  //if there's just one PF Cand then it's me, otherwise I have no univoque parent so my ref will be null
188  if (keys.size() == 1) {
189  photon.refToOrig_ = photon.sourceCandidatePtr(0);
190  } else {
191  photon.refToOrig_ = reco::CandidatePtr(pc.id());
192  }
193  }
195  std::vector<float> vCov = lazyToolsNoZS.localCovariances(*(photon.superCluster()->seed()));
196  float r9 = lazyToolsNoZS.e3x3(*(photon.superCluster()->seed())) / photon.superCluster()->rawEnergy();
197  float sigmaIetaIeta = (!edm::isNotFinite(vCov[0])) ? sqrt(vCov[0]) : 0;
198  float sigmaIetaIphi = vCov[1];
199  float sigmaIphiIphi = (!edm::isNotFinite(vCov[2])) ? sqrt(vCov[2]) : 0;
200  float e15o55 =
201  lazyToolsNoZS.e1x5(*(photon.superCluster()->seed())) / lazyToolsNoZS.e5x5(*(photon.superCluster()->seed()));
202  photon.addUserFloat("sigmaIetaIeta_NoZS", sigmaIetaIeta);
203  photon.addUserFloat("sigmaIetaIphi_NoZS", sigmaIetaIphi);
204  photon.addUserFloat("sigmaIphiIphi_NoZS", sigmaIphiIphi);
205  photon.addUserFloat("r9_NoZS", r9);
206  photon.addUserFloat("e1x5_over_e5x5_NoZS", e15o55);
207  }
208  }
209 
210  iEvent.put(std::move(out));
211 }

References EcalClusterLazyToolsT< ClusterTools >::e1x5(), EcalClusterLazyToolsT< ClusterTools >::e3x3(), EcalClusterLazyToolsT< ClusterTools >::e5x5(), edm::HandleBase::id(), iEvent, edm::isNotFinite(), crabWrapper::key, relativeConstraints::keys, EcalClusterLazyToolsT< ClusterTools >::localCovariances(), eostools::move(), MillePedeFileConverter_cfg::out, packedPFCandidateRefMixer_cfi::pf, muons2muons_cfi::photon, electrons_cff::r9, mathSSE::sqrt(), and TrackRefitter_38T_cff::src.

Member Data Documentation

◆ dropBasicClusters_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ dropPreshowerClusters_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ dropRecHits_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ dropRegressionData_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ dropSaturation_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ dropSeedCluster_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ dropSuperClusters_

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

Definition at line 39 of file PATPhotonSlimmer.cc.

◆ linkToPackedPF_

const bool pat::PATPhotonSlimmer::linkToPackedPF_
private

Definition at line 45 of file PATPhotonSlimmer.cc.

◆ modifyPhoton_

const bool pat::PATPhotonSlimmer::modifyPhoton_
private

Definition at line 49 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer().

◆ pc_

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

Definition at line 44 of file PATPhotonSlimmer.cc.

◆ pf2pc_

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

Definition at line 43 of file PATPhotonSlimmer.cc.

◆ photonModifier_

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

Definition at line 50 of file PATPhotonSlimmer.cc.

Referenced by PATPhotonSlimmer().

◆ reco2pf_

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

Definition at line 42 of file PATPhotonSlimmer.cc.

◆ reducedBarrelRecHitCollectionToken_

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

Definition at line 47 of file PATPhotonSlimmer.cc.

◆ reducedEndcapRecHitCollectionToken_

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

Definition at line 47 of file PATPhotonSlimmer.cc.

◆ saveNonZSClusterShapes_

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

Definition at line 46 of file PATPhotonSlimmer.cc.

◆ src_

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

Definition at line 37 of file PATPhotonSlimmer.cc.

edm::RefProd< pat::PackedCandidateCollection >
muons2muons_cfi.photon
photon
Definition: muons2muons_cfi.py:28
electrons_cff.r9
r9
Definition: electrons_cff.py:366
pat::PATPhotonSlimmer::reducedEndcapRecHitCollectionToken_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
Definition: PATPhotonSlimmer.cc:47
pat::PATPhotonSlimmer::dropPreshowerClusters_
const StringCutObjectSelector< pat::Photon > dropPreshowerClusters_
Definition: PATPhotonSlimmer.cc:39
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::Photon
Analysis-level Photon class.
Definition: Photon.h:46
pat::PATPhotonSlimmer::dropSuperClusters_
const StringCutObjectSelector< pat::Photon > dropSuperClusters_
Definition: PATPhotonSlimmer.cc:39
reco::Photon::SaturationInfo
Definition: Photon.h:258
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
pat::PATPhotonSlimmer::linkToPackedPF_
const bool linkToPackedPF_
Definition: PATPhotonSlimmer.cc:45
edm::Handle
Definition: AssociativeIterator.h:50
pat::PATPhotonSlimmer::modifyPhoton_
const bool modifyPhoton_
Definition: PATPhotonSlimmer.cc:49
pat::PATPhotonSlimmer::pf2pc_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
Definition: PATPhotonSlimmer.cc:43
pat::PATPhotonSlimmer::saveNonZSClusterShapes_
const StringCutObjectSelector< pat::Photon > saveNonZSClusterShapes_
Definition: PATPhotonSlimmer.cc:46
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalRecHitCollection
edm::SortedCollection< EcalRecHit > EcalRecHitCollection
Definition: EcalRecHitCollections.h:10
pat::PATPhotonSlimmer::dropRegressionData_
const StringCutObjectSelector< pat::Photon > dropRegressionData_
Definition: PATPhotonSlimmer.cc:39
pat::PATPhotonSlimmer::reco2pf_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
Definition: PATPhotonSlimmer.cc:42
edm::View
Definition: CaloClusterFwd.h:14
EcalClusterLazyToolsT
Definition: EcalClusterLazyTools.h:105
edm::ParameterSet
Definition: ParameterSet.h:36
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::PATPhotonSlimmer::src_
const edm::EDGetTokenT< edm::View< pat::Photon > > src_
Definition: PATPhotonSlimmer.cc:37
edm::Association
Definition: Association.h:18
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
edm::ValueMap
Definition: ValueMap.h:107
pat::PATPhotonSlimmer::dropSaturation_
const StringCutObjectSelector< pat::Photon > dropSaturation_
Definition: PATPhotonSlimmer.cc:39
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
pat::PATPhotonSlimmer::dropBasicClusters_
const StringCutObjectSelector< pat::Photon > dropBasicClusters_
Definition: PATPhotonSlimmer.cc:39
reco::CandidatePtr
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
pat::PATPhotonSlimmer::dropSeedCluster_
const StringCutObjectSelector< pat::Photon > dropSeedCluster_
Definition: PATPhotonSlimmer.cc:39
pat::PATPhotonSlimmer::pc_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
Definition: PATPhotonSlimmer.cc:44
crabWrapper.key
key
Definition: crabWrapper.py:19
pat::PATPhotonSlimmer::photonModifier_
std::unique_ptr< pat::ObjectModifier< pat::Photon > > photonModifier_
Definition: PATPhotonSlimmer.cc:50
edm::HandleBase::id
ProductID id() const
Definition: HandleBase.cc:13
edm::InputTag
Definition: InputTag.h:15
pat::PATPhotonSlimmer::dropRecHits_
const StringCutObjectSelector< pat::Photon > dropRecHits_
Definition: PATPhotonSlimmer.cc:39
pat::PATPhotonSlimmer::reducedBarrelRecHitCollectionToken_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
Definition: PATPhotonSlimmer.cc:47