Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:38

0001 #ifndef DataFormats_HcalRecHit_HBHERecHitAuxSetter_h_
0002 #define DataFormats_HcalRecHit_HBHERecHitAuxSetter_h_
0003 
0004 #include "DataFormats/HcalRecHit/interface/HBHERecHit.h"
0005 #include "DataFormats/HcalRecHit/interface/HBHEChannelInfo.h"
0006 #include "DataFormats/HcalRecHit/interface/CaloRecHitAuxSetter.h"
0007 
0008 //
0009 // Set rechit "auxiliary words" for the Phase 1 HBHE reco.
0010 //
0011 // The standars CaloRecHit "aux" word contains ADC values 0-3.
0012 //
0013 // The "auxHBHE" word of HBHERecHit contains ADC values 4-7.
0014 //
0015 // The "auxPhase1" word of HBHERecHit contains ADC values 8-9
0016 // and other info, as specified by the masks and offsets below.
0017 //
0018 struct HBHERecHitAuxSetter {
0019   static const unsigned MASK_ADC = 0xffff;
0020   static const unsigned OFF_ADC = 0;
0021 
0022   // How many ADC values are actually stored
0023   static const unsigned MASK_NSAMPLES = 0xf;
0024   static const unsigned OFF_NSAMPLES = 16;
0025 
0026   // Which ADC corresponds to the sample of interest.
0027   static const unsigned MASK_SOI = 0xf;
0028   static const unsigned OFF_SOI = 20;
0029 
0030   // CAPID for the sample of interest.
0031   static const unsigned MASK_CAPID = 0x3;
0032   static const unsigned OFF_CAPID = 24;
0033 
0034   // Various status bits (pack bools from HBHEChannelInfo)
0035   static const unsigned OFF_TDC_TIME = 26;
0036   static const unsigned OFF_DROPPED = 27;
0037   static const unsigned OFF_LINK_ERR = 28;
0038   static const unsigned OFF_CAPID_ERR = 29;
0039 
0040   // Flag identifying combined "Plan 1" rechits
0041   static const unsigned OFF_COMBINED = 30;
0042 
0043   // Main function for setting the aux words.
0044   constexpr static void setAux(const HBHEChannelInfo& info, HBHERecHit* rechit);
0045 };
0046 
0047 constexpr void HBHERecHitAuxSetter::setAux(const HBHEChannelInfo& info, HBHERecHit* rechit) {
0048   using namespace CaloRecHitAuxSetter;
0049 
0050   uint32_t aux = 0, auxHBHE = 0, auxPhase1 = 0;
0051 
0052   // Pack ADC values
0053   unsigned nSamples = info.nSamples();
0054   if (nSamples > 10)
0055     nSamples = 10;
0056   for (unsigned i = 0; i < 4 && i < nSamples; ++i)
0057     setField(&aux, 0xff, i * 8, info.tsAdc(i));
0058   for (unsigned i = 4; i < 8 && i < nSamples; ++i)
0059     setField(&auxHBHE, 0xff, (i - 4) * 8, info.tsAdc(i));
0060   for (unsigned i = 8; i < nSamples; ++i)
0061     setField(&auxPhase1, 0xff, (i - 8) * 8, info.tsAdc(i));
0062 
0063   // Pack other fields
0064   setField(&auxPhase1, MASK_NSAMPLES, OFF_NSAMPLES, nSamples);
0065   unsigned soi = info.soi();
0066   if (soi > 10)
0067     soi = 10;
0068   setField(&auxPhase1, MASK_SOI, OFF_SOI, soi);
0069   setField(&auxPhase1, MASK_CAPID, OFF_CAPID, info.capid());
0070 
0071   // Pack status bits
0072   setBit(&auxPhase1, OFF_TDC_TIME, info.hasTimeInfo());
0073   setBit(&auxPhase1, OFF_DROPPED, info.isDropped());
0074   setBit(&auxPhase1, OFF_LINK_ERR, info.hasLinkError());
0075   setBit(&auxPhase1, OFF_CAPID_ERR, info.hasCapidError());
0076 
0077   // Copy the aux words into the rechit
0078   rechit->setAux(aux);
0079   rechit->setAuxHBHE(auxHBHE);
0080   rechit->setAuxPhase1(auxPhase1);
0081 }
0082 
0083 #endif  // DataFormats_HcalRecHit_HBHERecHitAuxSetter_h_