CMS 3D CMS Logo

HGCalTriggerDigiProducer.cc
Go to the documentation of this file.
3 
7 
11 
15 
16 #include <sstream>
17 #include <memory>
18 
20  public:
23 
24  virtual void beginRun(const edm::Run&,
25  const edm::EventSetup&);
26  virtual void produce(edm::Event&, const edm::EventSetup&);
27 
28  private:
29  // inputs
32  // algorithm containers
33  std::unique_ptr<HGCalTriggerFECodecBase> codec_;
34  std::unique_ptr<HGCalTriggerBackendProcessor> backEndProcessor_;
35 };
36 
38 
41  inputee_(consumes<HGCEEDigiCollection>(conf.getParameter<edm::InputTag>("eeDigis"))),
42  inputfh_(consumes<HGCHEDigiCollection>(conf.getParameter<edm::InputTag>("fhDigis"))),
43  //inputbh_(consumes<HGCHEDigiCollection>(conf.getParameter<edm::InputTag>("bhDigis"))),
45 {
46  //setup FE codec
47  const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec");
48  const std::string& feCodecName = feCodecConfig.getParameter<std::string>("CodecName");
49  HGCalTriggerFECodecBase* codec = HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
50  codec_.reset(codec);
51  codec_->unSetDataPayload();
52 
53  produces<l1t::HGCFETriggerDigiCollection>();
54  // register backend processor products
55  backEndProcessor_->setProduces(*this);
56 }
57 
59  const edm::EventSetup& es) {
61  codec_->setGeometry(triggerGeometry_.product());
63 
64 }
65 
67  std::unique_ptr<l1t::HGCFETriggerDigiCollection>
68  fe_output( new l1t::HGCFETriggerDigiCollection );
69 
71  edm::Handle<HGCHEDigiCollection> fh_digis_h, bh_digis_h;
72 
73  e.getByToken(inputee_,ee_digis_h);
74  e.getByToken(inputfh_,fh_digis_h);
75  //e.getByToken(inputbh_,bh_digis_h);
76 
77  const HGCEEDigiCollection& ee_digis = *ee_digis_h;
78  const HGCHEDigiCollection& fh_digis = *fh_digis_h;
79  //const HGCHEDigiCollection& bh_digis = *bh_digis_h;
80 
81  // First find modules containing hits and prepare list of hits for each module
82  std::unordered_map<uint32_t, HGCEEDigiCollection> hit_modules_ee;
83  for(const auto& eedata : ee_digis) {
84  uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id());
85  auto itr_insert = hit_modules_ee.emplace(module,HGCEEDigiCollection());
86  itr_insert.first->second.push_back(eedata);
87  }
88  std::unordered_map<uint32_t,HGCHEDigiCollection> hit_modules_fh;
89  for(const auto& fhdata : fh_digis) {
90  uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id());
91  auto itr_insert = hit_modules_fh.emplace(module, HGCHEDigiCollection());
92  itr_insert.first->second.push_back(fhdata);
93  }
94  // loop on modules containing hits and call front-end processing
95  // we produce one output trigger digi per module in the FE
96  fe_output->reserve(hit_modules_ee.size() + hit_modules_fh.size());
97  std::stringstream output;
98  for( const auto& module_hits : hit_modules_ee ) {
99  fe_output->push_back(l1t::HGCFETriggerDigi());
100  l1t::HGCFETriggerDigi& digi = fe_output->back();
101  codec_->setDataPayload(module_hits.second,HGCHEDigiCollection(),HGCHEDigiCollection());
102  codec_->encode(digi);
103  digi.setDetId( DetId(module_hits.first) );
104  codec_->print(digi,output);
105  edm::LogInfo("HGCalTriggerDigiProducer")
106  << output.str();
107  codec_->unSetDataPayload();
108  output.str(std::string());
109  output.clear();
110  } //end loop on EE modules
111  for( const auto& module_hits : hit_modules_fh ) {
112  fe_output->push_back(l1t::HGCFETriggerDigi());
113  l1t::HGCFETriggerDigi& digi = fe_output->back();
114  codec_->setDataPayload(HGCEEDigiCollection(),module_hits.second,HGCHEDigiCollection());
115  codec_->encode(digi);
116  digi.setDetId( DetId(module_hits.first) );
117  codec_->print(digi,output);
118  edm::LogInfo("HGCalTriggerDigiProducer")
119  << output.str();
120  codec_->unSetDataPayload();
121  output.str(std::string());
122  output.clear();
123  } //end loop on FH modules
124 
125 
126  // get the orphan handle and fe digi collection
127  auto fe_digis_handle = e.put(std::move(fe_output));
128  auto fe_digis_coll = *fe_digis_handle;
129 
130  //now we run the emulation of the back-end processor
131  backEndProcessor_->reset();
132  backEndProcessor_->run(fe_digis_coll,es,e);
133  backEndProcessor_->putInEvent(e);
134 }
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:457
#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