CMS 3D CMS Logo

Namespaces | Classes | Typedefs | Functions | Variables
mtd_digitizer Namespace Reference

Namespaces

 MTDHelpers
 

Classes

struct  MTDCellId
 
struct  MTDCellInfo
 
class  MTDDigitizer
 

Typedefs

typedef float MTDSimData_t
 
typedef std::array< MTDSimData_t, nSamplesMTDSimHitData
 
typedef std::unordered_map< MTDCellId, MTDCellInfoMTDSimHitDataAccumulator
 

Functions

void loadSimHitAccumulator (MTDSimHitDataAccumulator &simData, const PMTDSimAccumulator &simAccumulator, const float minCharge, const float maxCharge)
 
void saveSimHitAccumulator (PMTDSimAccumulator &simResult, const MTDSimHitDataAccumulator &simData, const float minCharge, const float maxCharge)
 

Variables

constexpr size_t nSamples = 15
 
constexpr float PREMIX_MAX_TOF = 26.0f
 

Typedef Documentation

Definition at line 13 of file MTDDigitizerTypes.h.

Definition at line 15 of file MTDDigitizerTypes.h.

Definition at line 38 of file MTDDigitizerTypes.h.

Function Documentation

void mtd_digitizer::loadSimHitAccumulator ( MTDSimHitDataAccumulator simData,
const PMTDSimAccumulator simAccumulator,
const float  minCharge,
const float  maxCharge 
)
inline

Definition at line 90 of file MTDDigitizer.h.

References runEdmFileComparison::base, constexpr, cmsBatch::log, PREMIX_MAX_TOF, PMTDSimAccumulator::Data::sampleOffset, logintpack::unpack16log(), and relativeConstraints::value.

Referenced by HGCDigitizer::accumulate(), and mtd_digitizer::MTDDigitizer< Traits >::accumulate().

90  {
91  const float minPackChargeLog = minCharge > 0.f ? std::log(minCharge) : -2;
92  const float maxPackChargeLog = std::log(maxCharge);
94 
95  for(const auto& detIdIndexHitInfo: simAccumulator) {
96  auto foo = simData.emplace(MTDCellId(detIdIndexHitInfo.detId(), detIdIndexHitInfo.row(), detIdIndexHitInfo.column()),
97  MTDCellInfo());
98  auto simIt = foo.first;
99  auto& hit_info = simIt->second.hit_info;
100 
101  size_t iEn = detIdIndexHitInfo.energyIndex();
102  size_t iSample = detIdIndexHitInfo.sampleIndex();
103 
104  float value;
105  if(iEn == 1) {
106  value = static_cast<float>(detIdIndexHitInfo.data())/base*PREMIX_MAX_TOF;
107  }
108  else {
109  value = logintpack::unpack16log(detIdIndexHitInfo.data(), minPackChargeLog, maxPackChargeLog, base);
110  }
111 
112  if(iEn == 0) {
113  hit_info[iEn][iSample] += value;
114  }
115  else if(hit_info[iEn][iSample] == 0) {
116  // For iEn==1 the digitizers just set the TOF of the first SimHit
117  hit_info[iEn][iSample] = value;
118  }
119  }
120  }
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:55
constexpr float PREMIX_MAX_TOF
base
Make Sure CMSSW is Setup ##.
static constexpr unsigned sampleOffset
#define constexpr
void mtd_digitizer::saveSimHitAccumulator ( PMTDSimAccumulator simResult,
const MTDSimHitDataAccumulator simData,
const float  minCharge,
const float  maxCharge 
)
inline

Definition at line 56 of file MTDDigitizer.h.

References runEdmFileComparison::base, constexpr, HTMLExport::elem(), PMTDSimAccumulator::emplace_back(), PMTDSimAccumulator::Data::energyMask, cmsBatch::log, nSamples, logintpack::pack16log(), PREMIX_MAX_TOF, PMTDSimAccumulator::reserve(), PMTDSimAccumulator::Data::sampleMask, PMTDSimAccumulator::Data::sampleOffset, hcalTTPDigis_cfi::samples, and relativeConstraints::value.

Referenced by HGCDigitizer::finalizeEvent(), and mtd_digitizer::MTDDigitizer< Traits >::finalizeEvent().

56  {
57  constexpr auto nEnergies = std::tuple_size<decltype(MTDCellInfo().hit_info)>::value;
58  static_assert(nEnergies <= PMTDSimAccumulator::Data::energyMask+1, "PMTDSimAccumulator bit pattern needs to updated");
59  static_assert(nSamples <= PMTDSimAccumulator::Data::sampleMask+1, "PMTDSimAccumulator bit pattern needs to updated");
60 
61  const float minPackChargeLog = minCharge > 0.f ? std::log(minCharge) : -2;
62  const float maxPackChargeLog = std::log(maxCharge);
64 
65  simResult.reserve(simData.size());
66  // mimicing the digitization
67  for(const auto& elem: simData) {
68  // store only non-zero
69  for(size_t iEn = 0; iEn < nEnergies; ++iEn) {
70  const auto& samples = elem.second.hit_info[iEn];
71  for(size_t iSample = 0; iSample < nSamples; ++iSample) {
72  if(samples[iSample] > minCharge) {
73  unsigned short packed;
74  if(iEn == 1) {
75  // assuming linear range for tof of 0..26
76  packed = samples[iSample]/PREMIX_MAX_TOF * base;
77  }
78  else {
79  packed = logintpack::pack16log(samples[iSample], minPackChargeLog, maxPackChargeLog, base);
80  }
81  simResult.emplace_back(elem.first.detid_, elem.first.row_, elem.first.column_,
82  iEn, iSample, packed);
83  }
84  }
85  }
86  }
87  }
static constexpr unsigned energyMask
void emplace_back(unsigned int detId, unsigned char row, unsigned char column, unsigned short energyIndex, unsigned short sampleIndex, unsigned short data)
void reserve(size_t size)
constexpr float PREMIX_MAX_TOF
base
Make Sure CMSSW is Setup ##.
constexpr size_t nSamples
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
static constexpr unsigned sampleMask
static constexpr unsigned sampleOffset
int16_t pack16log(double x, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:26
#define constexpr

Variable Documentation

constexpr size_t mtd_digitizer::nSamples = 15

Definition at line 11 of file MTDDigitizerTypes.h.

Referenced by saveSimHitAccumulator().

constexpr float mtd_digitizer::PREMIX_MAX_TOF = 26.0f

Definition at line 23 of file MTDDigitizerTypes.h.

Referenced by loadSimHitAccumulator(), and saveSimHitAccumulator().