CMS 3D CMS Logo

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