CMS 3D CMS Logo

HGCalTriggerDigiFEReproducer.cc
Go to the documentation of this file.
3 
7 
11 
13 
17 
18 #include <sstream>
19 #include <memory>
20 
22 public:
25 
26  void beginRun(const edm::Run&, const edm::EventSetup&) override;
27  void produce(edm::Event&, const edm::EventSetup&) override;
28 
29 private:
30  // inputs
33  // algorithm containers
34  std::unique_ptr<HGCalTriggerFECodecBase> codec_;
35  std::unique_ptr<HGCalTriggerBackendProcessor> backEndProcessor_;
36 };
37 
39 
40 /*****************************************************************/
42  : inputdigi_(consumes<l1t::HGCFETriggerDigiCollection>(conf.getParameter<edm::InputTag>("feDigis"))),
44  std::make_unique<HGCalTriggerBackendProcessor>(conf.getParameterSet("BEConfiguration"), consumesCollector()))
45 /*****************************************************************/
46 {
47  //setup FE codec
48  const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec");
49  const std::string& feCodecName = feCodecConfig.getParameter<std::string>("CodecName");
50  codec_ =
51  std::unique_ptr<HGCalTriggerFECodecBase>{HGCalTriggerFECodecFactory::get()->create(feCodecName, feCodecConfig)};
52  codec_->unSetDataPayload();
53 
54  produces<l1t::HGCFETriggerDigiCollection>();
55  // register backend processor products
56  backEndProcessor_->setProduces(*this);
57 }
58 
59 /*****************************************************************/
61 /*****************************************************************/
62 {
64  codec_->setGeometry(triggerGeometry_.product());
66 }
67 
68 /*****************************************************************/
70 /*****************************************************************/
71 {
72  std::unique_ptr<l1t::HGCFETriggerDigiCollection> fe_output(new l1t::HGCFETriggerDigiCollection);
73 
75 
76  e.getByToken(inputdigi_, digis_h);
77 
78  const l1t::HGCFETriggerDigiCollection& digis = *digis_h;
79 
80  fe_output->reserve(digis.size());
81  std::stringstream output;
82  for (const auto& digi_in : digis) {
83  fe_output->push_back(l1t::HGCFETriggerDigi());
84  l1t::HGCFETriggerDigi& digi_out = fe_output->back();
85  codec_->setDataPayload(digi_in);
86  codec_->encode(digi_out);
87  digi_out.setDetId(digi_in.getDetId<HGCalDetId>());
88  codec_->print(digi_out, output);
89  edm::LogInfo("HGCalTriggerDigiFEReproducer") << output.str();
90  codec_->unSetDataPayload();
91  output.str(std::string());
92  output.clear();
93  }
94 
95  // get the orphan handle and fe digi collection
96  auto fe_digis_handle = e.put(std::move(fe_output));
97  auto fe_digis_coll = *fe_digis_handle;
98 
99  //now we run the emulation of the back-end processor
100  backEndProcessor_->run(fe_digis_coll, es, e);
101  backEndProcessor_->putInEvent(e);
102  backEndProcessor_->reset();
103 }
T getParameter(std::string const &) const
std::unique_ptr< HGCalTriggerFECodecBase > codec_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::ESHandle< HGCalTriggerGeometryBase > triggerGeometry_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
ParameterSet const & getParameterSet(ParameterSetID const &id)
edm::SortedCollection< HGCFETriggerDigi > HGCFETriggerDigiCollection
delete x;
Definition: CaloConfig.h:22
std::unique_ptr< HGCalTriggerBackendProcessor > backEndProcessor_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HGCalTriggerDigiFEReproducer(const edm::ParameterSet &)
void setDetId(const IDTYPE &id)
ParameterSet const & getParameterSet(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
HLT enums.
size_type size() const
T get() const
Definition: EventSetup.h:71
void beginRun(const edm::Run &, const edm::EventSetup &) override
void reserve(size_type n)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:45