Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <algorithm>
0002 #include <type_traits>
0003 
0004 #include "DataFormats/HcalRecHit/interface/CaloRecHitAuxSetter.h"
0005 
0006 #include "RecoLocalCalo/HcalRecAlgos/interface/HFAnodeStatus.h"
0007 #include "RecoLocalCalo/HcalRecAlgos/interface/HFRecHitAuxSetter.h"
0008 
0009 void HFRecHitAuxSetter::setAux(const HFPreRecHit& prehit,
0010                                const unsigned anodeStates[2],
0011                                const unsigned u_soiPhase,
0012                                HFRecHit* rechit) {
0013   using namespace CaloRecHitAuxSetter;
0014 
0015   const int wantedPhase = u_soiPhase < 2U ? u_soiPhase : 2U;
0016 
0017   for (unsigned ianode = 0; ianode < 2; ++ianode) {
0018     uint32_t aux = 0;
0019     const HFQIE10Info* anodeInfo = prehit.getHFQIE10Info(ianode);
0020     if (anodeInfo) {
0021       const int nRaw = anodeInfo->nRaw();
0022       const int soiStored = anodeInfo->soi();
0023       if (soiStored < nRaw) {
0024         // SOI is in the raw data. Figure out a good
0025         // way to map ADCs into the three bytes available.
0026         int shift = 0;
0027         int nStore = nRaw;
0028         if (nRaw > 3) {
0029           nStore = 3;
0030           if (soiStored > wantedPhase)
0031             shift = soiStored - wantedPhase;
0032           if (shift + nStore > nRaw)
0033             shift = nRaw - nStore;
0034         }
0035 
0036         // Fill out the ADC fields
0037         for (int iadc = 0; iadc < nStore; ++iadc) {
0038           const int istored = iadc + shift;
0039           const QIE10DataFrame::Sample ts(anodeInfo->getRaw(istored));
0040           setField(&aux, 0xff, iadc * 8, ts.adc());
0041           if (istored == soiStored)
0042             setField(&aux, MASK_CAPID, OFF_CAPID, ts.capid());
0043         }
0044         setField(&aux, MASK_SOI, OFF_SOI, soiStored - shift);
0045       } else
0046         setField(&aux, MASK_SOI, OFF_SOI, 3U);
0047     }
0048 
0049     // Remember anode status
0050     static_assert(HFAnodeStatus::N_POSSIBLE_STATES <= MASK_STATUS + 1,
0051                   "Possible states enum must fit into the bit field");
0052     setField(&aux, MASK_STATUS, OFF_STATUS, anodeStates[ianode]);
0053 
0054     // Fill the aux field in the rechit
0055     if (ianode)
0056       rechit->setAuxHF(aux);
0057     else
0058       rechit->setAux(aux);
0059   }
0060 }