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 {
23  public:
26 
27  void beginRun(const edm::Run&, const edm::EventSetup&) override;
28  void produce(edm::Event&, const edm::EventSetup&) override;
29 
30  private:
31  // inputs
34  // algorithm containers
35  std::unique_ptr<HGCalTriggerFECodecBase> codec_;
36  std::unique_ptr<HGCalTriggerBackendProcessor> backEndProcessor_;
37 };
38 
40 
41 
42 /*****************************************************************/
44  inputdigi_(consumes<l1t::HGCFETriggerDigiCollection>(conf.getParameter<edm::InputTag>("feDigis"))),
45  backEndProcessor_(new HGCalTriggerBackendProcessor(conf.getParameterSet("BEConfiguration"), consumesCollector()))
46 /*****************************************************************/
47 {
48  //setup FE codec
49  const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec");
50  const std::string& feCodecName = feCodecConfig.getParameter<std::string>("CodecName");
51  HGCalTriggerFECodecBase* codec = HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
52  codec_.reset(codec);
53  codec_->unSetDataPayload();
54 
55  produces<l1t::HGCFETriggerDigiCollection>();
56  // register backend processor products
57  backEndProcessor_->setProduces(*this);
58 }
59 
60 /*****************************************************************/
62 /*****************************************************************/
63 {
65  codec_->setGeometry(triggerGeometry_.product());
67 }
68 
69 /*****************************************************************/
71 /*****************************************************************/
72 {
73  std::unique_ptr<l1t::HGCFETriggerDigiCollection> fe_output( new l1t::HGCFETriggerDigiCollection );
74 
76 
77  e.getByToken(inputdigi_,digis_h);
78 
79  const l1t::HGCFETriggerDigiCollection& digis = *digis_h;
80 
81  fe_output->reserve(digis.size());
82  std::stringstream output;
83  for( const auto& digi_in : digis )
84  {
85  fe_output->push_back(l1t::HGCFETriggerDigi());
86  l1t::HGCFETriggerDigi& digi_out = fe_output->back();
87  codec_->setDataPayload(digi_in);
88  codec_->encode(digi_out);
89  digi_out.setDetId( digi_in.getDetId<HGCalDetId>() );
90  codec_->print(digi_out,output);
91  edm::LogInfo("HGCalTriggerDigiFEReproducer")
92  << output.str();
93  codec_->unSetDataPayload();
94  output.str(std::string());
95  output.clear();
96  }
97 
98  // get the orphan handle and fe digi collection
99  auto fe_digis_handle = e.put(std::move(fe_output));
100  auto fe_digis_coll = *fe_digis_handle;
101 
102  //now we run the emulation of the back-end processor
103  backEndProcessor_->run(fe_digis_coll,es,e);
104  backEndProcessor_->putInEvent(e);
105  backEndProcessor_->reset();
106 }
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:137
edm::ESHandle< HGCalTriggerGeometryBase > triggerGeometry_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ParameterSet const & getParameterSet(ParameterSetID const &id)
edm::SortedCollection< HGCFETriggerDigi > HGCFETriggerDigiCollection
delete x;
Definition: CaloConfig.h:22
std::unique_ptr< HGCalTriggerBackendProcessor > backEndProcessor_
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:63
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:510
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:44