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  // Scrap the trailing edge time for now -- until the front-end
18  // FPGA firmware is finalized and the description of the FPGA
19  // output becomes available
20  static const float timeFalling = HcalSpecialTimes::UNKNOWN_T_NOTDC;
21 
23 
25  coder.adc2fC(digi, cs);
26  const int nRead = cs.size();
27 
28  // Number of raw samples to store in HFQIE10Info
29  const int nStore = std::min(nRead, static_cast<int>(HFQIE10Info::N_RAW_MAX));
30 
31  if (sumAllTS_)
32  {
33  // This branch is intended for use with cosmic runs
34  double charge = 0.0, energy = 0.0;
36 
37  for (int ts=0; ts<nRead; ++ts)
38  {
39  const QIE10DataFrame::Sample s(digi[ts]);
40  const int capid = s.capid();
41  const float q = cs[ts] - calib.pedestal(capid);
42  charge += q;
43  energy += q*calib.respcorrgain(capid);
44  if (ts < nStore)
45  raw[ts] = s.wideRaw();
46  }
47 
48  // Timing measurement does not appear to be useful here
49  const float timeRising = HcalSpecialTimes::UNKNOWN_T_NOTDC;
50 
51  // The following HFQIE10Info arguments correspond to SOI
52  // not stored in the raw data. Essentially, only charge
53  // and energy are meaningful.
54  result = HFQIE10Info(digi.id(), charge, energy,
55  timeRising, timeFalling,
56  raw, nStore, nStore);
57  }
58  else if (0 <= tsToUse && tsToUse < nRead)
59  {
60  const QIE10DataFrame::Sample s(digi[tsToUse]);
61  const int capid = s.capid();
62  const float charge = cs[tsToUse] - calib.pedestal(capid);
63  const float energy = charge*calib.respcorrgain(capid);
64  const float timeRising = HcalSpecialTimes::getTDCTime(s.le_tdc());
65 
66  // Figure out the window in the raw data
67  // that we want to store. This window will
68  // have the width given by "nStore" and
69  // will start at "shift".
70  int shift = 0;
71  if (nRead > static_cast<int>(HFQIE10Info::N_RAW_MAX))
72  {
73  // Try to center the window on "tsToUse"
74  const int winCenter = nStore/2;
75  if (tsToUse > winCenter)
76  shift = tsToUse - winCenter;
77  if (shift + nStore > nRead)
78  shift = nRead - nStore;
79  }
80 
81  // Fill an array of raw values
83  for (int i=0; i<nStore; ++i)
84  raw[i] = digi[i + shift].wideRaw();
85 
86  result = HFQIE10Info(digi.id(), charge, energy,
87  timeRising, timeFalling,
88  raw, nStore, tsToUse - shift);
89  }
90  return result;
91 }
HFQIE10Info reconstruct(const QIE10DataFrame &digi, int tsToUse, const HcalCoder &coder, const HcalCalibrations &calibs) const
Definition: HFPreRecAlgo.cc:12
float getTDCTime(const int tdc)
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
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