CMS 3D CMS Logo

HOTriggerPrimitiveDigi.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDigi/interface/HOTriggerPrimitiveDigi.h"
00002 
00003 
00004 HOTriggerPrimitiveDigi::HOTriggerPrimitiveDigi(int ieta, int iphi, int nsamples, int whichSampleTriggered, int databits){
00005   if ((nsamples<0) || (nsamples>HO_TP_SAMPLES_MAX)) printf("HOTRiggerPrimitiveDigi: nsamples out of range.");
00006   if ((whichSampleTriggered<0) || (whichSampleTriggered>nsamples))
00007     printf("HOTriggerPrimitiveDigi: specified Triggering Sample out of range");
00008   if ( (databits>>nsamples) != 0x0000) 
00009     printf("HOTRiggerPrimitiveDigi: Specified extra bits out of nsamples range.");
00010   int samples=nsamples;
00011   if (samples<0) samples=0;
00012   if (samples>HO_TP_SAMPLES_MAX) samples=HO_TP_SAMPLES_MAX;
00013 
00014   theHO_TP=(abs(ieta)&0xf) | ((ieta<0)?(0x10):(0x00)) |
00015     ((iphi&0x7F)<<5) | 
00016     ((samples&0xF)<<12) | (((whichSampleTriggered)&0xF)<<16) |
00017     ((databits&0x3FF)<<20);
00018 }
00019 
00020 //Request the value of a given HO TP bit in the HO TP Digi.
00021 bool HOTriggerPrimitiveDigi::data(int whichbit) const{
00022   if ((whichbit<0) || (whichbit>nsamples())) {
00023     printf("HOTPDigi: Sample bit requested out of range.");
00024     return false;}
00025   return ((theHO_TP>>(20+whichbit))&0x0001);
00026 }
00027 
00028 /* Stream the formatted contents of the HOTriggerPrimitiveDigi. */
00029 std::ostream& operator<<(std::ostream& s, const HOTriggerPrimitiveDigi& HOtpd) {
00030   s << "(HO TP " << HOtpd.ieta() << ", " << HOtpd.iphi() << ",  ";
00031   //  s << HOtpd.whichSampleTriggered() << "_of_" << HOtpd.nsamples() << " [";
00032   for (int bit=0; bit<HOtpd.nsamples(); bit++) {
00033     if (HOtpd.data(bit)) s << "1";
00034     else s << "0";
00035     if (bit==HOtpd.whichSampleTriggered()) s<<"* ";
00036     else s << " ";
00037   }
00038   s << " )";
00039   return s;
00040 }
00041 

Generated on Tue Jun 9 17:31:00 2009 for CMSSW by  doxygen 1.5.4