CMS 3D CMS Logo

RecHitMapProducer.cc
Go to the documentation of this file.
1 // user include files
2 #include <unordered_map>
3 
7 
13 
17 
19 public:
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
24 
25 private:
32  bool hgcalOnly_;
33 };
34 
36 
37 using DetIdRecHitMap = std::unordered_map<DetId, const unsigned int>;
38 
40  : hits_ee_token_(consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("EEInput"))),
41  hits_fh_token_(consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("FHInput"))),
42  hits_bh_token_(consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("BHInput"))),
43  hits_eb_token_(consumes<reco::PFRecHitCollection>(ps.getParameter<edm::InputTag>("EBInput"))),
44  hits_hb_token_(consumes<reco::PFRecHitCollection>(ps.getParameter<edm::InputTag>("HBInput"))),
45  hits_ho_token_(consumes<reco::PFRecHitCollection>(ps.getParameter<edm::InputTag>("HOInput"))),
46  hgcalOnly_(ps.getParameter<bool>("hgcalOnly")) {
47  produces<DetIdRecHitMap>("hgcalRecHitMap");
48  if (!hgcalOnly_)
49  produces<DetIdRecHitMap>("barrelRecHitMap");
50 }
51 
54  desc.add<edm::InputTag>("EEInput", {"HGCalRecHit", "HGCEERecHits"});
55  desc.add<edm::InputTag>("FHInput", {"HGCalRecHit", "HGCHEFRecHits"});
56  desc.add<edm::InputTag>("BHInput", {"HGCalRecHit", "HGCHEBRecHits"});
57  desc.add<edm::InputTag>("EBInput", {"particleFlowRecHitECAL", ""});
58  desc.add<edm::InputTag>("HBInput", {"particleFlowRecHitHBHE", ""});
59  desc.add<edm::InputTag>("HOInput", {"particleFlowRecHitHO", ""});
60  desc.add<bool>("hgcalOnly", true);
61  descriptions.add("recHitMapProducer", desc);
62 }
63 
65  auto hitMapHGCal = std::make_unique<DetIdRecHitMap>();
66  const auto& ee_hits = evt.get(hits_ee_token_);
67  const auto& fh_hits = evt.get(hits_fh_token_);
68  const auto& bh_hits = evt.get(hits_bh_token_);
69 
70  MultiVectorManager<HGCRecHit> rechitManager;
71  rechitManager.addVector(ee_hits);
72  rechitManager.addVector(fh_hits);
73  rechitManager.addVector(bh_hits);
74 
75  for (unsigned int i = 0; i < rechitManager.size(); ++i) {
76  const auto recHitDetId = rechitManager[i].detid();
77  hitMapHGCal->emplace(recHitDetId, i);
78  }
79 
80  evt.put(std::move(hitMapHGCal), "hgcalRecHitMap");
81 
82  if (!hgcalOnly_) {
83  auto hitMapBarrel = std::make_unique<DetIdRecHitMap>();
84  MultiVectorManager<reco::PFRecHit> barrelRechitManager;
85  barrelRechitManager.addVector(evt.get(hits_eb_token_));
86  barrelRechitManager.addVector(evt.get(hits_hb_token_));
87  barrelRechitManager.addVector(evt.get(hits_ho_token_));
88  for (unsigned int i = 0; i < barrelRechitManager.size(); ++i) {
89  const auto recHitDetId = barrelRechitManager[i].detId();
90  hitMapBarrel->emplace(recHitDetId, i);
91  }
92  evt.put(std::move(hitMapBarrel), "barrelRecHitMap");
93  }
94 }
std::unordered_map< DetId, const unsigned int > DetIdRecHitMap
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::vector< HGCRecHit > HGCRecHitCollection
const edm::EDGetTokenT< reco::PFRecHitCollection > hits_ho_token_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:344
RecHitMapProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token_
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
const edm::EDGetTokenT< reco::PFRecHitCollection > hits_hb_token_
const edm::EDGetTokenT< reco::PFRecHitCollection > hits_eb_token_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token_
void addVector(std::span< const T > vec)
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511