CMS 3D CMS Logo

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 ------------
93  auto superClusters = iEvent.getHandle(superClustersToken_);
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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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
void beginRun(edm::Run const &, const edm::EventSetup &) final
int iEvent
Definition: GenABIO.cc:224
void addDetIds(const reco::SuperCluster &superClus, const HBHERecHitCollection &recHits, CollType &detIdsToStore) const
def unique(seq, keepstr=True)
Definition: tier0.py:24
const edm::EDGetTokenT< reco::GsfElectronCollection > elesToken_
static edm::ParameterSetDescription makePSetDescription()
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::PhotonCollection > phosToken_
const edm::EDGetTokenT< HBHERecHitCollection > recHitsToken_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45