Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-26 05:06:37

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