CMS 3D CMS Logo

EgammaIsoHcalDetIdCollectionProducer.cc
Go to the documentation of this file.
2 
5 
8 
10  : hcalHitSelector_(iConfig.getParameter<edm::ParameterSet>("hitSelection")) {
11  recHitsToken_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
12  elesToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("elesLabel"));
13 
14  phosToken_ = consumes<reco::PhotonCollection>(iConfig.getParameter<edm::InputTag>("phosLabel"));
15 
17  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("superClustersLabel"));
18 
19  minSCEt_ = iConfig.getParameter<double>("minSCEt");
20  minEleEt_ = iConfig.getParameter<double>("minEleEt");
21  minPhoEt_ = iConfig.getParameter<double>("minPhoEt");
22 
23  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
24 
25  //register your products
26  produces<DetIdCollection>(interestingDetIdCollection_);
27 }
28 
31  desc.add<edm::InputTag>("recHitsLabel", edm::InputTag("hbhereco"));
32  desc.add<edm::InputTag>("elesLabel", edm::InputTag("gedGsfElectrons"));
33  desc.add<edm::InputTag>("phosLabel", edm::InputTag("gedPhotons"));
34  desc.add<edm::InputTag>("superClustersLabel", edm::InputTag("particleFlowEGamma"));
35  desc.add<double>("minSCEt", 20);
36  desc.add<double>("minEleEt", 20);
37  desc.add<double>("minPhoEt", 20);
38  desc.add<std::string>("interestingDetIdCollection", "");
40  descriptions.add(("interestingGedEgammaIsoHCALDetId"), desc);
41 }
42 
44  hcalHitSelector_.setup(iSetup);
45 }
46 
47 // ------------ method called to produce the data ------------
50  iEvent.getByToken(superClustersToken_, superClusters);
51 
53  iEvent.getByToken(elesToken_, eles);
54 
56  iEvent.getByToken(phosToken_, phos);
57 
59  iEvent.getByToken(recHitsToken_, recHits);
60 
61  std::vector<DetId> indexToStore;
62  indexToStore.reserve(100);
63 
64  if (eles.isValid() && recHits.isValid()) {
65  for (auto& ele : *eles) {
66  float scEt = ele.superCluster()->energy() * std::sin(ele.superCluster()->position().theta());
67  if (scEt > minEleEt_ || ele.et() > minEleEt_) {
68  hcalHitSelector_.addDetIds(*ele.superCluster(), *recHits, indexToStore);
69  }
70  }
71  }
72  if (phos.isValid() && recHits.isValid()) {
73  for (auto& pho : *phos) {
74  float scEt = pho.superCluster()->energy() * std::sin(pho.superCluster()->position().theta());
75  if (scEt > minPhoEt_ || pho.et() > minPhoEt_) {
76  hcalHitSelector_.addDetIds(*pho.superCluster(), *recHits, indexToStore);
77  }
78  }
79  }
80  if (superClusters.isValid() && recHits.isValid()) {
81  for (auto& sc : *superClusters) {
82  float scEt = sc.energy() * std::sin(sc.position().theta());
83  if (scEt > minSCEt_) {
84  hcalHitSelector_.addDetIds(sc, *recHits, indexToStore);
85  }
86  }
87  }
88 
89  //unify the vector
90  std::sort(indexToStore.begin(), indexToStore.end());
91  std::unique(indexToStore.begin(), indexToStore.end());
92 
93  auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
94 
95  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_);
96 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void setup(const edm::EventSetup &iSetup)
void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
void beginRun(edm::Run const &, const edm::EventSetup &) final
int iEvent
Definition: GenABIO.cc:224
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:104
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
static edm::ParameterSetDescription makePSetDescription()
float theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:144
edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void addDetIds(const reco::SuperCluster &superClus, const HBHERecHitCollection &recHits, CollType &detIdsToStore) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
edm::EDGetTokenT< reco::PhotonCollection > phosToken_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45