CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HOTriggerPrimitiveDigi.cc
Go to the documentation of this file.
2 #include <cstdio>
3 
4 HOTriggerPrimitiveDigi::HOTriggerPrimitiveDigi(int ieta, int iphi, int nsamples, int whichSampleTriggered, int databits){
5  if ((nsamples<0) || (nsamples>HO_TP_SAMPLES_MAX)) printf("HOTRiggerPrimitiveDigi: nsamples out of range.");
6  if ((whichSampleTriggered<0) || (whichSampleTriggered>nsamples))
7  printf("HOTriggerPrimitiveDigi: specified Triggering Sample out of range");
8  if ( (databits>>nsamples) != 0x0000)
9  printf("HOTRiggerPrimitiveDigi: Specified extra bits out of nsamples range.");
10  int samples=nsamples;
11  if (samples<0) samples=0;
12  if (samples>HO_TP_SAMPLES_MAX) samples=HO_TP_SAMPLES_MAX;
13 
14  theHO_TP=(abs(ieta)&0xf) | ((ieta<0)?(0x10):(0x00)) |
15  ((iphi&0x7F)<<5) |
16  ((samples&0xF)<<12) | (((whichSampleTriggered)&0xF)<<16) |
17  ((databits&0x3FF)<<20);
18 }
19 
20 //Request the value of a given HO TP bit in the HO TP Digi.
21 bool HOTriggerPrimitiveDigi::data(int whichbit) const{
22  if ((whichbit<0) || (whichbit>nsamples())) {
23  printf("HOTPDigi: Sample bit requested out of range.");
24  return false;}
25  return ((theHO_TP>>(20+whichbit))&0x0001);
26 }
27 
28 /* Stream the formatted contents of the HOTriggerPrimitiveDigi. */
29 std::ostream& operator<<(std::ostream& s, const HOTriggerPrimitiveDigi& HOtpd) {
30  s << "(HO TP " << HOtpd.ieta() << ", " << HOtpd.iphi() << ", ";
31  // s << HOtpd.whichSampleTriggered() << "_of_" << HOtpd.nsamples() << " [";
32  for (int bit=0; bit<HOtpd.nsamples(); bit++) {
33  if (HOtpd.data(bit)) s << "1";
34  else s << "0";
35  if (bit==HOtpd.whichSampleTriggered()) s<<"* ";
36  else s << " ";
37  }
38  s << " )";
39  return s;
40 }
41 
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static const int HO_TP_SAMPLES_MAX
int iphi() const
get the iphi value
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool data(int whichbit=HO_TP_SAMPLES_MAX) const
int ieta() const
get the signed ieta value
int nsamples() const
get the number of samples used to compute the TP
int whichSampleTriggered() const
get the number of the triggering sample