CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EgammaIsoHcalDetIdCollectionProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaIsoHcalDetIdCollectionProducer
4 // Class: EgammaIsoHcalDetIdCollectionProducer
5 //
29 
31 public:
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
34 
35  void beginRun(edm::Run const&, const edm::EventSetup&) final;
36  void produce(edm::Event&, const edm::EventSetup&) override;
37 
38 private:
39  // ----------member data ---------------------------
44 
46 
47  float minSCEt_;
48  float minEleEt_;
49  float minPhoEt_;
50 
52 };
53 
56 
58  : recHitsToken_{consumes(iConfig.getParameter<edm::InputTag>("recHitsLabel"))},
59  superClustersToken_{consumes(iConfig.getParameter<edm::InputTag>("superClustersLabel"))},
60  elesToken_{consumes(iConfig.getParameter<edm::InputTag>("elesLabel"))},
61  phosToken_{consumes(iConfig.getParameter<edm::InputTag>("phosLabel"))},
62  hcalHitSelector_(iConfig.getParameter<edm::ParameterSet>("hitSelection"), consumesCollector()) {
63  minSCEt_ = iConfig.getParameter<double>("minSCEt");
64  minEleEt_ = iConfig.getParameter<double>("minEleEt");
65  minPhoEt_ = iConfig.getParameter<double>("minPhoEt");
66 
67  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
68 
69  //register your products
70  produces<DetIdCollection>(interestingDetIdCollection_);
71 }
72 
75  desc.add<edm::InputTag>("recHitsLabel", edm::InputTag("hbhereco"));
76  desc.add<edm::InputTag>("elesLabel", edm::InputTag("gedGsfElectrons"));
77  desc.add<edm::InputTag>("phosLabel", edm::InputTag("gedPhotons"));
78  desc.add<edm::InputTag>("superClustersLabel", edm::InputTag("particleFlowEGamma"));
79  desc.add<double>("minSCEt", 20);
80  desc.add<double>("minEleEt", 20);
81  desc.add<double>("minPhoEt", 20);
82  desc.add<std::string>("interestingDetIdCollection", "");
84  descriptions.add(("interestingGedEgammaIsoHCALDetId"), desc);
85 }
86 
88  hcalHitSelector_.setup(iSetup);
89 }
90 
91 // ------------ method called to produce the data ------------
94  auto eles = iEvent.getHandle(elesToken_);
95  auto phos = iEvent.getHandle(phosToken_);
96  auto recHits = iEvent.getHandle(recHitsToken_);
97 
98  std::vector<DetId> indexToStore;
99  indexToStore.reserve(100);
100 
101  if (eles.isValid() && recHits.isValid()) {
102  for (auto& ele : *eles) {
103  float scEt = ele.superCluster()->energy() * std::sin(ele.superCluster()->position().theta());
104  if (scEt > minEleEt_ || ele.et() > minEleEt_) {
105  hcalHitSelector_.addDetIds(*ele.superCluster(), *recHits, indexToStore);
106  }
107  }
108  }
109  if (phos.isValid() && recHits.isValid()) {
110  for (auto& pho : *phos) {
111  float scEt = pho.superCluster()->energy() * std::sin(pho.superCluster()->position().theta());
112  if (scEt > minPhoEt_ || pho.et() > minPhoEt_) {
113  hcalHitSelector_.addDetIds(*pho.superCluster(), *recHits, indexToStore);
114  }
115  }
116  }
117  if (superClusters.isValid() && recHits.isValid()) {
118  for (auto& sc : *superClusters) {
119  float scEt = sc.energy() * std::sin(sc.position().theta());
120  if (scEt > minSCEt_) {
121  hcalHitSelector_.addDetIds(sc, *recHits, indexToStore);
122  }
123  }
124  }
125 
126  //unify the vector
127  std::sort(indexToStore.begin(), indexToStore.end());
128  std::unique(indexToStore.begin(), indexToStore.end());
129 
130  auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
131 
132  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_);
133 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
def unique
Definition: tier0.py:24
void setup(const edm::EventSetup &iSetup)
void produce(edm::Event &, const edm::EventSetup &) override
void beginRun(edm::Run const &, const edm::EventSetup &) final
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
const edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static edm::ParameterSetDescription makePSetDescription()
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void addDetIds(const reco::SuperCluster &superClus, const HBHERecHitCollection &recHits, CollType &detIdsToStore) const
const edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::PhotonCollection > phosToken_
const edm::EDGetTokenT< HBHERecHitCollection > recHitsToken_
Definition: Run.h:45