Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:49

0001 #include <algorithm>
0002 
0003 #include "RecoLocalCalo/HcalRecAlgos/interface/HFPreRecAlgo.h"
0004 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalChannelProperties.h"
0005 
0006 #include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
0007 #include "DataFormats/HcalRecHit/interface/HcalSpecialTimes.h"
0008 
0009 #include "CalibFormats/HcalObjects/interface/HcalCoder.h"
0010 #include "CalibFormats/CaloObjects/interface/CaloSamples.h"
0011 
0012 HFQIE10Info HFPreRecAlgo::reconstruct(const QIE10DataFrame& digi,
0013                                       const int tsToUse,
0014                                       const HcalCoder& coder,
0015                                       const HcalChannelProperties& properties) const {
0016   // Scrap the trailing edge time for now -- until the front-end
0017   // FPGA firmware is finalized and the description of the FPGA
0018   // output becomes available
0019   static const float timeFalling = HcalSpecialTimes::UNKNOWN_T_NOTDC;
0020 
0021   HFQIE10Info result;
0022 
0023   CaloSamples cs;
0024   coder.adc2fC(digi, cs);
0025   const int nRead = cs.size();
0026 
0027   // Number of raw samples to store in HFQIE10Info
0028   const int nStore = std::min(nRead, static_cast<int>(HFQIE10Info::N_RAW_MAX));
0029 
0030   if (sumAllTS_) {
0031     // This branch is intended for use with cosmic runs
0032     double charge = 0.0, energy = 0.0;
0033     HFQIE10Info::raw_type raw[HFQIE10Info::N_RAW_MAX];
0034 
0035     for (int ts = 0; ts < nRead; ++ts) {
0036       const QIE10DataFrame::Sample s(digi[ts]);
0037       const int capid = s.capid();
0038       const HcalPipelinePedestalAndGain& pAndGain(properties.pedsAndGains.at(capid));
0039       const float q = cs[ts] - pAndGain.pedestal(false);
0040       charge += q;
0041       energy += q * pAndGain.gain();
0042       if (ts < nStore)
0043         raw[ts] = s.wideRaw();
0044     }
0045 
0046     // Timing measurement does not appear to be useful here
0047     const float timeRising = HcalSpecialTimes::UNKNOWN_T_NOTDC;
0048 
0049     // The following HFQIE10Info arguments correspond to SOI
0050     // not stored in the raw data. Essentially, only charge
0051     // and energy are meaningful.
0052     result = HFQIE10Info(digi.id(), charge, energy, timeRising, timeFalling, raw, nStore, nStore);
0053   } else if (0 <= tsToUse && tsToUse < nRead) {
0054     const QIE10DataFrame::Sample s(digi[tsToUse]);
0055     const int capid = s.capid();
0056     const HcalPipelinePedestalAndGain& pAndGain(properties.pedsAndGains.at(capid));
0057     const float charge = cs[tsToUse] - pAndGain.pedestal(false);
0058     const float energy = charge * pAndGain.gain();
0059     const float timeRising = HcalSpecialTimes::getTDCTime(s.le_tdc());
0060 
0061     // Figure out the window in the raw data
0062     // that we want to store. This window will
0063     // have the width given by "nStore" and
0064     // will start at "shift".
0065     int shift = 0;
0066     if (nRead > static_cast<int>(HFQIE10Info::N_RAW_MAX)) {
0067       // Try to center the window on "tsToUse"
0068       const int winCenter = nStore / 2;
0069       if (tsToUse > winCenter)
0070         shift = tsToUse - winCenter;
0071       if (shift + nStore > nRead)
0072         shift = nRead - nStore;
0073     }
0074 
0075     // Fill an array of raw values
0076     HFQIE10Info::raw_type raw[HFQIE10Info::N_RAW_MAX];
0077     for (int i = 0; i < nStore; ++i)
0078       raw[i] = digi[i + shift].wideRaw();
0079 
0080     result = HFQIE10Info(digi.id(), charge, energy, timeRising, timeFalling, raw, nStore, tsToUse - shift);
0081   }
0082   return result;
0083 }