CMS 3D CMS Logo

HGCalTriggerDigiFEReproducer.cc
Go to the documentation of this file.
3 
6 
10 
14 
15 #include <sstream>
16 #include <memory>
17 
19 {
20  public:
23 
24  virtual void beginRun(const edm::Run&, 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 
38 
39 /*****************************************************************/
41  inputdigi_(consumes<l1t::HGCFETriggerDigiCollection>(conf.getParameter<edm::InputTag>("feDigis")))
42 /*****************************************************************/
43 {
44  //setup FE codec
45  const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec");
46  const std::string& feCodecName = feCodecConfig.getParameter<std::string>("CodecName");
47  HGCalTriggerFECodecBase* codec = HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
48  codec_.reset(codec);
49  codec_->unSetDataPayload();
50 
51  produces<l1t::HGCFETriggerDigiCollection>();
52  //setup BE processor
53  backEndProcessor_ = std::make_unique<HGCalTriggerBackendProcessor>(conf.getParameterSet("BEConfiguration"));
54  // register backend processor products
55  backEndProcessor_->setProduces(*this);
56 }
57 
58 /*****************************************************************/
60 /*****************************************************************/
61 {
63  codec_->setGeometry(triggerGeometry_.product());
65 }
66 
67 /*****************************************************************/
69 /*****************************************************************/
70 {
71  std::unique_ptr<l1t::HGCFETriggerDigiCollection> fe_output( new l1t::HGCFETriggerDigiCollection );
72 
74 
75  e.getByToken(inputdigi_,digis_h);
76 
77  const l1t::HGCFETriggerDigiCollection& digis = *digis_h;
78 
79  fe_output->reserve(digis.size());
80  std::stringstream output;
81  for( const auto& digi_in : digis )
82  {
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")
90  << output.str();
91  codec_->unSetDataPayload();
92  output.str(std::string());
93  output.clear();
94  }
95 
96  // get the orphan handle and fe digi collection
97  auto fe_digis_handle = e.put(std::move(fe_output));
98  auto fe_digis_coll = *fe_digis_handle;
99 
100  //now we run the emulation of the back-end processor
101  backEndProcessor_->run(fe_digis_coll, es);
102  backEndProcessor_->putInEvent(e);
103  backEndProcessor_->reset();
104 }
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
std::unique_ptr< HGCalTriggerFECodecBase > codec_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
edm::ESHandle< HGCalTriggerGeometryBase > triggerGeometry_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::SortedCollection< HGCFETriggerDigi > HGCFETriggerDigiCollection
delete x;
Definition: CaloConfig.h:22
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< HGCalTriggerBackendProcessor > backEndProcessor_
HGCalTriggerDigiFEReproducer(const edm::ParameterSet &)
void setDetId(const IDTYPE &id)
ParameterSet const & getParameterSet(std::string const &) const
const T & get() const
Definition: EventSetup.h:56
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
HLT enums.
size_type size() const
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:42