CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PFClusterMatchedToPhotonsSelector Class Reference

#include <CommonTools/RecoAlgos/plugins/PFClusterMatchedToPhotonsSelector.cc>

Inheritance diagram for PFClusterMatchedToPhotonsSelector:
edm::stream::EDProducer<>

Public Member Functions

 PFClusterMatchedToPhotonsSelector (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociationassociationToken_
 
edm::EDGetTokenT< reco::GenParticleCollectiongenParticleToken_
 
double matchMaxDEDR2_
 
double matchMaxDR2_
 
edm::EDGetTokenT< reco::PFClusterCollectionparticleFlowClusterECALToken_
 
edm::EDGetTokenT< TrackingParticleCollectiontrackingParticleToken_
 
double volumeRadius_EB_
 
double volumeZ_EB_
 
double volumeZ_EE_
 

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

Description: Matches ECAL PF clusters to photons that do not convert

Implementation:

Definition at line 46 of file PFClusterMatchedToPhotonsSelector.cc.

Constructor & Destructor Documentation

PFClusterMatchedToPhotonsSelector::PFClusterMatchedToPhotonsSelector ( const edm::ParameterSet iConfig)

Definition at line 66 of file PFClusterMatchedToPhotonsSelector.cc.

References associationToken_, genParticleToken_, edm::ParameterSet::getParameter(), matchMaxDEDR2_, matchMaxDR2_, particleFlowClusterECALToken_, trackingParticleToken_, volumeRadius_EB_, volumeZ_EB_, and volumeZ_EE_.

66  {
67  //now do what ever initialization is needed
68  particleFlowClusterECALToken_ = consumes<reco::PFClusterCollection>(iConfig.getParameter<edm::InputTag>("pfClustersTag"));
69  associationToken_ = consumes<reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<edm::InputTag>("pfClustersTag"));
70  trackingParticleToken_ = consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("trackingParticleTag"));
71  genParticleToken_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticleTag"));
72 
73  matchMaxDR2_ = iConfig.getParameter<double>("maxDR2");
74  matchMaxDEDR2_ = iConfig.getParameter<double>("maxDEDR2");
75  volumeZ_EB_ = iConfig.getParameter<double>("volumeZ_EB");
76  volumeRadius_EB_ = iConfig.getParameter<double>("volumeRadius_EB");
77  volumeZ_EE_ = iConfig.getParameter<double>("volumeZ_EE");
78 
79  produces<reco::PFClusterCollection>();
80  produces<reco::PFCluster::EEtoPSAssociation>();
81  produces<edm::ValueMap<reco::GenParticleRef> >();
82 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
edm::EDGetTokenT< reco::PFClusterCollection > particleFlowClusterECALToken_
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > associationToken_

Member Function Documentation

void PFClusterMatchedToPhotonsSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 85 of file PFClusterMatchedToPhotonsSelector.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

85  {
87  desc.add<edm::InputTag>("pfClustersTag", edm::InputTag("particleFlowClusterECAL"));
88  desc.add<edm::InputTag>("trackingParticleTag", edm::InputTag("mix", "MergedTrackTruth"));
89  desc.add<edm::InputTag>("genParticleTag", edm::InputTag("genParticles"));
90  desc.add<double>("maxDR2", 0.1*0.1);
91  desc.add<double>("maxDEDR2", 0.5*0.5);
92  desc.add<double>("volumeZ_EB", 304.5);
93  desc.add<double>("volumeRadius_EB", 123.8);
94  desc.add<double>("volumeZ_EE", 317.0);
95  descriptions.add("pfClusterMatchedToPhotonsSelector", desc);
96 
97 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PFClusterMatchedToPhotonsSelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 99 of file PFClusterMatchedToPhotonsSelector.cc.

References funct::abs(), associationToken_, DEFINE_FWK_MODULE, reco::deltaR2(), edm::helper::Filler< Map >::fill(), genParticleToken_, edm::Event::getByToken(), mps_fire::i, edm::helper::Filler< Map >::insert(), trackerHitRTTI::isMatched(), matchMaxDEDR2_, matchMaxDR2_, eostools::move(), MillePedeFileConverter_cfg::out, particleFlowClusterECALToken_, edm::Handle< T >::product(), edm::Event::put(), jetUpdater_cfi::sort, sortByKey(), trackingParticleToken_, volumeRadius_EB_, volumeZ_EB_, and volumeZ_EE_.

99  {
100 
101  edm::Handle<reco::PFClusterCollection> particleFlowClusterECALHandle_;
103  edm::Handle<TrackingParticleCollection> trackingParticleHandle_;
104  edm::Handle<reco::GenParticleCollection> genParticleHandle_;
105  iEvent.getByToken(particleFlowClusterECALToken_, particleFlowClusterECALHandle_);
106  iEvent.getByToken(trackingParticleToken_, trackingParticleHandle_);
107  iEvent.getByToken(genParticleToken_, genParticleHandle_);
108  iEvent.getByToken(associationToken_, associationHandle_);
109 
110  std::unique_ptr<reco::PFClusterCollection> out = std::make_unique<reco::PFClusterCollection>();
111  std::unique_ptr<reco::PFCluster::EEtoPSAssociation> association_out = std::make_unique<reco::PFCluster::EEtoPSAssociation>();
112  std::unique_ptr<edm::ValueMap<reco::GenParticleRef> > genmatching_out = std::make_unique<edm::ValueMap<reco::GenParticleRef> >();
113 
114  std::vector<reco::GenParticleRef> genmatching;
115 
116  size_t iN(0);
117  for (size_t iP = 0; iP < particleFlowClusterECALHandle_->size(); iP++) {
118 
119  auto&& pfCluster = particleFlowClusterECALHandle_->at(iP);
120  bool isMatched = false;
122 
123  // Preselect PFclusters
124  if (pfCluster.energy() <= 0) {
125  continue;
126  }
127 
128  for (auto&& trackingParticle : *trackingParticleHandle_) {
129  if (trackingParticle.pdgId() != 22) continue;
130  if (trackingParticle.status() != 1) continue;
131  matchedKey = trackingParticle.genParticles().at(0).key();
132  float dR2 = reco::deltaR2(trackingParticle, pfCluster.position());
133  if (dR2 > matchMaxDR2_) continue;
134  float dE = 1. - trackingParticle.genParticles().at(0)->energy()/pfCluster.energy();
135  if ((dR2 + dE*dE) > matchMaxDEDR2_) continue;
136 
137  bool isConversion = false;
138  for (auto&& vertRef : trackingParticle.decayVertices()) {
139  if (vertRef->position().rho() > volumeRadius_EB_ && std::abs(vertRef->position().z()) < volumeZ_EB_) continue;
140  if (std::abs(vertRef->position().z()) > volumeZ_EE_) continue;
141 
142  for(auto&& tpRef: vertRef->daughterTracks()) {
143  if(std::abs(tpRef->pdgId()) == 11) isConversion = true;
144  break;
145  }
146  if (isConversion) break;
147  }
148  if (isConversion) continue;
149 
150  isMatched = true;
151  break;
152  }
153 
154  if (isMatched) {
155  out->push_back(pfCluster);
156  for (size_t i=0; i<associationHandle_.product()->size(); i++) {
157  if (associationHandle_.product()->at(i).first == iP) {
158  association_out->push_back(std::make_pair(iN, associationHandle_.product()->at(i).second));
159  }
160  }
161  genmatching.push_back(edm::Ref<reco::GenParticleCollection>(genParticleHandle_,matchedKey));
162  }
163  }
164 
165  std::sort(association_out->begin(),association_out->end(),sortByKey);
166  edm::OrphanHandle<reco::PFClusterCollection> pfClusterHandle= iEvent.put(std::move(out));
167  iEvent.put(std::move(association_out));
168 
169  edm::ValueMap<reco::GenParticleRef>::Filler mapFiller(*genmatching_out);
170  mapFiller.insert(pfClusterHandle, genmatching.begin(), genmatching.end());
171  mapFiller.fill();
172  iEvent.put(std::move(genmatching_out));
173 }
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:167
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
bool isMatched(TrackingRecHit const &hit)
edm::EDGetTokenT< reco::PFClusterCollection > particleFlowClusterECALToken_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T const * product() const
Definition: Handle.h:74
bool sortByKey(const EEPSPair &a, const EEPSPair &b)
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > associationToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<reco::PFCluster::EEtoPSAssociation> PFClusterMatchedToPhotonsSelector::associationToken_
private
edm::EDGetTokenT<reco::GenParticleCollection> PFClusterMatchedToPhotonsSelector::genParticleToken_
private
double PFClusterMatchedToPhotonsSelector::matchMaxDEDR2_
private
double PFClusterMatchedToPhotonsSelector::matchMaxDR2_
private
edm::EDGetTokenT<reco::PFClusterCollection> PFClusterMatchedToPhotonsSelector::particleFlowClusterECALToken_
private
edm::EDGetTokenT<TrackingParticleCollection> PFClusterMatchedToPhotonsSelector::trackingParticleToken_
private
double PFClusterMatchedToPhotonsSelector::volumeRadius_EB_
private
double PFClusterMatchedToPhotonsSelector::volumeZ_EB_
private
double PFClusterMatchedToPhotonsSelector::volumeZ_EE_
private