CMS 3D CMS Logo

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

#include <EgammaIsoESDetIdCollectionProducer.h>

Inheritance diagram for EgammaIsoESDetIdCollectionProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &, const edm::EventSetup &) overridefinal
 
 EgammaIsoESDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void addDetIds (const reco::SuperCluster &superClus, reco::PFClusterCollection clusters, const reco::PFCluster::EEtoPSAssociation &eeClusToESMap, std::vector< DetId > &detIdsToStore)
 

Private Attributes

edm::EDGetTokenT
< reco::PFClusterCollection
ecalPFClustersToken_
 
edm::EDGetTokenT
< reco::PFCluster::EEtoPSAssociation
eeClusToESMapToken_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
elesToken_
 
std::string interestingDetIdCollection_
 
float maxDR_
 
float minEleEt_
 
float minPhoEt_
 
float minSCEt_
 
edm::EDGetTokenT
< reco::PhotonCollection
phosToken_
 
edm::EDGetTokenT
< reco::SuperClusterCollection
superClustersToken_
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

author: Sam Harper (inspired by InterestingDetIdProducer)

Make a collection of detids to be kept in a AOD rechit collection These are all the ES DetIds of ES PFClusters associated to all PF clusters within dR of ele/pho/sc The aim is to save enough preshower info in the AOD to remake the PF clusters near an ele/pho/sc

Definition at line 42 of file EgammaIsoESDetIdCollectionProducer.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 10 of file EgammaIsoESDetIdCollectionProducer.cc.

References ecalPFClustersToken_, eeClusToESMapToken_, elesToken_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, maxDR_, minEleEt_, minPhoEt_, minSCEt_, phosToken_, AlCaHLTBitMon_QueryRunRegistry::string, and superClustersToken_.

11 {
12 
14  consumes<reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter< edm::InputTag > ("eeClusToESMapLabel"));
15 
17  consumes<reco::PFClusterCollection>(iConfig.getParameter<edm::InputTag>("ecalPFClustersLabel"));
18  elesToken_ =
19  consumes<reco::GsfElectronCollection>(iConfig.getParameter< edm::InputTag >("elesLabel"));
20 
21  phosToken_ =
22  consumes<reco::PhotonCollection>(iConfig.getParameter< edm::InputTag >("phosLabel"));
23 
25  consumes<reco::SuperClusterCollection>(iConfig.getParameter< edm::InputTag >("superClustersLabel"));
26 
27  minSCEt_ = iConfig.getParameter<double>("minSCEt");
28  minEleEt_ = iConfig.getParameter<double>("minEleEt");
29  minPhoEt_ = iConfig.getParameter<double>("minPhoEt");
30 
31 
32  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
33 
34  maxDR_ = iConfig.getParameter<double>("maxDR");
35 
36  //register your products
37  produces< DetIdCollection > (interestingDetIdCollection_) ;
38 
39 
40 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eeClusToESMapToken_
edm::EDGetTokenT< reco::PFClusterCollection > ecalPFClustersToken_
edm::EDGetTokenT< reco::PhotonCollection > phosToken_
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_

Member Function Documentation

void EgammaIsoESDetIdCollectionProducer::addDetIds ( const reco::SuperCluster superClus,
reco::PFClusterCollection  clusters,
const reco::PFCluster::EEtoPSAssociation eeClusToESMap,
std::vector< DetId > &  detIdsToStore 
)
private

Definition at line 109 of file EgammaIsoESDetIdCollectionProducer.cc.

References reco::deltaR2(), PFLayer::ECAL_ENDCAP, reco::CaloCluster::eta(), reco::PFCluster::layer(), maxDR_, and reco::CaloCluster::phi().

Referenced by produce().

110 {
111 
112  const float scEta = superClus.eta();
113  // if(std::abs(scEta)+maxDR_<1.5) return; //not possible to have a endcap cluster, let alone one with preshower (eta>1.65) so exit without checking further
114  const float scPhi = superClus.phi();
115 
116  const float maxDR2=maxDR_*maxDR_;
117 
118  for (size_t clusNr=0;clusNr<clusters.size();clusNr++){
119  const reco::PFCluster& clus = clusters[clusNr];
120  if(clus.layer()==PFLayer::ECAL_ENDCAP &&
121  reco::deltaR2(scEta,scPhi,clus.eta(),clus.phi())<maxDR2){
122 
123  auto keyVal = std::make_pair(clusNr,edm::Ptr<reco::PFCluster>());
124  const auto esClusters = std::equal_range(eeClusToESMap.begin(),eeClusToESMap.end(),keyVal,
125  [](const reco::PFCluster::EEtoPSAssociation::value_type& rhs, //roll on c++14, auto & lambda 4 evar!
127  bool{return rhs.first<lhs.first;}
128  );
129  // std::cout <<"cluster "<<clus.eta()<<" had "<<std::distance(esClusters.first,esClusters.second)<<" es clusters"<<std::endl;
130  for(auto esIt = esClusters.first;esIt!=esClusters.second;++esIt){
131  // std::cout <<"es clus "<<esIt->second->hitsAndFractions().size()<<std::endl;
132  for(const auto& hitAndFrac : esIt->second->hitsAndFractions()){
133  detIdsToStore.push_back(hitAndFrac.first);
134  }
135  }
136 
137  }//end of endcap & dR check
138  }//end of cluster loop
139 
140 
141 
142 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:86
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:163
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
Container::value_type value_type
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:166
void EgammaIsoESDetIdCollectionProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
finaloverridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 43 of file EgammaIsoESDetIdCollectionProducer.cc.

44 {
45 
46 }
void EgammaIsoESDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

producer

Implements edm::stream::EDProducerBase.

Definition at line 50 of file EgammaIsoESDetIdCollectionProducer.cc.

References addDetIds(), ecalPFClustersToken_, eeClusToESMapToken_, elesToken_, edm::Event::getByToken(), interestingDetIdCollection_, edm::HandleBase::isValid(), minEleEt_, minPhoEt_, minSCEt_, phosToken_, edm::Event::put(), funct::sin(), python.multivaluedict::sort(), and superClustersToken_.

52 {
53 
54  // take BasicClusters
56  iEvent.getByToken(superClustersToken_, superClusters);
57 
59  iEvent.getByToken(elesToken_,eles);
60 
62  iEvent.getByToken(phosToken_,phos);
63 
65  iEvent.getByToken(eeClusToESMapToken_,eeClusToESMap);
66 
68  iEvent.getByToken(ecalPFClustersToken_,ecalPFClusters);
69 
70  //Create empty output collections
71  std::vector<DetId> indexToStore;
72  indexToStore.reserve(100);
73 
74  if(eles.isValid() && eeClusToESMap.isValid() && ecalPFClusters.isValid()){
75  for(auto& ele : *eles){
76 
77  float scEt = ele.superCluster()->energy()*std::sin(ele.superCluster()->position().theta());
78  if(scEt > minEleEt_ || ele.et()> minEleEt_) addDetIds(*ele.superCluster(),*ecalPFClusters,*eeClusToESMap,indexToStore);
79  }
80  }
81  if(phos.isValid() && eeClusToESMap.isValid() && ecalPFClusters.isValid()){
82  for(auto& pho : *phos){
83  float scEt = pho.superCluster()->energy()*std::sin(pho.superCluster()->position().theta());
84  if(scEt > minPhoEt_ || pho.et()> minPhoEt_) addDetIds(*pho.superCluster(),*ecalPFClusters,*eeClusToESMap,indexToStore);
85  }
86  }
87  if(superClusters.isValid() && eeClusToESMap.isValid() && ecalPFClusters.isValid()){
88  for(auto& sc : *superClusters){
89  float scEt = sc.energy()*std::sin(sc.position().theta());
90  if(scEt > minSCEt_) addDetIds(sc,*ecalPFClusters,*eeClusToESMap,indexToStore);
91  }
92  }
93 
94  //unify the vector
95  std::sort(indexToStore.begin(),indexToStore.end());
96  std::unique(indexToStore.begin(),indexToStore.end());
97 
98  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection(indexToStore) ) ;
99 
100  iEvent.put( detIdCollection, interestingDetIdCollection_ );
101 
102 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > eeClusToESMapToken_
edm::EDGetTokenT< reco::PFClusterCollection > ecalPFClustersToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< reco::PhotonCollection > phosToken_
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
edm::EDCollection< DetId > DetIdCollection
void addDetIds(const reco::SuperCluster &superClus, reco::PFClusterCollection clusters, const reco::PFCluster::EEtoPSAssociation &eeClusToESMap, std::vector< DetId > &detIdsToStore)

Member Data Documentation

edm::EDGetTokenT<reco::PFClusterCollection> EgammaIsoESDetIdCollectionProducer::ecalPFClustersToken_
private
edm::EDGetTokenT<reco::PFCluster::EEtoPSAssociation> EgammaIsoESDetIdCollectionProducer::eeClusToESMapToken_
private
edm::EDGetTokenT<reco::GsfElectronCollection> EgammaIsoESDetIdCollectionProducer::elesToken_
private
std::string EgammaIsoESDetIdCollectionProducer::interestingDetIdCollection_
private
float EgammaIsoESDetIdCollectionProducer::maxDR_
private
float EgammaIsoESDetIdCollectionProducer::minEleEt_
private
float EgammaIsoESDetIdCollectionProducer::minPhoEt_
private
float EgammaIsoESDetIdCollectionProducer::minSCEt_
private
edm::EDGetTokenT<reco::PhotonCollection> EgammaIsoESDetIdCollectionProducer::phosToken_
private
edm::EDGetTokenT<reco::SuperClusterCollection> EgammaIsoESDetIdCollectionProducer::superClustersToken_
private