CMS 3D CMS Logo

SimpleElectronicsSimInMIPs.cc
Go to the documentation of this file.
2 
4 
5 using namespace ftl;
6 
8  : debug_(pset.getUntrackedParameter<bool>("debug", false)),
9  adcNbits_(pset.getParameter<uint32_t>("adcNbits")),
10  tdcNbits_(pset.getParameter<uint32_t>("tdcNbits")),
11  adcSaturation_MIP_(pset.getParameter<double>("adcSaturation_MIP")),
12  adcLSB_MIP_(adcSaturation_MIP_ / std::pow(2., adcNbits_)),
13  adcThreshold_MIP_(pset.getParameter<double>("adcThreshold_MIP")),
14  toaLSB_ns_(pset.getParameter<double>("toaLSB_ns")) {}
15 
17  FTLSimHitData chargeColl, toa;
18 
19  for (FTLSimHitDataAccumulator::const_iterator it = input.begin(); it != input.end(); it++) {
20  chargeColl.fill(0.f);
21  toa.fill(0.f);
22  for (size_t i = 0; i < it->second.hit_info[0].size(); i++) {
23  //time of arrival
24  float finalToA = (it->second).hit_info[1][i];
25  while (finalToA < 0.f)
26  finalToA += 25.f;
27  while (finalToA > 25.f)
28  finalToA -= 25.f;
29  toa[i] = finalToA;
30 
31  // collected charge (in this case in MIPs)
32  chargeColl[i] = (it->second).hit_info[0][i];
33  }
34 
35  //run the shaper to create a new data frame
36  FTLDataFrame rawDataFrame(it->first);
37  runTrivialShaper(rawDataFrame, chargeColl, toa);
38  updateOutput(output, rawDataFrame);
39  }
40 }
41 
43  const ftl::FTLSimHitData& chargeColl,
44  const ftl::FTLSimHitData& toa) const {
45  bool debug = debug_;
46 #ifdef EDM_ML_DEBUG
47  for (int it = 0; it < (int)(chargeColl.size()); it++)
48  debug |= (chargeColl[it] > adcThreshold_fC_);
49 #endif
50 
51  if (debug)
52  edm::LogVerbatim("FTLSimpleElectronicsSimInMIPs") << "[runTrivialShaper]" << std::endl;
53 
54  //set new ADCs
55  for (int it = 0; it < (int)(chargeColl.size()); it++) {
56  //brute force saturation, maybe could to better with an exponential like saturation
57  const uint32_t adc = std::floor(std::min(chargeColl[it], adcSaturation_MIP_) / adcLSB_MIP_);
58  const uint32_t tdc_time = std::floor(toa[it] / toaLSB_ns_);
59  FTLSample newSample;
60  newSample.set(chargeColl[it] > adcThreshold_MIP_, false, tdc_time, adc);
61  dataFrame.setSample(it, newSample);
62 
63  if (debug)
64  edm::LogVerbatim("FTLSimpleElectronicsSimInMIPs") << adc << " (" << chargeColl[it] << "/" << adcLSB_MIP_ << ") ";
65  }
66 
67  if (debug) {
68  std::ostringstream msg;
69  dataFrame.print(msg);
70  edm::LogVerbatim("FTLSimpleElectronicsSimInMIPs") << msg.str() << std::endl;
71  }
72 }
73 
75  int itIdx(9);
76  if (rawDataFrame.size() <= itIdx + 2)
77  return;
78 
79  FTLDataFrame dataFrame(rawDataFrame.id());
80  dataFrame.resize(5);
81  bool putInEvent(false);
82  for (int it = 0; it < 5; ++it) {
83  dataFrame.setSample(it, rawDataFrame[itIdx - 2 + it]);
84  if (it == 2)
85  putInEvent = rawDataFrame[itIdx - 2 + it].threshold();
86  }
87 
88  if (putInEvent) {
89  coll.push_back(dataFrame);
90  }
91 }
void push_back(T const &t)
int size() const
total number of samples in the digi
Definition: FTLDataFrameT.h:46
wrapper for a data word
Definition: FTLSample.h:13
static std::string const input
Definition: EdmProvDump.cc:48
std::unordered_map< uint32_t, FTLCellInfo > FTLSimHitDataAccumulator
void run(const ftl::FTLSimHitDataAccumulator &input, FTLDigiCollection &output) const
void resize(size_t s)
allow to set size
Definition: FTLDataFrameT.h:51
double f[11][100]
void setSample(int i, const S &sample)
Definition: FTLDataFrameT.h:58
void updateOutput(FTLDigiCollection &coll, const FTLDataFrame &rawDataFrame) const
T min(T a, T b)
Definition: MathUtil.h:58
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
#define debug
Definition: HDRShower.cc:19
JetCorrectorParametersCollection coll
Definition: classes.h:10
tuple msg
Definition: mps_check.py:285
std::array< FTLSimData_t, nSamples > FTLSimHitData
void runTrivialShaper(FTLDataFrame &dataFrame, const ftl::FTLSimHitData &chargeColl, const ftl::FTLSimHitData &toa) const
Readout digi for HGC.
Definition: FTLDataFrameT.h:14
void print(std::ostream &out=std::cout)
Definition: FTLDataFrameT.h:62
void set(bool thr, bool mode, uint16_t toa, uint16_t data)
Definition: FTLSample.h:32
SimpleElectronicsSimInMIPs(const edm::ParameterSet &pset)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const D & id() const
det id
Definition: FTLDataFrameT.h:31