CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
HGCalTriggerCellThresholdCodecImpl Class Reference

#include <HGCalTriggerCellThresholdCodecImpl.h>

Public Types

typedef HGCalTriggerCellThresholdDataPayload data_type
 

Public Member Functions

uint32_t adcnBits () const
 
uint32_t adcnBitsBH () const
 
double adcsaturation () const
 
double adcsaturationBH () const
 
size_t dataLength () const
 
data_type decode (const std::vector< bool > &, const uint32_t, const HGCalTriggerGeometryBase &) const
 
std::vector< bool > encode (const data_type &, const HGCalTriggerGeometryBase &) const
 
 HGCalTriggerCellThresholdCodecImpl (const edm::ParameterSet &conf)
 
void linearize (const std::vector< HGCDataFrame< DetId, HGCSample >> &, std::vector< std::pair< DetId, uint32_t > > &)
 
double linLSB () const
 
uint32_t linnBits () const
 
size_t nCellsInModule () const
 
int TCThreshold_ADC () const
 
double TCThreshold_fC () const
 
int TCThresholdBH_ADC () const
 
double TCThresholdBH_MIP () const
 
uint32_t tdcnBits () const
 
double tdcOnsetfC () const
 
double tdcsaturation () const
 
const std::vector< double > & ThicknessCorrections () const
 
void thresholdSelect (data_type &)
 
uint32_t triggerCellSaturationBits () const
 
void triggerCellSums (const HGCalTriggerGeometryBase &, const std::vector< std::pair< DetId, uint32_t > > &, data_type &)
 
uint32_t triggerCellTruncationBits () const
 

Private Attributes

double adcLSB_
 
double adcLSBBH_
 
uint32_t adcnBits_
 
uint32_t adcnBitsBH_
 
double adcsaturation_
 
double adcsaturationBH_
 
size_t dataLength_
 
double linLSB_
 
uint32_t linMax_
 
uint32_t linnBits_
 
size_t nCellsInModule_
 
int TCThreshold_ADC_
 
double TCThreshold_fC_
 
int TCThresholdBH_ADC_
 
double TCThresholdBH_MIP_
 
double tdcLSB_
 
uint32_t tdcnBits_
 
double tdcOnsetfC_
 
double tdcsaturation_
 
std::vector< double > thickness_corrections_
 
uint32_t triggerCellSaturationBits_
 
uint32_t triggerCellTruncationBits_
 

Detailed Description

Definition at line 27 of file HGCalTriggerCellThresholdCodecImpl.h.

Member Typedef Documentation

Definition at line 30 of file HGCalTriggerCellThresholdCodecImpl.h.

Constructor & Destructor Documentation

HGCalTriggerCellThresholdCodecImpl::HGCalTriggerCellThresholdCodecImpl ( const edm::ParameterSet conf)

Definition at line 6 of file HGCalTriggerCellThresholdCodecImpl.cc.

References adcLSB_, adcLSBBH_, adcnBits_, adcnBitsBH_, adcsaturation_, adcsaturationBH_, dataLength_, encode(), createfilelist::int, linLSB_, linMax_, linnBits_, funct::pow(), TCThreshold_ADC_, TCThreshold_fC_, TCThresholdBH_ADC_, TCThresholdBH_MIP_, tdcLSB_, tdcnBits_, tdcsaturation_, triggerCellSaturationBits_, and triggerCellTruncationBits_.

6  :
7  dataLength_(conf.getParameter<uint32_t>("DataLength")),
8  nCellsInModule_(conf.getParameter<uint32_t>("MaxCellsInModule")),
9  linLSB_(conf.getParameter<double>("linLSB")),
10  linnBits_(conf.getParameter<uint32_t>("linnBits")),
11  adcsaturation_(conf.getParameter<double>("adcsaturation")),
12  adcnBits_(conf.getParameter<uint32_t>("adcnBits")),
13  tdcsaturation_(conf.getParameter<double>("tdcsaturation")),
14  tdcnBits_(conf.getParameter<uint32_t>("tdcnBits")),
15  tdcOnsetfC_(conf.getParameter<double>("tdcOnsetfC")),
16  adcsaturationBH_(conf.getParameter<double>("adcsaturationBH")),
17  adcnBitsBH_(conf.getParameter<uint32_t>("adcnBitsBH")),
18  triggerCellTruncationBits_(conf.getParameter<uint32_t>("triggerCellTruncationBits")),
19  TCThreshold_fC_(conf.getParameter<double>("TCThreshold_fC")),
20  TCThresholdBH_MIP_(conf.getParameter<double>("TCThresholdBH_MIP")),
21  thickness_corrections_(conf.getParameter<std::vector<double>>("ThicknessCorrections"))
22 {
26  linMax_ = (0x1<<linnBits_)-1;
30 }
T getParameter(std::string const &) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Function Documentation

uint32_t HGCalTriggerCellThresholdCodecImpl::adcnBits ( ) const
inline
uint32_t HGCalTriggerCellThresholdCodecImpl::adcnBitsBH ( ) const
inline
double HGCalTriggerCellThresholdCodecImpl::adcsaturation ( ) const
inline
double HGCalTriggerCellThresholdCodecImpl::adcsaturationBH ( ) const
inline
size_t HGCalTriggerCellThresholdCodecImpl::dataLength ( ) const
inline
HGCalTriggerCellThresholdCodecImpl::data_type HGCalTriggerCellThresholdCodecImpl::decode ( const std::vector< bool > &  data,
const uint32_t  module,
const HGCalTriggerGeometryBase geometry 
) const

Definition at line 98 of file HGCalTriggerCellThresholdCodecImpl.cc.

References dataLength_, PV3DBase< T, PVType, FrameType >::eta(), Exception, HGCalTriggerGeometryBase::getOrderedTriggerCellsFromModule(), HGCalTriggerGeometryBase::getTriggerCellPosition(), mps_fire::i, linearize(), nCellsInModule_, p4, HGCalTriggerCellThresholdDataPayload::payload, PV3DBase< T, PVType, FrameType >::phi(), point, HGCalTriggerCellThresholdDataPayload::reset(), and mps_fire::result.

Referenced by HGCalTriggerCellThresholdCodec::decodeImpl(), and encode().

99 {
101  result.reset();
102  // TODO: could eventually reserve result memory to the max size of trigger cells
103 
105  size_t iselected = 0;
106  size_t index = 0;
107  for(const auto& triggercell : trigger_cells_in_module)
108  {
109  if(index>=nCellsInModule_)
110  {
111  throw cms::Exception("BadGeometry")
112  << "Number of trigger cells in module too large for available data payload\n";
113  }
114  if(data[index])
115  {
116  uint32_t value = 0;
117  for(size_t i=0;i<dataLength_;i++)
118  {
119  size_t ibit = nCellsInModule_+iselected*dataLength_+i;
120  if(data[ibit]) value |= (0x1<<i);
121  }
122  iselected++;
123  // Build trigger cell
124  if(value>0)
125  {
126  // Currently no hardware eta, phi and quality values
127  result.payload.emplace_back(reco::LeafCandidate::LorentzVector(),
128  value, 0, 0, 0, triggercell);
129  GlobalPoint point = geometry.getTriggerCellPosition(triggercell);
130  // 'value' is hardware, so p4 is meaningless, except for eta and phi
131  math::PtEtaPhiMLorentzVector p4((double)value/cosh(point.eta()), point.eta(), point.phi(), 0.);
132  result.payload.back().setP4(p4);
133  result.payload.back().setPosition(point);
134  }
135  }
136  index++;
137  }
138  return result;
139 }
virtual geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned trigger_cell_det_id) const =0
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double p4[4]
Definition: TauolaWrapper.h:92
Definition: value.py:1
std::set< unsigned > geom_ordered_set
T eta() const
Definition: PV3DBase.h:76
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
HGCalTriggerCellThresholdDataPayload data_type
Definition: vlib.h:208
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const =0
std::vector< bool > HGCalTriggerCellThresholdCodecImpl::encode ( const data_type data,
const HGCalTriggerGeometryBase geometry 
) const

Definition at line 36 of file HGCalTriggerCellThresholdCodecImpl.cc.

References dataLength_, decode(), Exception, HGCalTriggerGeometryBase::getModuleFromTriggerCell(), HGCalTriggerGeometryBase::getOrderedTriggerCellsFromModule(), mps_fire::i, nCellsInModule_, HGCalTriggerCellThresholdDataPayload::payload, mps_fire::result, findQualityFiles::size, triggerCellSaturationBits_, and triggerCellTruncationBits_.

Referenced by HGCalTriggerCellThresholdCodec::encodeImpl(), and HGCalTriggerCellThresholdCodecImpl().

37 {
38  // First nCellsInModule_ bits are encoding the map of selected trigger cells
39  // Followed by size words of dataLength_ bits, corresponding to energy/transverse energy of
40  // the selected trigger cells
41 
42  // Convert payload into a map for later search
43  std::unordered_map<uint32_t, uint32_t> data_map; // (detid,energy)
44  size_t size=0;
45  for(const auto& triggercell : data.payload)
46  {
47  data_map.emplace(triggercell.detId(), triggercell.hwPt());
48  if (triggercell.hwPt()>0) size++;
49  }
50  std::vector<bool> result(nCellsInModule_ + dataLength_*size, false);
51  // No data: return vector of 0
52  if(data.payload.empty()) return result;
53  // All trigger cells are in the same module
54  // Loop on trigger cell ids in module and check if energy in the cell
55  size_t index = 0; // index in module
56  size_t idata = 0; // counter for the number of non-zero energy values
57  // Retrieve once the ordered list of trigger cells in this module
58  uint32_t module = geometry.getModuleFromTriggerCell(data.payload.begin()->detId());
59  HGCalTriggerGeometryBase::geom_ordered_set trigger_cells_in_module = geometry.getOrderedTriggerCellsFromModule(module);
60  for(const auto& triggercell_id : trigger_cells_in_module)
61  {
62  // Find if this trigger cell has data
63  const auto& data_itr = data_map.find(triggercell_id);
64  // if not data, increase index and skip
65  if(data_itr==data_map.end())
66  {
67  index++;
68  continue;
69  }
70  // else fill result vector with data
71  // (set the corresponding adress bit and fill energy if >0)
72  if(index>=nCellsInModule_)
73  {
74  throw cms::Exception("BadGeometry")
75  << "Number of trigger cells in module too large for available data payload\n";
76  }
77  uint32_t value = data_itr->second;
78  if(value>0)
79  {
80  // Set map bit to 1
81  result[index] = true;
82  // Saturate and truncate energy values
83  if(value+1>(0x1u<<triggerCellSaturationBits_)) value = (0x1<<triggerCellSaturationBits_)-1;
84  for(size_t i=0; i<dataLength_; i++)
85  {
86  // remove the lowest bits (=triggerCellTruncationBits_)
87  result[nCellsInModule_ + idata*dataLength_ + i] = static_cast<bool>(value & (0x1<<(i+triggerCellTruncationBits_)));
88  }
89  idata++;
90  }
91  index++;
92  }
93  return result;
94 }
size
Write out results.
virtual geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned trigger_cell_det_id) const =0
Definition: value.py:1
virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const =0
std::set< unsigned > geom_ordered_set
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Definition: vlib.h:208
void HGCalTriggerCellThresholdCodecImpl::linearize ( const std::vector< HGCDataFrame< DetId, HGCSample >> &  dataframes,
std::vector< std::pair< DetId, uint32_t > > &  linearized_dataframes 
)

Definition at line 144 of file HGCalTriggerCellThresholdCodecImpl.cc.

References adcLSB_, CustomPhysics_cfi::amplitude, data, DetId::Forward, DetId::Hcal, linLSB_, linMax_, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, tdcLSB_, tdcOnsetfC_, and triggerCellSums().

Referenced by decode(), and HGCalTriggerCellThresholdCodec::setDataPayloadImpl().

146 {
147  double amplitude = 0.;
148  uint32_t amplitude_int = 0;
149  const int kIntimeSample = 2;
150 
151  for(const auto& frame : dataframes) {//loop on DIGI
152  if(frame.id().det()==DetId::Forward) {
153  if (frame[kIntimeSample].mode()) {//TOT mode
154  amplitude =( floor(tdcOnsetfC_/adcLSB_) + 1.0 )* adcLSB_ + double(frame[kIntimeSample].data()) * tdcLSB_;
155  }
156  else {//ADC mode
157  amplitude = double(frame[kIntimeSample].data()) * adcLSB_;
158  }
159 
160  amplitude_int = uint32_t (floor(amplitude/linLSB_+0.5));
161  }
162  else if(frame.id().det()==DetId::Hcal) {
163  // no linearization here. Take the raw ADC data
164  amplitude_int = frame[kIntimeSample].data();
165  }
166  if (amplitude_int>linMax_) amplitude_int = linMax_;
167 
168  linearized_dataframes.push_back(std::make_pair (frame.id(), amplitude_int));
169  }
170 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double HGCalTriggerCellThresholdCodecImpl::linLSB ( ) const
inline
uint32_t HGCalTriggerCellThresholdCodecImpl::linnBits ( ) const
inline
size_t HGCalTriggerCellThresholdCodecImpl::nCellsInModule ( ) const
inline
int HGCalTriggerCellThresholdCodecImpl::TCThreshold_ADC ( ) const
inline
double HGCalTriggerCellThresholdCodecImpl::TCThreshold_fC ( ) const
inline
int HGCalTriggerCellThresholdCodecImpl::TCThresholdBH_ADC ( ) const
inline
double HGCalTriggerCellThresholdCodecImpl::TCThresholdBH_MIP ( ) const
inline
uint32_t HGCalTriggerCellThresholdCodecImpl::tdcnBits ( ) const
inline
double HGCalTriggerCellThresholdCodecImpl::tdcOnsetfC ( ) const
inline
double HGCalTriggerCellThresholdCodecImpl::tdcsaturation ( ) const
inline
const std::vector<double>& HGCalTriggerCellThresholdCodecImpl::ThicknessCorrections ( ) const
inline
void HGCalTriggerCellThresholdCodecImpl::thresholdSelect ( data_type data)
uint32_t HGCalTriggerCellThresholdCodecImpl::triggerCellSaturationBits ( ) const
inline
void HGCalTriggerCellThresholdCodecImpl::triggerCellSums ( const HGCalTriggerGeometryBase geometry,
const std::vector< std::pair< DetId, uint32_t > > &  linearized_dataframes,
data_type data 
)

Definition at line 175 of file HGCalTriggerCellThresholdCodecImpl.cc.

References HGCalTopology::dddConstants(), DetId::det(), HGCalTriggerGeometryBase::eeTopology(), HGCalTriggerGeometryBase::fhTopology(), DetId::Forward, HGCalTriggerGeometryBase::getModuleFromTriggerCell(), HGCalTriggerGeometryBase::getOrderedTriggerCellsFromModule(), HGCalTriggerGeometryBase::getTriggerCellFromCell(), HGCEE, HGCHEF, HGCalTriggerCellThresholdDataPayload::payload, jets_cff::payload, DetId::subdetId(), thickness_corrections_, thresholdSelect(), relativeConstraints::value, and HGCalDDDConstants::waferTypeL().

Referenced by linearize(), and HGCalTriggerCellThresholdCodec::setDataPayloadImpl().

176 {
177  if(linearized_dataframes.empty()) return;
178  std::map<HGCalDetId, uint32_t> payload;
179  // sum energies in trigger cells
180  for(const auto& frame : linearized_dataframes)
181  {
182  DetId cellid(frame.first);
183  // find trigger cell associated to cell
184  uint32_t tcid = geometry.getTriggerCellFromCell(cellid);
185  HGCalDetId triggercellid( tcid );
186  payload.insert( std::make_pair(triggercellid, 0) ); // do nothing if key exists already
187  uint32_t value = frame.second;
188  // equalize value among cell thicknesses
189  if(cellid.det()==DetId::Forward)
190  {
191  int thickness = 0;
192  switch(cellid.subdetId())
193  {
195  thickness = geometry.eeTopology().dddConstants().waferTypeL(HGCalDetId(cellid).wafer())-1;
196  break;
198  thickness = geometry.fhTopology().dddConstants().waferTypeL(HGCalDetId(cellid).wafer())-1;
199  break;
200  default:
201  break;
202  };
203  double thickness_correction = thickness_corrections_.at(thickness);
204  value = (double)value*thickness_correction;
205  }
206  payload[triggercellid] += value; // 32 bits integer should be largely enough
207 
208  }
209  uint32_t module = geometry.getModuleFromTriggerCell(payload.begin()->first);
210  HGCalTriggerGeometryBase::geom_ordered_set trigger_cells_in_module = geometry.getOrderedTriggerCellsFromModule(module);
211  // fill data payload
212  for(const auto& id_value : payload)
213  {
214  // Store only energy value and detid
215  // No need position here
216  data.payload.emplace_back(reco::LeafCandidate::LorentzVector(),
217  id_value.second, 0, 0, 0, id_value.first.rawId());
218  }
219 }
virtual geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned trigger_cell_det_id) const =0
const HGCalTopology & eeTopology() const
int waferTypeL(int wafer) const
Definition: value.py:1
Definition: DetId.h:18
virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const =0
const HGCalDDDConstants & dddConstants() const
std::set< unsigned > geom_ordered_set
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Definition: vlib.h:208
virtual unsigned getTriggerCellFromCell(const unsigned cell_det_id) const =0
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
const HGCalTopology & fhTopology() const
uint32_t HGCalTriggerCellThresholdCodecImpl::triggerCellTruncationBits ( ) const
inline

Member Data Documentation

double HGCalTriggerCellThresholdCodecImpl::adcLSB_
private
double HGCalTriggerCellThresholdCodecImpl::adcLSBBH_
private
uint32_t HGCalTriggerCellThresholdCodecImpl::adcnBits_
private
uint32_t HGCalTriggerCellThresholdCodecImpl::adcnBitsBH_
private
double HGCalTriggerCellThresholdCodecImpl::adcsaturation_
private
double HGCalTriggerCellThresholdCodecImpl::adcsaturationBH_
private
size_t HGCalTriggerCellThresholdCodecImpl::dataLength_
private
double HGCalTriggerCellThresholdCodecImpl::linLSB_
private
uint32_t HGCalTriggerCellThresholdCodecImpl::linMax_
private
uint32_t HGCalTriggerCellThresholdCodecImpl::linnBits_
private
size_t HGCalTriggerCellThresholdCodecImpl::nCellsInModule_
private

Definition at line 67 of file HGCalTriggerCellThresholdCodecImpl.h.

Referenced by decode(), and encode().

int HGCalTriggerCellThresholdCodecImpl::TCThreshold_ADC_
private
double HGCalTriggerCellThresholdCodecImpl::TCThreshold_fC_
private
int HGCalTriggerCellThresholdCodecImpl::TCThresholdBH_ADC_
private
double HGCalTriggerCellThresholdCodecImpl::TCThresholdBH_MIP_
private
double HGCalTriggerCellThresholdCodecImpl::tdcLSB_
private
uint32_t HGCalTriggerCellThresholdCodecImpl::tdcnBits_
private
double HGCalTriggerCellThresholdCodecImpl::tdcOnsetfC_
private

Definition at line 75 of file HGCalTriggerCellThresholdCodecImpl.h.

Referenced by linearize().

double HGCalTriggerCellThresholdCodecImpl::tdcsaturation_
private
std::vector<double> HGCalTriggerCellThresholdCodecImpl::thickness_corrections_
private

Definition at line 87 of file HGCalTriggerCellThresholdCodecImpl.h.

Referenced by triggerCellSums().

uint32_t HGCalTriggerCellThresholdCodecImpl::triggerCellSaturationBits_
private
uint32_t HGCalTriggerCellThresholdCodecImpl::triggerCellTruncationBits_
private