CMS 3D CMS Logo

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

#include <EgammaIsoHcalDetIdCollectionProducer.h>

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

Public Member Functions

virtual void beginRun (edm::Run const &, const edm::EventSetup &) override final
 
 EgammaIsoHcalDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void addDetIds (const reco::SuperCluster &superClus, const HBHERecHitCollection &recHits, std::vector< DetId > &detIdsToStore)
 

Private Attributes

edm::EDGetTokenT< reco::GsfElectronCollectionelesToken_
 
std::string interestingDetIdCollection_
 
int maxDIEta_
 
int maxDIPhi_
 
float minEleEt_
 
float minEnergyHCAL_
 
float minPhoEt_
 
float minSCEt_
 
edm::EDGetTokenT< reco::PhotonCollectionphosToken_
 
edm::EDGetTokenT< HBHERecHitCollectionrecHitsToken_
 
edm::EDGetTokenT< reco::SuperClusterCollectionsuperClustersToken_
 
edm::ESHandle< CaloTowerConstituentsMaptowerMap_
 

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
 
- 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

Original author: Sam Harper (RAL)

Make a collection of detids to be kept tipically in a AOD rechit collection Modified from the ECAL version "InterestingDetIdCollectionProducer" to be HCAL

Definition at line 44 of file EgammaIsoHcalDetIdCollectionProducer.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 9 of file EgammaIsoHcalDetIdCollectionProducer.cc.

References elesToken_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, maxDIEta_, maxDIPhi_, minEleEt_, minEnergyHCAL_, minPhoEt_, minSCEt_, phosToken_, recHitsToken_, AlCaHLTBitMon_QueryRunRegistry::string, and superClustersToken_.

10 {
11 
12  recHitsToken_ =
13  consumes<HBHERecHitCollection>(iConfig.getParameter< edm::InputTag > ("recHitsLabel"));
14  elesToken_ =
15  consumes<reco::GsfElectronCollection>(iConfig.getParameter< edm::InputTag >("elesLabel"));
16 
17  phosToken_ =
18  consumes<reco::PhotonCollection>(iConfig.getParameter< edm::InputTag >("phosLabel"));
19 
21  consumes<reco::SuperClusterCollection>(iConfig.getParameter< edm::InputTag >("superClustersLabel"));
22 
23  minSCEt_ = iConfig.getParameter<double>("minSCEt");
24  minEleEt_ = iConfig.getParameter<double>("minEleEt");
25  minPhoEt_ = iConfig.getParameter<double>("minPhoEt");
26 
27 
28  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
29 
30  maxDIEta_ = iConfig.getParameter<int>("maxDIEta");
31  maxDIPhi_ = iConfig.getParameter<int>("maxDIPhi");
32 
33  minEnergyHCAL_= iConfig.getParameter<double>("minEnergyHCAL");
34 
35  //register your products
36  produces< DetIdCollection > (interestingDetIdCollection_) ;
37 
38 
39 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
edm::EDGetTokenT< HBHERecHitCollection > recHitsToken_
edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
edm::EDGetTokenT< reco::PhotonCollection > phosToken_

Member Function Documentation

void EgammaIsoHcalDetIdCollectionProducer::addDetIds ( const reco::SuperCluster superClus,
const HBHERecHitCollection recHits,
std::vector< DetId > &  detIdsToStore 
)
private

Definition at line 128 of file EgammaIsoHcalDetIdCollectionProducer.cc.

References funct::abs(), calDIEta(), calDIPhi(), DetId::det(), DetId::Ecal, DetId::Forward, maxDIEta_, maxDIPhi_, minEnergyHCAL_, rpcPointValidation_cfi::recHit, reco::SuperCluster::seed(), ecaldqm::towerId(), towerMap_, and CaloTowerConstituentsMap::towerOf().

Referenced by produce().

129 {
130  DetId seedId = superClus.seed()->seed();
131  if(seedId.det() != DetId::Ecal && seedId.det() != DetId::Forward) {
132  edm::LogError("EgammaIsoHcalDetIdCollectionProducerError") << "Somehow the supercluster has a seed which is not ECAL, something is badly wrong";
133  }
134  //so we are using CaloTowers to get the iEta/iPhi of the HCAL rec hit behind the seed cluster, this might go funny on tower 28 but shouldnt matter there
135 
136  if( seedId.det() == DetId::Forward ) return;
137 
139  int seedHcalIEta = towerId.ieta();
140  int seedHcalIPhi = towerId.iphi();
141 
142  for(auto& recHit : recHits){
143  int dIEtaAbs = std::abs(calDIEta(seedHcalIEta,recHit.id().ieta()));
144  int dIPhiAbs = std::abs(calDIPhi(seedHcalIPhi,recHit.id().iphi()));
145 
146  if(dIEtaAbs<=maxDIEta_ && dIPhiAbs<=maxDIPhi_ && recHit.energy()>minEnergyHCAL_) detIdsToStore.push_back(recHit.id().rawId());
147  }
148 
149 }
int calDIPhi(int iPhi1, int iPhi2)
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned towerId(DetId const &)
Definition: DetId.h:18
edm::ESHandle< CaloTowerConstituentsMap > towerMap_
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
int calDIEta(int iEta1, int iEta2)
void EgammaIsoHcalDetIdCollectionProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
finaloverridevirtual

Definition at line 42 of file EgammaIsoHcalDetIdCollectionProducer.cc.

References edm::EventSetup::get(), and towerMap_.

43 {
44  iSetup.get<CaloGeometryRecord>().get(towerMap_);
45  // std::cout <<" got geom "<<towerMap_.isValid()<<" "<<&(*towerMap_)<<std::endl;
46 }
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< CaloTowerConstituentsMap > towerMap_
void EgammaIsoHcalDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

producer

Definition at line 50 of file EgammaIsoHcalDetIdCollectionProducer.cc.

References addDetIds(), elesToken_, SimCluster::energy(), edm::Event::getByToken(), interestingDetIdCollection_, edm::HandleBase::isValid(), minEleEt_, minPhoEt_, minSCEt_, eostools::move(), phosToken_, edm::Event::put(), recHitsToken_, SimDataFormats::CaloAnalysis::sc, funct::sin(), superClustersToken_, SimCluster::theta(), and tier0::unique().

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(recHitsToken_,recHits);
66 
67  //Create empty output collections
68  std::vector<DetId> indexToStore;
69  indexToStore.reserve(100);
70 
71  if(eles.isValid() && recHits.isValid()){
72  for(auto& ele : *eles){
73 
74  float scEt = ele.superCluster()->energy()*std::sin(ele.superCluster()->position().theta());
75  if(scEt > minEleEt_ || ele.et()> minEleEt_) addDetIds(*ele.superCluster(),*recHits,indexToStore);
76  }
77  }
78  if(phos.isValid() && recHits.isValid()){
79  for(auto& pho : *phos){
80  float scEt = pho.superCluster()->energy()*std::sin(pho.superCluster()->position().theta());
81  if(scEt > minPhoEt_ || pho.et()> minPhoEt_) addDetIds(*pho.superCluster(),*recHits,indexToStore);
82  }
83  }
84  if(superClusters.isValid() && recHits.isValid()){
85  for(auto& sc : *superClusters){
86  float scEt = sc.energy()*std::sin(sc.position().theta());
87  if(scEt > minSCEt_) addDetIds(sc,*recHits,indexToStore);
88  }
89  }
90 
91  //unify the vector
92  std::sort(indexToStore.begin(),indexToStore.end());
93  std::unique(indexToStore.begin(),indexToStore.end());
94 
95  auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
96 
97  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_ );
98 
99 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
def unique(seq, keepstr=True)
Definition: tier0.py:24
edm::EDGetTokenT< HBHERecHitCollection > recHitsToken_
float energy() const
Energy. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:111
bool isValid() const
Definition: HandleBase.h:74
float theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:166
edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
edm::EDGetTokenT< reco::PhotonCollection > phosToken_
void addDetIds(const reco::SuperCluster &superClus, const HBHERecHitCollection &recHits, std::vector< DetId > &detIdsToStore)
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::EDGetTokenT<reco::GsfElectronCollection> EgammaIsoHcalDetIdCollectionProducer::elesToken_
private
std::string EgammaIsoHcalDetIdCollectionProducer::interestingDetIdCollection_
private
int EgammaIsoHcalDetIdCollectionProducer::maxDIEta_
private
int EgammaIsoHcalDetIdCollectionProducer::maxDIPhi_
private
float EgammaIsoHcalDetIdCollectionProducer::minEleEt_
private
float EgammaIsoHcalDetIdCollectionProducer::minEnergyHCAL_
private
float EgammaIsoHcalDetIdCollectionProducer::minPhoEt_
private
float EgammaIsoHcalDetIdCollectionProducer::minSCEt_
private
edm::EDGetTokenT<reco::PhotonCollection> EgammaIsoHcalDetIdCollectionProducer::phosToken_
private
edm::EDGetTokenT<HBHERecHitCollection> EgammaIsoHcalDetIdCollectionProducer::recHitsToken_
private
edm::EDGetTokenT<reco::SuperClusterCollection> EgammaIsoHcalDetIdCollectionProducer::superClustersToken_
private
edm::ESHandle<CaloTowerConstituentsMap> EgammaIsoHcalDetIdCollectionProducer::towerMap_
private

Definition at line 72 of file EgammaIsoHcalDetIdCollectionProducer.h.

Referenced by addDetIds(), and beginRun().