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 int kInTimeBX = 9
 
constexpr int kNumberOfBX = 15
 
constexpr size_t nSamples = 15
 
constexpr float PREMIX_MAX_TOF = 25.0f
 

Typedef Documentation

◆ MTDSimData_t

Definition at line 13 of file MTDDigitizerTypes.h.

◆ MTDSimHitData

Definition at line 15 of file MTDDigitizerTypes.h.

◆ MTDSimHitDataAccumulator

Definition at line 39 of file MTDDigitizerTypes.h.

Function Documentation

◆ loadSimHitAccumulator()

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

Definition at line 92 of file MTDDigitizer.h.

References newFWLiteAna::base, PMTDSimAccumulator::Data::dataMask, PMTDSimAccumulator::Data::energyMask, Exception, dqm-mbProfile::log, PREMIX_MAX_TOF, PMTDSimAccumulator::Data::sampleMask, logintpack::unpack16log(), and relativeConstraints::value.

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

95  {
96  const float minPackChargeLog = minCharge > 0.f ? std::log(minCharge) : -2;
97  const float maxPackChargeLog = std::log(maxCharge);
98  constexpr uint16_t base = PMTDSimAccumulator::Data::dataMask;
99 
100  for (const auto& detIdIndexHitInfo : simAccumulator) {
101  auto foo = simData.emplace(
102  MTDCellId(detIdIndexHitInfo.detId(), detIdIndexHitInfo.row(), detIdIndexHitInfo.column()), MTDCellInfo());
103  auto simIt = foo.first;
104  auto& hit_info = simIt->second.hit_info;
105 
106  size_t iEn = detIdIndexHitInfo.energyIndex();
107  size_t iSample = detIdIndexHitInfo.sampleIndex();
108 
110  throw cms::Exception("MTDDigitixer::loadSimHitAccumulator")
111  << "Index out of range: iEn = " << iEn << " iSample = " << iSample << std::endl;
112 
113  float value;
114  if (iEn == 1 || iEn == 3) {
115  value = static_cast<float>(detIdIndexHitInfo.data()) / base * PREMIX_MAX_TOF;
116  } else {
117  value = logintpack::unpack16log(detIdIndexHitInfo.data(), minPackChargeLog, maxPackChargeLog, base);
118  }
119 
120  if (iEn == 0 || iEn == 2) {
121  hit_info[iEn][iSample] += value;
122  } else if (hit_info[iEn][iSample] == 0 || value < hit_info[iEn][iSample]) {
123  // For iEn==1 the digitizers just set the TOF of the first SimHit
124  hit_info[iEn][iSample] = value;
125  }
126  }
127  }
static constexpr unsigned energyMask
base
Main Program
Definition: newFWLiteAna.py:92
double unpack16log(int16_t i, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:62
constexpr float PREMIX_MAX_TOF
Definition: value.py:1
static constexpr unsigned dataMask
static constexpr unsigned sampleMask

◆ saveSimHitAccumulator()

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 newFWLiteAna::base, PMTDSimAccumulator::Data::dataMask, PMTDSimAccumulator::emplace_back(), PMTDSimAccumulator::Data::energyMask, dqm-mbProfile::log, nSamples, logintpack::pack16log(), PREMIX_MAX_TOF, PMTDSimAccumulator::reserve(), PMTDSimAccumulator::Data::sampleMask, EgammaValidation_cff::samples, and relativeConstraints::value.

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

59  {
60  constexpr auto nEnergies = std::tuple_size<decltype(MTDCellInfo().hit_info)>::value;
61  static_assert(nEnergies == PMTDSimAccumulator::Data::energyMask + 1,
62  "PMTDSimAccumulator bit pattern needs to be updated");
64  "PMTDSimAccumulator bit pattern needs to be updated");
65 
66  const float minPackChargeLog = minCharge > 0.f ? std::log(minCharge) : -2;
67  const float maxPackChargeLog = std::log(maxCharge);
68  constexpr uint16_t base = PMTDSimAccumulator::Data::dataMask;
69 
70  simResult.reserve(simData.size());
71  // mimicking the digitization
72  for (const auto& elem : simData) {
73  // store only non-zero
74  for (size_t iEn = 0; iEn < nEnergies; ++iEn) {
75  const auto& samples = elem.second.hit_info[iEn];
76  for (size_t iSample = 0; iSample < nSamples; ++iSample) {
77  if (samples[iSample] > minCharge) {
78  unsigned short packed;
79  if (iEn == 1 || iEn == 3) {
80  // assuming linear range for tof of 0..25
81  packed = samples[iSample] / PREMIX_MAX_TOF * base;
82  } else {
83  packed = logintpack::pack16log(samples[iSample], minPackChargeLog, maxPackChargeLog, base);
84  }
85  simResult.emplace_back(elem.first.detid_, elem.first.row_, elem.first.column_, iEn, iSample, packed);
86  }
87  }
88  }
89  }
90  }
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)
base
Main Program
Definition: newFWLiteAna.py:92
constexpr float PREMIX_MAX_TOF
static constexpr unsigned dataMask
static constexpr unsigned sampleMask
int16_t pack16log(double x, double lmin, double lmax, uint16_t base=32768)
Definition: liblogintpack.h:27

Variable Documentation

◆ kInTimeBX

constexpr int mtd_digitizer::kInTimeBX = 9

Definition at line 42 of file MTDDigitizerTypes.h.

Referenced by BTLDeviceSim::getHitsResponse(), and BTLElectronicsSim::run().

◆ kNumberOfBX

constexpr int mtd_digitizer::kNumberOfBX = 15

Definition at line 41 of file MTDDigitizerTypes.h.

Referenced by BTLDeviceSim::getHitsResponse().

◆ nSamples

constexpr size_t mtd_digitizer::nSamples = 15

Definition at line 11 of file MTDDigitizerTypes.h.

Referenced by saveSimHitAccumulator().

◆ PREMIX_MAX_TOF

constexpr float mtd_digitizer::PREMIX_MAX_TOF = 25.0f

Definition at line 24 of file MTDDigitizerTypes.h.

Referenced by loadSimHitAccumulator(), and saveSimHitAccumulator().