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

Public Member Functions

void beginRun (edm::Run const &, const edm::EventSetup &) final
 
 EgammaIsoHcalDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 producer More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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
 

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:36
int calDIEta(int iEta1, int iEta2)
void EgammaIsoHcalDetIdCollectionProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
final

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:59
edm::ESHandle< CaloTowerConstituentsMap > towerMap_
void EgammaIsoHcalDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

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:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
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().