CMS 3D CMS Logo

HFPreRecAlgo.cc
Go to the documentation of this file.
1 #include <algorithm>
2 
4 
7 
11 
13  const int tsToUse,
14  const HcalCoder& coder,
15  const HcalCalibrations& calib) const
16 {
17  // Conversion from TDC to ns for the QIE10 chip
18  static const float qie10_tdc_to_ns = 0.5f;
19 
20  // TDC values produced in case the pulse is always above/below
21  // the discriminator
22  static const int qie10_tdc_code_overshoot = 62;
23  static const int qie10_tdc_code_undershoot = 63;
24 
25  // Scrap the trailing edge time for now -- until the front-end
26  // FPGA firmware is finalized and the description of the FPGA
27  // output becomes available
28  static const float timeFalling = HcalSpecialTimes::UNKNOWN_T_NOTDC;
29 
31 
33  coder.adc2fC(digi, cs);
34  const int nRead = cs.size();
35 
36  // Number of raw samples to store in HFQIE10Info
37  const int nStore = std::min(nRead, static_cast<int>(HFQIE10Info::N_RAW_MAX));
38 
39  if (sumAllTS_)
40  {
41  // This branch is intended for use with cosmic runs
42  double charge = 0.0, energy = 0.0;
44 
45  for (int ts=0; ts<nRead; ++ts)
46  {
47  const QIE10DataFrame::Sample s(digi[ts]);
48  const int capid = s.capid();
49  const float q = cs[ts] - calib.pedestal(capid);
50  charge += q;
51  energy += q*calib.respcorrgain(capid);
52  if (ts < nStore)
53  raw[ts] = s.wideRaw();
54  }
55 
56  // Timing measurement does not appear to be useful here
57  const float timeRising = HcalSpecialTimes::UNKNOWN_T_NOTDC;
58 
59  // The following HFQIE10Info arguments correspond to SOI
60  // not stored in the raw data. Essentially, only charge
61  // and energy are meaningful.
62  result = HFQIE10Info(digi.id(), charge, energy,
63  timeRising, timeFalling,
64  raw, nStore, nStore);
65  }
66  else if (0 <= tsToUse && tsToUse < nRead)
67  {
68  const QIE10DataFrame::Sample s(digi[tsToUse]);
69  const int capid = s.capid();
70  const float charge = cs[tsToUse] - calib.pedestal(capid);
71  const float energy = charge*calib.respcorrgain(capid);
72 
73  const int tdc = s.le_tdc();
74  float timeRising = qie10_tdc_to_ns*tdc;
75  if (tdc == qie10_tdc_code_overshoot)
77  else if (tdc == qie10_tdc_code_undershoot)
79 
80  // Figure out the window in the raw data
81  // that we want to store. This window will
82  // have the width given by "nStore" and
83  // will start at "shift".
84  int shift = 0;
85  if (nRead > static_cast<int>(HFQIE10Info::N_RAW_MAX))
86  {
87  // Try to center the window on "tsToUse"
88  const int winCenter = nStore/2;
89  if (tsToUse > winCenter)
90  shift = tsToUse - winCenter;
91  if (shift + nStore > nRead)
92  shift = nRead - nStore;
93  }
94 
95  // Fill an array of raw values
97  for (int i=0; i<nStore; ++i)
98  raw[i] = digi[i + shift].wideRaw();
99 
100  result = HFQIE10Info(digi.id(), charge, energy,
101  timeRising, timeFalling,
102  raw, nStore, tsToUse - shift);
103  }
104  return result;
105 }
HFQIE10Info reconstruct(const QIE10DataFrame &digi, int tsToUse, const HcalCoder &coder, const HcalCalibrations &calibs) const
Definition: HFPreRecAlgo.cc:12
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
auto_ptr< ClusterSequence > cs
edm::DataFrame::id_type id() const
double pedestal(int fCapId) const
get pedestal for capid=0..3
constexpr float UNKNOWN_T_UNDERSHOOT
constexpr float UNKNOWN_T_OVERSHOOT
wide_type wideRaw() const
T min(T a, T b)
Definition: MathUtil.h:58
QIE10DataFrame::Sample::wide_type raw_type
Definition: HFQIE10Info.h:19
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
int size() const
get the size
Definition: CaloSamples.h:24
constexpr float UNKNOWN_T_NOTDC
static unsigned int const shift
static const unsigned N_RAW_MAX
Definition: HFQIE10Info.h:21