CMS 3D CMS Logo

HGCalBestChoiceCodec.cc
Go to the documentation of this file.
2 #include <limits>
3 
4 using namespace HGCalTriggerFE;
5 
8  "HGCalBestChoiceCodec");
9 
10 /*****************************************************************/
12  codecImpl_(conf)
13 /*****************************************************************/
14 {
15 }
16 
17 
18 /*****************************************************************/
20  const HGCHEDigiCollection& fh,
21  const HGCBHDigiCollection& )
22 /*****************************************************************/
23 {
24  data_.reset();
25  std::vector<HGCDataFrame<DetId,HGCSample>> dataframes;
26  std::vector<std::pair<DetId, uint32_t > > linearized_dataframes;
27  // convert ee and fh hit collections into the same object
28  if(!ee.empty())
29  {
30  for(const auto& eedata : ee)
31  {
32  dataframes.emplace_back(eedata.id());
33  for(int i=0; i<eedata.size(); i++)
34  {
35  dataframes.back().setSample(i, eedata.sample(i));
36  }
37  }
38  }
39  else if(!fh.empty())
40  {
41  for(const auto& fhdata : fh)
42  {
43  dataframes.emplace_back(fhdata.id());
44  for(int i=0; i<fhdata.size(); i++)
45  {
46  dataframes.back().setSample(i, fhdata.sample(i));
47  }
48  }
49  }
50  // linearize input energy on 16 bits
51  codecImpl_.linearize(dataframes, linearized_dataframes);
52  // sum energy in trigger cells
53  codecImpl_.triggerCellSums(*geometry_, linearized_dataframes, data_);
54  // choose best trigger cells in the module
56 }
57 
58 /*****************************************************************/
60 /*****************************************************************/
61 {
62  data_.reset();
63  // decode input data with different parameters
64  // (no selection, so NData=number of trigger cells in module)
65  // FIXME:
66  // Not very clean to define an alternative codec within this codec
67  // Also, the codec is built each time the method is called, which is not very efficient
68  // This may need a restructuration of the FECodec
69  edm::ParameterSet conf;
70  conf.addParameter<std::string>("CodecName", name());
71  conf.addParameter<uint32_t> ("CodecIndex", getCodecType());
72  conf.addParameter<uint32_t> ("NData", HGCalBestChoiceCodec::data_type::size);
73  // The data length should be the same for input and output, which is limiting
74  conf.addParameter<uint32_t> ("DataLength", codecImpl_.dataLength());
75  conf.addParameter<double> ("linLSB", codecImpl_.linLSB());
76  conf.addParameter<double> ("adcsaturation", codecImpl_.adcsaturation());
77  conf.addParameter<uint32_t> ("adcnBits", codecImpl_.adcnBits());
78  conf.addParameter<double> ("tdcsaturation", codecImpl_.tdcsaturation());
79  conf.addParameter<uint32_t> ("tdcnBits", codecImpl_.tdcnBits());
80  conf.addParameter<double> ("tdcOnsetfC", codecImpl_.tdcOnsetfC());
81  conf.addParameter<uint32_t> ("triggerCellTruncationBits", codecImpl_.triggerCellTruncationBits());
82  HGCalBestChoiceCodec codecInput(conf);
83  codecInput.setGeometry(geometry_);
84  digi.decode(codecInput,data_);
85  // choose best trigger cells in the module
87 }
88 
89 
90 /*****************************************************************/
92 /*****************************************************************/
93 {
94  return codecImpl_.encode(data);
95 }
96 
97 /*****************************************************************/
98 HGCalBestChoiceCodec::data_type HGCalBestChoiceCodec::decodeImpl(const std::vector<bool>& data, const uint32_t) const
99 /*****************************************************************/
100 {
101  return codecImpl_.decode(data);
102 }
103 
104 
data_type decode(const std::vector< bool > &) const
std::vector< bool > encodeImpl(const data_type &) const
std::vector< bool > encode(const data_type &) const
void decode(const CODEC &codec, DATA &data) const
data_type decodeImpl(const std::vector< bool > &, const uint32_t) const
HGCalBestChoiceCodecImpl codecImpl_
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:144
const unsigned char getCodecType() const
const HGCalTriggerGeometryBase * geometry_
void triggerCellSums(const HGCalTriggerGeometryBase &, const std::vector< std::pair< DetId, uint32_t > > &, data_type &)
void linearize(const std::vector< HGCDataFrame< DetId, HGCSample >> &, std::vector< std::pair< DetId, uint32_t > > &)
uint32_t triggerCellTruncationBits() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const std::string & name() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setDataPayloadImpl(const HGCEEDigiCollection &ee, const HGCHEDigiCollection &fh, const HGCBHDigiCollection &bh)
HGCalBestChoiceCodec(const edm::ParameterSet &conf)