CMS 3D CMS Logo

HGCalTriggerDigiProducer.cc
Go to the documentation of this file.
3 
7 
11 
15 
16 #include <memory>
17 
19  public:
22 
23  virtual void beginRun(const edm::Run&,
24  const edm::EventSetup&);
25  virtual void produce(edm::Event&, const edm::EventSetup&);
26 
27  private:
28  // inputs
31  // algorithm containers
32  std::unique_ptr<HGCalTriggerFECodecBase> codec_;
33  std::unique_ptr<HGCalTriggerBackendProcessor> backEndProcessor_;
34 };
35 
37 
40  inputee_(consumes<HGCEEDigiCollection>(conf.getParameter<edm::InputTag>("eeDigis"))),
41  inputfh_(consumes<HGCHEDigiCollection>(conf.getParameter<edm::InputTag>("fhDigis"))),
42  //inputbh_(consumes<HGCHEDigiCollection>(conf.getParameter<edm::InputTag>("bhDigis"))),
44 {
45  //setup FE codec
46  const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec");
47  const std::string& feCodecName = feCodecConfig.getParameter<std::string>("CodecName");
48  HGCalTriggerFECodecBase* codec = HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
49  codec_.reset(codec);
50  codec_->unSetDataPayload();
51 
52  produces<l1t::HGCFETriggerDigiCollection>();
53  // register backend processor products
54  backEndProcessor_->setProduces(*this);
55 }
56 
58  const edm::EventSetup& es) {
60  codec_->setGeometry(triggerGeometry_.product());
62 
63 }
64 
66  std::unique_ptr<l1t::HGCFETriggerDigiCollection>
67  fe_output( new l1t::HGCFETriggerDigiCollection );
68 
70  edm::Handle<HGCHEDigiCollection> fh_digis_h, bh_digis_h;
71 
72  e.getByToken(inputee_,ee_digis_h);
73  e.getByToken(inputfh_,fh_digis_h);
74  //e.getByToken(inputbh_,bh_digis_h);
75 
76  const HGCEEDigiCollection& ee_digis = *ee_digis_h;
77  const HGCHEDigiCollection& fh_digis = *fh_digis_h;
78  //const HGCHEDigiCollection& bh_digis = *bh_digis_h;
79 
80  // First find modules containing hits and prepare list of hits for each module
81  std::unordered_map<uint32_t, HGCEEDigiCollection> hit_modules_ee;
82  for(const auto& eedata : ee_digis) {
83  uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id());
84  auto itr_insert = hit_modules_ee.emplace(module,HGCEEDigiCollection());
85  itr_insert.first->second.push_back(eedata);
86  }
87  std::unordered_map<uint32_t,HGCHEDigiCollection> hit_modules_fh;
88  for(const auto& fhdata : fh_digis) {
89  uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id());
90  auto itr_insert = hit_modules_fh.emplace(module, HGCHEDigiCollection());
91  itr_insert.first->second.push_back(fhdata);
92  }
93  // loop on modules containing hits and call front-end processing
94  // we produce one output trigger digi per module in the FE
95  fe_output->reserve(hit_modules_ee.size() + hit_modules_fh.size());
96  for( const auto& module_hits : hit_modules_ee ) {
97  fe_output->push_back(l1t::HGCFETriggerDigi());
98  l1t::HGCFETriggerDigi& digi = fe_output->back();
99  codec_->setDataPayload(module_hits.second,HGCHEDigiCollection(),HGCHEDigiCollection());
100  codec_->encode(digi);
101  digi.setDetId( DetId(module_hits.first) );
102  codec_->unSetDataPayload();
103  } //end loop on EE modules
104  for( const auto& module_hits : hit_modules_fh ) {
105  fe_output->push_back(l1t::HGCFETriggerDigi());
106  l1t::HGCFETriggerDigi& digi = fe_output->back();
107  codec_->setDataPayload(HGCEEDigiCollection(),module_hits.second,HGCHEDigiCollection());
108  codec_->encode(digi);
109  digi.setDetId( DetId(module_hits.first) );
110  codec_->unSetDataPayload();
111  } //end loop on FH modules
112 
113 
114  // get the orphan handle and fe digi collection
115  auto fe_digis_handle = e.put(std::move(fe_output));
116  auto fe_digis_coll = *fe_digis_handle;
117 
118  //now we run the emulation of the back-end processor
119  backEndProcessor_->reset();
120  backEndProcessor_->run(fe_digis_coll,es,e);
121  backEndProcessor_->putInEvent(e);
122 }
T getParameter(std::string const &) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
edm::SortedCollection< HGCEEDataFrame > HGCEEDigiCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ParameterSet const & getParameterSet(ParameterSetID const &id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< HGCalTriggerFECodecBase > codec_
virtual void produce(edm::Event &, const edm::EventSetup &)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void setDetId(const IDTYPE &id)
HGCalTriggerDigiProducer(const edm::ParameterSet &)
edm::ESHandle< HGCalTriggerGeometryBase > triggerGeometry_
std::unique_ptr< HGCalTriggerBackendProcessor > backEndProcessor_
virtual unsigned getModuleFromCell(const unsigned cell_det_id) const =0
Definition: DetId.h:18
ParameterSet const & getParameterSet(std::string const &) const
const T & get() const
Definition: EventSetup.h:56
HLT enums.
T const * product() const
Definition: ESHandle.h:86
Definition: vlib.h:208
edm::SortedCollection< HGCHEDataFrame > HGCHEDigiCollection
def move(src, dest)
Definition: eostools.py:510
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:42