Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/HcalDigi/interface/HOTriggerPrimitiveDigi.h"
0002 #include <cstdio>
0003 
0004 HOTriggerPrimitiveDigi::HOTriggerPrimitiveDigi(
0005     int ieta, int iphi, int nsamples, int whichSampleTriggered, int databits) {
0006   if ((nsamples < 0) || (nsamples > HO_TP_SAMPLES_MAX))
0007     printf("HOTRiggerPrimitiveDigi: nsamples out of range.");
0008   if ((whichSampleTriggered < 0) || (whichSampleTriggered > nsamples))
0009     printf("HOTriggerPrimitiveDigi: specified Triggering Sample out of range");
0010   if ((databits >> nsamples) != 0x0000)
0011     printf("HOTRiggerPrimitiveDigi: Specified extra bits out of nsamples range.");
0012   int samples = nsamples;
0013   if (samples < 0)
0014     samples = 0;
0015   if (samples > HO_TP_SAMPLES_MAX)
0016     samples = HO_TP_SAMPLES_MAX;
0017 
0018   theHO_TP = (abs(ieta) & 0xf) | ((ieta < 0) ? (0x10) : (0x00)) | ((iphi & 0x7F) << 5) | ((samples & 0xF) << 12) |
0019              (((whichSampleTriggered)&0xF) << 16) | ((databits & 0x3FF) << 20);
0020 }
0021 
0022 //Request the value of a given HO TP bit in the HO TP Digi.
0023 bool HOTriggerPrimitiveDigi::data(int whichbit) const {
0024   if ((whichbit < 0) || (whichbit > nsamples())) {
0025     printf("HOTPDigi: Sample bit requested out of range.");
0026     return false;
0027   }
0028   return ((theHO_TP >> (20 + whichbit)) & 0x0001);
0029 }
0030 
0031 /* Stream the formatted contents of the HOTriggerPrimitiveDigi. */
0032 std::ostream& operator<<(std::ostream& s, const HOTriggerPrimitiveDigi& HOtpd) {
0033   s << "(HO TP " << HOtpd.ieta() << ", " << HOtpd.iphi() << ",  ";
0034   //  s << HOtpd.whichSampleTriggered() << "_of_" << HOtpd.nsamples() << " [";
0035   for (int bit = 0; bit < HOtpd.nsamples(); bit++) {
0036     if (HOtpd.data(bit))
0037       s << "1";
0038     else
0039       s << "0";
0040     if (bit == HOtpd.whichSampleTriggered())
0041       s << "* ";
0042     else
0043       s << " ";
0044   }
0045   s << " )";
0046   return s;
0047 }