CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCalTriggerDigiProducer.cc
Go to the documentation of this file.
3 
6 
10 
14 
15 #include <sstream>
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
30  // algorithm containers
31  std::unique_ptr<HGCalTriggerGeometryBase> triggerGeometry_;
32  std::unique_ptr<HGCalTriggerFECodecBase> codec_;
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"))),
43  backEndProcessor_(conf.getParameterSet("BEConfiguration")) {
44 
45  //setup geometry configuration
46  const edm::ParameterSet& geometryConfig =
47  conf.getParameterSet("TriggerGeometry");
48  const std::string& trigGeomName =
49  geometryConfig.getParameter<std::string>("TriggerGeometryName");
51  HGCalTriggerGeometryFactory::get()->create(trigGeomName,geometryConfig);
52  triggerGeometry_.reset(geometry);
53 
54  //setup FE codec
55  const edm::ParameterSet& feCodecConfig =
56  conf.getParameterSet("FECodec");
57  const std::string& feCodecName =
58  feCodecConfig.getParameter<std::string>("CodecName");
60  HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig);
61  codec_.reset(codec);
62  codec_->unSetDataPayload();
63 
64  produces<l1t::HGCFETriggerDigiCollection>();
65  // register backend processor products
67 }
68 
70  const edm::EventSetup& es) {
71  triggerGeometry_->reset();
73  const std::string& ee_sd_name = triggerGeometry_->eeSDName();
74  const std::string& fh_sd_name = triggerGeometry_->fhSDName();
75  const std::string& bh_sd_name = triggerGeometry_->bhSDName();
76  es.get<IdealGeometryRecord>().get(ee_sd_name,info.geom_ee);
77  es.get<IdealGeometryRecord>().get(fh_sd_name,info.geom_fh);
78  es.get<IdealGeometryRecord>().get(bh_sd_name,info.geom_bh);
79  es.get<IdealGeometryRecord>().get(ee_sd_name,info.topo_ee);
80  es.get<IdealGeometryRecord>().get(fh_sd_name,info.topo_fh);
81  es.get<IdealGeometryRecord>().get(bh_sd_name,info.topo_bh);
82  triggerGeometry_->initialize(info);
83 }
84 
86  std::unique_ptr<l1t::HGCFETriggerDigiCollection>
87  fe_output( new l1t::HGCFETriggerDigiCollection );
88 
90  edm::Handle<HGCHEDigiCollection> fh_digis_h, bh_digis_h;
91 
92  e.getByToken(inputee_,ee_digis_h);
93  e.getByToken(inputfh_,fh_digis_h);
94  //e.getByToken(inputbh_,bh_digis_h);
95 
96  const HGCEEDigiCollection& ee_digis = *ee_digis_h;
97  const HGCHEDigiCollection& fh_digis = *fh_digis_h;
98  //const HGCHEDigiCollection& bh_digis = *bh_digis_h;
99 
100  // First find modules containing hits and prepare list of hits for each module
101  std::unordered_map<uint32_t, HGCEEDigiCollection> hit_modules_ee;
102  for(const auto& eedata : ee_digis) {
103  uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id());
104  auto itr_insert = hit_modules_ee.emplace(module,HGCEEDigiCollection());
105  itr_insert.first->second.push_back(eedata);
106  }
107  std::unordered_map<uint32_t,HGCHEDigiCollection> hit_modules_fh;
108  for(const auto& fhdata : fh_digis) {
109  uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id());
110  auto itr_insert = hit_modules_fh.emplace(module, HGCHEDigiCollection());
111  itr_insert.first->second.push_back(fhdata);
112  }
113  // loop on modules containing hits and call front-end processing
114  // we produce one output trigger digi per module in the FE
115  fe_output->reserve(hit_modules_ee.size() + hit_modules_fh.size());
116  std::stringstream output;
117  for( const auto& module_hits : hit_modules_ee ) {
118  fe_output->push_back(l1t::HGCFETriggerDigi());
119  l1t::HGCFETriggerDigi& digi = fe_output->back();
120  codec_->setDataPayload(*triggerGeometry_, module_hits.second,HGCHEDigiCollection(),HGCHEDigiCollection());
121  codec_->encode(digi);
122  digi.setDetId( DetId(module_hits.first) );
123  codec_->print(digi,output);
124  edm::LogInfo("HGCalTriggerDigiProducer")
125  << output.str();
126  codec_->unSetDataPayload();
127  output.str(std::string());
128  output.clear();
129  } //end loop on EE modules
130  for( const auto& module_hits : hit_modules_fh ) {
131  fe_output->push_back(l1t::HGCFETriggerDigi());
132  l1t::HGCFETriggerDigi& digi = fe_output->back();
133  codec_->setDataPayload(*triggerGeometry_,HGCEEDigiCollection(),module_hits.second,HGCHEDigiCollection());
134  codec_->encode(digi);
135  digi.setDetId( DetId(module_hits.first) );
136  codec_->print(digi,output);
137  edm::LogInfo("HGCalTriggerDigiProducer")
138  << output.str();
139  codec_->unSetDataPayload();
140  output.str(std::string());
141  output.clear();
142  } //end loop on FH modules
143 
144 
145  // get the orphan handle and fe digi collection
146  auto fe_digis_handle = e.put(std::move(fe_output));
147  auto fe_digis_coll = *fe_digis_handle;
148 
149  //now we run the emulation of the back-end processor
150  backEndProcessor_.run(fe_digis_coll,triggerGeometry_);
153 }
T getParameter(std::string const &) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
HGCalTriggerBackendProcessor backEndProcessor_
std::unique_ptr< HGCalTriggerGeometryBase > triggerGeometry_
static const TGPicture * info(bool iBackgroundIsBlack)
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
edm::ESHandle< HGCalTopology > topo_ee
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ParameterSet const & getParameterSet(ParameterSetID const &id)
edm::ESHandle< HGCalGeometry > geom_bh
std::unique_ptr< HGCalTriggerFECodecBase > codec_
virtual void produce(edm::Event &, const edm::EventSetup &)
void setDetId(const IDTYPE &id)
edm::ESHandle< HGCalGeometry > geom_ee
def move
Definition: eostools.py:510
void run(const l1t::HGCFETriggerDigiCollection &coll, const std::unique_ptr< HGCalTriggerGeometryBase > &geom)
edm::ESHandle< HGCalGeometry > geom_fh
edm::ESHandle< HGCalTopology > topo_bh
HGCalTriggerDigiProducer(const edm::ParameterSet &)
void setProduces(edm::EDProducer &prod) const
edm::ESHandle< HGCalTopology > topo_fh
Definition: DetId.h:18
ParameterSet const & getParameterSet(std::string const &) const
const T & get() const
Definition: EventSetup.h:56
ESHandle< TrackerGeometry > geometry
Definition: vlib.h:208
edm::SortedCollection< HGCHEDataFrame > HGCHEDigiCollection
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:42