CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::PATPhotonProducer Class Reference

Produces the pat::Photon. More...

#include "PhysicsTools/PatAlgos/interface/PATPhotonProducer.h"

Inheritance diagram for pat::PATPhotonProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATPhotonProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATPhotonProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::vector
< edm::Handle< edm::ValueMap
< IsoDeposit > > > 
IsoDepositMaps
 
typedef std::pair
< pat::IsolationKeys,
edm::InputTag
IsolationLabel
 
typedef std::vector
< IsolationLabel
IsolationLabels
 
typedef std::vector
< edm::Handle< edm::ValueMap
< double > > > 
IsolationValueMaps
 
typedef std::pair< std::string,
edm::InputTag
NameTag
 

Private Member Functions

template<typename T >
void readIsolationLabels (const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
 

Private Attributes

bool addEfficiencies_
 
bool addGenMatch_
 
bool addPhotonID_
 
bool addResolutions_
 
const CaloTopologyecalTopology_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
bool embedBasicClusters_
 
bool embedGenMatch_
 
bool embedPreshowerClusters_
 
bool embedRecHits_
 
bool embedSeedCluster_
 
bool embedSuperCluster_
 
GreaterByEt< PhotoneTComparator_
 
std::vector< edm::EDGetTokenT
< edm::Association
< reco::GenParticleCollection > > > 
genMatchTokens_
 
IsolationLabels isoDepositLabels_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< IsoDeposit > > > 
isoDepositTokens_
 
IsolationLabels isolationValueLabels_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< double > > > 
isolationValueTokens_
 
pat::helper::MultiIsolator isolator_
 
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
 
std::vector< NameTagphotIDSrcs_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< Bool_t > > > 
photIDTokens_
 
edm::EDGetTokenT< edm::View
< reco::Photon > > 
photonToken_
 
edm::InputTag reducedBarrelRecHitCollection_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedBarrelRecHitCollectionToken_
 
edm::InputTag reducedEndcapRecHitCollection_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedEndcapRecHitCollectionToken_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
pat::PATUserDataHelper
< pat::Photon
userDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

Produces the pat::Photon.

The PATPhotonProducer produces the analysis-level pat::Photon starting from a collection of objects of PhotonType.

Author
Steven Lowette
Version
Id:
PATPhotonProducer.h,v 1.19 2009/06/25 23:49:35 gpetrucc Exp

Definition at line 40 of file PATPhotonProducer.h.

Member Typedef Documentation

Definition at line 73 of file PATPhotonProducer.h.

Definition at line 75 of file PATPhotonProducer.h.

Definition at line 76 of file PATPhotonProducer.h.

typedef std::vector< edm::Handle< edm::ValueMap<double> > > pat::PATPhotonProducer::IsolationValueMaps
private

Definition at line 74 of file PATPhotonProducer.h.

typedef std::pair<std::string, edm::InputTag> pat::PATPhotonProducer::NameTag
private

Definition at line 100 of file PATPhotonProducer.h.

Constructor & Destructor Documentation

PATPhotonProducer::PATPhotonProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 23 of file PATPhotonProducer.cc.

References addGenMatch_, edm::EDConsumerBase::consumes(), embedBasicClusters_, embedGenMatch_, embedPreshowerClusters_, embedRecHits_, embedSeedCluster_, embedSuperCluster_, edm::ParameterSet::existsAs(), genMatchTokens_, edm::ParameterSet::getParameter(), photonToken_, reducedBarrelRecHitCollection_, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollection_, reducedEndcapRecHitCollectionToken_, GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

23  :
24  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false) ,
25  useUserData_(iConfig.exists("userData"))
26 {
27  // initialize the configurables
28  photonToken_ = consumes<edm::View<reco::Photon> >(iConfig.getParameter<edm::InputTag>("photonSource"));
29  embedSuperCluster_ = iConfig.getParameter<bool>("embedSuperCluster");
30  embedSeedCluster_ = iConfig.getParameter<bool>( "embedSeedCluster" );
31  embedBasicClusters_ = iConfig.getParameter<bool>( "embedBasicClusters" );
32  embedPreshowerClusters_ = iConfig.getParameter<bool>( "embedPreshowerClusters" );
33  embedRecHits_ = iConfig.getParameter<bool>( "embedRecHits" );
34  reducedBarrelRecHitCollection_ = iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection");
35  reducedBarrelRecHitCollectionToken_ = mayConsume<EcalRecHitCollection>(reducedBarrelRecHitCollection_);
36  reducedEndcapRecHitCollection_ = iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection");
37  reducedEndcapRecHitCollectionToken_ = mayConsume<EcalRecHitCollection>(reducedEndcapRecHitCollection_);
38  // MC matching configurables
39  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
40  if (addGenMatch_) {
41  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
42  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
44  }
45  else {
46  genMatchTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" ), [this](edm::InputTag const & tag){return consumes<edm::Association<reco::GenParticleCollection> >(tag);});
47  }
48  }
49  // Efficiency configurables
50  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
51  if (addEfficiencies_) {
53  }
54  // photon ID configurables
55  addPhotonID_ = iConfig.getParameter<bool>( "addPhotonID" );
56  if (addPhotonID_) {
57  // it might be a single photon ID
58  if (iConfig.existsAs<edm::InputTag>("photonIDSource")) {
59  photIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("photonIDSource")));
60  }
61  // or there might be many of them
62  if (iConfig.existsAs<edm::ParameterSet>("photonIDSources")) {
63  // please don't configure me twice
64  if (!photIDSrcs_.empty()){
65  throw cms::Exception("Configuration") << "PATPhotonProducer: you can't specify both 'photonIDSource' and 'photonIDSources'\n";
66  }
67  // read the different photon ID names
68  edm::ParameterSet idps = iConfig.getParameter<edm::ParameterSet>("photonIDSources");
69  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
70  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
71  photIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
72  }
73  }
74  // but in any case at least once
75  if (photIDSrcs_.empty()) throw cms::Exception("Configuration") <<
76  "PATPhotonProducer: id addPhotonID is true, you must specify either:\n" <<
77  "\tInputTag photonIDSource = <someTag>\n" << "or\n" <<
78  "\tPSet photonIDSources = { \n" <<
79  "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
80  "\t}\n";
81  }
82  photIDTokens_ = edm::vector_transform(photIDSrcs_, [this](NameTag const & tag){return mayConsume<edm::ValueMap<Bool_t> >(tag.second);});
83  // Resolution configurables
84  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
85  if (addResolutions_) {
87  }
88  // Check to see if the user wants to add user data
89  if ( useUserData_ ) {
91  }
92  // produces vector of photons
93  produces<std::vector<Photon> >();
94 
95  // read isoDeposit labels, for direct embedding
97  // read isolation value labels, for direct embedding
99 
100 }
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
pat::PATUserDataHelper< pat::Photon > userDataHelper_
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
static const HistoName names[]
std::pair< std::string, edm::InputTag > NameTag
std::vector< edm::EDGetTokenT< edm::ValueMap< Bool_t > > > photIDTokens_
edm::EDGetTokenT< edm::View< reco::Photon > > photonToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
pat::helper::KinResolutionsLoader resolutionLoader_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
edm::InputTag reducedEndcapRecHitCollection_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:192
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
IsolationLabels isoDepositLabels_
IsolationLabels isolationValueLabels_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
pat::helper::EfficiencyLoader efficiencyLoader_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< NameTag > photIDSrcs_
pat::helper::MultiIsolator isolator_
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
edm::InputTag reducedBarrelRecHitCollection_
PATPhotonProducer::~PATPhotonProducer ( )

Definition at line 102 of file PATPhotonProducer.cc.

102  {
103 }

Member Function Documentation

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

Definition at line 281 of file PATPhotonProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), edm::ParameterSetDescription::setComment(), and edm::ParameterDescriptionNode::setComment().

282 {
284  iDesc.setComment("PAT photon producer module");
285 
286  // input source
287  iDesc.add<edm::InputTag>("photonSource", edm::InputTag("no default"))->setComment("input collection");
288 
289  iDesc.add<edm::InputTag>("reducedBarrelRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
290  iDesc.add<edm::InputTag>("reducedEndcapRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
291 
292  iDesc.add<bool>("embedSuperCluster", true)->setComment("embed external super cluster");
293  iDesc.add<bool>("embedSeedCluster", true)->setComment("embed external seed cluster");
294  iDesc.add<bool>("embedBasicClusters", true)->setComment("embed external basic clusters");
295  iDesc.add<bool>("embedPreshowerClusters", true)->setComment("embed external preshower clusters");
296  iDesc.add<bool>("embedRecHits", true)->setComment("embed external RecHits");
297 
298  // MC matching configurables
299  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
300  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
301  std::vector<edm::InputTag> emptySourceVector;
302  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
303  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
304  )->setComment("input with MC match information");
305 
307 
308  // photon ID configurables
309  iDesc.add<bool>("addPhotonID",true)->setComment("add photon ID variables");
310  edm::ParameterSetDescription photonIDSourcesPSet;
311  photonIDSourcesPSet.setAllowAnything();
312  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("photonIDSource", edm::InputTag(), true) xor
313  edm::ParameterDescription<edm::ParameterSetDescription>("photonIDSources", photonIDSourcesPSet, true)
314  )->setComment("input with photon ID variables");
315 
316  // IsoDeposit configurables
317  edm::ParameterSetDescription isoDepositsPSet;
318  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
319  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
320  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
321  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
322  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
323  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
324  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
325  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
326  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
327  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
328  iDesc.addOptional("isoDeposits", isoDepositsPSet);
329 
330  // isolation values configurables
331  edm::ParameterSetDescription isolationValuesPSet;
332  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
333  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
334  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
335  isolationValuesPSet.addOptional<edm::InputTag>("pfAllParticles");
336  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
337  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
338  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
339  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
340  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
341  isolationValuesPSet.addOptional<std::vector<edm::InputTag> >("user");
342  iDesc.addOptional("isolationValues", isolationValuesPSet);
343 
344  // Efficiency configurables
345  edm::ParameterSetDescription efficienciesPSet;
346  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
347  iDesc.add("efficiencies", efficienciesPSet);
348  iDesc.add<bool>("addEfficiencies", false);
349 
350  // Check to see if the user wants to add user data
351  edm::ParameterSetDescription userDataPSet;
353  iDesc.addOptional("userData", userDataPSet);
354 
355  edm::ParameterSetDescription isolationPSet;
356  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
357  iDesc.add("userIsolation", isolationPSet);
358 
359  descriptions.add("PATPhotonProducer", iDesc);
360 
361 }
void setComment(std::string const &value)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATPhotonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 105 of file PATPhotonProducer.cc.

References addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), addPhotonID_, Reference_intrackfit_cff::barrel, pat::helper::MultiIsolator::beginEvent(), DetId::Ecal, EcalBarrel, EcalEndcap, ecalTopology_, efficiencyLoader_, pat::Photon::embedBasicClusters(), embedBasicClusters_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::Photon::embedPreshowerClusters(), embedPreshowerClusters_, pat::Photon::embedRecHits(), embedRecHits_, pat::Photon::embedSeedCluster(), embedSeedCluster_, pat::Photon::embedSuperCluster(), embedSuperCluster_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), pat::helper::MultiIsolator::enabled(), edm::SortedCollection< T, SORT >::end(), pat::helper::MultiIsolator::endEvent(), eTComparator_, pat::helper::MultiIsolator::fill(), edm::SortedCollection< T, SORT >::find(), first, genMatchTokens_, edm::EventSetup::get(), edm::Event::getByToken(), EcalClusterLazyTools::getMaximum(), CaloTopology::getSubdetectorTopology(), CaloSubdetectorTopology::getWindow(), i, customizeTrackingMonitorSeedNumber::idx, isoDepositLabels_, isoDepositTokens_, isolationValueLabels_, isolationValueTokens_, isolator_, isolatorTmpStorage_, edm::EventBase::isRealData(), j, n, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), photIDSrcs_, photIDTokens_, interactiveExample::photons, photonToken_, edm::SortedCollection< T, SORT >::push_back(), edm::Event::put(), reducedBarrelRecHitCollection_, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollection_, reducedEndcapRecHitCollectionToken_, resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::Photon::setIsoDeposit(), pat::Photon::setIsolation(), pat::Photon::setPhotonIDs(), pat::helper::KinResolutionsLoader::setResolutions(), edm::SortedCollection< T, SORT >::size(), edm::SortedCollection< T, SORT >::sort(), python.multivaluedict::sort(), AlCaHLTBitMon_QueryRunRegistry::string, userDataHelper_, and useUserData_.

106 {
107  // switch off embedding (in unschedules mode)
108  if (iEvent.isRealData()){
109  addGenMatch_ = false;
110  embedGenMatch_ = false;
111  }
112 
113  edm::ESHandle<CaloTopology> theCaloTopology;
114  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
115  ecalTopology_ = & (*theCaloTopology);
116 
117  // Get the vector of Photon's from the event
119  iEvent.getByToken(photonToken_, photons);
120 
121  edm::InputTag reducedEBRecHitCollection(std::string("reducedEcalRecHitsEB"));
122  edm::InputTag reducedEERecHitCollection(std::string("reducedEcalRecHitsEE"));
124 
125  // prepare the MC matching
126  std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(genMatchTokens_.size());
127  if (addGenMatch_) {
128  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
129  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
130  }
131  }
132 
133  if (isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
134 
136  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
137 
138  IsoDepositMaps deposits(isoDepositTokens_.size());
139  for (size_t j = 0, nd = isoDepositTokens_.size(); j < nd; ++j) {
140  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
141  }
142 
143  IsolationValueMaps isolationValues(isolationValueTokens_.size());
144  for (size_t j = 0; j<isolationValueTokens_.size(); ++j) {
145  iEvent.getByToken(isolationValueTokens_[j], isolationValues[j]);
146  }
147 
148 
149  // prepare ID extraction
150  std::vector<edm::Handle<edm::ValueMap<Bool_t> > > idhandles;
151  std::vector<pat::Photon::IdPair> ids;
152  if (addPhotonID_) {
153  idhandles.resize(photIDSrcs_.size());
154  ids.resize(photIDSrcs_.size());
155  for (size_t i = 0; i < photIDSrcs_.size(); ++i) {
156  iEvent.getByToken(photIDTokens_[i], idhandles[i]);
157  ids[i].first = photIDSrcs_[i].first;
158  }
159  }
160 
161  // loop over photons
162  std::vector<Photon> * PATPhotons = new std::vector<Photon>();
163  for (edm::View<reco::Photon>::const_iterator itPhoton = photons->begin(); itPhoton != photons->end(); itPhoton++) {
164  // construct the Photon from the ref -> save ref to original object
165  unsigned int idx = itPhoton - photons->begin();
166  edm::RefToBase<reco::Photon> photonRef = photons->refAt(idx);
167  edm::Ptr<reco::Photon> photonPtr = photons->ptrAt(idx);
168  Photon aPhoton(photonRef);
169  if (embedSuperCluster_) aPhoton.embedSuperCluster();
170  if (embedSeedCluster_) aPhoton.embedSeedCluster();
171  if (embedBasicClusters_) aPhoton.embedBasicClusters();
172  if (embedPreshowerClusters_) aPhoton.embedPreshowerClusters();
173 
174  std::vector<DetId> selectedCells;
175  bool barrel = itPhoton->isEB();
176  //loop over sub clusters
177  if (embedBasicClusters_) {
178  for (reco::CaloCluster_iterator clusIt = itPhoton->superCluster()->clustersBegin(); clusIt!=itPhoton->superCluster()->clustersEnd(); ++clusIt) {
179  //get seed (max energy xtal)
180  DetId seed = lazyTools.getMaximum(**clusIt).first;
181  //get all xtals in 5x5 window around the seed
182  std::vector<DetId> dets5x5 = (barrel) ? ecalTopology_->getSubdetectorTopology(DetId::Ecal,EcalBarrel)->getWindow(seed,5,5):
184  selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
185 
186  //get all xtals belonging to cluster
187  for (const std::pair<DetId, float> &hit : (*clusIt)->hitsAndFractions()) {
188  selectedCells.push_back(hit.first);
189  }
190  }
191  }
192 
193  //remove duplicates
194  std::sort(selectedCells.begin(),selectedCells.end());
195  std::unique(selectedCells.begin(),selectedCells.end());
196 
197  // Retrieve the corresponding RecHits
198 
200  if(barrel)
202  else
204 
205  EcalRecHitCollection selectedRecHits;
206  const EcalRecHitCollection *recHits = rechitsH.product();
207 
208  unsigned nSelectedCells = selectedCells.size();
209  for (unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
210  EcalRecHitCollection::const_iterator it = recHits->find( selectedCells[icell] );
211  if ( it != recHits->end() ) {
212  selectedRecHits.push_back(*it);
213  }
214  }
215  selectedRecHits.sort();
216  if (embedRecHits_) aPhoton.embedRecHits(& selectedRecHits);
217 
218  // store the match to the generated final state muons
219  if (addGenMatch_) {
220  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
221  reco::GenParticleRef genPhoton = (*genMatches[i])[photonRef];
222  aPhoton.addGenParticleRef(genPhoton);
223  }
224  if (embedGenMatch_) aPhoton.embedGenParticle();
225  }
226 
227  if (efficiencyLoader_.enabled()) {
228  efficiencyLoader_.setEfficiencies( aPhoton, photonRef );
229  }
230 
231  if (resolutionLoader_.enabled()) {
233  }
234 
235  // here comes the extra functionality
236  if (isolator_.enabled()) {
237  isolator_.fill(*photons, idx, isolatorTmpStorage_);
238  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
239  // better to loop backwards, so the vector is resized less times
240  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
241  aPhoton.setIsolation(it->first, it->second);
242  }
243  }
244 
245  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
246  aPhoton.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[photonRef]);
247  }
248 
249  for (size_t j = 0; j<isolationValues.size(); ++j) {
250  aPhoton.setIsolation(isolationValueLabels_[j].first,(*isolationValues[j])[photonRef]);
251  }
252 
253  // add photon ID info
254  if (addPhotonID_) {
255  for (size_t i = 0; i < photIDSrcs_.size(); ++i) {
256  ids[i].second = (*idhandles[i])[photonRef];
257  }
258  aPhoton.setPhotonIDs(ids);
259  }
260 
261  if ( useUserData_ ) {
262  userDataHelper_.add( aPhoton, iEvent, iSetup );
263  }
264 
265 
266  // add the Photon to the vector of Photons
267  PATPhotons->push_back(aPhoton);
268  }
269 
270  // sort Photons in ET
271  std::sort(PATPhotons->begin(), PATPhotons->end(), eTComparator_);
272 
273  // put genEvt object in Event
274  std::auto_ptr<std::vector<Photon> > myPhotons(PATPhotons);
275  iEvent.put(myPhotons);
277 
278 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
Analysis-level Photon class.
Definition: Photon.h:47
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
pat::PATUserDataHelper< pat::Photon > userDataHelper_
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
std::vector< edm::EDGetTokenT< edm::ValueMap< Bool_t > > > photIDTokens_
edm::EDGetTokenT< edm::View< reco::Photon > > photonToken_
std::vector< EcalRecHit >::const_iterator const_iterator
void push_back(T const &t)
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
pat::helper::KinResolutionsLoader resolutionLoader_
GreaterByEt< Photon > eTComparator_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
bool isRealData() const
Definition: EventBase.h:60
edm::InputTag reducedEndcapRecHitCollection_
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
IsolationLabels isoDepositLabels_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
const CaloTopology * ecalTopology_
IsolationLabels isolationValueLabels_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
pat::helper::EfficiencyLoader efficiencyLoader_
int j
Definition: DBlmapReader.cc:9
std::vector< NameTag > photIDSrcs_
bool first
Definition: L1TdeRCT.cc:79
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
pat::helper::MultiIsolator isolator_
const_iterator end() const
Definition: DetId.h:18
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & get() const
Definition: EventSetup.h:55
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
iterator find(key_type k)
size_type size() const
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
edm::InputTag reducedBarrelRecHitCollection_
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
template<typename T >
void PATPhotonProducer::readIsolationLabels ( const edm::ParameterSet iConfig,
const char *  psetName,
IsolationLabels labels,
std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &  tokens 
)
private

fill the labels vector from the contents of the parameter set, for the isodeposit or isolation values embedding

Definition at line 118 of file PATPhotonProducer.h.

References pat::EcalIso, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), pat::HcalIso, combine::key, diffTwoXMLs::label, pat::PfAllParticleIso, pat::PfChargedAllIso, pat::PfChargedHadronIso, pat::PfGammaIso, pat::PfNeutralHadronIso, pat::PfPUChargedHadronIso, pat::TrackIso, pat::UserBaseIso, and edm::vector_transform().

121  {
122 
123  labels.clear();
124 
125  if (iConfig.exists( psetName )) {
126  edm::ParameterSet depconf
127  = iConfig.getParameter<edm::ParameterSet>(psetName);
128 
129  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
130  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
131  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
132  if (depconf.exists("pfAllParticles")) {
133  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
134  }
135  if (depconf.exists("pfChargedHadrons")) {
136  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
137  }
138  if (depconf.exists("pfChargedAll")) {
139  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
140  }
141  if (depconf.exists("pfPUChargedHadrons")) {
142  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
143  }
144  if (depconf.exists("pfNeutralHadrons")) {
145  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
146  }
147  if (depconf.exists("pfPhotons")) {
148  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
149  }
150  if (depconf.exists("user")) {
151  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
152  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
153  int key = UserBaseIso;
154  for ( ; it != ed; ++it, ++key) {
155  labels.push_back(std::make_pair(IsolationKeys(key), *it));
156  }
157  }
158  }
159 
160  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
161 
162 }
T getParameter(std::string const &) const
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
bool exists(std::string const &parameterName) const
checks if a parameter exists
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
list key
Definition: combine.py:13

Member Data Documentation

bool pat::PATPhotonProducer::addEfficiencies_
private

Definition at line 93 of file PATPhotonProducer.h.

bool pat::PATPhotonProducer::addGenMatch_
private

Definition at line 66 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

bool pat::PATPhotonProducer::addPhotonID_
private

Definition at line 99 of file PATPhotonProducer.h.

Referenced by produce().

bool pat::PATPhotonProducer::addResolutions_
private

Definition at line 96 of file PATPhotonProducer.h.

const CaloTopology* pat::PATPhotonProducer::ecalTopology_
private

Definition at line 107 of file PATPhotonProducer.h.

Referenced by produce().

pat::helper::EfficiencyLoader pat::PATPhotonProducer::efficiencyLoader_
private

Definition at line 94 of file PATPhotonProducer.h.

Referenced by produce().

bool pat::PATPhotonProducer::embedBasicClusters_
private

Definition at line 57 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

bool pat::PATPhotonProducer::embedGenMatch_
private

Definition at line 67 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

bool pat::PATPhotonProducer::embedPreshowerClusters_
private

Definition at line 58 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

bool pat::PATPhotonProducer::embedRecHits_
private

Definition at line 59 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

bool pat::PATPhotonProducer::embedSeedCluster_
private

Definition at line 56 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

bool pat::PATPhotonProducer::embedSuperCluster_
private

Definition at line 55 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

GreaterByEt<Photon> pat::PATPhotonProducer::eTComparator_
private

Definition at line 71 of file PATPhotonProducer.h.

Referenced by produce().

std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > pat::PATPhotonProducer::genMatchTokens_
private

Definition at line 68 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

IsolationLabels pat::PATPhotonProducer::isoDepositLabels_
private

Definition at line 83 of file PATPhotonProducer.h.

Referenced by produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > pat::PATPhotonProducer::isoDepositTokens_
private

Definition at line 80 of file PATPhotonProducer.h.

Referenced by produce().

IsolationLabels pat::PATPhotonProducer::isolationValueLabels_
private

Definition at line 84 of file PATPhotonProducer.h.

Referenced by produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > pat::PATPhotonProducer::isolationValueTokens_
private

Definition at line 81 of file PATPhotonProducer.h.

Referenced by produce().

pat::helper::MultiIsolator pat::PATPhotonProducer::isolator_
private

Definition at line 78 of file PATPhotonProducer.h.

Referenced by produce().

pat::helper::MultiIsolator::IsolationValuePairs pat::PATPhotonProducer::isolatorTmpStorage_
private

Definition at line 79 of file PATPhotonProducer.h.

Referenced by produce().

std::vector<NameTag> pat::PATPhotonProducer::photIDSrcs_
private

Definition at line 101 of file PATPhotonProducer.h.

Referenced by produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<Bool_t> > > pat::PATPhotonProducer::photIDTokens_
private

Definition at line 102 of file PATPhotonProducer.h.

Referenced by produce().

edm::EDGetTokenT<edm::View<reco::Photon> > pat::PATPhotonProducer::photonToken_
private

Definition at line 54 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

edm::InputTag pat::PATPhotonProducer::reducedBarrelRecHitCollection_
private

Definition at line 61 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

edm::EDGetTokenT<EcalRecHitCollection> pat::PATPhotonProducer::reducedBarrelRecHitCollectionToken_
private

Definition at line 62 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

edm::InputTag pat::PATPhotonProducer::reducedEndcapRecHitCollection_
private

Definition at line 63 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

edm::EDGetTokenT<EcalRecHitCollection> pat::PATPhotonProducer::reducedEndcapRecHitCollectionToken_
private

Definition at line 64 of file PATPhotonProducer.h.

Referenced by PATPhotonProducer(), and produce().

pat::helper::KinResolutionsLoader pat::PATPhotonProducer::resolutionLoader_
private

Definition at line 97 of file PATPhotonProducer.h.

Referenced by produce().

pat::PATUserDataHelper<pat::Photon> pat::PATPhotonProducer::userDataHelper_
private

Definition at line 105 of file PATPhotonProducer.h.

Referenced by produce().

bool pat::PATPhotonProducer::useUserData_
private

Definition at line 104 of file PATPhotonProducer.h.

Referenced by produce().